Skip to content

Commit efec423

Browse files
committed
update metro
1 parent 557436e commit efec423

File tree

3 files changed

+29
-40
lines changed

3 files changed

+29
-40
lines changed

example/babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
presets: ['module:@react-native/metro-config'],
2+
presets: ['module:@react-native/babel-preset'],
33
};

example/metro.config.js

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
1+
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
2+
23
const fs = require('fs');
34
const path = require('path');
4-
const escape = require('escape-string-regexp');
55
const exclusionList = require('metro-config/src/defaults/exclusionList');
6-
const pack = require('../package.json');
7-
8-
const root = path.resolve(__dirname, '..');
9-
const modules = Object.keys({ ...pack.peerDependencies });
106

117
const rnwPath = fs.realpathSync(
128
path.resolve(require.resolve('react-native-windows/package.json'), '..'),
@@ -20,40 +16,33 @@ const rnwPath = fs.realpathSync(
2016
*
2117
* @type {import('metro-config').MetroConfig}
2218
*/
23-
const config = {
24-
watchFolders: [root,
25-
//
26-
],
2719

28-
// We need to make sure that only one version is loaded for peerDependencies
29-
// So we block them at the root, and alias them to the versions in example's node_modules
20+
const config = {
21+
//
3022
resolver: {
31-
blacklistRE: exclusionList(
32-
modules.map(
33-
(m) =>
34-
new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`)
35-
).concat([
36-
// This stops "npx @react-native-community/cli run-windows" from causing the metro server to crash if its already running
37-
new RegExp(
38-
`${path.resolve(__dirname, 'windows').replace(/[/\\]/g, '/')}.*`,
39-
),
40-
// This prevents "npx @react-native-community/cli run-windows" from hitting: EBUSY: resource busy or locked, open msbuild.ProjectImports.zip or other files produced by msbuild
41-
new RegExp(`${rnwPath}/build/.*`),
42-
new RegExp(`${rnwPath}/target/.*`),
43-
/.*\.ProjectImports\.zip/,
44-
])
45-
),
46-
47-
extraNodeModules: modules.reduce((acc, name) => {
48-
acc[name] = path.join(__dirname, 'node_modules', name);
49-
return acc;
50-
},
51-
{
52-
//
53-
}
54-
),
23+
blockList: exclusionList([
24+
// This stops "npx @react-native-community/cli run-windows" from causing the metro server to crash if its already running
25+
new RegExp(
26+
`${path.resolve(__dirname, 'windows').replace(/[/\\]/g, '/')}.*`,
27+
),
28+
// This prevents "npx @react-native-community/cli run-windows" from hitting: EBUSY: resource busy or locked, open msbuild.ProjectImports.zip or other files produced by msbuild
29+
new RegExp(`${rnwPath}/build/.*`),
30+
new RegExp(`${rnwPath}/target/.*`),
31+
/.*\.ProjectImports\.zip/,
32+
]),
33+
//
34+
extraNodeModules: {
35+
'react-native-print': path.resolve(
36+
__dirname,
37+
'../'
38+
), }
5539
},
56-
40+
watchFolders:[
41+
// This allows us to use the local version of react-native-windows
42+
rnwPath,
43+
// This allows us to use the local version of react-native-print
44+
path.resolve(__dirname, '../'),
45+
],
5746
transformer: {
5847
getTransformOptions: async () => ({
5948
transform: {

example/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
"babel-jest": "^25.1.0",
2929
"eslint": "^6.5.1",
3030
"jest": "^25.1.0",
31-
"metro-react-native-babel-preset": "^0.59.0",
3231
"react-test-renderer": "16.13.1",
3332
"selenium-appium": "^0.0.15",
3433
"selenium-webdriver": "^4.0.0-alpha.7",
3534
"@rnx-kit/jest-preset": "^0.1.17",
36-
"@react-native/metro-config": "^0.77.2"
35+
"@react-native/metro-config": "^0.77.2",
36+
"@react-native/babel-preset": "^0.77.2"
3737
},
3838
"jest": {
3939
"preset": "react-native"

0 commit comments

Comments
 (0)