@expo/cli 1.0.0-canary-20250729-d8899ae → 54.0.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/build/bin/cli +1 -1
- package/build/metro-require/require.js +24 -13
- package/build/src/api/getExpoSchema.js +8 -7
- package/build/src/api/getExpoSchema.js.map +1 -1
- package/build/src/expoUpdatesExports.js +28 -0
- package/build/src/expoUpdatesExports.js.map +1 -0
- package/build/src/export/embed/exportEmbedAsync.js +4 -2
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/export/exportApp.js +7 -4
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportAssets.js +20 -4
- package/build/src/export/exportAssets.js.map +1 -1
- package/build/src/export/exportHermes.js +34 -9
- package/build/src/export/exportHermes.js.map +1 -1
- package/build/src/export/exportStaticAsync.js +19 -2
- package/build/src/export/exportStaticAsync.js.map +1 -1
- package/build/src/export/index.js +1 -0
- package/build/src/export/index.js.map +1 -1
- package/build/src/export/resolveOptions.js +1 -0
- package/build/src/export/resolveOptions.js.map +1 -1
- package/build/src/export/saveAssets.js +12 -0
- package/build/src/export/saveAssets.js.map +1 -1
- package/build/src/install/checkPackages.js +9 -1
- package/build/src/install/checkPackages.js.map +1 -1
- package/build/src/lint/lintAsync.js +2 -0
- package/build/src/lint/lintAsync.js.map +1 -1
- package/build/src/prebuild/prebuildAsync.js +18 -0
- package/build/src/prebuild/prebuildAsync.js.map +1 -1
- package/build/src/prebuild/resolveLocalTemplate.js +42 -0
- package/build/src/prebuild/resolveLocalTemplate.js.map +1 -0
- package/build/src/prebuild/resolveTemplate.js +17 -7
- package/build/src/prebuild/resolveTemplate.js.map +1 -1
- package/build/src/prebuild/updateFromTemplate.js +1 -0
- package/build/src/prebuild/updateFromTemplate.js.map +1 -1
- package/build/src/prebuild/updatePackageJson.js +5 -3
- package/build/src/prebuild/updatePackageJson.js.map +1 -1
- package/build/src/run/android/resolveOptions.js +2 -2
- package/build/src/run/android/resolveOptions.js.map +1 -1
- package/build/src/run/ios/options/resolveOptions.js +2 -2
- package/build/src/run/ios/options/resolveOptions.js.map +1 -1
- package/build/src/run/ios/runIosAsync.js +3 -0
- package/build/src/run/ios/runIosAsync.js.map +1 -1
- package/build/src/serve/serveAsync.js +5 -2
- package/build/src/serve/serveAsync.js.map +1 -1
- package/build/src/start/platforms/ExpoGoInstaller.js +1 -1
- package/build/src/start/platforms/ExpoGoInstaller.js.map +1 -1
- package/build/src/start/server/DevToolsPluginManager.js +7 -35
- package/build/src/start/server/DevToolsPluginManager.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +68 -29
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/MetroTerminalReporter.js +63 -18
- package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
- package/build/src/start/server/metro/createExpoAutolinkingResolver.js +121 -0
- package/build/src/start/server/metro/createExpoAutolinkingResolver.js.map +1 -0
- package/build/src/start/server/metro/createServerComponentsMiddleware.js +4 -4
- package/build/src/start/server/metro/createServerComponentsMiddleware.js.map +1 -1
- package/build/src/start/server/metro/createServerRouteMiddleware.js +54 -8
- package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
- package/build/src/start/server/metro/dev-server/createMetroMiddleware.js +1 -1
- package/build/src/start/server/metro/dev-server/createMetroMiddleware.js.map +1 -1
- package/build/src/start/server/metro/fetchRouterManifest.js +1 -0
- package/build/src/start/server/metro/fetchRouterManifest.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +20 -18
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/metroErrorInterface.js +20 -13
- package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
- package/build/src/start/server/metro/router.js +75 -0
- package/build/src/start/server/metro/router.js.map +1 -1
- package/build/src/start/server/metro/serializeHtml.js +45 -5
- package/build/src/start/server/metro/serializeHtml.js.map +1 -1
- package/build/src/start/server/metro/withMetroErrorReportingResolver.js +267 -0
- package/build/src/start/server/metro/withMetroErrorReportingResolver.js.map +1 -0
- package/build/src/start/server/metro/withMetroMultiPlatform.js +50 -35
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/metro/withMetroResolvers.js +0 -176
- package/build/src/start/server/metro/withMetroResolvers.js.map +1 -1
- package/build/src/start/server/metro/withMetroSupervisingTransformWorker.js +63 -0
- package/build/src/start/server/metro/withMetroSupervisingTransformWorker.js.map +1 -0
- package/build/src/start/server/middleware/createBuiltinAPIRequestHandler.js +1 -1
- package/build/src/start/server/middleware/createBuiltinAPIRequestHandler.js.map +1 -1
- package/build/src/start/server/middleware/metroOptions.js +7 -2
- package/build/src/start/server/middleware/metroOptions.js.map +1 -1
- package/build/src/start/server/serverLogLikeMetro.js +13 -11
- package/build/src/start/server/serverLogLikeMetro.js.map +1 -1
- package/build/src/utils/build-cache-providers/index.js.map +1 -1
- package/build/src/utils/dir.js +7 -0
- package/build/src/utils/dir.js.map +1 -1
- package/build/src/utils/env.js +3 -1
- package/build/src/utils/env.js.map +1 -1
- package/build/src/utils/errors.js +1 -1
- package/build/src/utils/errors.js.map +1 -1
- package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
- package/build/src/utils/telemetry/utils/context.js +1 -1
- package/internal/unstable-expo-updates-exports.d.ts +31 -0
- package/internal/unstable-expo-updates-exports.js +3 -0
- package/package.json +33 -18
- package/static/template/[...rsc]+api.ts +1 -1
- package/build/src/start/server/metro/createExpoStickyResolver.js +0 -137
- package/build/src/start/server/metro/createExpoStickyResolver.js.map +0 -1
- package/build/src/utils/jsonSchemaDeref.js +0 -150
- package/build/src/utils/jsonSchemaDeref.js.map +0 -1
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
createMutateResolutionError: function() {
|
|
13
|
+
return createMutateResolutionError;
|
|
14
|
+
},
|
|
15
|
+
withMetroErrorReportingResolver: function() {
|
|
16
|
+
return withMetroErrorReportingResolver;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
function _chalk() {
|
|
20
|
+
const data = /*#__PURE__*/ _interop_require_default(require("chalk"));
|
|
21
|
+
_chalk = function() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
return data;
|
|
25
|
+
}
|
|
26
|
+
function _path() {
|
|
27
|
+
const data = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
28
|
+
_path = function() {
|
|
29
|
+
return data;
|
|
30
|
+
};
|
|
31
|
+
return data;
|
|
32
|
+
}
|
|
33
|
+
function _util() {
|
|
34
|
+
const data = require("util");
|
|
35
|
+
_util = function() {
|
|
36
|
+
return data;
|
|
37
|
+
};
|
|
38
|
+
return data;
|
|
39
|
+
}
|
|
40
|
+
const _dir = require("../../../utils/dir");
|
|
41
|
+
const _env = require("../../../utils/env");
|
|
42
|
+
function _interop_require_default(obj) {
|
|
43
|
+
return obj && obj.__esModule ? obj : {
|
|
44
|
+
default: obj
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const debug = require('debug')('expo:metro:withMetroResolvers');
|
|
48
|
+
// TODO: Do we need to expose this?
|
|
49
|
+
const STACK_DEPTH_LIMIT = 35;
|
|
50
|
+
const STACK_COUNT_LIMIT = 2000;
|
|
51
|
+
function withMetroErrorReportingResolver(config) {
|
|
52
|
+
var _config_resolver;
|
|
53
|
+
if (!_env.env.EXPO_METRO_UNSTABLE_ERRORS) {
|
|
54
|
+
return config;
|
|
55
|
+
}
|
|
56
|
+
const originalResolveRequest = (_config_resolver = config.resolver) == null ? void 0 : _config_resolver.resolveRequest;
|
|
57
|
+
const depGraph = new Map();
|
|
58
|
+
const mutateResolutionError = createMutateResolutionError(config, depGraph);
|
|
59
|
+
return {
|
|
60
|
+
...config,
|
|
61
|
+
resolver: {
|
|
62
|
+
...config.resolver,
|
|
63
|
+
resolveRequest (context, moduleName, platform) {
|
|
64
|
+
const storeResult = (res)=>{
|
|
65
|
+
const inputPlatform = platform ?? 'null';
|
|
66
|
+
const key = optionsKeyForContext(context);
|
|
67
|
+
if (!depGraph.has(key)) depGraph.set(key, new Map());
|
|
68
|
+
const mapByTarget = depGraph.get(key);
|
|
69
|
+
if (!mapByTarget.has(inputPlatform)) mapByTarget.set(inputPlatform, new Map());
|
|
70
|
+
const mapByPlatform = mapByTarget.get(inputPlatform);
|
|
71
|
+
if (!mapByPlatform.has(context.originModulePath)) mapByPlatform.set(context.originModulePath, new Set());
|
|
72
|
+
const setForModule = mapByPlatform.get(context.originModulePath);
|
|
73
|
+
const qualifiedModuleName = (res == null ? void 0 : res.type) === 'sourceFile' ? res.filePath : moduleName;
|
|
74
|
+
setForModule.add({
|
|
75
|
+
path: qualifiedModuleName,
|
|
76
|
+
request: moduleName
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
// If the user defined a resolver, run it first and depend on the documented
|
|
80
|
+
// chaining logic: https://facebook.github.io/metro/docs/resolution/#resolution-algorithm
|
|
81
|
+
//
|
|
82
|
+
// config.resolver.resolveRequest = (context, moduleName, platform) => {
|
|
83
|
+
//
|
|
84
|
+
// // Do work...
|
|
85
|
+
//
|
|
86
|
+
// return context.resolveRequest(context, moduleName, platform);
|
|
87
|
+
// };
|
|
88
|
+
try {
|
|
89
|
+
const firstResolver = originalResolveRequest ?? context.resolveRequest;
|
|
90
|
+
const res = firstResolver(context, moduleName, platform);
|
|
91
|
+
storeResult(res);
|
|
92
|
+
return res;
|
|
93
|
+
} catch (error) {
|
|
94
|
+
throw mutateResolutionError(error, context, moduleName, platform);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function optionsKeyForContext(context) {
|
|
101
|
+
const canonicalize = require('@expo/metro/metro-core/canonicalize');
|
|
102
|
+
// Compound key for the resolver cache
|
|
103
|
+
return JSON.stringify(context.customResolverOptions ?? {}, canonicalize) ?? '';
|
|
104
|
+
}
|
|
105
|
+
const createMutateResolutionError = (config, depGraph, stackDepthLimit = STACK_DEPTH_LIMIT, stackCountLimit = STACK_COUNT_LIMIT)=>(error, context, moduleName, platform)=>{
|
|
106
|
+
var _config_server;
|
|
107
|
+
const inputPlatform = platform ?? 'null';
|
|
108
|
+
const mapByOrigin = depGraph.get(optionsKeyForContext(context));
|
|
109
|
+
const mapByPlatform = mapByOrigin == null ? void 0 : mapByOrigin.get(inputPlatform);
|
|
110
|
+
if (!mapByPlatform) {
|
|
111
|
+
return error;
|
|
112
|
+
}
|
|
113
|
+
// collect all references inversely using some expensive lookup
|
|
114
|
+
const getReferences = (origin)=>{
|
|
115
|
+
const inverseOrigin = [];
|
|
116
|
+
if (!mapByPlatform) {
|
|
117
|
+
return inverseOrigin;
|
|
118
|
+
}
|
|
119
|
+
for (const [originKey, mapByTarget] of mapByPlatform){
|
|
120
|
+
// search comparing origin to path
|
|
121
|
+
const found = [
|
|
122
|
+
...mapByTarget.values()
|
|
123
|
+
].find((resolution)=>resolution.path === origin);
|
|
124
|
+
if (found) {
|
|
125
|
+
inverseOrigin.push({
|
|
126
|
+
origin,
|
|
127
|
+
previous: originKey,
|
|
128
|
+
request: found.request
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return inverseOrigin;
|
|
133
|
+
};
|
|
134
|
+
const root = ((_config_server = config.server) == null ? void 0 : _config_server.unstable_serverRoot) ?? config.projectRoot;
|
|
135
|
+
const projectRoot = config.projectRoot;
|
|
136
|
+
let stackCounter = 0;
|
|
137
|
+
let inverseStack;
|
|
138
|
+
/** @returns boolean - done */ const saveStack = (stack)=>{
|
|
139
|
+
stackCounter++;
|
|
140
|
+
if (!inverseStack) {
|
|
141
|
+
// First stack, save it
|
|
142
|
+
inverseStack = stack;
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
if (stackCounter >= stackCountLimit) {
|
|
146
|
+
// Too many stacks explored, stop searching
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
if (stack.circular || stack.limited) {
|
|
150
|
+
// Not better than the current one, skip
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
if (inverseStack.circular || inverseStack.limited) {
|
|
154
|
+
// Current one is better than the previous one, save it
|
|
155
|
+
inverseStack = stack;
|
|
156
|
+
// No return as we want to continue validation the new stack
|
|
157
|
+
}
|
|
158
|
+
if (inverseStack.projectRoot) {
|
|
159
|
+
// The best possible stack already acquired, skip
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
const stackOrigin = stack.frames[stack.frames.length - 1].origin;
|
|
163
|
+
if (stackOrigin && (0, _dir.isPathInside)(stackOrigin, projectRoot) && !stackOrigin.includes('node_modules')) {
|
|
164
|
+
// The best stack to show to users is the one leading from the project code.
|
|
165
|
+
stack.serverRoot = true;
|
|
166
|
+
inverseStack = stack;
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
if (// Has to be after the project root check
|
|
170
|
+
stackOrigin && (0, _dir.isPathInside)(stackOrigin, root) && !stackOrigin.includes('node_modules')) {
|
|
171
|
+
// The best stack to show to users is the one leading from the monorepo code.
|
|
172
|
+
stack.serverRoot = true;
|
|
173
|
+
inverseStack = stack;
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
// If new stack is not better do nothing
|
|
177
|
+
return false;
|
|
178
|
+
};
|
|
179
|
+
/** @returns boolean - done */ const recurseBackWithLimit = (frame, limit, stack = {
|
|
180
|
+
frames: []
|
|
181
|
+
}, visited = new Set())=>{
|
|
182
|
+
stack.frames.push(frame);
|
|
183
|
+
if (visited.has(frame.origin)) {
|
|
184
|
+
stack.circular = true;
|
|
185
|
+
return saveStack(stack);
|
|
186
|
+
}
|
|
187
|
+
if (stack.frames.length >= limit) {
|
|
188
|
+
stack.limited = true;
|
|
189
|
+
return saveStack(stack);
|
|
190
|
+
}
|
|
191
|
+
visited.add(frame.origin);
|
|
192
|
+
const inverse = getReferences(frame.origin);
|
|
193
|
+
if (inverse.length === 0) {
|
|
194
|
+
// No more references, push the stack and return
|
|
195
|
+
return saveStack(stack);
|
|
196
|
+
}
|
|
197
|
+
for (const match of inverse){
|
|
198
|
+
// Use more qualified name if possible
|
|
199
|
+
// results.origin = match.origin;
|
|
200
|
+
// Found entry point
|
|
201
|
+
if (frame.origin === match.previous) {
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
const isDone = recurseBackWithLimit({
|
|
205
|
+
origin: match.previous,
|
|
206
|
+
request: match.request
|
|
207
|
+
}, limit, {
|
|
208
|
+
frames: [
|
|
209
|
+
...stack.frames
|
|
210
|
+
]
|
|
211
|
+
}, new Set(visited));
|
|
212
|
+
if (isDone) {
|
|
213
|
+
return true; // Stop search
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return false; // Continue search
|
|
217
|
+
};
|
|
218
|
+
recurseBackWithLimit({
|
|
219
|
+
origin: context.originModulePath,
|
|
220
|
+
request: moduleName
|
|
221
|
+
}, stackDepthLimit);
|
|
222
|
+
debug('Number of explored stacks:', stackCounter);
|
|
223
|
+
if (inverseStack && inverseStack.frames.length > 0) {
|
|
224
|
+
const formattedImport = (0, _chalk().default)`{gray |} {cyan import} `;
|
|
225
|
+
const importMessagePadding = ' '.repeat((0, _util().stripVTControlCharacters)(formattedImport).length + 1);
|
|
226
|
+
debug('Found inverse graph:', JSON.stringify(inverseStack, null, 2));
|
|
227
|
+
let extraMessage = _chalk().default.bold(`Import stack${stackCounter >= stackCountLimit ? ` (${stackCounter})` : ''}:`);
|
|
228
|
+
for (const frame of inverseStack.frames){
|
|
229
|
+
let currentMessage = '';
|
|
230
|
+
let filename = _path().default.relative(root, frame.origin);
|
|
231
|
+
if (filename.match(/\?ctx=[\w\d]+$/)) {
|
|
232
|
+
filename = filename.replace(/\?ctx=[\w\d]+$/, _chalk().default.dim(' (require.context)'));
|
|
233
|
+
} else {
|
|
234
|
+
let formattedRequest = _chalk().default.green(`"${frame.request}"`);
|
|
235
|
+
if (// If bundling for web and the import is pulling internals from outside of react-native
|
|
236
|
+
// then mark it as an invalid import.
|
|
237
|
+
inputPlatform === 'web' && !/^(node_modules\/)?react-native\//.test(filename) && frame.request.match(/^react-native\/.*/)) {
|
|
238
|
+
formattedRequest = formattedRequest + (0, _chalk().default)`\n${importMessagePadding}{yellow ^ Importing react-native internals is not supported on web.}`;
|
|
239
|
+
}
|
|
240
|
+
filename = filename + (0, _chalk().default)`\n${formattedImport}${formattedRequest}`;
|
|
241
|
+
}
|
|
242
|
+
let line = '\n' + _chalk().default.gray(' ') + filename;
|
|
243
|
+
if (filename.match(/node_modules/)) {
|
|
244
|
+
line = _chalk().default.gray(// Bold the node module name
|
|
245
|
+
line.replace(/node_modules\/([^/]+)/, (_match, p1)=>{
|
|
246
|
+
return 'node_modules/' + _chalk().default.bold(p1);
|
|
247
|
+
}));
|
|
248
|
+
}
|
|
249
|
+
currentMessage += `\n${line}`;
|
|
250
|
+
extraMessage += currentMessage;
|
|
251
|
+
}
|
|
252
|
+
if (inverseStack.circular) {
|
|
253
|
+
extraMessage += (0, _chalk().default)`\n${importMessagePadding}{yellow ^ The import above creates circular dependency.}`;
|
|
254
|
+
}
|
|
255
|
+
if (inverseStack.limited) {
|
|
256
|
+
extraMessage += (0, _chalk().default)`\n\n {bold {yellow Depth limit reached. The actual stack is longer than what you can see above.}}`;
|
|
257
|
+
}
|
|
258
|
+
extraMessage += '\n';
|
|
259
|
+
// @ts-expect-error
|
|
260
|
+
error._expoImportStack = extraMessage;
|
|
261
|
+
} else {
|
|
262
|
+
debug('Found no inverse tree for:', context.originModulePath);
|
|
263
|
+
}
|
|
264
|
+
return error;
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
//# sourceMappingURL=withMetroErrorReportingResolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/withMetroErrorReportingResolver.ts"],"sourcesContent":["import type { ConfigT as MetroConfig } from '@expo/metro/metro-config';\nimport type { ResolutionContext } from '@expo/metro/metro-resolver';\nimport chalk from 'chalk';\nimport path from 'path';\nimport { stripVTControlCharacters } from 'util';\n\nimport type { ExpoCustomMetroResolver } from './withMetroResolvers';\nimport { isPathInside } from '../../../utils/dir';\nimport { env } from '../../../utils/env';\n\nconst debug = require('debug')('expo:metro:withMetroResolvers') as typeof console.log;\n\n// TODO: Do we need to expose this?\nconst STACK_DEPTH_LIMIT = 35;\nconst STACK_COUNT_LIMIT = 2_000;\n\nexport function withMetroErrorReportingResolver(config: MetroConfig): MetroConfig {\n if (!env.EXPO_METRO_UNSTABLE_ERRORS) {\n return config;\n }\n\n const originalResolveRequest = config.resolver?.resolveRequest;\n\n const depGraph: DepGraph = new Map();\n\n const mutateResolutionError = createMutateResolutionError(config, depGraph);\n\n return {\n ...config,\n resolver: {\n ...config.resolver,\n resolveRequest(context, moduleName, platform) {\n const storeResult = (res: NonNullable<ReturnType<ExpoCustomMetroResolver>>) => {\n const inputPlatform = platform ?? 'null';\n\n const key = optionsKeyForContext(context);\n if (!depGraph.has(key)) depGraph.set(key, new Map());\n const mapByTarget = depGraph.get(key);\n if (!mapByTarget!.has(inputPlatform)) mapByTarget!.set(inputPlatform, new Map());\n const mapByPlatform = mapByTarget!.get(inputPlatform);\n if (!mapByPlatform!.has(context.originModulePath))\n mapByPlatform!.set(context.originModulePath, new Set());\n const setForModule = mapByPlatform!.get(context.originModulePath)!;\n\n const qualifiedModuleName = res?.type === 'sourceFile' ? res.filePath : moduleName;\n setForModule.add({ path: qualifiedModuleName, request: moduleName });\n };\n\n // If the user defined a resolver, run it first and depend on the documented\n // chaining logic: https://facebook.github.io/metro/docs/resolution/#resolution-algorithm\n //\n // config.resolver.resolveRequest = (context, moduleName, platform) => {\n //\n // // Do work...\n //\n // return context.resolveRequest(context, moduleName, platform);\n // };\n try {\n const firstResolver = originalResolveRequest ?? context.resolveRequest;\n const res = firstResolver(context, moduleName, platform);\n storeResult(res);\n return res;\n } catch (error: any) {\n throw mutateResolutionError(error, context, moduleName, platform);\n }\n },\n },\n };\n}\n\nexport type DepGraph = Map<\n // custom options\n string,\n Map<\n // platform\n string,\n Map<\n // origin module name\n string,\n Set<{\n // required module name\n path: string;\n // This isn't entirely accurate since a module can be imported multiple times in a file,\n // and use different names. But it's good enough for now.\n request: string;\n }>\n >\n >\n>;\n\nfunction optionsKeyForContext(context: ResolutionContext) {\n const canonicalize: typeof import('@expo/metro/metro-core/canonicalize').default = require('@expo/metro/metro-core/canonicalize');\n // Compound key for the resolver cache\n return JSON.stringify(context.customResolverOptions ?? {}, canonicalize) ?? '';\n}\n\nexport const createMutateResolutionError =\n (\n config: MetroConfig,\n depGraph: DepGraph,\n stackDepthLimit = STACK_DEPTH_LIMIT,\n stackCountLimit = STACK_COUNT_LIMIT\n ) =>\n (error: Error, context: ResolutionContext, moduleName: string, platform: string | null) => {\n const inputPlatform = platform ?? 'null';\n\n const mapByOrigin = depGraph.get(optionsKeyForContext(context));\n const mapByPlatform = mapByOrigin?.get(inputPlatform);\n\n if (!mapByPlatform) {\n return error;\n }\n\n // collect all references inversely using some expensive lookup\n\n const getReferences = (origin: string) => {\n const inverseOrigin: { origin: string; previous: string; request: string }[] = [];\n\n if (!mapByPlatform) {\n return inverseOrigin;\n }\n\n for (const [originKey, mapByTarget] of mapByPlatform) {\n // search comparing origin to path\n\n const found = [...mapByTarget.values()].find((resolution) => resolution.path === origin);\n if (found) {\n inverseOrigin.push({\n origin,\n previous: originKey,\n request: found.request,\n });\n }\n }\n\n return inverseOrigin;\n };\n\n const root = config.server?.unstable_serverRoot ?? config.projectRoot;\n const projectRoot = config.projectRoot;\n\n type Frame = {\n origin: string;\n request: string;\n };\n type Stack = {\n circular?: boolean;\n limited?: boolean;\n serverRoot?: boolean;\n projectRoot?: boolean;\n frames: Frame[];\n };\n\n let stackCounter = 0;\n let inverseStack: Stack | undefined;\n /** @returns boolean - done */\n const saveStack = (stack: Stack): boolean => {\n stackCounter++;\n\n if (!inverseStack) {\n // First stack, save it\n inverseStack = stack;\n return false;\n }\n\n if (stackCounter >= stackCountLimit) {\n // Too many stacks explored, stop searching\n return true;\n }\n\n if (stack.circular || stack.limited) {\n // Not better than the current one, skip\n return false;\n }\n\n if (inverseStack.circular || inverseStack.limited) {\n // Current one is better than the previous one, save it\n inverseStack = stack;\n // No return as we want to continue validation the new stack\n }\n\n if (inverseStack.projectRoot) {\n // The best possible stack already acquired, skip\n return true;\n }\n\n const stackOrigin = stack.frames[stack.frames.length - 1].origin;\n\n if (\n stackOrigin &&\n isPathInside(stackOrigin, projectRoot) &&\n !stackOrigin.includes('node_modules')\n ) {\n // The best stack to show to users is the one leading from the project code.\n stack.serverRoot = true;\n inverseStack = stack;\n return true;\n }\n\n if (\n // Has to be after the project root check\n stackOrigin &&\n isPathInside(stackOrigin, root) &&\n !stackOrigin.includes('node_modules')\n ) {\n // The best stack to show to users is the one leading from the monorepo code.\n stack.serverRoot = true;\n inverseStack = stack;\n return false;\n }\n\n // If new stack is not better do nothing\n return false;\n };\n\n /** @returns boolean - done */\n const recurseBackWithLimit = (\n frame: { origin: string; request: string },\n limit: number,\n stack: Stack = { frames: [] },\n visited: Set<string> = new Set()\n ): boolean => {\n stack.frames.push(frame);\n\n if (visited.has(frame.origin)) {\n stack.circular = true;\n return saveStack(stack);\n }\n\n if (stack.frames.length >= limit) {\n stack.limited = true;\n return saveStack(stack);\n }\n\n visited.add(frame.origin);\n\n const inverse = getReferences(frame.origin);\n if (inverse.length === 0) {\n // No more references, push the stack and return\n return saveStack(stack);\n }\n\n for (const match of inverse) {\n // Use more qualified name if possible\n // results.origin = match.origin;\n // Found entry point\n if (frame.origin === match.previous) {\n continue;\n }\n\n const isDone = recurseBackWithLimit(\n { origin: match.previous, request: match.request },\n limit,\n {\n frames: [...stack.frames],\n },\n new Set(visited)\n );\n\n if (isDone) {\n return true; // Stop search\n }\n }\n\n return false; // Continue search\n };\n\n recurseBackWithLimit(\n { origin: context.originModulePath, request: moduleName },\n stackDepthLimit\n );\n\n debug('Number of explored stacks:', stackCounter);\n\n if (inverseStack && inverseStack.frames.length > 0) {\n const formattedImport = chalk`{gray |} {cyan import} `;\n const importMessagePadding = ' '.repeat(stripVTControlCharacters(formattedImport).length + 1);\n\n debug('Found inverse graph:', JSON.stringify(inverseStack, null, 2));\n\n let extraMessage = chalk.bold(\n `Import stack${stackCounter >= stackCountLimit ? ` (${stackCounter})` : ''}:`\n );\n\n for (const frame of inverseStack.frames) {\n let currentMessage = '';\n let filename = path.relative(root, frame.origin);\n\n if (filename.match(/\\?ctx=[\\w\\d]+$/)) {\n filename = filename.replace(/\\?ctx=[\\w\\d]+$/, chalk.dim(' (require.context)'));\n } else {\n let formattedRequest = chalk.green(`\"${frame.request}\"`);\n\n if (\n // If bundling for web and the import is pulling internals from outside of react-native\n // then mark it as an invalid import.\n inputPlatform === 'web' &&\n !/^(node_modules\\/)?react-native\\//.test(filename) &&\n frame.request.match(/^react-native\\/.*/)\n ) {\n formattedRequest =\n formattedRequest +\n chalk`\\n${importMessagePadding}{yellow ^ Importing react-native internals is not supported on web.}`;\n }\n\n filename = filename + chalk`\\n${formattedImport}${formattedRequest}`;\n }\n\n let line = '\\n' + chalk.gray(' ') + filename;\n if (filename.match(/node_modules/)) {\n line = chalk.gray(\n // Bold the node module name\n line.replace(/node_modules\\/([^/]+)/, (_match, p1) => {\n return 'node_modules/' + chalk.bold(p1);\n })\n );\n }\n currentMessage += `\\n${line}`;\n extraMessage += currentMessage;\n }\n\n if (inverseStack.circular) {\n extraMessage += chalk`\\n${importMessagePadding}{yellow ^ The import above creates circular dependency.}`;\n }\n\n if (inverseStack.limited) {\n extraMessage += chalk`\\n\\n {bold {yellow Depth limit reached. The actual stack is longer than what you can see above.}}`;\n }\n\n extraMessage += '\\n';\n\n // @ts-expect-error\n error._expoImportStack = extraMessage;\n } else {\n debug('Found no inverse tree for:', context.originModulePath);\n }\n\n return error;\n };\n"],"names":["createMutateResolutionError","withMetroErrorReportingResolver","debug","require","STACK_DEPTH_LIMIT","STACK_COUNT_LIMIT","config","env","EXPO_METRO_UNSTABLE_ERRORS","originalResolveRequest","resolver","resolveRequest","depGraph","Map","mutateResolutionError","context","moduleName","platform","storeResult","res","inputPlatform","key","optionsKeyForContext","has","set","mapByTarget","get","mapByPlatform","originModulePath","Set","setForModule","qualifiedModuleName","type","filePath","add","path","request","firstResolver","error","canonicalize","JSON","stringify","customResolverOptions","stackDepthLimit","stackCountLimit","mapByOrigin","getReferences","origin","inverseOrigin","originKey","found","values","find","resolution","push","previous","root","server","unstable_serverRoot","projectRoot","stackCounter","inverseStack","saveStack","stack","circular","limited","stackOrigin","frames","length","isPathInside","includes","serverRoot","recurseBackWithLimit","frame","limit","visited","inverse","match","isDone","formattedImport","chalk","importMessagePadding","repeat","stripVTControlCharacters","extraMessage","bold","currentMessage","filename","relative","replace","dim","formattedRequest","green","test","line","gray","_match","p1","_expoImportStack"],"mappings":";;;;;;;;;;;IAgGaA,2BAA2B;eAA3BA;;IAhFGC,+BAA+B;eAA/BA;;;;gEAdE;;;;;;;gEACD;;;;;;;yBACwB;;;;;;qBAGZ;qBACT;;;;;;AAEpB,MAAMC,QAAQC,QAAQ,SAAS;AAE/B,mCAAmC;AACnC,MAAMC,oBAAoB;AAC1B,MAAMC,oBAAoB;AAEnB,SAASJ,gCAAgCK,MAAmB;QAKlCA;IAJ/B,IAAI,CAACC,QAAG,CAACC,0BAA0B,EAAE;QACnC,OAAOF;IACT;IAEA,MAAMG,0BAAyBH,mBAAAA,OAAOI,QAAQ,qBAAfJ,iBAAiBK,cAAc;IAE9D,MAAMC,WAAqB,IAAIC;IAE/B,MAAMC,wBAAwBd,4BAA4BM,QAAQM;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
const _createExpoAutolinkingResolver = require("./createExpoAutolinkingResolver");
|
|
65
66
|
const _createExpoFallbackResolver = require("./createExpoFallbackResolver");
|
|
66
67
|
const _createExpoMetroResolver = require("./createExpoMetroResolver");
|
|
67
|
-
const _createExpoStickyResolver = require("./createExpoStickyResolver");
|
|
68
68
|
const _externals = require("./externals");
|
|
69
69
|
const _metroErrors = require("./metroErrors");
|
|
70
70
|
const _metroVirtualModules = require("./metroVirtualModules");
|
|
71
|
+
const _withMetroErrorReportingResolver = require("./withMetroErrorReportingResolver");
|
|
71
72
|
const _withMetroResolvers = require("./withMetroResolvers");
|
|
73
|
+
const _withMetroSupervisingTransformWorker = require("./withMetroSupervisingTransformWorker");
|
|
72
74
|
const _log = require("../../../log");
|
|
73
75
|
const _FileNotifier = require("../../../utils/FileNotifier");
|
|
74
76
|
const _env = require("../../../utils/env");
|
|
@@ -101,22 +103,38 @@ function withWebPolyfills(config, { getMetroBundler }) {
|
|
|
101
103
|
return 'try { global.$$require_external = typeof expo === "undefined" ? require : (moduleId) => { throw new Error(`Node.js standard library module ${moduleId} is not available in this JavaScript environment`);} } catch { global.$$require_external = (moduleId) => { throw new Error(`Node.js standard library module ${moduleId} is not available in this JavaScript environment`);} }';
|
|
102
104
|
}
|
|
103
105
|
})());
|
|
106
|
+
const virtualModulesPolyfills = [
|
|
107
|
+
virtualModuleId,
|
|
108
|
+
virtualEnvVarId
|
|
109
|
+
];
|
|
104
110
|
if (ctx.platform === 'web') {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
try {
|
|
112
|
+
const rnGetPolyfills = require('react-native/rn-get-polyfills');
|
|
113
|
+
return [
|
|
114
|
+
...virtualModulesPolyfills,
|
|
115
|
+
// Ensure that the error-guard polyfill is included in the web polyfills to
|
|
116
|
+
// make metro-runtime work correctly.
|
|
117
|
+
// TODO: This module is pretty big for a function that simply re-throws an error that doesn't need to be caught.
|
|
118
|
+
// NOTE(@kitten): This is technically the public API to get polyfills rather than resolving directly into
|
|
119
|
+
// `@react-native/js-polyfills`. We should really just start vendoring these, but for now, this exclusion works
|
|
120
|
+
...rnGetPolyfills().filter((x)=>!x.includes('/console'))
|
|
121
|
+
];
|
|
122
|
+
} catch (error) {
|
|
123
|
+
if ('code' in error && error.code === 'MODULE_NOT_FOUND') {
|
|
124
|
+
// If react-native is not installed, because we're targeting web, we still continue
|
|
125
|
+
// This should be rare, but we add it so we don't unnecessarily have a fixed peer dependency on react-native
|
|
126
|
+
debug('Skipping react-native/rn-get-polyfills from getPolyfills. react-native is not installed.');
|
|
127
|
+
return virtualModulesPolyfills;
|
|
128
|
+
} else {
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
113
132
|
}
|
|
114
|
-
// Generally uses
|
|
133
|
+
// Generally uses `@expo/metro-config`'s `getPolyfills` function, unless overridden
|
|
115
134
|
const polyfills = originalGetPolyfills(ctx);
|
|
116
135
|
return [
|
|
117
136
|
...polyfills,
|
|
118
|
-
|
|
119
|
-
virtualEnvVarId,
|
|
137
|
+
...virtualModulesPolyfills,
|
|
120
138
|
// Removed on server platforms during the transform.
|
|
121
139
|
require.resolve('expo/virtual/streams.js')
|
|
122
140
|
];
|
|
@@ -143,7 +161,7 @@ function getNodejsExtensions(srcExts) {
|
|
|
143
161
|
nodejsSourceExtensions.splice(jsIndex + 1, 0, ...mjsExts);
|
|
144
162
|
return nodejsSourceExtensions;
|
|
145
163
|
}
|
|
146
|
-
function withExtendedResolver(config, { tsconfig,
|
|
164
|
+
function withExtendedResolver(config, { tsconfig, autolinkingModuleResolverInput, isTsconfigPathsEnabled, isFastResolverEnabled, isExporting, isReactCanaryEnabled, isReactServerComponentsEnabled, getMetroBundler }) {
|
|
147
165
|
var _config_resolver, _config_resolver1, _config_resolver2, _config_resolver3, _config_serializer_createModuleIdFactory, _config_serializer;
|
|
148
166
|
if (isReactServerComponentsEnabled) {
|
|
149
167
|
_log.Log.warn(`React Server Components (beta) is enabled.`);
|
|
@@ -154,9 +172,6 @@ function withExtendedResolver(config, { tsconfig, stickyModuleResolverInput, isT
|
|
|
154
172
|
if (isFastResolverEnabled) {
|
|
155
173
|
_log.Log.log(_chalk().default.dim`Fast resolver is enabled.`);
|
|
156
174
|
}
|
|
157
|
-
if (stickyModuleResolverInput) {
|
|
158
|
-
_log.Log.log(_chalk().default.dim`Sticky resolver is enabled.`);
|
|
159
|
-
}
|
|
160
175
|
const defaultResolver = _metroresolver().resolve;
|
|
161
176
|
const resolver = isFastResolverEnabled ? (0, _createExpoMetroResolver.createFastResolver)({
|
|
162
177
|
preserveSymlinks: true,
|
|
@@ -476,7 +491,7 @@ function withExtendedResolver(config, { tsconfig, stickyModuleResolverInput, isT
|
|
|
476
491
|
}
|
|
477
492
|
return null;
|
|
478
493
|
},
|
|
479
|
-
(0,
|
|
494
|
+
(0, _createExpoAutolinkingResolver.createAutolinkingModuleResolver)(autolinkingModuleResolverInput, {
|
|
480
495
|
getStrictResolver
|
|
481
496
|
}),
|
|
482
497
|
// TODO: Reduce these as much as possible in the future.
|
|
@@ -489,9 +504,14 @@ function withExtendedResolver(config, { tsconfig, stickyModuleResolverInput, isT
|
|
|
489
504
|
}
|
|
490
505
|
if (platform === 'web') {
|
|
491
506
|
if (result.filePath.includes('node_modules')) {
|
|
492
|
-
//
|
|
493
|
-
if (
|
|
494
|
-
|
|
507
|
+
// Disallow importing confusing native modules on web
|
|
508
|
+
if ([
|
|
509
|
+
'react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore',
|
|
510
|
+
'react-native/Libraries/Utilities/codegenNativeCommands',
|
|
511
|
+
'react-native/Libraries/Utilities/codegenNativeComponent'
|
|
512
|
+
].some((matcher)=>// Support absolute and modules with .js extensions.
|
|
513
|
+
moduleName.includes(matcher))) {
|
|
514
|
+
throw new _createExpoMetroResolver.FailedToResolvePathError(`Importing native-only module "${moduleName}" on web from: ${_path().default.relative(config.projectRoot, context.originModulePath)}`);
|
|
495
515
|
}
|
|
496
516
|
// Replace with static shims
|
|
497
517
|
const normalName = normalizeSlashes(result.filePath)// Drop everything up until the `node_modules` folder.
|
|
@@ -632,19 +652,17 @@ function withExtendedResolver(config, { tsconfig, stickyModuleResolverInput, isT
|
|
|
632
652
|
}
|
|
633
653
|
return context;
|
|
634
654
|
});
|
|
635
|
-
return (0,
|
|
655
|
+
return (0, _withMetroErrorReportingResolver.withMetroErrorReportingResolver)((0, _withMetroSupervisingTransformWorker.withMetroSupervisingTransformWorker)(metroConfigWithCustomContext));
|
|
636
656
|
}
|
|
637
657
|
function shouldAliasModule(input, alias) {
|
|
638
658
|
var _input_result, _input_result1;
|
|
639
659
|
return input.platform === alias.platform && ((_input_result = input.result) == null ? void 0 : _input_result.type) === 'sourceFile' && typeof ((_input_result1 = input.result) == null ? void 0 : _input_result1.filePath) === 'string' && normalizeSlashes(input.result.filePath).endsWith(alias.output);
|
|
640
660
|
}
|
|
641
|
-
async function withMetroMultiPlatformAsync(projectRoot, { config, exp, platformBundlers, isTsconfigPathsEnabled,
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
metroDefaults.moduleSystem = require.resolve('@expo/cli/build/metro-require/require');
|
|
647
|
-
}
|
|
661
|
+
async function withMetroMultiPlatformAsync(projectRoot, { config, exp, platformBundlers, isTsconfigPathsEnabled, isAutolinkingResolverEnabled, isFastResolverEnabled, isExporting, isReactCanaryEnabled, isReactServerComponentsEnabled, getMetroBundler }) {
|
|
662
|
+
// Change the default metro-runtime to a custom one that supports bundle splitting.
|
|
663
|
+
// NOTE(@kitten): This is now always active and EXPO_USE_METRO_REQUIRE / isNamedRequiresEnabled is disregarded
|
|
664
|
+
const metroDefaults = require('@expo/metro/metro-config/defaults/defaults');
|
|
665
|
+
metroDefaults.moduleSystem = require.resolve('@expo/cli/build/metro-require/require');
|
|
648
666
|
if (!config.projectRoot) {
|
|
649
667
|
// @ts-expect-error: read-only types
|
|
650
668
|
config.projectRoot = projectRoot;
|
|
@@ -668,9 +686,6 @@ async function withMetroMultiPlatformAsync(projectRoot, { config, exp, platformB
|
|
|
668
686
|
config.watchFolders.push(_path().default.join(require.resolve('@expo/cli/package.json'), '..'));
|
|
669
687
|
}
|
|
670
688
|
}
|
|
671
|
-
// TODO: Remove this
|
|
672
|
-
// @ts-expect-error: Invalidate the cache when the location of expo-router changes on-disk.
|
|
673
|
-
config.transformer._expoRouterPath = _resolvefrom().default.silent(projectRoot, 'expo-router');
|
|
674
689
|
let tsconfig = null;
|
|
675
690
|
if (isTsconfigPathsEnabled) {
|
|
676
691
|
tsconfig = await (0, _loadTsConfigPaths.loadTsConfigPathsAsync)(projectRoot);
|
|
@@ -689,15 +704,15 @@ async function withMetroMultiPlatformAsync(projectRoot, { config, exp, platformB
|
|
|
689
704
|
config = withWebPolyfills(config, {
|
|
690
705
|
getMetroBundler
|
|
691
706
|
});
|
|
692
|
-
let
|
|
693
|
-
if (
|
|
694
|
-
|
|
707
|
+
let autolinkingModuleResolverInput;
|
|
708
|
+
if (isAutolinkingResolverEnabled) {
|
|
709
|
+
autolinkingModuleResolverInput = await (0, _createExpoAutolinkingResolver.createAutolinkingModuleResolverInput)({
|
|
695
710
|
platforms: expoConfigPlatforms,
|
|
696
711
|
projectRoot
|
|
697
712
|
});
|
|
698
713
|
}
|
|
699
714
|
return withExtendedResolver(config, {
|
|
700
|
-
|
|
715
|
+
autolinkingModuleResolverInput,
|
|
701
716
|
tsconfig,
|
|
702
717
|
isExporting,
|
|
703
718
|
isTsconfigPathsEnabled,
|