@react-native/metro-config 0.74.0 → 0.74.2

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.
@@ -0,0 +1,12 @@
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
+ *
8
+ * @format
9
+ * @oncall react_native
10
+ */
11
+
12
+ export * from "./index.flow";
@@ -0,0 +1,17 @@
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
+ *
8
+ * @format
9
+ * @oncall react_native
10
+ */
11
+
12
+ import type { ConfigT } from "metro-config";
13
+ export { mergeConfig } from "metro-config";
14
+ /**
15
+ * Get the base Metro configuration for a React Native project.
16
+ */
17
+ export declare function getDefaultConfig(projectRoot: string): ConfigT;
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+ exports.getDefaultConfig = getDefaultConfig;
7
+ Object.defineProperty(exports, "mergeConfig", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _metroConfig.mergeConfig;
11
+ },
12
+ });
13
+ var _metroConfig = require("metro-config");
14
+ /**
15
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
16
+ *
17
+ * This source code is licensed under the MIT license found in the
18
+ * LICENSE file in the root directory of this source tree.
19
+ *
20
+ *
21
+ * @format
22
+ * @oncall react_native
23
+ */
24
+
25
+ const INTERNAL_CALLSITES_REGEX = new RegExp(
26
+ [
27
+ "/Libraries/BatchedBridge/MessageQueue\\.js$",
28
+ "/Libraries/Core/.+\\.js$",
29
+ "/Libraries/LogBox/.+\\.js$",
30
+ "/Libraries/Network/.+\\.js$",
31
+ "/Libraries/Pressability/.+\\.js$",
32
+ "/Libraries/Renderer/implementations/.+\\.js$",
33
+ "/Libraries/Utilities/.+\\.js$",
34
+ "/Libraries/vendor/.+\\.js$",
35
+ "/Libraries/WebSocket/.+\\.js$",
36
+ "/Libraries/YellowBox/.+\\.js$",
37
+ "/metro-runtime/.+\\.js$",
38
+ "/node_modules/@babel/runtime/.+\\.js$",
39
+ "/node_modules/event-target-shim/.+\\.js$",
40
+ "/node_modules/invariant/.+\\.js$",
41
+ "/node_modules/react-devtools-core/.+\\.js$",
42
+ "/node_modules/react-native/index.js$",
43
+ "/node_modules/react-refresh/.+\\.js$",
44
+ "/node_modules/scheduler/.+\\.js$",
45
+ "^\\[native code\\]$",
46
+ ].join("|")
47
+ );
48
+ /**
49
+ * Get the base Metro configuration for a React Native project.
50
+ */
51
+ function getDefaultConfig(projectRoot) {
52
+ const config = {
53
+ resolver: {
54
+ resolverMainFields: ["react-native", "browser", "main"],
55
+ platforms: ["android", "ios"],
56
+ unstable_conditionNames: ["require", "import", "react-native"],
57
+ },
58
+ serializer: {
59
+ // Note: This option is overridden in cli-plugin-metro (getOverrideConfig)
60
+ getModulesRunBeforeMainModule: () => [
61
+ require.resolve("react-native/Libraries/Core/InitializeCore"),
62
+ ],
63
+ // $FlowFixMe[untyped-import]
64
+ getPolyfills: () => require("@react-native/js-polyfills")(),
65
+ },
66
+ server: {
67
+ port: Number(process.env.RCT_METRO_PORT) || 8081,
68
+ },
69
+ symbolicator: {
70
+ customizeFrame: (frame) => {
71
+ const collapse = Boolean(
72
+ frame.file != null && INTERNAL_CALLSITES_REGEX.test(frame.file)
73
+ );
74
+ return {
75
+ collapse,
76
+ };
77
+ },
78
+ },
79
+ transformer: {
80
+ allowOptionalDependencies: true,
81
+ assetRegistryPath: "react-native/Libraries/Image/AssetRegistry",
82
+ asyncRequireModulePath: require.resolve(
83
+ "metro-runtime/src/modules/asyncRequire"
84
+ ),
85
+ babelTransformerPath: require.resolve(
86
+ "@react-native/metro-babel-transformer"
87
+ ),
88
+ getTransformOptions: async () => ({
89
+ transform: {
90
+ experimentalImportSupport: false,
91
+ inlineRequires: true,
92
+ },
93
+ }),
94
+ },
95
+ watchFolders: [],
96
+ };
97
+
98
+ // Set global hook so that the CLI can detect when this config has been loaded
99
+ global.__REACT_NATIVE_METRO_CONFIG_LOADED = true;
100
+ return (0, _metroConfig.mergeConfig)(
101
+ _metroConfig.getDefaultConfig.getDefaultValues(projectRoot),
102
+ config
103
+ );
104
+ }
@@ -0,0 +1,19 @@
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 strict-local
8
+ * @format
9
+ * @oncall react_native
10
+ */
11
+
12
+ import type { ConfigT } from "metro-config";
13
+
14
+ export { mergeConfig } from "metro-config";
15
+
16
+ /**
17
+ * Get the base Metro configuration for a React Native project.
18
+ */
19
+ declare export function getDefaultConfig(projectRoot: string): ConfigT;
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+ var _index = require("./index.flow");
7
+ Object.keys(_index).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _index[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _index[key];
14
+ },
15
+ });
16
+ });
@@ -0,0 +1,12 @@
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
+ * @format
9
+ * @oncall react_native
10
+ */
11
+
12
+ export * from "./index.flow";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native/metro-config",
3
- "version": "0.74.0",
3
+ "version": "0.74.2",
4
4
  "description": "Metro configuration for React Native.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -9,20 +9,15 @@
9
9
  "directory": "packages/metro-config"
10
10
  },
11
11
  "homepage": "https://github.com/facebook/react-native/tree/HEAD/packages/metro-config#readme",
12
- "keywords": [
13
- "metro",
14
- "config",
15
- "react-native"
16
- ],
12
+ "keywords": ["metro", "config", "react-native"],
17
13
  "bugs": "https://github.com/facebook/react-native/issues",
18
- "engines": {
19
- "node": ">=18"
20
- },
21
- "exports": "./index.js",
14
+ "engines": { "node": ">=18" },
15
+ "exports": { ".": "./dist/index.js", "./package.json": "./package.json" },
16
+ "files": ["dist"],
22
17
  "dependencies": {
23
- "@react-native/metro-babel-transformer": "^0.74.0",
24
- "@react-native/js-polyfills": "^0.74.0",
25
- "metro-config": "0.79.1",
26
- "metro-runtime": "0.79.1"
18
+ "@react-native/js-polyfills": "0.74.0",
19
+ "@react-native/metro-babel-transformer": "0.74.2",
20
+ "metro-config": "^0.80.3",
21
+ "metro-runtime": "^0.80.3"
27
22
  }
28
23
  }
package/index.js DELETED
@@ -1,97 +0,0 @@
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/BatchedBridge/MessageQueue\\.js$',
18
- '/Libraries/Core/.+\\.js$',
19
- '/Libraries/LogBox/.+\\.js$',
20
- '/Libraries/Network/.+\\.js$',
21
- '/Libraries/Pressability/.+\\.js$',
22
- '/Libraries/Renderer/implementations/.+\\.js$',
23
- '/Libraries/Utilities/.+\\.js$',
24
- '/Libraries/vendor/.+\\.js$',
25
- '/Libraries/WebSocket/.+\\.js$',
26
- '/Libraries/YellowBox/.+\\.js$',
27
- '/metro-runtime/.+\\.js$',
28
- '/node_modules/@babel/runtime/.+\\.js$',
29
- '/node_modules/event-target-shim/.+\\.js$',
30
- '/node_modules/invariant/.+\\.js$',
31
- '/node_modules/react-devtools-core/.+\\.js$',
32
- '/node_modules/react-native/index.js$',
33
- '/node_modules/react-refresh/.+\\.js$',
34
- '/node_modules/scheduler/.+\\.js$',
35
- '^\\[native code\\]$',
36
- ].join('|'),
37
- );
38
-
39
- /**
40
- * Get the base Metro configuration for a React Native project.
41
- */
42
- function getDefaultConfig(
43
- projectRoot /*: string */
44
- ) /*: ConfigT */ {
45
- const config = {
46
- resolver: {
47
- resolverMainFields: ['react-native', 'browser', 'main'],
48
- platforms: ['android', 'ios'],
49
- unstable_conditionNames: ['require', 'import', 'react-native'],
50
- },
51
- serializer: {
52
- // Note: This option is overridden in cli-plugin-metro (getOverrideConfig)
53
- getModulesRunBeforeMainModule: () => [
54
- require.resolve('react-native/Libraries/Core/InitializeCore'),
55
- ],
56
- getPolyfills: () => require('@react-native/js-polyfills')(),
57
- },
58
- server: {
59
- port: Number(process.env.RCT_METRO_PORT) || 8081,
60
- },
61
- symbolicator: {
62
- customizeFrame: (frame /*: $ReadOnly<{file: ?string, ...}>*/) => {
63
- const collapse = Boolean(
64
- frame.file && INTERNAL_CALLSITES_REGEX.test(frame.file),
65
- );
66
- return {collapse};
67
- },
68
- },
69
- transformer: {
70
- allowOptionalDependencies: true,
71
- assetRegistryPath: 'react-native/Libraries/Image/AssetRegistry',
72
- asyncRequireModulePath: require.resolve(
73
- 'metro-runtime/src/modules/asyncRequire',
74
- ),
75
- babelTransformerPath: require.resolve(
76
- '@react-native/metro-babel-transformer',
77
- ),
78
- getTransformOptions: async () => ({
79
- transform: {
80
- experimentalImportSupport: false,
81
- inlineRequires: true,
82
- },
83
- }),
84
- },
85
- watchFolders: [],
86
- };
87
-
88
- // Set global hook so that the CLI can detect when this config has been loaded
89
- global.__REACT_NATIVE_METRO_CONFIG_LOADED = true;
90
-
91
- return mergeConfig(
92
- getBaseConfig.getDefaultValues(projectRoot),
93
- config,
94
- );
95
- }
96
-
97
- module.exports = {getDefaultConfig, mergeConfig};