@expo/metro-config 0.2.2 → 0.2.7
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/README.md +131 -0
- package/build/ExpoMetroConfig.d.ts +2 -1
- package/build/ExpoMetroConfig.js +72 -24
- package/build/ExpoMetroConfig.js.map +1 -1
- package/build/getWatchFolders.d.ts +16 -0
- package/build/getWatchFolders.js +89 -0
- package/build/getWatchFolders.js.map +1 -0
- package/build/monorepoAssetsPlugin.d.ts +19 -0
- package/build/monorepoAssetsPlugin.js +22 -0
- package/build/monorepoAssetsPlugin.js.map +1 -0
- package/build/transformer/createExoticTransformer.d.ts +20 -17
- package/build/transformer/createExoticTransformer.js +106 -175
- package/build/transformer/createExoticTransformer.js.map +1 -1
- package/build/transformer/createMatcher.js +3 -0
- package/build/transformer/createMatcher.js.map +1 -1
- package/build/transformer/createMultiRuleTransformer.d.ts +14 -0
- package/build/transformer/createMultiRuleTransformer.js +185 -0
- package/build/transformer/createMultiRuleTransformer.js.map +1 -0
- package/build/transformer/getBabelConfig.js +8 -8
- package/build/transformer/getBabelConfig.js.map +1 -1
- package/build/transformer/index.d.ts +4 -0
- package/build/transformer/index.js +13 -0
- package/build/transformer/index.js.map +1 -0
- package/build/transformer/metro-expo-exotic-babel-transformer.js +1 -80
- package/build/transformer/metro-expo-exotic-babel-transformer.js.map +1 -1
- package/package.json +6 -4
- package/transformer/index.d.ts +1 -0
- package/transformer/index.js +1 -0
package/README.md
CHANGED
|
@@ -1,3 +1,134 @@
|
|
|
1
1
|
# expo-metro-config
|
|
2
2
|
|
|
3
3
|
A Metro config for running React Native projects with the Metro bundler.
|
|
4
|
+
|
|
5
|
+
## Exotic
|
|
6
|
+
|
|
7
|
+
When enabled, exotic mode adds the following assumptions:
|
|
8
|
+
|
|
9
|
+
- Resolver Fields: `browser, main`
|
|
10
|
+
- The `react-native` field in module `package.json` is **NOT** supported.
|
|
11
|
+
- Packages using `react-native-builder-bob` will default to using the CommonJS setting in exotic. If you need to modify your Node modules manually, be sure to change the files in your `lib/commonjs/` folder.
|
|
12
|
+
- Extensions: `ts, tsx, js, jsx, json, cjs`
|
|
13
|
+
- `cjs` is added.
|
|
14
|
+
- `.babelrc` support is removed in favor of `babel.config.js`.
|
|
15
|
+
- `x_facebook_sources` is toggled off by default.
|
|
16
|
+
|
|
17
|
+
### Default Rules
|
|
18
|
+
|
|
19
|
+
1. Modules with `.*/lib/commonjs/` are skipped.
|
|
20
|
+
2. React Native is transformed with Sucrase to remove flow types and other unsupported language features.
|
|
21
|
+
- If the React Native team transpiles react-native before shipping, we can remove this step.
|
|
22
|
+
3. Expo modules are transformed with Sucrase to remove import/export syntax. This is temporary while we figure out how to add ESModule support to the native runtime.
|
|
23
|
+
- This is for improved tree shaking.
|
|
24
|
+
4. Known community modules (especially ones included in Expo Go) are transformed using a more expensive Sucrase preset
|
|
25
|
+
- We may add support for extending this list in the future.
|
|
26
|
+
5. All other node modules are skipped.
|
|
27
|
+
6. All remaining code is assumed to be application code and transpiled with your local Babel preset.
|
|
28
|
+
- "Victory Native" packages use too many language features so they are transpiled with Babel.
|
|
29
|
+
|
|
30
|
+
### Extra Customization
|
|
31
|
+
|
|
32
|
+
> Experimental
|
|
33
|
+
|
|
34
|
+
You can use `@expo/metro-config/transformer` to extend the experimental transformer API.
|
|
35
|
+
This can be used for:
|
|
36
|
+
|
|
37
|
+
- Adding extra modules that need to be transpiled locally (`transpileModules`).
|
|
38
|
+
- Adding extra `nodeModulesPaths` for monorepo support.
|
|
39
|
+
- Adding support for the `react-native` main resolver field back.
|
|
40
|
+
|
|
41
|
+
`metro-exotic-transformer.js`
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
const { createExoticTransformer } = require('@expo/metro-config/transformer');
|
|
45
|
+
|
|
46
|
+
module.exports = createExoticTransformer({
|
|
47
|
+
transpileModules: ['@stripe/stripe-react-native'],
|
|
48
|
+
// You can uncomment the following lines to add any extra node_modules paths in a monorepo:
|
|
49
|
+
// nodeModulesPaths: [
|
|
50
|
+
// 'node_modules',
|
|
51
|
+
// // Generally you'll add this when your config is in `apps/my-app/metro.config.js`
|
|
52
|
+
// '../../node_modules',
|
|
53
|
+
// // If you have custom packages in a `packages/` folder
|
|
54
|
+
// '../../packages',
|
|
55
|
+
// ],
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Then use it in your project:
|
|
60
|
+
|
|
61
|
+
`metro.config.js`
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
const { getDefaultConfig } = require('@expo/metro-config');
|
|
65
|
+
|
|
66
|
+
const defaultConfig = getDefaultConfig(__dirname, {
|
|
67
|
+
// Initialize in exotic mode.
|
|
68
|
+
// If you want to preserve `react-native` resolver main field, and omit cjs support, then leave this undefined
|
|
69
|
+
// and skip setting the `EXPO_USE_EXOTIC` environment variable.
|
|
70
|
+
mode: 'exotic',
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Use the new transformer
|
|
74
|
+
baseConfig.transformer.babelTransformerPath = require.resolve('./metro-exotic-transformer');
|
|
75
|
+
|
|
76
|
+
// Optionally, you can add support for the `react-native` resolver field back
|
|
77
|
+
// doing this will increase bundling time and size as many community packages ship untransformed code using this feature.
|
|
78
|
+
// Other packages like `nanoid` use the field to support `react-native` so you may need to enable it regardless.
|
|
79
|
+
// defaultConfig.resolver.resolverMainFields.unshift('react-native');
|
|
80
|
+
|
|
81
|
+
module.exports = baseConfig;
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Source Maps
|
|
85
|
+
|
|
86
|
+
Metro bundler adds an undocumented extension to source maps which provides slightly different names for anonymous functions. The source map sizes increase a lot by adding the `x_facebook_sources` object, and the net transformation time also increases by a noticeable amount. By default, exotic disables this feature. The feature can be re-enabled with `EXPO_USE_FB_SOURCES`. Here are the results:
|
|
87
|
+
|
|
88
|
+
<table>
|
|
89
|
+
<tr>
|
|
90
|
+
<th>Enabled</th>
|
|
91
|
+
<th>Disabled</th>
|
|
92
|
+
</tr>
|
|
93
|
+
<tr>
|
|
94
|
+
<td>iOS Bundling: <b>7664ms</b></td>
|
|
95
|
+
<td>iOS Bundling: <b>6875ms</b></td>
|
|
96
|
+
</tr>
|
|
97
|
+
<tr>
|
|
98
|
+
<td><img src="https://user-images.githubusercontent.com/9664363/134078785-c9b0d93d-3dfb-4552-b786-b45059e10c3b.png" width="200" /></td>
|
|
99
|
+
<td><img src="https://user-images.githubusercontent.com/9664363/134078781-9f79e9d8-56c7-4e20-952f-8214deb3f0ca.png" width="200" /></td>
|
|
100
|
+
</tr>
|
|
101
|
+
</table>
|
|
102
|
+
|
|
103
|
+
- Most error reporting services don't support `x_facebook_sources` so the larger size mostly just increases hosting costs (when uploaded).
|
|
104
|
+
- Documentation for `x_facebook_sources` is not provided.
|
|
105
|
+
|
|
106
|
+
Cite: [#3861](https://github.com/expo/expo-cli/pull/3861)
|
|
107
|
+
|
|
108
|
+
### Troubleshooting
|
|
109
|
+
|
|
110
|
+
You should see the following log when Exotic is enabled:
|
|
111
|
+
|
|
112
|
+
> Unstable feature **EXPO_USE_EXOTIC** is enabled. Bundling may not work as expected, and is subject to breaking changes.
|
|
113
|
+
|
|
114
|
+
Or if `EXPO_DEBUG=1` is enabled, you'll see exotic mode in the settings breakdown.
|
|
115
|
+
|
|
116
|
+
If you don't see this message, check to ensure your `metro.config.js` is using `@expo/metro-config` and the version is at least `0.2.2`.
|
|
117
|
+
|
|
118
|
+
The transformer can be debugged using the environment variable: `DEBUG=expo:metro:exotic-babel-transformer` or `DEBUG=expo:metro:*`
|
|
119
|
+
|
|
120
|
+
### Adding Resolver Fields
|
|
121
|
+
|
|
122
|
+
You can add the `react-native` field back manually when exotic mode is enabled, we will investigate adding it back after more community packages have had time to adjust to transforming their code ahead of time.
|
|
123
|
+
|
|
124
|
+
`metro.config.js`
|
|
125
|
+
|
|
126
|
+
```js
|
|
127
|
+
const { getDefaultConfig } = require('@expo/metro-config');
|
|
128
|
+
|
|
129
|
+
const defaultConfig = getDefaultConfig(__dirname);
|
|
130
|
+
|
|
131
|
+
defaultConfig.resolver.resolverMainFields.unshift('react-native');
|
|
132
|
+
|
|
133
|
+
module.exports = defaultConfig;
|
|
134
|
+
```
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { ProjectTarget } from '@expo/config';
|
|
2
2
|
import { Reporter } from 'metro';
|
|
3
3
|
import type MetroConfig from 'metro-config';
|
|
4
|
+
export declare function getModulesPaths(projectRoot: string): string[];
|
|
4
5
|
export declare const EXPO_DEBUG: boolean;
|
|
5
|
-
export declare const EXPO_USE_EXOTIC: boolean;
|
|
6
6
|
export declare const INTERNAL_CALLSITES_REGEX: RegExp;
|
|
7
7
|
export interface DefaultConfigOptions {
|
|
8
8
|
target?: ProjectTarget;
|
|
9
|
+
mode?: 'exotic';
|
|
9
10
|
}
|
|
10
11
|
export declare function getDefaultConfig(projectRoot: string, options?: DefaultConfigOptions): MetroConfig.InputConfigT;
|
|
11
12
|
export interface LoadOptions {
|
package/build/ExpoMetroConfig.js
CHANGED
|
@@ -4,16 +4,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.loadAsync = exports.getDefaultConfig = exports.INTERNAL_CALLSITES_REGEX = exports.
|
|
7
|
+
exports.loadAsync = exports.getDefaultConfig = exports.INTERNAL_CALLSITES_REGEX = exports.EXPO_DEBUG = exports.getModulesPaths = void 0;
|
|
8
8
|
const config_1 = require("@expo/config");
|
|
9
9
|
const paths_1 = require("@expo/config/paths");
|
|
10
10
|
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
+
const find_yarn_workspace_root_1 = __importDefault(require("find-yarn-workspace-root"));
|
|
11
12
|
const getenv_1 = require("getenv");
|
|
12
13
|
const path_1 = __importDefault(require("path"));
|
|
13
14
|
const resolve_from_1 = __importDefault(require("resolve-from"));
|
|
15
|
+
const getWatchFolders_1 = require("./getWatchFolders");
|
|
14
16
|
const importMetroFromProject_1 = require("./importMetroFromProject");
|
|
17
|
+
function getModulesPaths(projectRoot) {
|
|
18
|
+
const paths = [];
|
|
19
|
+
paths.push(path_1.default.resolve(projectRoot, 'node_modules'));
|
|
20
|
+
const workspaceRoot = find_yarn_workspace_root_1.default(path_1.default.resolve(projectRoot)); // Absolute path or null
|
|
21
|
+
if (workspaceRoot) {
|
|
22
|
+
paths.push(path_1.default.resolve(workspaceRoot, 'node_modules'));
|
|
23
|
+
}
|
|
24
|
+
return paths;
|
|
25
|
+
}
|
|
26
|
+
exports.getModulesPaths = getModulesPaths;
|
|
15
27
|
exports.EXPO_DEBUG = getenv_1.boolish('EXPO_DEBUG', false);
|
|
16
|
-
|
|
28
|
+
const EXPO_USE_EXOTIC = getenv_1.boolish('EXPO_USE_EXOTIC', false);
|
|
17
29
|
// Import only the types here, the values will be imported from the project, at runtime.
|
|
18
30
|
exports.INTERNAL_CALLSITES_REGEX = new RegExp([
|
|
19
31
|
'/Libraries/Renderer/implementations/.+\\.js$',
|
|
@@ -58,9 +70,29 @@ function getProjectBabelConfigFile(projectRoot) {
|
|
|
58
70
|
resolve_from_1.default.silent(projectRoot, './.babelrc') ||
|
|
59
71
|
resolve_from_1.default.silent(projectRoot, './.babelrc.js'));
|
|
60
72
|
}
|
|
73
|
+
function getAssetPlugins(projectRoot) {
|
|
74
|
+
const assetPlugins = [];
|
|
75
|
+
assetPlugins.push(require.resolve('./monorepoAssetsPlugin'));
|
|
76
|
+
let hashAssetFilesPath;
|
|
77
|
+
try {
|
|
78
|
+
hashAssetFilesPath = resolve_from_1.default(projectRoot, 'expo-asset/tools/hashAssetFiles');
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
// TODO: we should warn/throw an error if the user has expo-updates installed but does not
|
|
82
|
+
// have hashAssetFiles available, or if the user is in managed workflow and does not have
|
|
83
|
+
// hashAssetFiles available. but in a bare app w/o expo-updates, just using dev-client,
|
|
84
|
+
// it is not needed
|
|
85
|
+
}
|
|
86
|
+
if (hashAssetFilesPath) {
|
|
87
|
+
assetPlugins.push(hashAssetFilesPath);
|
|
88
|
+
}
|
|
89
|
+
return assetPlugins;
|
|
90
|
+
}
|
|
61
91
|
let hasWarnedAboutExotic = false;
|
|
62
92
|
function getDefaultConfig(projectRoot, options = {}) {
|
|
63
|
-
|
|
93
|
+
var _a;
|
|
94
|
+
const isExotic = options.mode === 'exotic' || EXPO_USE_EXOTIC;
|
|
95
|
+
if (isExotic && !hasWarnedAboutExotic) {
|
|
64
96
|
hasWarnedAboutExotic = true;
|
|
65
97
|
console.log(chalk_1.default.gray(`\u203A Unstable feature ${chalk_1.default.bold `EXPO_USE_EXOTIC`} is enabled. Bundling may not work as expected, and is subject to breaking changes.`));
|
|
66
98
|
}
|
|
@@ -76,16 +108,6 @@ function getDefaultConfig(projectRoot, options = {}) {
|
|
|
76
108
|
catch {
|
|
77
109
|
// noop -- falls back to a hardcoded value.
|
|
78
110
|
}
|
|
79
|
-
let hashAssetFilesPath;
|
|
80
|
-
try {
|
|
81
|
-
hashAssetFilesPath = resolve_from_1.default(projectRoot, 'expo-asset/tools/hashAssetFiles');
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
// TODO: we should warn/throw an error if the user has expo-updates installed but does not
|
|
85
|
-
// have hashAssetFiles available, or if the user is in managed workflow and does not have
|
|
86
|
-
// hashAssetFiles available. but in a bare app w/o expo-updates, just using dev-client,
|
|
87
|
-
// it is not needed
|
|
88
|
-
}
|
|
89
111
|
const isLegacy = readIsLegacyImportsEnabled(projectRoot);
|
|
90
112
|
// Deprecated -- SDK 41 --
|
|
91
113
|
if (options.target) {
|
|
@@ -123,12 +145,21 @@ function getDefaultConfig(projectRoot, options = {}) {
|
|
|
123
145
|
const sourceExts = target === 'bare'
|
|
124
146
|
? paths_1.getBareExtensions([], sourceExtsConfig)
|
|
125
147
|
: paths_1.getManagedExtensions([], sourceExtsConfig);
|
|
126
|
-
if (
|
|
148
|
+
if (isExotic) {
|
|
127
149
|
// Add support for cjs (without platform extensions).
|
|
128
150
|
sourceExts.push('cjs');
|
|
129
151
|
}
|
|
130
152
|
const babelConfigPath = getProjectBabelConfigFile(projectRoot);
|
|
131
153
|
const isCustomBabelConfigDefined = !!babelConfigPath;
|
|
154
|
+
const resolverMainFields = [];
|
|
155
|
+
// Disable `react-native` in exotic mode, since library authors
|
|
156
|
+
// use it to ship raw application code to the project.
|
|
157
|
+
if (!isExotic) {
|
|
158
|
+
resolverMainFields.push('react-native');
|
|
159
|
+
}
|
|
160
|
+
resolverMainFields.push('browser', 'main');
|
|
161
|
+
const watchFolders = getWatchFolders_1.getWatchFolders(projectRoot);
|
|
162
|
+
const nodeModulesPaths = getModulesPaths(projectRoot);
|
|
132
163
|
if (exports.EXPO_DEBUG) {
|
|
133
164
|
console.log();
|
|
134
165
|
console.log(`Expo Metro config:`);
|
|
@@ -137,27 +168,43 @@ function getDefaultConfig(projectRoot, options = {}) {
|
|
|
137
168
|
console.log(`- Extensions: ${sourceExts.join(', ')}`);
|
|
138
169
|
console.log(`- React Native: ${reactNativePath}`);
|
|
139
170
|
console.log(`- Babel config: ${babelConfigPath || 'babel-preset-expo (default)'}`);
|
|
140
|
-
console.log(`-
|
|
171
|
+
console.log(`- Resolver Fields: ${resolverMainFields.join(', ')}`);
|
|
172
|
+
console.log(`- Watch Folders: ${watchFolders.join(', ')}`);
|
|
173
|
+
console.log(`- Node Module Paths: ${nodeModulesPaths.join(', ')}`);
|
|
174
|
+
console.log(`- Exotic: ${isExotic}`);
|
|
141
175
|
console.log();
|
|
142
176
|
}
|
|
143
177
|
const {
|
|
144
178
|
// Remove the default reporter which metro always resolves to be the react-native-community/cli reporter.
|
|
145
179
|
// This prints a giant React logo which is less accessible to users on smaller terminals.
|
|
146
180
|
reporter, ...metroDefaultValues } = MetroConfig.getDefaultConfig.getDefaultValues(projectRoot);
|
|
147
|
-
const
|
|
148
|
-
//
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
181
|
+
const customEnhanceMiddleware = (_a = metroDefaultValues.server) === null || _a === void 0 ? void 0 : _a.enhanceMiddleware;
|
|
182
|
+
// @ts-ignore can't mutate readonly config
|
|
183
|
+
const enhanceMiddleware = (metroMiddleware, server) => {
|
|
184
|
+
if (customEnhanceMiddleware) {
|
|
185
|
+
metroMiddleware = customEnhanceMiddleware(metroMiddleware, server);
|
|
186
|
+
}
|
|
187
|
+
const debug = require('debug')('expo:metro-config:middleware');
|
|
188
|
+
// Add extra middleware to redirect assets in a monorepo.
|
|
189
|
+
return (req, res, next) => {
|
|
190
|
+
const { url } = req;
|
|
191
|
+
if (url && url.startsWith('/assets/')) {
|
|
192
|
+
// Added by the assetPlugins
|
|
193
|
+
req.url = url.replace(/@@\//g, '../');
|
|
194
|
+
debug('Redirect asset:', url, '->', req.url);
|
|
195
|
+
}
|
|
196
|
+
return metroMiddleware(req, res, next);
|
|
197
|
+
};
|
|
198
|
+
};
|
|
154
199
|
// Merge in the default config from Metro here, even though loadConfig uses it as defaults.
|
|
155
200
|
// This is a convenience for getDefaultConfig use in metro.config.js, e.g. to modify assetExts.
|
|
156
201
|
return MetroConfig.mergeConfig(metroDefaultValues, {
|
|
202
|
+
watchFolders,
|
|
157
203
|
resolver: {
|
|
158
204
|
resolverMainFields,
|
|
159
205
|
platforms: ['ios', 'android', 'native'],
|
|
160
206
|
sourceExts,
|
|
207
|
+
nodeModulesPaths,
|
|
161
208
|
},
|
|
162
209
|
serializer: {
|
|
163
210
|
getModulesRunBeforeMainModule: () => [
|
|
@@ -168,6 +215,7 @@ function getDefaultConfig(projectRoot, options = {}) {
|
|
|
168
215
|
},
|
|
169
216
|
server: {
|
|
170
217
|
port: Number(process.env.RCT_METRO_PORT) || 8081,
|
|
218
|
+
enhanceMiddleware,
|
|
171
219
|
},
|
|
172
220
|
symbolicator: {
|
|
173
221
|
customizeFrame: frame => {
|
|
@@ -188,7 +236,7 @@ function getDefaultConfig(projectRoot, options = {}) {
|
|
|
188
236
|
},
|
|
189
237
|
transformer: {
|
|
190
238
|
allowOptionalDependencies: true,
|
|
191
|
-
babelTransformerPath:
|
|
239
|
+
babelTransformerPath: isExotic
|
|
192
240
|
? require.resolve('./transformer/metro-expo-exotic-babel-transformer')
|
|
193
241
|
: isCustomBabelConfigDefined
|
|
194
242
|
? // If the user defined a babel config file in their project,
|
|
@@ -198,7 +246,7 @@ function getDefaultConfig(projectRoot, options = {}) {
|
|
|
198
246
|
: // Otherwise, use a custom transformer that uses `babel-preset-expo` by default for projects.
|
|
199
247
|
require.resolve('./transformer/metro-expo-babel-transformer'),
|
|
200
248
|
assetRegistryPath: 'react-native/Libraries/Image/AssetRegistry',
|
|
201
|
-
assetPlugins:
|
|
249
|
+
assetPlugins: getAssetPlugins(projectRoot),
|
|
202
250
|
},
|
|
203
251
|
});
|
|
204
252
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoMetroConfig.js","sourceRoot":"","sources":["../src/ExpoMetroConfig.ts"],"names":[],"mappings":";AAAA,qEAAqE;;;;;;AAErE,yCAAkG;AAClG,8CAA6E;AAC7E,kDAA0B;AAC1B,mCAAiC;AAGjC,gDAAwB;AACxB,gEAAuC;AAEvC,qEAAwE;AAE3D,QAAA,UAAU,GAAG,gBAAO,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;AAC1C,QAAA,eAAe,GAAG,gBAAO,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;AAEjE,wFAAwF;AAC3E,QAAA,wBAAwB,GAAG,IAAI,MAAM,CAChD;IACE,8CAA8C;IAC9C,6CAA6C;IAC7C,+BAA+B;IAC/B,4BAA4B;IAC5B,iCAAiC;IACjC,2CAA2C;IAC3C,qCAAqC;IACrC,iCAAiC;IACjC,sDAAsD;IACtD,oDAAoD;IACpD,sCAAsC;IACtC,iCAAiC;IACjC,yCAAyC;IACzC,u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CAAC,UAAU,CACjC,EAAE,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,YAAY,EAAE,EAClD,aAAa,CACd,CAAC;AACJ,CAAC;AAbD,8BAaC","sourcesContent":["// Copyright 2021-present 650 Industries (Expo). All rights reserved.\n\nimport { getConfig, getDefaultTarget, isLegacyImportsEnabled, ProjectTarget } from '@expo/config';\nimport { getBareExtensions, getManagedExtensions } from '@expo/config/paths';\nimport chalk from 'chalk';\nimport { boolish } from 'getenv';\nimport { Reporter } from 'metro';\nimport type MetroConfig from 'metro-config';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { importMetroConfigFromProject } from './importMetroFromProject';\n\nexport const EXPO_DEBUG = boolish('EXPO_DEBUG', false);\nexport const EXPO_USE_EXOTIC = boolish('EXPO_USE_EXOTIC', false);\n\n// Import only the types here, the values will be imported from the project, at runtime.\nexport const INTERNAL_CALLSITES_REGEX = new RegExp(\n [\n '/Libraries/Renderer/implementations/.+\\\\.js$',\n '/Libraries/BatchedBridge/MessageQueue\\\\.js$',\n '/Libraries/YellowBox/.+\\\\.js$',\n '/Libraries/LogBox/.+\\\\.js$',\n '/Libraries/Core/Timers/.+\\\\.js$',\n 'node_modules/react-devtools-core/.+\\\\.js$',\n 'node_modules/react-refresh/.+\\\\.js$',\n 'node_modules/scheduler/.+\\\\.js$',\n // Metro replaces `require()` with a different method,\n // we want to omit this method from the stack trace.\n // This is akin to most React tooling.\n '/metro/.*/polyfills/require.js$',\n // Hide frames related to a fast refresh.\n '/metro/.*/lib/bundle-modules/.+\\\\.js$',\n '/metro/.*/lib/bundle-modules/.+\\\\.js$',\n 'node_modules/react-native/Libraries/Utilities/HMRClient.js$',\n 'node_modules/eventemitter3/index.js',\n 'node_modules/event-target-shim/dist/.+\\\\.js$',\n // Ignore the log forwarder used in the Expo Go app\n '/expo/build/environment/react-native-logs.fx.js$',\n '/src/environment/react-native-logs.fx.ts$',\n '/expo/build/logs/RemoteConsole.js$',\n // Improve errors thrown by invariant (ex: `Invariant Violation: \"main\" has not been registered`).\n 'node_modules/invariant/.+\\\\.js$',\n // Remove babel runtime additions\n 'node_modules/regenerator-runtime/.+\\\\.js$',\n // Remove react native setImmediate ponyfill\n 'node_modules/promise/setimmediate/.+\\\\.js$',\n // Babel helpers that implement language features\n 'node_modules/@babel/runtime/.+\\\\.js$',\n // Block native code invocations\n `\\\\[native code\\\\]`,\n ].join('|')\n);\n\nexport interface DefaultConfigOptions {\n target?: ProjectTarget;\n}\n\nfunction readIsLegacyImportsEnabled(projectRoot: string): boolean {\n const config = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n return isLegacyImportsEnabled(config.exp);\n}\n\nfunction getProjectBabelConfigFile(projectRoot: string): string | undefined {\n return (\n resolveFrom.silent(projectRoot, './babel.config.js') ||\n resolveFrom.silent(projectRoot, './.babelrc') ||\n resolveFrom.silent(projectRoot, './.babelrc.js')\n );\n}\n\nlet hasWarnedAboutExotic = false;\n\nexport function getDefaultConfig(\n projectRoot: string,\n options: DefaultConfigOptions = {}\n): MetroConfig.InputConfigT {\n if (EXPO_USE_EXOTIC && !hasWarnedAboutExotic) {\n hasWarnedAboutExotic = true;\n console.log(\n chalk.gray(\n `\\u203A Unstable feature ${chalk.bold`EXPO_USE_EXOTIC`} is enabled. Bundling may not work as expected, and is subject to breaking changes.`\n )\n );\n }\n const MetroConfig = importMetroConfigFromProject(projectRoot);\n\n const reactNativePath = path.dirname(resolveFrom(projectRoot, 'react-native/package.json'));\n\n try {\n // Set the `EXPO_METRO_CACHE_KEY_VERSION` variable for use in the custom babel transformer.\n // This hack is used because there doesn't appear to be anyway to resolve\n // `babel-preset-fbjs` relative to the project root later (in `metro-expo-babel-transformer`).\n const babelPresetFbjsPath = resolveFrom(projectRoot, 'babel-preset-fbjs/package.json');\n process.env.EXPO_METRO_CACHE_KEY_VERSION = String(require(babelPresetFbjsPath).version);\n } catch {\n // noop -- falls back to a hardcoded value.\n }\n\n let hashAssetFilesPath;\n try {\n hashAssetFilesPath = resolveFrom(projectRoot, 'expo-asset/tools/hashAssetFiles');\n } catch {\n // TODO: we should warn/throw an error if the user has expo-updates installed but does not\n // have hashAssetFiles available, or if the user is in managed workflow and does not have\n // hashAssetFiles available. but in a bare app w/o expo-updates, just using dev-client,\n // it is not needed\n }\n\n const isLegacy = readIsLegacyImportsEnabled(projectRoot);\n // Deprecated -- SDK 41 --\n if (options.target) {\n if (!isLegacy) {\n console.warn(\n chalk.yellow(\n `The target option is deprecated. Learn more: http://expo.fyi/expo-extension-migration`\n )\n );\n delete options.target;\n }\n } else if (process.env.EXPO_TARGET) {\n console.error(\n 'EXPO_TARGET is deprecated. Learn more: http://expo.fyi/expo-extension-migration'\n );\n if (isLegacy) {\n // EXPO_TARGET is used by @expo/metro-config to determine the target when getDefaultConfig is\n // called from metro.config.js.\n // @ts-ignore\n options.target = process.env.EXPO_TARGET;\n }\n } else if (isLegacy) {\n // Fall back to guessing based on the project structure in legacy mode.\n options.target = getDefaultTarget(projectRoot);\n }\n\n if (!options.target) {\n // Default to bare -- no .expo extension.\n options.target = 'bare';\n }\n // End deprecated -- SDK 41 --\n\n const { target } = options;\n if (!(target === 'managed' || target === 'bare')) {\n throw new Error(\n `Invalid target: '${target}'. Debug info: \\n${JSON.stringify(\n {\n 'options.target': options.target,\n default: getDefaultTarget(projectRoot),\n },\n null,\n 2\n )}`\n );\n }\n const sourceExtsConfig = { isTS: true, isReact: true, isModern: false };\n const sourceExts =\n target === 'bare'\n ? getBareExtensions([], sourceExtsConfig)\n : getManagedExtensions([], sourceExtsConfig);\n\n if (EXPO_USE_EXOTIC) {\n // Add support for cjs (without platform extensions).\n sourceExts.push('cjs');\n }\n\n const babelConfigPath = getProjectBabelConfigFile(projectRoot);\n const isCustomBabelConfigDefined = !!babelConfigPath;\n\n if (EXPO_DEBUG) {\n console.log();\n console.log(`Expo Metro config:`);\n console.log(`- Bundler target: ${target}`);\n console.log(`- Legacy: ${isLegacy}`);\n console.log(`- Extensions: ${sourceExts.join(', ')}`);\n console.log(`- React Native: ${reactNativePath}`);\n console.log(`- Babel config: ${babelConfigPath || 'babel-preset-expo (default)'}`);\n console.log(`- Exotic: ${EXPO_USE_EXOTIC}`);\n console.log();\n }\n const {\n // Remove the default reporter which metro always resolves to be the react-native-community/cli reporter.\n // This prints a giant React logo which is less accessible to users on smaller terminals.\n reporter,\n ...metroDefaultValues\n } = MetroConfig.getDefaultConfig.getDefaultValues(projectRoot);\n\n const resolverMainFields: string[] = [];\n\n // Disable `react-native` in exotic mode, since library authors\n // use it to ship raw application code to the project.\n if (!EXPO_USE_EXOTIC) {\n resolverMainFields.push('react-native');\n }\n resolverMainFields.push('browser', 'main');\n\n // Merge in the default config from Metro here, even though loadConfig uses it as defaults.\n // This is a convenience for getDefaultConfig use in metro.config.js, e.g. to modify assetExts.\n return MetroConfig.mergeConfig(metroDefaultValues, {\n resolver: {\n resolverMainFields,\n platforms: ['ios', 'android', 'native'],\n sourceExts,\n },\n serializer: {\n getModulesRunBeforeMainModule: () => [\n require.resolve(path.join(reactNativePath, 'Libraries/Core/InitializeCore')),\n // TODO: Bacon: load Expo side-effects\n ],\n getPolyfills: () => require(path.join(reactNativePath, 'rn-get-polyfills'))(),\n },\n server: {\n port: Number(process.env.RCT_METRO_PORT) || 8081,\n },\n symbolicator: {\n customizeFrame: frame => {\n let collapse = Boolean(frame.file && INTERNAL_CALLSITES_REGEX.test(frame.file));\n\n if (!collapse) {\n // This represents the first frame of the stacktrace.\n // Often this looks like: `__r(0);`.\n // The URL will also be unactionable in the app and therefore not very useful to the developer.\n if (\n frame.column === 3 &&\n frame.methodName === 'global code' &&\n frame.file?.match(/^https?:\\/\\//g)\n ) {\n collapse = true;\n }\n }\n\n return { ...(frame || {}), collapse };\n },\n },\n transformer: {\n allowOptionalDependencies: true,\n babelTransformerPath: EXPO_USE_EXOTIC\n ? require.resolve('./transformer/metro-expo-exotic-babel-transformer')\n : isCustomBabelConfigDefined\n ? // If the user defined a babel config file in their project,\n // then use the default transformer.\n // Try to use the project copy before falling back on the global version\n resolveFrom.silent(projectRoot, 'metro-react-native-babel-transformer')\n : // Otherwise, use a custom transformer that uses `babel-preset-expo` by default for projects.\n require.resolve('./transformer/metro-expo-babel-transformer'),\n assetRegistryPath: 'react-native/Libraries/Image/AssetRegistry',\n assetPlugins: hashAssetFilesPath ? [hashAssetFilesPath] : undefined,\n },\n });\n}\n\nexport interface LoadOptions {\n config?: string;\n maxWorkers?: number;\n port?: number;\n reporter?: Reporter;\n resetCache?: boolean;\n target?: ProjectTarget;\n}\n\nexport async function loadAsync(\n projectRoot: string,\n { reporter, target, ...metroOptions }: LoadOptions = {}\n): Promise<MetroConfig.ConfigT> {\n let defaultConfig = getDefaultConfig(projectRoot, { target });\n if (reporter) {\n defaultConfig = { ...defaultConfig, reporter };\n }\n const MetroConfig = importMetroConfigFromProject(projectRoot);\n return await MetroConfig.loadConfig(\n { cwd: projectRoot, projectRoot, ...metroOptions },\n defaultConfig\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ExpoMetroConfig.js","sourceRoot":"","sources":["../src/ExpoMetroConfig.ts"],"names":[],"mappings":";AAAA,qEAAqE;;;;;;AAErE,yCAAkG;AAClG,8CAA6E;AAC7E,kDAA0B;AAC1B,wFAAyD;AACzD,mCAAiC;AAIjC,gDAAwB;AACxB,gEAAuC;AAEvC,uDAAoD;AACpD,qEAAwE;AAExE,SAAgB,eAAe,CAAC,WAAmB;IACjD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,IAAI,CAAC,cAAI,CAAC,OAAO,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC;IAEtD,MAAM,aAAa,GAAG,kCAAiB,CAAC,cAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,wBAAwB;IAC5F,IAAI,aAAa,EAAE;QACjB,KAAK,CAAC,IAAI,CAAC,cAAI,CAAC,OAAO,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC,CAAC;K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QAAQ;gBAC5B,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,mDAAmD,CAAC;gBACtE,CAAC,CAAC,0BAA0B;oBAC5B,CAAC,CAAC,4DAA4D;wBAC5D,oCAAoC;wBACpC,wEAAwE;wBACxE,sBAAW,CAAC,MAAM,CAAC,WAAW,EAAE,sCAAsC,CAAC;oBACzE,CAAC,CAAC,6FAA6F;wBAC7F,OAAO,CAAC,OAAO,CAAC,4CAA4C,CAAC;YACjE,iBAAiB,EAAE,4CAA4C;YAC/D,YAAY,EAAE,eAAe,CAAC,WAAW,CAAC;SAC3C;KACF,CAAC,CAAC;AACL,CAAC;AAtMD,4CAsMC;AAWM,KAAK,UAAU,SAAS,CAC7B,WAAmB,EACnB,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,YAAY,KAAkB,EAAE;IAEvD,IAAI,aAAa,GAAG,gBAAgB,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9D,IAAI,QAAQ,EAAE;QACZ,aAAa,GAAG,EAAE,GAAG,aAAa,EAAE,QAAQ,EAAE,CAAC;KAChD;IACD,MAAM,WAAW,GAAG,qDAA4B,CAAC,WAAW,CAAC,CAAC;IAC9D,OAAO,MAAM,WAAW,CAAC,UAAU,CACjC,EAAE,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,YAAY,EAAE,EAClD,aAAa,CACd,CAAC;AACJ,CAAC;AAbD,8BAaC","sourcesContent":["// Copyright 2021-present 650 Industries (Expo). All rights reserved.\n\nimport { getConfig, getDefaultTarget, isLegacyImportsEnabled, ProjectTarget } from '@expo/config';\nimport { getBareExtensions, getManagedExtensions } from '@expo/config/paths';\nimport chalk from 'chalk';\nimport findWorkspaceRoot from 'find-yarn-workspace-root';\nimport { boolish } from 'getenv';\nimport type { IncomingMessage, ServerResponse } from 'http';\nimport { Reporter } from 'metro';\nimport type MetroConfig from 'metro-config';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { getWatchFolders } from './getWatchFolders';\nimport { importMetroConfigFromProject } from './importMetroFromProject';\n\nexport function getModulesPaths(projectRoot: string): string[] {\n const paths: string[] = [];\n paths.push(path.resolve(projectRoot, 'node_modules'));\n\n const workspaceRoot = findWorkspaceRoot(path.resolve(projectRoot)); // Absolute path or null\n if (workspaceRoot) {\n paths.push(path.resolve(workspaceRoot, 'node_modules'));\n }\n\n return paths;\n}\n\nexport const EXPO_DEBUG = boolish('EXPO_DEBUG', false);\nconst EXPO_USE_EXOTIC = boolish('EXPO_USE_EXOTIC', false);\n\n// Import only the types here, the values will be imported from the project, at runtime.\nexport const INTERNAL_CALLSITES_REGEX = new RegExp(\n [\n '/Libraries/Renderer/implementations/.+\\\\.js$',\n '/Libraries/BatchedBridge/MessageQueue\\\\.js$',\n '/Libraries/YellowBox/.+\\\\.js$',\n '/Libraries/LogBox/.+\\\\.js$',\n '/Libraries/Core/Timers/.+\\\\.js$',\n 'node_modules/react-devtools-core/.+\\\\.js$',\n 'node_modules/react-refresh/.+\\\\.js$',\n 'node_modules/scheduler/.+\\\\.js$',\n // Metro replaces `require()` with a different method,\n // we want to omit this method from the stack trace.\n // This is akin to most React tooling.\n '/metro/.*/polyfills/require.js$',\n // Hide frames related to a fast refresh.\n '/metro/.*/lib/bundle-modules/.+\\\\.js$',\n '/metro/.*/lib/bundle-modules/.+\\\\.js$',\n 'node_modules/react-native/Libraries/Utilities/HMRClient.js$',\n 'node_modules/eventemitter3/index.js',\n 'node_modules/event-target-shim/dist/.+\\\\.js$',\n // Ignore the log forwarder used in the Expo Go app\n '/expo/build/environment/react-native-logs.fx.js$',\n '/src/environment/react-native-logs.fx.ts$',\n '/expo/build/logs/RemoteConsole.js$',\n // Improve errors thrown by invariant (ex: `Invariant Violation: \"main\" has not been registered`).\n 'node_modules/invariant/.+\\\\.js$',\n // Remove babel runtime additions\n 'node_modules/regenerator-runtime/.+\\\\.js$',\n // Remove react native setImmediate ponyfill\n 'node_modules/promise/setimmediate/.+\\\\.js$',\n // Babel helpers that implement language features\n 'node_modules/@babel/runtime/.+\\\\.js$',\n // Block native code invocations\n `\\\\[native code\\\\]`,\n ].join('|')\n);\n\nexport interface DefaultConfigOptions {\n target?: ProjectTarget;\n mode?: 'exotic';\n}\n\nfunction readIsLegacyImportsEnabled(projectRoot: string): boolean {\n const config = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n return isLegacyImportsEnabled(config.exp);\n}\n\nfunction getProjectBabelConfigFile(projectRoot: string): string | undefined {\n return (\n resolveFrom.silent(projectRoot, './babel.config.js') ||\n resolveFrom.silent(projectRoot, './.babelrc') ||\n resolveFrom.silent(projectRoot, './.babelrc.js')\n );\n}\n\nfunction getAssetPlugins(projectRoot: string): string[] {\n const assetPlugins: string[] = [];\n\n assetPlugins.push(require.resolve('./monorepoAssetsPlugin'));\n\n let hashAssetFilesPath;\n try {\n hashAssetFilesPath = resolveFrom(projectRoot, 'expo-asset/tools/hashAssetFiles');\n } catch {\n // TODO: we should warn/throw an error if the user has expo-updates installed but does not\n // have hashAssetFiles available, or if the user is in managed workflow and does not have\n // hashAssetFiles available. but in a bare app w/o expo-updates, just using dev-client,\n // it is not needed\n }\n\n if (hashAssetFilesPath) {\n assetPlugins.push(hashAssetFilesPath);\n }\n\n return assetPlugins;\n}\n\nlet hasWarnedAboutExotic = false;\n\nexport function getDefaultConfig(\n projectRoot: string,\n options: DefaultConfigOptions = {}\n): MetroConfig.InputConfigT {\n const isExotic = options.mode === 'exotic' || EXPO_USE_EXOTIC;\n\n if (isExotic && !hasWarnedAboutExotic) {\n hasWarnedAboutExotic = true;\n console.log(\n chalk.gray(\n `\\u203A Unstable feature ${chalk.bold`EXPO_USE_EXOTIC`} is enabled. Bundling may not work as expected, and is subject to breaking changes.`\n )\n );\n }\n const MetroConfig = importMetroConfigFromProject(projectRoot);\n\n const reactNativePath = path.dirname(resolveFrom(projectRoot, 'react-native/package.json'));\n\n try {\n // Set the `EXPO_METRO_CACHE_KEY_VERSION` variable for use in the custom babel transformer.\n // This hack is used because there doesn't appear to be anyway to resolve\n // `babel-preset-fbjs` relative to the project root later (in `metro-expo-babel-transformer`).\n const babelPresetFbjsPath = resolveFrom(projectRoot, 'babel-preset-fbjs/package.json');\n process.env.EXPO_METRO_CACHE_KEY_VERSION = String(require(babelPresetFbjsPath).version);\n } catch {\n // noop -- falls back to a hardcoded value.\n }\n\n const isLegacy = readIsLegacyImportsEnabled(projectRoot);\n // Deprecated -- SDK 41 --\n if (options.target) {\n if (!isLegacy) {\n console.warn(\n chalk.yellow(\n `The target option is deprecated. Learn more: http://expo.fyi/expo-extension-migration`\n )\n );\n delete options.target;\n }\n } else if (process.env.EXPO_TARGET) {\n console.error(\n 'EXPO_TARGET is deprecated. Learn more: http://expo.fyi/expo-extension-migration'\n );\n if (isLegacy) {\n // EXPO_TARGET is used by @expo/metro-config to determine the target when getDefaultConfig is\n // called from metro.config.js.\n // @ts-ignore\n options.target = process.env.EXPO_TARGET;\n }\n } else if (isLegacy) {\n // Fall back to guessing based on the project structure in legacy mode.\n options.target = getDefaultTarget(projectRoot);\n }\n\n if (!options.target) {\n // Default to bare -- no .expo extension.\n options.target = 'bare';\n }\n // End deprecated -- SDK 41 --\n\n const { target } = options;\n if (!(target === 'managed' || target === 'bare')) {\n throw new Error(\n `Invalid target: '${target}'. Debug info: \\n${JSON.stringify(\n {\n 'options.target': options.target,\n default: getDefaultTarget(projectRoot),\n },\n null,\n 2\n )}`\n );\n }\n const sourceExtsConfig = { isTS: true, isReact: true, isModern: false };\n const sourceExts =\n target === 'bare'\n ? getBareExtensions([], sourceExtsConfig)\n : getManagedExtensions([], sourceExtsConfig);\n\n if (isExotic) {\n // Add support for cjs (without platform extensions).\n sourceExts.push('cjs');\n }\n\n const babelConfigPath = getProjectBabelConfigFile(projectRoot);\n const isCustomBabelConfigDefined = !!babelConfigPath;\n\n const resolverMainFields: string[] = [];\n\n // Disable `react-native` in exotic mode, since library authors\n // use it to ship raw application code to the project.\n if (!isExotic) {\n resolverMainFields.push('react-native');\n }\n resolverMainFields.push('browser', 'main');\n\n const watchFolders = getWatchFolders(projectRoot);\n const nodeModulesPaths = getModulesPaths(projectRoot);\n if (EXPO_DEBUG) {\n console.log();\n console.log(`Expo Metro config:`);\n console.log(`- Bundler target: ${target}`);\n console.log(`- Legacy: ${isLegacy}`);\n console.log(`- Extensions: ${sourceExts.join(', ')}`);\n console.log(`- React Native: ${reactNativePath}`);\n console.log(`- Babel config: ${babelConfigPath || 'babel-preset-expo (default)'}`);\n console.log(`- Resolver Fields: ${resolverMainFields.join(', ')}`);\n console.log(`- Watch Folders: ${watchFolders.join(', ')}`);\n console.log(`- Node Module Paths: ${nodeModulesPaths.join(', ')}`);\n console.log(`- Exotic: ${isExotic}`);\n console.log();\n }\n const {\n // Remove the default reporter which metro always resolves to be the react-native-community/cli reporter.\n // This prints a giant React logo which is less accessible to users on smaller terminals.\n reporter,\n ...metroDefaultValues\n } = MetroConfig.getDefaultConfig.getDefaultValues(projectRoot);\n\n const customEnhanceMiddleware = metroDefaultValues.server?.enhanceMiddleware;\n\n // @ts-ignore can't mutate readonly config\n const enhanceMiddleware = (metroMiddleware: any, server: Metro.Server) => {\n if (customEnhanceMiddleware) {\n metroMiddleware = customEnhanceMiddleware(metroMiddleware, server);\n }\n\n const debug = require('debug')('expo:metro-config:middleware');\n\n // Add extra middleware to redirect assets in a monorepo.\n return (req: IncomingMessage, res: ServerResponse, next: (err?: Error) => void) => {\n const { url } = req;\n if (url && url.startsWith('/assets/')) {\n // Added by the assetPlugins\n req.url = url.replace(/@@\\//g, '../');\n debug('Redirect asset:', url, '->', req.url);\n }\n\n return metroMiddleware(req, res, next);\n };\n };\n\n // Merge in the default config from Metro here, even though loadConfig uses it as defaults.\n // This is a convenience for getDefaultConfig use in metro.config.js, e.g. to modify assetExts.\n return MetroConfig.mergeConfig(metroDefaultValues, {\n watchFolders,\n resolver: {\n resolverMainFields,\n platforms: ['ios', 'android', 'native'],\n sourceExts,\n nodeModulesPaths,\n },\n serializer: {\n getModulesRunBeforeMainModule: () => [\n require.resolve(path.join(reactNativePath, 'Libraries/Core/InitializeCore')),\n // TODO: Bacon: load Expo side-effects\n ],\n getPolyfills: () => require(path.join(reactNativePath, 'rn-get-polyfills'))(),\n },\n server: {\n port: Number(process.env.RCT_METRO_PORT) || 8081,\n enhanceMiddleware,\n },\n symbolicator: {\n customizeFrame: frame => {\n let collapse = Boolean(frame.file && INTERNAL_CALLSITES_REGEX.test(frame.file));\n\n if (!collapse) {\n // This represents the first frame of the stacktrace.\n // Often this looks like: `__r(0);`.\n // The URL will also be unactionable in the app and therefore not very useful to the developer.\n if (\n frame.column === 3 &&\n frame.methodName === 'global code' &&\n frame.file?.match(/^https?:\\/\\//g)\n ) {\n collapse = true;\n }\n }\n\n return { ...(frame || {}), collapse };\n },\n },\n transformer: {\n allowOptionalDependencies: true,\n babelTransformerPath: isExotic\n ? require.resolve('./transformer/metro-expo-exotic-babel-transformer')\n : isCustomBabelConfigDefined\n ? // If the user defined a babel config file in their project,\n // then use the default transformer.\n // Try to use the project copy before falling back on the global version\n resolveFrom.silent(projectRoot, 'metro-react-native-babel-transformer')\n : // Otherwise, use a custom transformer that uses `babel-preset-expo` by default for projects.\n require.resolve('./transformer/metro-expo-babel-transformer'),\n assetRegistryPath: 'react-native/Libraries/Image/AssetRegistry',\n assetPlugins: getAssetPlugins(projectRoot),\n },\n });\n}\n\nexport interface LoadOptions {\n config?: string;\n maxWorkers?: number;\n port?: number;\n reporter?: Reporter;\n resetCache?: boolean;\n target?: ProjectTarget;\n}\n\nexport async function loadAsync(\n projectRoot: string,\n { reporter, target, ...metroOptions }: LoadOptions = {}\n): Promise<MetroConfig.ConfigT> {\n let defaultConfig = getDefaultConfig(projectRoot, { target });\n if (reporter) {\n defaultConfig = { ...defaultConfig, reporter };\n }\n const MetroConfig = importMetroConfigFromProject(projectRoot);\n return await MetroConfig.loadConfig(\n { cwd: projectRoot, projectRoot, ...metroOptions },\n defaultConfig\n );\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param workspaceProjectRoot Root file path for the yarn workspace
|
|
3
|
+
* @param linkedPackages List of folders that contain linked node modules, ex: `['packages/*', 'apps/*']`
|
|
4
|
+
* @returns List of valid package.json file paths, ex: `['/Users/me/app/apps/my-app/package.json', '/Users/me/app/packages/my-package/package.json']`
|
|
5
|
+
*/
|
|
6
|
+
export declare function globAllPackageJsonPaths(workspaceProjectRoot: string, linkedPackages: string[]): string[];
|
|
7
|
+
/**
|
|
8
|
+
* @param workspaceProjectRoot root file path for a yarn workspace.
|
|
9
|
+
* @returns list of package.json file paths that are linked to the yarn workspace.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveAllWorkspacePackageJsonPaths(workspaceProjectRoot: string): string[];
|
|
12
|
+
/**
|
|
13
|
+
* @param projectRoot file path to app's project root
|
|
14
|
+
* @returns list of node module paths to watch in Metro bundler, ex: `['/Users/me/app/node_modules/', '/Users/me/app/apps/my-app/', '/Users/me/app/packages/my-package/']`
|
|
15
|
+
*/
|
|
16
|
+
export declare function getWatchFolders(projectRoot: string): string[];
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getWatchFolders = exports.resolveAllWorkspacePackageJsonPaths = exports.globAllPackageJsonPaths = void 0;
|
|
7
|
+
const json_file_1 = __importDefault(require("@expo/json-file"));
|
|
8
|
+
const assert_1 = __importDefault(require("assert"));
|
|
9
|
+
const find_yarn_workspace_root_1 = __importDefault(require("find-yarn-workspace-root"));
|
|
10
|
+
const glob_1 = require("glob");
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
/**
|
|
13
|
+
* @param workspaceProjectRoot Root file path for the yarn workspace
|
|
14
|
+
* @param linkedPackages List of folders that contain linked node modules, ex: `['packages/*', 'apps/*']`
|
|
15
|
+
* @returns List of valid package.json file paths, ex: `['/Users/me/app/apps/my-app/package.json', '/Users/me/app/packages/my-package/package.json']`
|
|
16
|
+
*/
|
|
17
|
+
function globAllPackageJsonPaths(workspaceProjectRoot, linkedPackages) {
|
|
18
|
+
return linkedPackages
|
|
19
|
+
.map(glob => {
|
|
20
|
+
return glob_1.sync(path_1.default.join(glob, 'package.json').replace(/\\/g, '/'), {
|
|
21
|
+
cwd: workspaceProjectRoot,
|
|
22
|
+
absolute: true,
|
|
23
|
+
ignore: ['**/@(Carthage|Pods|node_modules)/**'],
|
|
24
|
+
}).map(pkgPath => {
|
|
25
|
+
try {
|
|
26
|
+
json_file_1.default.read(pkgPath);
|
|
27
|
+
return pkgPath;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// Skip adding path if the package.json is invalid or cannot be read.
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
});
|
|
34
|
+
})
|
|
35
|
+
.flat()
|
|
36
|
+
.filter(Boolean)
|
|
37
|
+
.map(p => path_1.default.join(p));
|
|
38
|
+
}
|
|
39
|
+
exports.globAllPackageJsonPaths = globAllPackageJsonPaths;
|
|
40
|
+
function getWorkspacePackagesArray({ workspaces }) {
|
|
41
|
+
if (Array.isArray(workspaces)) {
|
|
42
|
+
return workspaces;
|
|
43
|
+
}
|
|
44
|
+
assert_1.default(workspaces === null || workspaces === void 0 ? void 0 : workspaces.packages, 'Could not find a `workspaces` object in the root package.json');
|
|
45
|
+
return workspaces.packages;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @param workspaceProjectRoot root file path for a yarn workspace.
|
|
49
|
+
* @returns list of package.json file paths that are linked to the yarn workspace.
|
|
50
|
+
*/
|
|
51
|
+
function resolveAllWorkspacePackageJsonPaths(workspaceProjectRoot) {
|
|
52
|
+
try {
|
|
53
|
+
const rootPackageJsonFilePath = path_1.default.join(workspaceProjectRoot, 'package.json');
|
|
54
|
+
// Could throw if package.json is invalid.
|
|
55
|
+
const rootPackageJson = json_file_1.default.read(rootPackageJsonFilePath);
|
|
56
|
+
// Extract the "packages" array or use "workspaces" as packages array (yarn workspaces spec).
|
|
57
|
+
const packages = getWorkspacePackagesArray(rootPackageJson);
|
|
58
|
+
// Glob all package.json files and return valid paths.
|
|
59
|
+
return globAllPackageJsonPaths(workspaceProjectRoot, packages);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.resolveAllWorkspacePackageJsonPaths = resolveAllWorkspacePackageJsonPaths;
|
|
66
|
+
/**
|
|
67
|
+
* @param projectRoot file path to app's project root
|
|
68
|
+
* @returns list of node module paths to watch in Metro bundler, ex: `['/Users/me/app/node_modules/', '/Users/me/app/apps/my-app/', '/Users/me/app/packages/my-package/']`
|
|
69
|
+
*/
|
|
70
|
+
function getWatchFolders(projectRoot) {
|
|
71
|
+
const workspaceRoot = find_yarn_workspace_root_1.default(path_1.default.resolve(projectRoot));
|
|
72
|
+
// Rely on default behavior in standard projects.
|
|
73
|
+
if (!workspaceRoot) {
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
const packages = resolveAllWorkspacePackageJsonPaths(workspaceRoot);
|
|
77
|
+
if (!packages.length) {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
return uniqueItems([
|
|
81
|
+
path_1.default.join(workspaceRoot, 'node_modules'),
|
|
82
|
+
...packages.map(pkg => path_1.default.dirname(pkg)),
|
|
83
|
+
]);
|
|
84
|
+
}
|
|
85
|
+
exports.getWatchFolders = getWatchFolders;
|
|
86
|
+
function uniqueItems(items) {
|
|
87
|
+
return [...new Set(items)];
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=getWatchFolders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getWatchFolders.js","sourceRoot":"","sources":["../src/getWat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AAC,CAAC;QAChF,0CAA0C;QAC1C,MAAM,eAAe,GAAG,mBAAQ,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QAE/D,6FAA6F;QAC7F,MAAM,QAAQ,GAAG,yBAAyB,CAAC,eAAe,CAAC,CAAC;QAE5D,sDAAsD;QACtD,OAAO,uBAAuB,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAC;KAChE;IAAC,MAAM;QACN,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AAdD,kFAcC;AAED;;;GAGG;AACH,SAAgB,eAAe,CAAC,WAAmB;IACjD,MAAM,aAAa,GAAG,kCAAiB,CAAC,cAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IACnE,iDAAiD;IACjD,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO,EAAE,CAAC;KACX;IAED,MAAM,QAAQ,GAAG,mCAAmC,CAAC,aAAa,CAAC,CAAC;IACpE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;QACpB,OAAO,EAAE,CAAC;KACX;IAED,OAAO,WAAW,CAAC;QACjB,cAAI,CAAC,IAAI,CAAC,aAAa,EAAE,cAAc,CAAC;QACxC,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,cAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;KAC1C,CAAC,CAAC;AACL,CAAC;AAhBD,0CAgBC;AAED,SAAS,WAAW,CAAC,KAAe;IAClC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import JsonFile from '@expo/json-file';\nimport assert from 'assert';\nimport findWorkspaceRoot from 'find-yarn-workspace-root';\nimport { sync as globSync } from 'glob';\nimport path from 'path';\n\n/**\n * @param workspaceProjectRoot Root file path for the yarn workspace\n * @param linkedPackages List of folders that contain linked node modules, ex: `['packages/*', 'apps/*']`\n * @returns List of valid package.json file paths, ex: `['/Users/me/app/apps/my-app/package.json', '/Users/me/app/packages/my-package/package.json']`\n */\nexport function globAllPackageJsonPaths(\n workspaceProjectRoot: string,\n linkedPackages: string[]\n): string[] {\n return linkedPackages\n .map(glob => {\n return globSync(path.join(glob, 'package.json').replace(/\\\\/g, '/'), {\n cwd: workspaceProjectRoot,\n absolute: true,\n ignore: ['**/@(Carthage|Pods|node_modules)/**'],\n }).map(pkgPath => {\n try {\n JsonFile.read(pkgPath);\n return pkgPath;\n } catch {\n // Skip adding path if the package.json is invalid or cannot be read.\n }\n return null;\n });\n })\n .flat()\n .filter(Boolean)\n .map(p => path.join(p as string));\n}\n\nfunction getWorkspacePackagesArray({ workspaces }: any): string[] {\n if (Array.isArray(workspaces)) {\n return workspaces;\n }\n\n assert(workspaces?.packages, 'Could not find a `workspaces` object in the root package.json');\n\n return workspaces.packages;\n}\n\n/**\n * @param workspaceProjectRoot root file path for a yarn workspace.\n * @returns list of package.json file paths that are linked to the yarn workspace.\n */\nexport function resolveAllWorkspacePackageJsonPaths(workspaceProjectRoot: string) {\n try {\n const rootPackageJsonFilePath = path.join(workspaceProjectRoot, 'package.json');\n // Could throw if package.json is invalid.\n const rootPackageJson = JsonFile.read(rootPackageJsonFilePath);\n\n // Extract the \"packages\" array or use \"workspaces\" as packages array (yarn workspaces spec).\n const packages = getWorkspacePackagesArray(rootPackageJson);\n\n // Glob all package.json files and return valid paths.\n return globAllPackageJsonPaths(workspaceProjectRoot, packages);\n } catch {\n return [];\n }\n}\n\n/**\n * @param projectRoot file path to app's project root\n * @returns list of node module paths to watch in Metro bundler, ex: `['/Users/me/app/node_modules/', '/Users/me/app/apps/my-app/', '/Users/me/app/packages/my-package/']`\n */\nexport function getWatchFolders(projectRoot: string): string[] {\n const workspaceRoot = findWorkspaceRoot(path.resolve(projectRoot));\n // Rely on default behavior in standard projects.\n if (!workspaceRoot) {\n return [];\n }\n\n const packages = resolveAllWorkspacePackageJsonPaths(workspaceRoot);\n if (!packages.length) {\n return [];\n }\n\n return uniqueItems([\n path.join(workspaceRoot, 'node_modules'),\n ...packages.map(pkg => path.dirname(pkg)),\n ]);\n}\n\nfunction uniqueItems(items: string[]): string[] {\n return [...new Set(items)];\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assets work by fetching from the localhost using a filepath, example:
|
|
3
|
+
* `./icon.png` would be fetched via `http://127.0.0.1:19000/assets/./icon.png`
|
|
4
|
+
*
|
|
5
|
+
* In the case of a monorepo, you may need to reach outside of the root folder:
|
|
6
|
+
*
|
|
7
|
+
* App running at `monorepo/apps/my-app/` would fetch a resource from `monorepo/node_modules/my-package/icon.png`
|
|
8
|
+
* this would be done with `http://127.0.0.1:19000/assets/../../node_modules/my-package/icon.png`.
|
|
9
|
+
*
|
|
10
|
+
* The problem is that Metro dev server would collapse this URL into `http://127.0.0.1:19000/node_modules/my-package/icon.png` which is invalid.
|
|
11
|
+
*
|
|
12
|
+
* To combat this, we replace the `../` with a random character that cannot be collapsed: `@@/` (must be a character that can be encoded), then we add some dev server middleware to transform this back to `../` before fetching the asset.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
declare function monorepoAssetsPlugin(assetData: {
|
|
16
|
+
httpServerLocation: string;
|
|
17
|
+
}): {
|
|
18
|
+
httpServerLocation: string;
|
|
19
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Assets work by fetching from the localhost using a filepath, example:
|
|
4
|
+
* `./icon.png` would be fetched via `http://127.0.0.1:19000/assets/./icon.png`
|
|
5
|
+
*
|
|
6
|
+
* In the case of a monorepo, you may need to reach outside of the root folder:
|
|
7
|
+
*
|
|
8
|
+
* App running at `monorepo/apps/my-app/` would fetch a resource from `monorepo/node_modules/my-package/icon.png`
|
|
9
|
+
* this would be done with `http://127.0.0.1:19000/assets/../../node_modules/my-package/icon.png`.
|
|
10
|
+
*
|
|
11
|
+
* The problem is that Metro dev server would collapse this URL into `http://127.0.0.1:19000/node_modules/my-package/icon.png` which is invalid.
|
|
12
|
+
*
|
|
13
|
+
* To combat this, we replace the `../` with a random character that cannot be collapsed: `@@/` (must be a character that can be encoded), then we add some dev server middleware to transform this back to `../` before fetching the asset.
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
function monorepoAssetsPlugin(assetData) {
|
|
17
|
+
assetData.httpServerLocation = assetData.httpServerLocation.replace(/\.\.\//g, '@@/');
|
|
18
|
+
return assetData;
|
|
19
|
+
}
|
|
20
|
+
// Export with `module.exports` for Metro asset plugin loading.
|
|
21
|
+
module.exports = monorepoAssetsPlugin;
|
|
22
|
+
//# sourceMappingURL=monorepoAssetsPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monorepoAssetsPlugin.js","sourceRoot":"","sources":["../src/monorepoAssetsPlugin.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;AACH,SAAS,oBAAoB,CAAC,SAAyC;IACrE,SAAS,CAAC,kBAAkB,GAAG,SAAS,CAAC,kBAAkB,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IACtF,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,+DAA+D;AAC/D,MAAM,CAAC,OAAO,GAAG,oBAAoB,CAAC","sourcesContent":["/**\n * Assets work by fetching from the localhost using a filepath, example:\n * `./icon.png` would be fetched via `http://127.0.0.1:19000/assets/./icon.png`\n *\n * In the case of a monorepo, you may need to reach outside of the root folder:\n *\n * App running at `monorepo/apps/my-app/` would fetch a resource from `monorepo/node_modules/my-package/icon.png`\n * this would be done with `http://127.0.0.1:19000/assets/../../node_modules/my-package/icon.png`.\n *\n * The problem is that Metro dev server would collapse this URL into `http://127.0.0.1:19000/node_modules/my-package/icon.png` which is invalid.\n *\n * To combat this, we replace the `../` with a random character that cannot be collapsed: `@@/` (must be a character that can be encoded), then we add some dev server middleware to transform this back to `../` before fetching the asset.\n *\n */\nfunction monorepoAssetsPlugin(assetData: { httpServerLocation: string }) {\n assetData.httpServerLocation = assetData.httpServerLocation.replace(/\\.\\.\\//g, '@@/');\n return assetData;\n}\n\n// Export with `module.exports` for Metro asset plugin loading.\nmodule.exports = monorepoAssetsPlugin;\n"]}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export declare
|
|
1
|
+
import { BabelTransformer } from 'metro-babel-transformer';
|
|
2
|
+
/**
|
|
3
|
+
* Create an experimental multi-rule transformer for a React Native app.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```
|
|
7
|
+
* module.exports = createExoticTransformer({
|
|
8
|
+
* nodeModulesPaths: ['react-native'],
|
|
9
|
+
* transpileModules: ['@stripe/stripe-react-native'],
|
|
10
|
+
* });
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @param props.nodeModulesPaths paths to node_modules folders, relative to project root. Default: `['node_modules']`
|
|
14
|
+
* @param props.transpileModules matchers for module names that should be transpiled using the project Babel configuration. Example: `['@stripe/stripe-react-native']`
|
|
15
|
+
* @returns a Metro `transformer` function and default `getCacheKey` function.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createExoticTransformer({ nodeModulesPaths, transpileModules, }: {
|
|
18
|
+
nodeModulesPaths?: string[];
|
|
19
|
+
transpileModules?: string[];
|
|
20
|
+
}): BabelTransformer;
|