@react-native/metro-config 0.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +86 -0
- package/package.json +16 -0
package/index.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow
|
|
8
|
+
* @noformat
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/*:: import type {ConfigT} from 'metro-config'; */
|
|
12
|
+
|
|
13
|
+
const {getDefaultConfig: getBaseConfig, mergeConfig} = require('metro-config');
|
|
14
|
+
|
|
15
|
+
const INTERNAL_CALLSITES_REGEX = new RegExp(
|
|
16
|
+
[
|
|
17
|
+
'/Libraries/Renderer/implementations/.+\\.js$',
|
|
18
|
+
'/Libraries/BatchedBridge/MessageQueue\\.js$',
|
|
19
|
+
'/Libraries/YellowBox/.+\\.js$',
|
|
20
|
+
'/Libraries/LogBox/.+\\.js$',
|
|
21
|
+
'/Libraries/Core/Timers/.+\\.js$',
|
|
22
|
+
'/Libraries/WebSocket/.+\\.js$',
|
|
23
|
+
'/Libraries/vendor/.+\\.js$',
|
|
24
|
+
'/node_modules/react-devtools-core/.+\\.js$',
|
|
25
|
+
'/node_modules/react-refresh/.+\\.js$',
|
|
26
|
+
'/node_modules/scheduler/.+\\.js$',
|
|
27
|
+
'/node_modules/event-target-shim/.+\\.js$',
|
|
28
|
+
'/node_modules/invariant/.+\\.js$',
|
|
29
|
+
'/node_modules/react-native/index.js$',
|
|
30
|
+
'/metro-runtime/.+\\.js$',
|
|
31
|
+
'^\\[native code\\]$',
|
|
32
|
+
].join('|'),
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Get the base Metro configuration for a React Native project.
|
|
37
|
+
*/
|
|
38
|
+
function getDefaultConfig(
|
|
39
|
+
projectRoot /*: string */
|
|
40
|
+
) /*: ConfigT */ {
|
|
41
|
+
const config = {
|
|
42
|
+
resolver: {
|
|
43
|
+
resolverMainFields: ['react-native', 'browser', 'main'],
|
|
44
|
+
platforms: ['android', 'ios'],
|
|
45
|
+
unstable_conditionNames: ['import', 'require', 'react-native'],
|
|
46
|
+
},
|
|
47
|
+
serializer: {
|
|
48
|
+
getPolyfills: () => require('@react-native/js-polyfills')(),
|
|
49
|
+
},
|
|
50
|
+
server: {
|
|
51
|
+
port: Number(process.env.RCT_METRO_PORT) || 8081,
|
|
52
|
+
},
|
|
53
|
+
symbolicator: {
|
|
54
|
+
customizeFrame: (frame /*: $ReadOnly<{file: ?string, ...}>*/) => {
|
|
55
|
+
const collapse = Boolean(
|
|
56
|
+
frame.file && INTERNAL_CALLSITES_REGEX.test(frame.file),
|
|
57
|
+
);
|
|
58
|
+
return {collapse};
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
transformer: {
|
|
62
|
+
allowOptionalDependencies: true,
|
|
63
|
+
assetRegistryPath: 'react-native/Libraries/Image/AssetRegistry',
|
|
64
|
+
asyncRequireModulePath: require.resolve(
|
|
65
|
+
'metro-runtime/src/modules/asyncRequire',
|
|
66
|
+
),
|
|
67
|
+
babelTransformerPath: require.resolve(
|
|
68
|
+
'metro-react-native-babel-transformer',
|
|
69
|
+
),
|
|
70
|
+
getTransformOptions: async () => ({
|
|
71
|
+
transform: {
|
|
72
|
+
experimentalImportSupport: false,
|
|
73
|
+
inlineRequires: true,
|
|
74
|
+
},
|
|
75
|
+
}),
|
|
76
|
+
},
|
|
77
|
+
watchFolders: [],
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return mergeConfig(
|
|
81
|
+
getBaseConfig.getDefaultValues(projectRoot),
|
|
82
|
+
config,
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
module.exports = {getDefaultConfig};
|
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-native/metro-config",
|
|
3
|
+
"version": "0.72.0",
|
|
4
|
+
"description": "Metro configuration for React Native.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git@github.com:facebook/react-native.git",
|
|
8
|
+
"directory": "packages/metro-config"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"exports": "./index.js",
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@react-native/js-polyfills": "^0.72.1",
|
|
14
|
+
"metro-config": "0.75.1"
|
|
15
|
+
}
|
|
16
|
+
}
|