-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
metro.config.js
61 lines (54 loc) · 1.67 KB
/
metro.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* @format
*/
const fs = require('fs');
const path = require('path');
const {
getModulesRunBeforeMainModule,
reactNativePlatformResolver,
} = require('react-native-windows/metro-react-native-platform');
const rnwPath = __dirname;
module.exports = {
// WatchFolders is only needed due to the yarn workspace layout of node_modules, we need to watch the symlinked locations separately
watchFolders: [
// Include hoisted modules
path.resolve(__dirname, '../node_modules'),
],
resolver: {
resolveRequest: reactNativePlatformResolver({
windesktop: 'react-native-windows',
windows: 'react-native-windows',
}),
extraNodeModules: {
// Redirect react-native-windows to this folder
'react-native-windows': rnwPath,
},
},
serializer: {
getModulesRunBeforeMainModule,
},
transformer: {
// The cli defaults this to a full path to react-native, which bypasses the reactNativePlatformResolver above
// Hopefully we can fix the default in the future
assetRegistryPath: 'react-native/Libraries/Image/AssetRegistry',
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
};
// Check that we have built our JS files before running the bundler, otherwise we'll get a harder to diagnose "Unable to resolve module" error
if (
!fs.existsSync(
path.resolve(
__dirname,
'Libraries/Components/AccessibilityInfo/AccessibilityInfo.windows.js',
),
)
) {
throw new Error(
'[31m\nThis package must be built before running the bundler. Did you mean to run "[39m[33myarn build[39m[31m" first?[39m\n',
);
}