Skip to content

Commit dcbe447

Browse files
committed
fix: extend @react-native/metro-config for react-native 0.72
1 parent 99e990a commit dcbe447

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

packages/create-react-native-library/templates/common/example/metro.config.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1+
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
12
const path = require('path');
23
const escape = require('escape-string-regexp');
34
const exclusionList = require('metro-config/src/defaults/exclusionList');
45
const pak = require('../package.json');
56

67
const root = path.resolve(__dirname, '..');
8+
const modules = Object.keys({ ...pak.peerDependencies });
79

8-
const modules = Object.keys({
9-
...pak.peerDependencies,
10-
});
11-
12-
module.exports = {
13-
projectRoot: __dirname,
10+
/**
11+
* Metro configuration
12+
* https://facebook.github.io/metro/docs/configuration
13+
*
14+
* @type {import('metro-config').MetroConfig}
15+
*/
16+
const config = {
1417
watchFolders: [root],
1518

1619
// We need to make sure that only one version is loaded for peerDependencies
@@ -38,3 +41,5 @@ module.exports = {
3841
}),
3942
},
4043
};
44+
45+
module.exports = mergeConfig(getDefaultConfig(__dirname), config);

packages/create-react-native-library/templates/expo-library/example/metro.config.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ const exclusionList = require('metro-config/src/defaults/exclusionList');
55
const pak = require('../package.json');
66

77
const root = path.resolve(__dirname, '..');
8-
9-
const modules = Object.keys({
10-
...pak.peerDependencies,
11-
});
8+
const modules = Object.keys({ ...pak.peerDependencies });
129

1310
const defaultConfig = getDefaultConfig(__dirname);
1411

15-
module.exports = {
12+
/**
13+
* Metro configuration
14+
* https://facebook.github.io/metro/docs/configuration
15+
*
16+
* @type {import('metro-config').MetroConfig}
17+
*/
18+
const config = {
1619
...defaultConfig,
1720

1821
projectRoot: __dirname,
@@ -36,3 +39,5 @@ module.exports = {
3639
}, {}),
3740
},
3841
};
42+
43+
module.exports = config;

0 commit comments

Comments
 (0)