6
6
*/
7
7
const fs = require ( "fs" ) ;
8
8
const path = require ( "path" ) ;
9
- const blacklist = require ( "metro-config/src/defaults/blacklist" ) ;
9
+
10
+ const exclusionList = ( ( ) => {
11
+ try {
12
+ return require ( "metro-config/src/defaults/exclusionList" ) ;
13
+ } catch ( _ ) {
14
+ // `blacklist` was renamed to `exclusionList` in 0.60
15
+ return require ( "metro-config/src/defaults/blacklist" ) ;
16
+ }
17
+ } ) ( ) ;
10
18
11
19
const rnPath = fs . realpathSync (
12
20
path . resolve ( require . resolve ( "react-native/package.json" ) )
@@ -15,31 +23,30 @@ const rnwPath = fs.realpathSync(
15
23
path . resolve ( require . resolve ( "react-native-windows/package.json" ) )
16
24
) ;
17
25
26
+ const blockList = exclusionList ( [
27
+ // Since there are multiple copies of react-native, we need to ensure that
28
+ // Metro only sees one of them. This should go when haste-map is removed.
29
+ new RegExp ( `${ ( path . resolve ( rnPath ) + path . sep ) . replace ( / [ / \\ ] / g, "/" ) } .*` ) ,
30
+
31
+ // This stops "react-native run-windows" from causing the metro server to
32
+ // crash if its already running
33
+ new RegExp ( `${ path . resolve ( __dirname , "windows" ) . replace ( / [ / \\ ] / g, "/" ) } .*` ) ,
34
+
35
+ // Workaround for `EBUSY: resource busy or locked, open
36
+ // '~\msbuild.ProjectImports.zip'` when building with `yarn windows --release`
37
+ / .* \. P r o j e c t I m p o r t s \. z i p / ,
38
+ ] ) ;
39
+
18
40
module . exports = {
19
41
resolver : {
20
42
extraNodeModules : {
21
43
// Redirect react-native to react-native-windows
22
44
"react-native" : rnwPath ,
23
45
"react-native-windows" : rnwPath ,
24
46
} ,
25
- // Include the macos platform in addition to the defaults because the fork includes macos, but doesn't declare it
26
- platforms : [ "ios" , "android" , "windesktop" , "windows" , "web" , "macos" ] ,
27
- // Since there are multiple copies of react-native, we need to ensure that metro only sees one of them
28
- // This should go in RN 0.61 when haste is removed
29
- blacklistRE : blacklist ( [
30
- new RegExp (
31
- `${ ( path . resolve ( rnPath ) + path . sep ) . replace ( / [ / \\ ] / g, "/" ) } .*`
32
- ) ,
33
-
34
- // This stops "react-native run-windows" from causing the metro server to crash if its already running
35
- new RegExp (
36
- `${ path . resolve ( __dirname , "windows" ) . replace ( / [ / \\ ] / g, "/" ) } .*`
37
- ) ,
38
-
39
- // Workaround for `EBUSY: resource busy or locked, open '~\msbuild.ProjectImports.zip'`
40
- // when building with `yarn windows --release`
41
- / .* \. P r o j e c t I m p o r t s \. z i p / ,
42
- ] ) ,
47
+ platforms : [ "windesktop" , "windows" ] ,
48
+ blacklistRE : blockList ,
49
+ blockList,
43
50
} ,
44
51
transformer : {
45
52
getTransformOptions : async ( ) => ( {
0 commit comments