@expo/cli 0.13.2 → 0.14.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 +27 -25
- package/build/bin/cli.map +1 -1
- package/build/src/config/configAsync.js +1 -1
- package/build/src/config/configAsync.js.map +1 -1
- package/build/src/config/index.js +2 -2
- package/build/src/config/index.js.map +1 -1
- package/build/src/customize/generate.js +1 -1
- package/build/src/customize/generate.js.map +1 -1
- package/build/src/customize/typescript.js +3 -3
- package/build/src/customize/typescript.js.map +1 -1
- package/build/src/export/createMetadataJson.js.map +1 -1
- package/build/src/export/embed/index.js +4 -4
- package/build/src/export/embed/index.js.map +1 -1
- package/build/src/export/exportApp.js +6 -4
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportHermes.js +20 -10
- package/build/src/export/exportHermes.js.map +1 -1
- package/build/src/export/exportStaticAsync.js +55 -39
- package/build/src/export/exportStaticAsync.js.map +1 -1
- package/build/src/export/fork-bundleAsync.js +44 -13
- package/build/src/export/fork-bundleAsync.js.map +1 -1
- package/build/src/export/index.js +2 -2
- package/build/src/export/index.js.map +1 -1
- package/build/src/export/web/index.js +2 -2
- package/build/src/export/web/index.js.map +1 -1
- package/build/src/export/writeContents.js +3 -1
- package/build/src/export/writeContents.js.map +1 -1
- package/build/src/install/installAsync.js +1 -1
- package/build/src/install/installAsync.js.map +1 -1
- package/build/src/login/index.js +1 -1
- package/build/src/login/index.js.map +1 -1
- package/build/src/logout/index.js +1 -1
- package/build/src/logout/index.js.map +1 -1
- package/build/src/prebuild/index.js +3 -3
- package/build/src/prebuild/index.js.map +1 -1
- package/build/src/prebuild/prebuildAsync.js +2 -2
- package/build/src/prebuild/prebuildAsync.js.map +1 -1
- package/build/src/register/index.js +1 -1
- package/build/src/register/index.js.map +1 -1
- package/build/src/run/android/index.js +2 -2
- package/build/src/run/android/index.js.map +1 -1
- package/build/src/run/ios/appleDevice/AppleDevice.js +35 -2
- package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -1
- package/build/src/run/ios/index.js +2 -2
- package/build/src/run/ios/index.js.map +1 -1
- package/build/src/start/index.js +3 -3
- package/build/src/start/index.js.map +1 -1
- package/build/src/start/server/getStaticRenderFunctions.js +4 -1
- package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +29 -10
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/bundleApiRoutes.js +0 -16
- package/build/src/start/server/metro/bundleApiRoutes.js.map +1 -1
- package/build/src/start/server/metro/createExpoMetroResolver.js +170 -0
- package/build/src/start/server/metro/createExpoMetroResolver.js.map +1 -0
- package/build/src/start/server/metro/fetchRouterManifest.js.map +1 -1
- package/build/src/start/server/metro/formatFileCandidates.js +72 -0
- package/build/src/start/server/metro/formatFileCandidates.js.map +1 -0
- package/build/src/start/server/metro/instantiateMetro.js +6 -7
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/metroErrorInterface.js +2 -1
- package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
- package/build/src/start/server/metro/router.js +2 -2
- package/build/src/start/server/metro/router.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +31 -14
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +43 -15
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/resolveAssets.js.map +1 -1
- package/build/src/start/server/type-generation/expo-env.js +1 -1
- package/build/src/start/server/type-generation/expo-env.js.map +1 -1
- package/build/src/start/server/type-generation/routes.js +1 -0
- package/build/src/start/server/type-generation/routes.js.map +1 -1
- package/build/src/utils/analytics/rudderstackClient.js +2 -2
- package/build/src/utils/cocoapods.js +1 -0
- package/build/src/utils/cocoapods.js.map +1 -1
- package/build/src/utils/env.js +3 -0
- package/build/src/utils/env.js.map +1 -1
- package/build/src/whoami/index.js +1 -1
- package/build/src/whoami/index.js.map +1 -1
- package/package.json +7 -8
- package/static/shims/react-native-web/dist/cjs/exports/BackHandler/index.js +10 -0
- package/static/shims/react-native-web/dist/exports/BackHandler/index.js +7 -0
- package/build/src/export/createBundles.js +0 -37
- package/build/src/export/createBundles.js.map +0 -1
- package/build/src/start/server/middleware/resolveEntryPoint.js +0 -42
- package/build/src/start/server/middleware/resolveEntryPoint.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/router.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport { sync as globSync } from 'glob';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { Log } from '../../../log';\nimport { directoryExistsSync } from '../../../utils/dir';\n\nconst debug = require('debug')('expo:start:server:metro:router') as typeof console.log;\n\n/**\n * Get the relative path for requiring the `/app` folder relative to the `expo-router/entry` file.\n * This mechanism does require the server to restart after the `expo-router` package is installed.\n */\nexport function getAppRouterRelativeEntryPath(\n projectRoot: string,\n routerDirectory: string = getRouterDirectory(projectRoot)\n): string | undefined {\n // Auto pick App entry\n const routerEntry =\n resolveFrom.silent(projectRoot, 'expo-router/entry') ?? getFallbackEntryRoot(projectRoot);\n if (!routerEntry) {\n return undefined;\n }\n // It doesn't matter if the app folder exists.\n const appFolder = path.join(projectRoot, routerDirectory);\n const appRoot = path.relative(path.dirname(routerEntry), appFolder);\n debug('
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/router.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport { sync as globSync } from 'glob';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { Log } from '../../../log';\nimport { directoryExistsSync } from '../../../utils/dir';\n\nconst debug = require('debug')('expo:start:server:metro:router') as typeof console.log;\n\n/**\n * Get the relative path for requiring the `/app` folder relative to the `expo-router/entry` file.\n * This mechanism does require the server to restart after the `expo-router` package is installed.\n */\nexport function getAppRouterRelativeEntryPath(\n projectRoot: string,\n routerDirectory: string = getRouterDirectory(projectRoot)\n): string | undefined {\n // Auto pick App entry\n const routerEntry =\n resolveFrom.silent(projectRoot, 'expo-router/entry') ?? getFallbackEntryRoot(projectRoot);\n if (!routerEntry) {\n return undefined;\n }\n // It doesn't matter if the app folder exists.\n const appFolder = path.join(projectRoot, routerDirectory);\n const appRoot = path.relative(path.dirname(routerEntry), appFolder);\n debug('expo-router entry', routerEntry, appFolder, appRoot);\n return appRoot;\n}\n\n/** If the `expo-router` package is not installed, then use the `expo` package to determine where the node modules are relative to the project. */\nfunction getFallbackEntryRoot(projectRoot: string): string {\n const expoRoot = resolveFrom.silent(projectRoot, 'expo/package.json');\n if (expoRoot) {\n return path.join(path.dirname(path.dirname(expoRoot)), 'expo-router/entry');\n }\n return path.join(projectRoot, 'node_modules/expo-router/entry');\n}\n\nexport function getRouterDirectoryModuleIdWithManifest(\n projectRoot: string,\n exp: ExpoConfig\n): string {\n return exp.extra?.router?.unstable_src ?? getRouterDirectory(projectRoot);\n}\n\nexport function getRouterDirectoryWithManifest(projectRoot: string, exp: ExpoConfig): string {\n return path.join(projectRoot, getRouterDirectoryModuleIdWithManifest(projectRoot, exp));\n}\n\nexport function getRouterDirectory(projectRoot: string): string {\n // more specific directories first\n if (directoryExistsSync(path.join(projectRoot, 'src/app'))) {\n Log.log(chalk.gray('Using src/app as the root directory for Expo Router.'));\n return 'src/app';\n }\n\n debug('Using app as the root directory for Expo Router.');\n return 'app';\n}\n\nexport function isApiRouteConvention(name: string): boolean {\n return /\\+api\\.[tj]sx?$/.test(name);\n}\n\nexport function getApiRoutesForDirectory(cwd: string) {\n return globSync('**/*+api.@(ts|tsx|js|jsx)', {\n cwd,\n absolute: true,\n });\n}\n\n// Used to emulate a context module, but way faster. TODO: May need to adjust the extensions to stay in sync with Metro.\nexport function getRoutePaths(cwd: string) {\n return globSync('**/*.@(ts|tsx|js|jsx)', {\n cwd,\n }).map((p) => './' + normalizePaths(p));\n}\n\nfunction normalizePaths(p: string) {\n return p.replace(/\\\\/g, '/');\n}\n"],"names":["getAppRouterRelativeEntryPath","getRouterDirectoryModuleIdWithManifest","getRouterDirectoryWithManifest","getRouterDirectory","isApiRouteConvention","getApiRoutesForDirectory","getRoutePaths","debug","require","projectRoot","routerDirectory","resolveFrom","routerEntry","silent","getFallbackEntryRoot","undefined","appFolder","path","join","appRoot","relative","dirname","expoRoot","exp","extra","router","unstable_src","directoryExistsSync","Log","log","chalk","gray","name","test","cwd","globSync","absolute","map","p","normalizePaths","replace"],"mappings":"AAAA;;;;QAegBA,6BAA6B,GAA7BA,6BAA6B;QA0B7BC,sCAAsC,GAAtCA,sCAAsC;QAOtCC,8BAA8B,GAA9BA,8BAA8B;QAI9BC,kBAAkB,GAAlBA,kBAAkB;QAWlBC,oBAAoB,GAApBA,oBAAoB;QAIpBC,wBAAwB,GAAxBA,wBAAwB;QAQxBC,aAAa,GAAbA,aAAa;AA1EX,IAAA,MAAO,kCAAP,OAAO,EAAA;AACQ,IAAA,KAAM,WAAN,MAAM,CAAA;AACtB,IAAA,KAAM,kCAAN,MAAM,EAAA;AACC,IAAA,YAAc,kCAAd,cAAc,EAAA;AAElB,IAAA,IAAc,WAAd,cAAc,CAAA;AACE,IAAA,IAAoB,WAApB,oBAAoB,CAAA;;;;;;AAExD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,gCAAgC,CAAC,AAAsB,AAAC;AAMhF,SAASR,6BAA6B,CAC3CS,WAAmB,EACnBC,eAAuB,GAAGP,kBAAkB,CAACM,WAAW,CAAC,EACrC;QAGlBE,GAAoD;IAFtD,sBAAsB;IACtB,MAAMC,WAAW,GACfD,CAAAA,GAAoD,GAApDA,YAAW,QAAA,CAACE,MAAM,CAACJ,WAAW,EAAE,mBAAmB,CAAC,YAApDE,GAAoD,GAAIG,oBAAoB,CAACL,WAAW,CAAC,AAAC;IAC5F,IA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AAW,EAAER,sCAAsC,CAACQ,WAAW,EAAEc,GAAG,CAAC,CAAC,CAAC;CACzF;AAEM,SAASpB,kBAAkB,CAACM,WAAmB,EAAU;IAC9D,kCAAkC;IAClC,IAAIkB,CAAAA,GAAAA,IAAmB,AAAmC,CAAA,oBAAnC,CAACV,KAAI,QAAA,CAACC,IAAI,CAACT,WAAW,EAAE,SAAS,CAAC,CAAC,EAAE;QAC1DmB,IAAG,IAAA,CAACC,GAAG,CAACC,MAAK,QAAA,CAACC,IAAI,CAAC,sDAAsD,CAAC,CAAC,CAAC;QAC5E,OAAO,SAAS,CAAC;KAClB;IAEDxB,KAAK,CAAC,kDAAkD,CAAC,CAAC;IAC1D,OAAO,KAAK,CAAC;CACd;AAEM,SAASH,oBAAoB,CAAC4B,IAAY,EAAW;IAC1D,OAAO,kBAAkBC,IAAI,CAACD,IAAI,CAAC,CAAC;CACrC;AAEM,SAAS3B,wBAAwB,CAAC6B,GAAW,EAAE;IACpD,OAAOC,CAAAA,GAAAA,KAAQ,AAGb,CAAA,KAHa,CAAC,2BAA2B,EAAE;QAC3CD,GAAG;QACHE,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;CACJ;AAGM,SAAS9B,aAAa,CAAC4B,GAAW,EAAE;IACzC,OAAOC,CAAAA,GAAAA,KAAQ,AAEb,CAAA,KAFa,CAAC,uBAAuB,EAAE;QACvCD,GAAG;KACJ,CAAC,CAACG,GAAG,CAAC,CAACC,CAAC,GAAK,IAAI,GAAGC,cAAc,CAACD,CAAC,CAAC;IAAA,CAAC,CAAC;CACzC;AAED,SAASC,cAAc,CAACD,CAAS,EAAE;IACjC,OAAOA,CAAC,CAACE,OAAO,QAAQ,GAAG,CAAC,CAAC;CAC9B"}
|
|
@@ -7,10 +7,10 @@ exports.withExtendedResolver = withExtendedResolver;
|
|
|
7
7
|
exports.shouldAliasAssetRegistryForWeb = shouldAliasAssetRegistryForWeb;
|
|
8
8
|
exports.shouldAliasModule = shouldAliasModule;
|
|
9
9
|
exports.withMetroMultiPlatformAsync = withMetroMultiPlatformAsync;
|
|
10
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
11
10
|
var _fs = _interopRequireDefault(require("fs"));
|
|
12
11
|
var _path = _interopRequireDefault(require("path"));
|
|
13
12
|
var _resolveFrom = _interopRequireDefault(require("resolve-from"));
|
|
13
|
+
var _createExpoMetroResolver = require("./createExpoMetroResolver");
|
|
14
14
|
var _externals = require("./externals");
|
|
15
15
|
var _metroErrors = require("./metroErrors");
|
|
16
16
|
var _resolveFromProject = require("./resolveFromProject");
|
|
@@ -21,7 +21,6 @@ var _fileNotifier = require("../../../utils/FileNotifier");
|
|
|
21
21
|
var _env = require("../../../utils/env");
|
|
22
22
|
var _exit = require("../../../utils/exit");
|
|
23
23
|
var _interactive = require("../../../utils/interactive");
|
|
24
|
-
var _link = require("../../../utils/link");
|
|
25
24
|
var _loadTsConfigPaths = require("../../../utils/tsconfig/loadTsConfigPaths");
|
|
26
25
|
var _resolveWithTsConfigPaths = require("../../../utils/tsconfig/resolveWithTsConfigPaths");
|
|
27
26
|
var _webSupportProjectPrerequisite = require("../../doctor/web/WebSupportProjectPrerequisite");
|
|
@@ -72,7 +71,11 @@ function getNodejsExtensions(srcExts) {
|
|
|
72
71
|
nodejsSourceExtensions.splice(jsIndex + 1, 0, ...mjsExts);
|
|
73
72
|
return nodejsSourceExtensions;
|
|
74
73
|
}
|
|
75
|
-
function withExtendedResolver(config, { projectRoot , tsconfig , platforms , isTsconfigPathsEnabled }) {
|
|
74
|
+
function withExtendedResolver(config, { projectRoot , tsconfig , platforms , isTsconfigPathsEnabled , isFastResolverEnabled }) {
|
|
75
|
+
var ref2;
|
|
76
|
+
if (isFastResolverEnabled) {
|
|
77
|
+
_log.Log.warn(`Experimental bundling features are enabled.`);
|
|
78
|
+
}
|
|
76
79
|
// Get the `transformer.assetRegistryPath`
|
|
77
80
|
// this needs to be unified since you can't dynamically
|
|
78
81
|
// swap out the transformer based on platform.
|
|
@@ -84,7 +87,10 @@ function withExtendedResolver(config, { projectRoot , tsconfig , platforms , isT
|
|
|
84
87
|
_path.default.resolve((0, _resolveFrom).default(projectRoot, "expo-router/build/fork/react-native-web-container")));
|
|
85
88
|
} catch {}
|
|
86
89
|
const isWebEnabled = platforms.includes("web");
|
|
87
|
-
|
|
90
|
+
var ref1;
|
|
91
|
+
const resolver = isFastResolverEnabled ? (0, _createExpoMetroResolver).createFastResolver({
|
|
92
|
+
preserveSymlinks: (ref1 = (ref2 = config.resolver) == null ? void 0 : ref2.unstable_enableSymlinks) != null ? ref1 : false
|
|
93
|
+
}) : (0, _resolveFromProject).importMetroResolverFromProject(projectRoot).resolve;
|
|
88
94
|
const extraNodeModules = {};
|
|
89
95
|
const aliases = {
|
|
90
96
|
web: {
|
|
@@ -145,6 +151,7 @@ function withExtendedResolver(config, { projectRoot , tsconfig , platforms , isT
|
|
|
145
151
|
debug("Skipping tsconfig.json paths support");
|
|
146
152
|
}
|
|
147
153
|
let nodejsSourceExtensions = null;
|
|
154
|
+
const shimsFolder = _path.default.join(require.resolve("@expo/cli/package.json"), "..", "static/shims");
|
|
148
155
|
return (0, _withMetroResolvers).withMetroResolvers(config, projectRoot, [
|
|
149
156
|
// Add a resolver to alias the web asset resolver.
|
|
150
157
|
(immutableContext, moduleName1, platform)=>{
|
|
@@ -206,7 +213,7 @@ function withExtendedResolver(config, { projectRoot , tsconfig , platforms , isT
|
|
|
206
213
|
mainFields = preferredMainFields[platform];
|
|
207
214
|
}
|
|
208
215
|
function doResolve(moduleName) {
|
|
209
|
-
return
|
|
216
|
+
return resolver({
|
|
210
217
|
...context,
|
|
211
218
|
resolveRequest: undefined,
|
|
212
219
|
mainFields,
|
|
@@ -249,7 +256,7 @@ function withExtendedResolver(config, { projectRoot , tsconfig , platforms , isT
|
|
|
249
256
|
moduleName: moduleName1
|
|
250
257
|
}, optionalResolve);
|
|
251
258
|
}
|
|
252
|
-
if (// is web
|
|
259
|
+
if (!isFastResolverEnabled && // is web
|
|
253
260
|
platform === "web" && // Not server runtime
|
|
254
261
|
!isNode && // Is Node.js built-in
|
|
255
262
|
(0, _externals).isNodeExternal(moduleName1)) {
|
|
@@ -264,7 +271,7 @@ function withExtendedResolver(config, { projectRoot , tsconfig , platforms , isT
|
|
|
264
271
|
}
|
|
265
272
|
}
|
|
266
273
|
result != null ? result : result = doResolve(moduleName1);
|
|
267
|
-
if (result) {
|
|
274
|
+
if ((result == null ? void 0 : result.type) === "sourceFile") {
|
|
268
275
|
// Replace the web resolver with the original one.
|
|
269
276
|
// This is basically an alias for web-only.
|
|
270
277
|
if (shouldAliasAssetRegistryForWeb(platform, result)) {
|
|
@@ -284,6 +291,15 @@ function withExtendedResolver(config, { projectRoot , tsconfig , platforms , isT
|
|
|
284
291
|
})) {
|
|
285
292
|
// @ts-expect-error: `readonly` for some reason.
|
|
286
293
|
result.filePath = reactNativeWebAppContainer;
|
|
294
|
+
} else if (platform === "web" && result.filePath.includes("node_modules")) {
|
|
295
|
+
// Replace with static shims
|
|
296
|
+
const normalName = normalizeSlashes(result.filePath)// Drop everything up until the `node_modules` folder.
|
|
297
|
+
.replace(/.*node_modules\//, "");
|
|
298
|
+
const shimPath = _path.default.join(shimsFolder, normalName);
|
|
299
|
+
if (_fs.default.existsSync(shimPath)) {
|
|
300
|
+
// @ts-expect-error: `readonly` for some reason.
|
|
301
|
+
result.filePath = shimPath;
|
|
302
|
+
}
|
|
287
303
|
}
|
|
288
304
|
}
|
|
289
305
|
return result;
|
|
@@ -294,10 +310,10 @@ function shouldAliasAssetRegistryForWeb(platform, result) {
|
|
|
294
310
|
return platform === "web" && (result == null ? void 0 : result.type) === "sourceFile" && typeof (result == null ? void 0 : result.filePath) === "string" && normalizeSlashes(result.filePath).endsWith("react-native-web/dist/modules/AssetRegistry/index.js");
|
|
295
311
|
}
|
|
296
312
|
function shouldAliasModule(input, alias) {
|
|
297
|
-
var ref,
|
|
298
|
-
return input.platform === alias.platform && ((ref = input.result) == null ? void 0 : ref.type) === "sourceFile" && typeof ((
|
|
313
|
+
var ref, ref3;
|
|
314
|
+
return input.platform === alias.platform && ((ref = input.result) == null ? void 0 : ref.type) === "sourceFile" && typeof ((ref3 = input.result) == null ? void 0 : ref3.filePath) === "string" && normalizeSlashes(input.result.filePath).endsWith(alias.output);
|
|
299
315
|
}
|
|
300
|
-
async function withMetroMultiPlatformAsync(projectRoot, { config , platformBundlers , isTsconfigPathsEnabled , webOutput , routerDirectory }) {
|
|
316
|
+
async function withMetroMultiPlatformAsync(projectRoot, { config , platformBundlers , isTsconfigPathsEnabled , webOutput , routerDirectory , isFastResolverEnabled }) {
|
|
301
317
|
// Auto pick app entry for router.
|
|
302
318
|
process.env.EXPO_ROUTER_APP_ROOT = (0, _router).getAppRouterRelativeEntryPath(projectRoot, routerDirectory);
|
|
303
319
|
var _EXPO_PUBLIC_PROJECT_ROOT;
|
|
@@ -321,7 +337,6 @@ async function withMetroMultiPlatformAsync(projectRoot, { config , platformBundl
|
|
|
321
337
|
}
|
|
322
338
|
let tsconfig = null;
|
|
323
339
|
if (isTsconfigPathsEnabled) {
|
|
324
|
-
_log.Log.warn(_chalk.default.yellow`Experimental path aliases feature is enabled. ` + (0, _link).learnMore("https://docs.expo.dev/guides/typescript/#path-aliases"));
|
|
325
340
|
tsconfig = await (0, _loadTsConfigPaths).loadTsConfigPathsAsync(projectRoot);
|
|
326
341
|
}
|
|
327
342
|
await (0, _externals).setupNodeExternals(projectRoot);
|
|
@@ -329,10 +344,11 @@ async function withMetroMultiPlatformAsync(projectRoot, { config , platformBundl
|
|
|
329
344
|
config,
|
|
330
345
|
platformBundlers,
|
|
331
346
|
tsconfig,
|
|
332
|
-
isTsconfigPathsEnabled
|
|
347
|
+
isTsconfigPathsEnabled,
|
|
348
|
+
isFastResolverEnabled
|
|
333
349
|
});
|
|
334
350
|
}
|
|
335
|
-
function withMetroMultiPlatform(projectRoot, { config , platformBundlers , isTsconfigPathsEnabled , tsconfig }) {
|
|
351
|
+
function withMetroMultiPlatform(projectRoot, { config , platformBundlers , isTsconfigPathsEnabled , tsconfig , isFastResolverEnabled }) {
|
|
336
352
|
let expoConfigPlatforms = Object.entries(platformBundlers).filter(([, bundler])=>bundler === "metro"
|
|
337
353
|
).map(([platform])=>platform
|
|
338
354
|
);
|
|
@@ -350,7 +366,8 @@ function withMetroMultiPlatform(projectRoot, { config , platformBundlers , isTsc
|
|
|
350
366
|
projectRoot,
|
|
351
367
|
tsconfig,
|
|
352
368
|
isTsconfigPathsEnabled,
|
|
353
|
-
platforms: expoConfigPlatforms
|
|
369
|
+
platforms: expoConfigPlatforms,
|
|
370
|
+
isFastResolverEnabled
|
|
354
371
|
});
|
|
355
372
|
}
|
|
356
373
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/withMetroMultiPlatform.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport { ConfigT } from 'metro-config';\nimport { Resolution, ResolutionContext } from 'metro-resolver';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport {\n EXTERNAL_REQUIRE_NATIVE_POLYFILL,\n EXTERNAL_REQUIRE_POLYFILL,\n getNodeExternalModuleId,\n isNodeExternal,\n setupNodeExternals,\n} from './externals';\nimport { isFailedToResolveNameError, isFailedToResolvePathError } from './metroErrors';\nimport { importMetroResolverFromProject } from './resolveFromProject';\nimport { getAppRouterRelativeEntryPath } from './router';\nimport { withMetroResolvers } from './withMetroResolvers';\nimport { Log } from '../../../log';\nimport { FileNotifier } from '../../../utils/FileNotifier';\nimport { env } from '../../../utils/env';\nimport { installExitHooks } from '../../../utils/exit';\nimport { isInteractive } from '../../../utils/interactive';\nimport { learnMore } from '../../../utils/link';\nimport { loadTsConfigPathsAsync, TsConfigPaths } from '../../../utils/tsconfig/loadTsConfigPaths';\nimport { resolveWithTsConfigPaths } from '../../../utils/tsconfig/resolveWithTsConfigPaths';\nimport { WebSupportProjectPrerequisite } from '../../doctor/web/WebSupportProjectPrerequisite';\nimport { PlatformBundlers } from '../platformBundlers';\n\ntype Mutable<T> = { -readonly [K in keyof T]: T[K] };\n\nconst debug = require('debug')('expo:start:server:metro:multi-platform') as typeof console.log;\n\nfunction withWebPolyfills(config: ConfigT, projectRoot: string): ConfigT {\n const originalGetPolyfills = config.serializer.getPolyfills\n ? config.serializer.getPolyfills.bind(config.serializer)\n : () => [];\n\n const getPolyfills = (ctx: { platform: string | null }): readonly string[] => {\n if (ctx.platform === 'web') {\n return [\n // NOTE: We might need this for all platforms\n path.join(projectRoot, EXTERNAL_REQUIRE_POLYFILL),\n // TODO: runtime polyfills, i.e. Fast Refresh, error overlay, React Dev Tools...\n ];\n }\n // Generally uses `rn-get-polyfills`\n const polyfills = originalGetPolyfills(ctx);\n\n return [...polyfills, EXTERNAL_REQUIRE_NATIVE_POLYFILL];\n };\n\n return {\n ...config,\n serializer: {\n ...config.serializer,\n getPolyfills,\n },\n };\n}\n\nfunction normalizeSlashes(p: string) {\n return p.replace(/\\\\/g, '/');\n}\n\nexport function getNodejsExtensions(srcExts: readonly string[]): string[] {\n const mjsExts = srcExts.filter((ext) => /mjs$/.test(ext));\n const nodejsSourceExtensions = srcExts.filter((ext) => !/mjs$/.test(ext));\n // find index of last `*.js` extension\n const jsIndex = nodejsSourceExtensions.reduce((index, ext, i) => {\n return /jsx?$/.test(ext) ? i : index;\n }, -1);\n\n // insert `*.mjs` extensions after `*.js` extensions\n nodejsSourceExtensions.splice(jsIndex + 1, 0, ...mjsExts);\n\n return nodejsSourceExtensions;\n}\n\n/**\n * Apply custom resolvers to do the following:\n * - Disable `.native.js` extensions on web.\n * - Alias `react-native` to `react-native-web` on web.\n * - Redirect `react-native-web/dist/modules/AssetRegistry/index.js` to `@react-native/assets/registry.js` on web.\n * - Add support for `tsconfig.json`/`jsconfig.json` aliases via `compilerOptions.paths`.\n */\nexport function withExtendedResolver(\n config: ConfigT,\n {\n projectRoot,\n tsconfig,\n platforms,\n isTsconfigPathsEnabled,\n }: {\n projectRoot: string;\n tsconfig: TsConfigPaths | null;\n platforms: string[];\n isTsconfigPathsEnabled?: boolean;\n }\n) {\n // Get the `transformer.assetRegistryPath`\n // this needs to be unified since you can't dynamically\n // swap out the transformer based on platform.\n const assetRegistryPath = fs.realpathSync(\n // This is the native asset registry alias for native.\n path.resolve(resolveFrom(projectRoot, 'react-native/Libraries/Image/AssetRegistry'))\n // NOTE(EvanBacon): This is the newer import but it doesn't work in the expo/expo monorepo.\n // path.resolve(resolveFrom(projectRoot, '@react-native/assets/registry.js'))\n );\n\n let reactNativeWebAppContainer: string | null = null;\n try {\n reactNativeWebAppContainer = fs.realpathSync(\n // This is the native asset registry alias for native.\n path.resolve(resolveFrom(projectRoot, 'expo-router/build/fork/react-native-web-container'))\n // NOTE(EvanBacon): This is the newer import but it doesn't work in the expo/expo monorepo.\n // path.resolve(resolveFrom(projectRoot, '@react-native/assets/registry.js'))\n );\n } catch {}\n\n const isWebEnabled = platforms.includes('web');\n\n const { resolve } = importMetroResolverFromProject(projectRoot);\n\n const extraNodeModules: { [key: string]: Record<string, string> } = {};\n\n const aliases: { [key: string]: Record<string, string> } = {\n web: {\n 'react-native': 'react-native-web',\n 'react-native/index': 'react-native-web',\n },\n };\n\n if (isWebEnabled) {\n // Allow `react-native-web` to be optional when web is not enabled but path aliases is.\n extraNodeModules['web'] = {\n 'react-native': path.resolve(require.resolve('react-native-web/package.json'), '..'),\n };\n }\n\n const preferredMainFields: { [key: string]: string[] } = {\n // Defaults from Expo Webpack. Most packages using `react-native` don't support web\n // in the `react-native` field, so we should prefer the `browser` field.\n // https://github.com/expo/router/issues/37\n web: ['browser', 'module', 'main'],\n };\n\n let tsConfigResolve = tsconfig?.paths\n ? resolveWithTsConfigPaths.bind(resolveWithTsConfigPaths, {\n paths: tsconfig.paths ?? {},\n baseUrl: tsconfig.baseUrl,\n })\n : null;\n\n if (isTsconfigPathsEnabled && isInteractive()) {\n // TODO: We should track all the files that used imports and invalidate them\n // currently the user will need to save all the files that use imports to\n // use the new aliases.\n const configWatcher = new FileNotifier(projectRoot, ['./tsconfig.json', './jsconfig.json']);\n configWatcher.startObserving(() => {\n debug('Reloading tsconfig.json');\n loadTsConfigPathsAsync(projectRoot).then((tsConfigPaths) => {\n if (tsConfigPaths?.paths && !!Object.keys(tsConfigPaths.paths).length) {\n debug('Enabling tsconfig.json paths support');\n tsConfigResolve = resolveWithTsConfigPaths.bind(resolveWithTsConfigPaths, {\n paths: tsConfigPaths.paths ?? {},\n baseUrl: tsConfigPaths.baseUrl,\n });\n } else {\n debug('Disabling tsconfig.json paths support');\n tsConfigResolve = null;\n }\n });\n });\n\n // TODO: This probably prevents the process from exiting.\n installExitHooks(() => {\n configWatcher.stopObserving();\n });\n } else {\n debug('Skipping tsconfig.json paths support');\n }\n\n let nodejsSourceExtensions: string[] | null = null;\n\n return withMetroResolvers(config, projectRoot, [\n // Add a resolver to alias the web asset resolver.\n (immutableContext: ResolutionContext, moduleName: string, platform: string | null) => {\n let context = {\n ...immutableContext,\n } as Mutable<ResolutionContext> & {\n mainFields: string[];\n customResolverOptions?: Record<string, string>;\n };\n\n const environment = context.customResolverOptions?.environment;\n const isNode = environment === 'node';\n\n // TODO: We need to prevent the require.context from including API routes as these use externals.\n // Should be fine after async routes lands.\n if (isNode) {\n const moduleId = isNodeExternal(moduleName);\n if (moduleId) {\n moduleName = getNodeExternalModuleId(context.originModulePath, moduleId);\n debug(`Redirecting Node.js external \"${moduleId}\" to \"${moduleName}\"`);\n }\n\n // Adjust nodejs source extensions to sort mjs after js, including platform variants.\n if (nodejsSourceExtensions === null) {\n nodejsSourceExtensions = getNodejsExtensions(context.sourceExts);\n }\n context.sourceExts = nodejsSourceExtensions;\n }\n\n // Conditionally remap `react-native` to `react-native-web` on web in\n // a way that doesn't require Babel to resolve the alias.\n if (platform && platform in aliases && aliases[platform][moduleName]) {\n moduleName = aliases[platform][moduleName];\n }\n\n // TODO: We may be able to remove this in the future, it's doing no harm\n // by staying here.\n // Conditionally remap `react-native` to `react-native-web`\n if (platform && platform in extraNodeModules) {\n context.extraNodeModules = {\n ...extraNodeModules[platform],\n ...context.extraNodeModules,\n };\n }\n\n if (tsconfig?.baseUrl && isTsconfigPathsEnabled) {\n context = {\n ...context,\n nodeModulesPaths: [\n ...immutableContext.nodeModulesPaths,\n // add last to ensure node modules are resolved first\n tsconfig.baseUrl,\n ],\n };\n }\n\n let mainFields: string[] = context.mainFields;\n\n if (isNode) {\n // Node.js runtimes should only be importing main at the moment.\n // This is a temporary fix until we can support the package.json exports.\n mainFields = ['main', 'module'];\n } else if (env.EXPO_METRO_NO_MAIN_FIELD_OVERRIDE) {\n mainFields = context.mainFields;\n } else if (platform && platform in preferredMainFields) {\n mainFields = preferredMainFields[platform];\n }\n function doResolve(moduleName: string): Resolution | null {\n return resolve(\n {\n ...context,\n resolveRequest: undefined,\n mainFields,\n\n // Passing `mainFields` directly won't be considered (in certain version of Metro)\n // we need to extend the `getPackageMainPath` directly to\n // use platform specific `mainFields`.\n // @ts-ignore\n getPackageMainPath(packageJsonPath) {\n // @ts-expect-error: mainFields is not on type\n const package_ = context.moduleCache.getPackage(packageJsonPath);\n return package_.getMain(mainFields);\n },\n },\n moduleName,\n platform\n );\n }\n\n function optionalResolve(moduleName: string): Resolution | null {\n try {\n return doResolve(moduleName);\n } catch (error) {\n // If the error is directly related to a resolver not being able to resolve a module, then\n // we can ignore the error and try the next resolver. Otherwise, we should throw the error.\n const isResolutionError =\n isFailedToResolveNameError(error) || isFailedToResolvePathError(error);\n if (!isResolutionError) {\n throw error;\n }\n }\n return null;\n }\n\n let result: Resolution | null = null;\n\n // React Native uses `event-target-shim` incorrectly and this causes the native runtime\n // to fail to load. This is a temporary workaround until we can fix this upstream.\n // https://github.com/facebook/react-native/pull/38628\n if (\n moduleName.includes('event-target-shim') &&\n context.originModulePath.includes(path.sep + 'react-native' + path.sep)\n ) {\n context.sourceExts = context.sourceExts.filter((f) => !f.includes('mjs'));\n debug('Skip mjs support for event-target-shim in:', context.originModulePath);\n }\n\n if (tsConfigResolve) {\n result = tsConfigResolve(\n {\n originModulePath: context.originModulePath,\n moduleName,\n },\n optionalResolve\n );\n }\n\n if (\n // is web\n platform === 'web' &&\n // Not server runtime\n !isNode &&\n // Is Node.js built-in\n isNodeExternal(moduleName)\n ) {\n // Perform optional resolve first. If the module doesn't exist (no module in the node_modules)\n // then we can mock the file to use an empty module.\n result ??= optionalResolve(moduleName);\n\n if (!result) {\n // In this case, mock the file to use an empty module.\n return {\n type: 'empty',\n };\n }\n }\n\n result ??= doResolve(moduleName);\n\n if (result) {\n // Replace the web resolver with the original one.\n // This is basically an alias for web-only.\n if (shouldAliasAssetRegistryForWeb(platform, result)) {\n // @ts-expect-error: `readonly` for some reason.\n result.filePath = assetRegistryPath;\n }\n\n // React Native Web adds a couple extra divs for no reason, these\n // make static rendering much harder as we expect the root element to be `<html>`.\n // This resolution will alias to a simple in-out component to avoid React Native web.\n if (\n // Only apply the transform if expo-router is present.\n reactNativeWebAppContainer &&\n shouldAliasModule(\n {\n platform,\n result,\n },\n {\n platform: 'web',\n output: 'react-native-web/dist/exports/AppRegistry/AppContainer.js',\n }\n )\n ) {\n // @ts-expect-error: `readonly` for some reason.\n result.filePath = reactNativeWebAppContainer;\n }\n }\n return result;\n },\n ]);\n}\n\n/** @returns `true` if the incoming resolution should be swapped on web. */\nexport function shouldAliasAssetRegistryForWeb(\n platform: string | null,\n result: Resolution\n): boolean {\n return (\n platform === 'web' &&\n result?.type === 'sourceFile' &&\n typeof result?.filePath === 'string' &&\n normalizeSlashes(result.filePath).endsWith(\n 'react-native-web/dist/modules/AssetRegistry/index.js'\n )\n );\n}\n/** @returns `true` if the incoming resolution should be swapped. */\nexport function shouldAliasModule(\n input: {\n platform: string | null;\n result: Resolution;\n },\n alias: { platform: string; output: string }\n): boolean {\n return (\n input.platform === alias.platform &&\n input.result?.type === 'sourceFile' &&\n typeof input.result?.filePath === 'string' &&\n normalizeSlashes(input.result.filePath).endsWith(alias.output)\n );\n}\n\n/** Add support for `react-native-web` and the Web platform. */\nexport async function withMetroMultiPlatformAsync(\n projectRoot: string,\n {\n config,\n platformBundlers,\n isTsconfigPathsEnabled,\n webOutput,\n routerDirectory,\n }: {\n config: ConfigT;\n isTsconfigPathsEnabled: boolean;\n platformBundlers: PlatformBundlers;\n webOutput?: 'single' | 'static' | 'server';\n routerDirectory: string;\n }\n) {\n // Auto pick app entry for router.\n process.env.EXPO_ROUTER_APP_ROOT = getAppRouterRelativeEntryPath(projectRoot, routerDirectory);\n\n // Required for @expo/metro-runtime to format paths in the web LogBox.\n process.env.EXPO_PUBLIC_PROJECT_ROOT = process.env.EXPO_PUBLIC_PROJECT_ROOT ?? projectRoot;\n\n if (['static', 'server'].includes(webOutput ?? '')) {\n // Enable static rendering in runtime space.\n process.env.EXPO_PUBLIC_USE_STATIC = '1';\n }\n\n // Ensure the cache is invalidated if these values change.\n // @ts-expect-error\n config.transformer._expoRouterRootDirectory = process.env.EXPO_ROUTER_APP_ROOT;\n // @ts-expect-error\n config.transformer._expoRouterWebRendering = webOutput;\n // TODO: import mode\n\n if (platformBundlers.web === 'metro') {\n await new WebSupportProjectPrerequisite(projectRoot).assertAsync();\n }\n\n let tsconfig: null | TsConfigPaths = null;\n\n if (isTsconfigPathsEnabled) {\n Log.warn(\n chalk.yellow`Experimental path aliases feature is enabled. ` +\n learnMore('https://docs.expo.dev/guides/typescript/#path-aliases')\n );\n tsconfig = await loadTsConfigPathsAsync(projectRoot);\n }\n\n await setupNodeExternals(projectRoot);\n\n return withMetroMultiPlatform(projectRoot, {\n config,\n platformBundlers,\n tsconfig,\n isTsconfigPathsEnabled,\n });\n}\n\nfunction withMetroMultiPlatform(\n projectRoot: string,\n {\n config,\n platformBundlers,\n isTsconfigPathsEnabled,\n tsconfig,\n }: {\n config: ConfigT;\n isTsconfigPathsEnabled: boolean;\n platformBundlers: PlatformBundlers;\n tsconfig: TsConfigPaths | null;\n }\n) {\n let expoConfigPlatforms = Object.entries(platformBundlers)\n .filter(([, bundler]) => bundler === 'metro')\n .map(([platform]) => platform);\n\n if (Array.isArray(config.resolver.platforms)) {\n expoConfigPlatforms = [...new Set(expoConfigPlatforms.concat(config.resolver.platforms))];\n }\n\n // @ts-expect-error: typed as `readonly`.\n config.resolver.platforms = expoConfigPlatforms;\n\n if (expoConfigPlatforms.includes('web')) {\n config = withWebPolyfills(config, projectRoot);\n }\n\n return withExtendedResolver(config, {\n projectRoot,\n tsconfig,\n isTsconfigPathsEnabled,\n platforms: expoConfigPlatforms,\n });\n}\n"],"names":["getNodejsExtensions","withExtendedResolver","shouldAliasAssetRegistryForWeb","shouldAliasModule","withMetroMultiPlatformAsync","debug","require","withWebPolyfills","config","projectRoot","originalGetPolyfills","serializer","getPolyfills","bind","ctx","platform","path","join","EXTERNAL_REQUIRE_POLYFILL","polyfills","EXTERNAL_REQUIRE_NATIVE_POLYFILL","normalizeSlashes","p","replace","srcExts","mjsExts","filter","ext","test","nodejsSourceExtensions","jsIndex","reduce","index","i","splice","tsconfig","platforms","isTsconfigPathsEnabled","assetRegistryPath","fs","realpathSync","resolve","resolveFrom","reactNativeWebAppContainer","isWebEnabled","includes","importMetroResolverFromProject","extraNodeModules","aliases","web","preferredMainFields","tsConfigResolve","paths","resolveWithTsConfigPaths","baseUrl","isInteractive","configWatcher","FileNotifier","startObserving","loadTsConfigPathsAsync","then","tsConfigPaths","Object","keys","length","installExitHooks","stopObserving","withMetroResolvers","immutableContext","moduleName","context","environment","customResolverOptions","isNode","moduleId","isNodeExternal","getNodeExternalModuleId","originModulePath","sourceExts","nodeModulesPaths","mainFields","env","EXPO_METRO_NO_MAIN_FIELD_OVERRIDE","doResolve","resolveRequest","undefined","getPackageMainPath","packageJsonPath","package_","moduleCache","getPackage","getMain","optionalResolve","error","isResolutionError","isFailedToResolveNameError","isFailedToResolvePathError","result","sep","f","type","filePath","output","endsWith","input","alias","platformBundlers","webOutput","routerDirectory","process","EXPO_ROUTER_APP_ROOT","getAppRouterRelativeEntryPath","EXPO_PUBLIC_PROJECT_ROOT","EXPO_PUBLIC_USE_STATIC","transformer","_expoRouterRootDirectory","_expoRouterWebRendering","WebSupportProjectPrerequisite","assertAsync","Log","warn","chalk","yellow","learnMore","setupNodeExternals","withMetroMultiPlatform","expoConfigPlatforms","entries","bundler","map","Array","isArray","resolver","Set","concat"],"mappings":"AAMA;;;;QAiEgBA,mBAAmB,GAAnBA,mBAAmB;QAqBnBC,oBAAoB,GAApBA,oBAAoB;QA2RpBC,8BAA8B,GAA9BA,8BAA8B;QAc9BC,iBAAiB,GAAjBA,iBAAiB;QAgBXC,2BAA2B,GAA3BA,2BAA2B;AA/Y/B,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAGF,IAAA,KAAM,kCAAN,MAAM,EAAA;AACC,IAAA,YAAc,kCAAd,cAAc,EAAA;AAQ/B,IAAA,UAAa,WAAb,aAAa,CAAA;AACmD,IAAA,YAAe,WAAf,eAAe,CAAA;AACvC,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AACvB,IAAA,OAAU,WAAV,UAAU,CAAA;AACrB,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AACrC,IAAA,IAAc,WAAd,cAAc,CAAA;AACL,IAAA,aAA6B,WAA7B,6BAA6B,CAAA;AACtC,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACP,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AACxB,IAAA,YAA4B,WAA5B,4BAA4B,CAAA;AAChC,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AACO,IAAA,kBAA2C,WAA3C,2CAA2C,CAAA;AACxD,IAAA,yBAAkD,WAAlD,kDAAkD,CAAA;AAC7C,IAAA,8BAAgD,WAAhD,gDAAgD,CAAA;;;;;;AAK9F,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAA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CAACjF,QAAQ,CAAC,KAAK,CAAC,EAAE;QACvCrC,MAAM,GAAGD,gBAAgB,CAACC,MAAM,EAAEC,WAAW,CAAC,CAAC;KAChD;IAED,OAAOR,oBAAoB,CAACO,MAAM,EAAE;QAClCC,WAAW;QACX0B,QAAQ;QACRE,sBAAsB;QACtBD,SAAS,EAAE0F,mBAAmB;KAC/B,CAAC,CAAC;CACJ"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/withMetroMultiPlatform.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport fs from 'fs';\nimport { ConfigT } from 'metro-config';\nimport { Resolution, ResolutionContext } from 'metro-resolver';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { createFastResolver } from './createExpoMetroResolver';\nimport {\n EXTERNAL_REQUIRE_NATIVE_POLYFILL,\n EXTERNAL_REQUIRE_POLYFILL,\n getNodeExternalModuleId,\n isNodeExternal,\n setupNodeExternals,\n} from './externals';\nimport { isFailedToResolveNameError, isFailedToResolvePathError } from './metroErrors';\nimport { importMetroResolverFromProject } from './resolveFromProject';\nimport { getAppRouterRelativeEntryPath } from './router';\nimport { withMetroResolvers } from './withMetroResolvers';\nimport { Log } from '../../../log';\nimport { FileNotifier } from '../../../utils/FileNotifier';\nimport { env } from '../../../utils/env';\nimport { installExitHooks } from '../../../utils/exit';\nimport { isInteractive } from '../../../utils/interactive';\nimport { loadTsConfigPathsAsync, TsConfigPaths } from '../../../utils/tsconfig/loadTsConfigPaths';\nimport { resolveWithTsConfigPaths } from '../../../utils/tsconfig/resolveWithTsConfigPaths';\nimport { WebSupportProjectPrerequisite } from '../../doctor/web/WebSupportProjectPrerequisite';\nimport { PlatformBundlers } from '../platformBundlers';\n\ntype Mutable<T> = { -readonly [K in keyof T]: T[K] };\n\nconst debug = require('debug')('expo:start:server:metro:multi-platform') as typeof console.log;\n\nfunction withWebPolyfills(config: ConfigT, projectRoot: string): ConfigT {\n const originalGetPolyfills = config.serializer.getPolyfills\n ? config.serializer.getPolyfills.bind(config.serializer)\n : () => [];\n\n const getPolyfills = (ctx: { platform: string | null }): readonly string[] => {\n if (ctx.platform === 'web') {\n return [\n // NOTE: We might need this for all platforms\n path.join(projectRoot, EXTERNAL_REQUIRE_POLYFILL),\n // TODO: runtime polyfills, i.e. Fast Refresh, error overlay, React Dev Tools...\n ];\n }\n // Generally uses `rn-get-polyfills`\n const polyfills = originalGetPolyfills(ctx);\n\n return [...polyfills, EXTERNAL_REQUIRE_NATIVE_POLYFILL];\n };\n\n return {\n ...config,\n serializer: {\n ...config.serializer,\n getPolyfills,\n },\n };\n}\n\nfunction normalizeSlashes(p: string) {\n return p.replace(/\\\\/g, '/');\n}\n\nexport function getNodejsExtensions(srcExts: readonly string[]): string[] {\n const mjsExts = srcExts.filter((ext) => /mjs$/.test(ext));\n const nodejsSourceExtensions = srcExts.filter((ext) => !/mjs$/.test(ext));\n // find index of last `*.js` extension\n const jsIndex = nodejsSourceExtensions.reduce((index, ext, i) => {\n return /jsx?$/.test(ext) ? i : index;\n }, -1);\n\n // insert `*.mjs` extensions after `*.js` extensions\n nodejsSourceExtensions.splice(jsIndex + 1, 0, ...mjsExts);\n\n return nodejsSourceExtensions;\n}\n\n/**\n * Apply custom resolvers to do the following:\n * - Disable `.native.js` extensions on web.\n * - Alias `react-native` to `react-native-web` on web.\n * - Redirect `react-native-web/dist/modules/AssetRegistry/index.js` to `@react-native/assets/registry.js` on web.\n * - Add support for `tsconfig.json`/`jsconfig.json` aliases via `compilerOptions.paths`.\n */\nexport function withExtendedResolver(\n config: ConfigT,\n {\n projectRoot,\n tsconfig,\n platforms,\n isTsconfigPathsEnabled,\n isFastResolverEnabled,\n }: {\n projectRoot: string;\n tsconfig: TsConfigPaths | null;\n platforms: string[];\n isTsconfigPathsEnabled?: boolean;\n isFastResolverEnabled?: boolean;\n }\n) {\n if (isFastResolverEnabled) {\n Log.warn(`Experimental bundling features are enabled.`);\n }\n\n // Get the `transformer.assetRegistryPath`\n // this needs to be unified since you can't dynamically\n // swap out the transformer based on platform.\n const assetRegistryPath = fs.realpathSync(\n // This is the native asset registry alias for native.\n path.resolve(resolveFrom(projectRoot, 'react-native/Libraries/Image/AssetRegistry'))\n // NOTE(EvanBacon): This is the newer import but it doesn't work in the expo/expo monorepo.\n // path.resolve(resolveFrom(projectRoot, '@react-native/assets-registry/registry.js'))\n );\n\n let reactNativeWebAppContainer: string | null = null;\n try {\n reactNativeWebAppContainer = fs.realpathSync(\n // This is the native asset registry alias for native.\n path.resolve(resolveFrom(projectRoot, 'expo-router/build/fork/react-native-web-container'))\n // NOTE(EvanBacon): This is the newer import but it doesn't work in the expo/expo monorepo.\n // path.resolve(resolveFrom(projectRoot, '@react-native/assets/registry.js'))\n );\n } catch {}\n\n const isWebEnabled = platforms.includes('web');\n\n const resolver = isFastResolverEnabled\n ? createFastResolver({ preserveSymlinks: config.resolver?.unstable_enableSymlinks ?? false })\n : importMetroResolverFromProject(projectRoot).resolve;\n\n const extraNodeModules: { [key: string]: Record<string, string> } = {};\n\n const aliases: { [key: string]: Record<string, string> } = {\n web: {\n 'react-native': 'react-native-web',\n 'react-native/index': 'react-native-web',\n },\n };\n\n if (isWebEnabled) {\n // Allow `react-native-web` to be optional when web is not enabled but path aliases is.\n extraNodeModules['web'] = {\n 'react-native': path.resolve(require.resolve('react-native-web/package.json'), '..'),\n };\n }\n\n const preferredMainFields: { [key: string]: string[] } = {\n // Defaults from Expo Webpack. Most packages using `react-native` don't support web\n // in the `react-native` field, so we should prefer the `browser` field.\n // https://github.com/expo/router/issues/37\n web: ['browser', 'module', 'main'],\n };\n\n let tsConfigResolve = tsconfig?.paths\n ? resolveWithTsConfigPaths.bind(resolveWithTsConfigPaths, {\n paths: tsconfig.paths ?? {},\n baseUrl: tsconfig.baseUrl,\n })\n : null;\n\n if (isTsconfigPathsEnabled && isInteractive()) {\n // TODO: We should track all the files that used imports and invalidate them\n // currently the user will need to save all the files that use imports to\n // use the new aliases.\n const configWatcher = new FileNotifier(projectRoot, ['./tsconfig.json', './jsconfig.json']);\n configWatcher.startObserving(() => {\n debug('Reloading tsconfig.json');\n loadTsConfigPathsAsync(projectRoot).then((tsConfigPaths) => {\n if (tsConfigPaths?.paths && !!Object.keys(tsConfigPaths.paths).length) {\n debug('Enabling tsconfig.json paths support');\n tsConfigResolve = resolveWithTsConfigPaths.bind(resolveWithTsConfigPaths, {\n paths: tsConfigPaths.paths ?? {},\n baseUrl: tsConfigPaths.baseUrl,\n });\n } else {\n debug('Disabling tsconfig.json paths support');\n tsConfigResolve = null;\n }\n });\n });\n\n // TODO: This probably prevents the process from exiting.\n installExitHooks(() => {\n configWatcher.stopObserving();\n });\n } else {\n debug('Skipping tsconfig.json paths support');\n }\n\n let nodejsSourceExtensions: string[] | null = null;\n\n const shimsFolder = path.join(require.resolve('@expo/cli/package.json'), '..', 'static/shims');\n\n return withMetroResolvers(config, projectRoot, [\n // Add a resolver to alias the web asset resolver.\n (immutableContext: ResolutionContext, moduleName: string, platform: string | null) => {\n let context = {\n ...immutableContext,\n } as Mutable<ResolutionContext> & {\n mainFields: string[];\n customResolverOptions?: Record<string, string>;\n };\n\n const environment = context.customResolverOptions?.environment;\n const isNode = environment === 'node';\n\n // TODO: We need to prevent the require.context from including API routes as these use externals.\n // Should be fine after async routes lands.\n if (isNode) {\n const moduleId = isNodeExternal(moduleName);\n if (moduleId) {\n moduleName = getNodeExternalModuleId(context.originModulePath, moduleId);\n debug(`Redirecting Node.js external \"${moduleId}\" to \"${moduleName}\"`);\n }\n\n // Adjust nodejs source extensions to sort mjs after js, including platform variants.\n if (nodejsSourceExtensions === null) {\n nodejsSourceExtensions = getNodejsExtensions(context.sourceExts);\n }\n context.sourceExts = nodejsSourceExtensions;\n }\n\n // Conditionally remap `react-native` to `react-native-web` on web in\n // a way that doesn't require Babel to resolve the alias.\n if (platform && platform in aliases && aliases[platform][moduleName]) {\n moduleName = aliases[platform][moduleName];\n }\n\n // TODO: We may be able to remove this in the future, it's doing no harm\n // by staying here.\n // Conditionally remap `react-native` to `react-native-web`\n if (platform && platform in extraNodeModules) {\n context.extraNodeModules = {\n ...extraNodeModules[platform],\n ...context.extraNodeModules,\n };\n }\n\n if (tsconfig?.baseUrl && isTsconfigPathsEnabled) {\n context = {\n ...context,\n nodeModulesPaths: [\n ...immutableContext.nodeModulesPaths,\n // add last to ensure node modules are resolved first\n tsconfig.baseUrl,\n ],\n };\n }\n\n let mainFields: string[] = context.mainFields;\n\n if (isNode) {\n // Node.js runtimes should only be importing main at the moment.\n // This is a temporary fix until we can support the package.json exports.\n mainFields = ['main', 'module'];\n } else if (env.EXPO_METRO_NO_MAIN_FIELD_OVERRIDE) {\n mainFields = context.mainFields;\n } else if (platform && platform in preferredMainFields) {\n mainFields = preferredMainFields[platform];\n }\n function doResolve(moduleName: string): Resolution | null {\n return resolver(\n {\n ...context,\n resolveRequest: undefined,\n mainFields,\n // Passing `mainFields` directly won't be considered (in certain version of Metro)\n // we need to extend the `getPackageMainPath` directly to\n // use platform specific `mainFields`.\n // @ts-ignore\n getPackageMainPath(packageJsonPath) {\n // @ts-expect-error: mainFields is not on type\n const package_ = context.moduleCache.getPackage(packageJsonPath);\n return package_.getMain(mainFields);\n },\n },\n moduleName,\n platform\n );\n }\n\n function optionalResolve(moduleName: string): Resolution | null {\n try {\n return doResolve(moduleName);\n } catch (error) {\n // If the error is directly related to a resolver not being able to resolve a module, then\n // we can ignore the error and try the next resolver. Otherwise, we should throw the error.\n const isResolutionError =\n isFailedToResolveNameError(error) || isFailedToResolvePathError(error);\n if (!isResolutionError) {\n throw error;\n }\n }\n return null;\n }\n\n let result: Resolution | null = null;\n\n // React Native uses `event-target-shim` incorrectly and this causes the native runtime\n // to fail to load. This is a temporary workaround until we can fix this upstream.\n // https://github.com/facebook/react-native/pull/38628\n if (\n moduleName.includes('event-target-shim') &&\n context.originModulePath.includes(path.sep + 'react-native' + path.sep)\n ) {\n context.sourceExts = context.sourceExts.filter((f) => !f.includes('mjs'));\n debug('Skip mjs support for event-target-shim in:', context.originModulePath);\n }\n\n if (tsConfigResolve) {\n result = tsConfigResolve(\n {\n originModulePath: context.originModulePath,\n moduleName,\n },\n optionalResolve\n );\n }\n\n if (\n !isFastResolverEnabled &&\n // is web\n platform === 'web' &&\n // Not server runtime\n !isNode &&\n // Is Node.js built-in\n isNodeExternal(moduleName)\n ) {\n // Perform optional resolve first. If the module doesn't exist (no module in the node_modules)\n // then we can mock the file to use an empty module.\n result ??= optionalResolve(moduleName);\n\n if (!result) {\n // In this case, mock the file to use an empty module.\n return {\n type: 'empty',\n };\n }\n }\n\n result ??= doResolve(moduleName);\n\n if (result?.type === 'sourceFile') {\n // Replace the web resolver with the original one.\n // This is basically an alias for web-only.\n if (shouldAliasAssetRegistryForWeb(platform, result)) {\n // @ts-expect-error: `readonly` for some reason.\n result.filePath = assetRegistryPath;\n }\n\n // React Native Web adds a couple extra divs for no reason, these\n // make static rendering much harder as we expect the root element to be `<html>`.\n // This resolution will alias to a simple in-out component to avoid React Native web.\n if (\n // Only apply the transform if expo-router is present.\n reactNativeWebAppContainer &&\n shouldAliasModule(\n {\n platform,\n result,\n },\n {\n platform: 'web',\n output: 'react-native-web/dist/exports/AppRegistry/AppContainer.js',\n }\n )\n ) {\n // @ts-expect-error: `readonly` for some reason.\n result.filePath = reactNativeWebAppContainer;\n } else if (platform === 'web' && result.filePath.includes('node_modules')) {\n // Replace with static shims\n\n const normalName = normalizeSlashes(result.filePath)\n // Drop everything up until the `node_modules` folder.\n .replace(/.*node_modules\\//, '');\n\n const shimPath = path.join(shimsFolder, normalName);\n if (fs.existsSync(shimPath)) {\n // @ts-expect-error: `readonly` for some reason.\n result.filePath = shimPath;\n }\n }\n }\n return result;\n },\n ]);\n}\n\n/** @returns `true` if the incoming resolution should be swapped on web. */\nexport function shouldAliasAssetRegistryForWeb(\n platform: string | null,\n result: Resolution\n): boolean {\n return (\n platform === 'web' &&\n result?.type === 'sourceFile' &&\n typeof result?.filePath === 'string' &&\n normalizeSlashes(result.filePath).endsWith(\n 'react-native-web/dist/modules/AssetRegistry/index.js'\n )\n );\n}\n/** @returns `true` if the incoming resolution should be swapped. */\nexport function shouldAliasModule(\n input: {\n platform: string | null;\n result: Resolution;\n },\n alias: { platform: string; output: string }\n): boolean {\n return (\n input.platform === alias.platform &&\n input.result?.type === 'sourceFile' &&\n typeof input.result?.filePath === 'string' &&\n normalizeSlashes(input.result.filePath).endsWith(alias.output)\n );\n}\n\n/** Add support for `react-native-web` and the Web platform. */\nexport async function withMetroMultiPlatformAsync(\n projectRoot: string,\n {\n config,\n platformBundlers,\n isTsconfigPathsEnabled,\n webOutput,\n routerDirectory,\n isFastResolverEnabled,\n }: {\n config: ConfigT;\n isTsconfigPathsEnabled: boolean;\n platformBundlers: PlatformBundlers;\n webOutput?: 'single' | 'static' | 'server';\n routerDirectory: string;\n isFastResolverEnabled?: boolean;\n }\n) {\n // Auto pick app entry for router.\n process.env.EXPO_ROUTER_APP_ROOT = getAppRouterRelativeEntryPath(projectRoot, routerDirectory);\n\n // Required for @expo/metro-runtime to format paths in the web LogBox.\n process.env.EXPO_PUBLIC_PROJECT_ROOT = process.env.EXPO_PUBLIC_PROJECT_ROOT ?? projectRoot;\n\n if (['static', 'server'].includes(webOutput ?? '')) {\n // Enable static rendering in runtime space.\n process.env.EXPO_PUBLIC_USE_STATIC = '1';\n }\n\n // Ensure the cache is invalidated if these values change.\n // @ts-expect-error\n config.transformer._expoRouterRootDirectory = process.env.EXPO_ROUTER_APP_ROOT;\n // @ts-expect-error\n config.transformer._expoRouterWebRendering = webOutput;\n // TODO: import mode\n\n if (platformBundlers.web === 'metro') {\n await new WebSupportProjectPrerequisite(projectRoot).assertAsync();\n }\n\n let tsconfig: null | TsConfigPaths = null;\n\n if (isTsconfigPathsEnabled) {\n tsconfig = await loadTsConfigPathsAsync(projectRoot);\n }\n\n await setupNodeExternals(projectRoot);\n\n return withMetroMultiPlatform(projectRoot, {\n config,\n platformBundlers,\n tsconfig,\n isTsconfigPathsEnabled,\n isFastResolverEnabled,\n });\n}\n\nfunction withMetroMultiPlatform(\n projectRoot: string,\n {\n config,\n platformBundlers,\n isTsconfigPathsEnabled,\n tsconfig,\n isFastResolverEnabled,\n }: {\n config: ConfigT;\n isTsconfigPathsEnabled: boolean;\n platformBundlers: PlatformBundlers;\n tsconfig: TsConfigPaths | null;\n isFastResolverEnabled?: boolean;\n }\n) {\n let expoConfigPlatforms = Object.entries(platformBundlers)\n .filter(([, bundler]) => bundler === 'metro')\n .map(([platform]) => platform);\n\n if (Array.isArray(config.resolver.platforms)) {\n expoConfigPlatforms = [...new Set(expoConfigPlatforms.concat(config.resolver.platforms))];\n }\n\n // @ts-expect-error: typed as `readonly`.\n config.resolver.platforms = expoConfigPlatforms;\n\n if (expoConfigPlatforms.includes('web')) {\n config = withWebPolyfills(config, projectRoot);\n }\n\n return withExtendedResolver(config, {\n projectRoot,\n tsconfig,\n isTsconfigPathsEnabled,\n platforms: expoConfigPlatforms,\n isFastResolverEnabled,\n });\n}\n"],"names":["getNodejsExtensions","withExtendedResolver","shouldAliasAssetRegistryForWeb","shouldAliasModule","withMetroMultiPlatformAsync","debug","require","withWebPolyfills","config","projectRoot","originalGetPolyfills","serializer","getPolyfills","bind","ctx","platform","path","join","EXTERNAL_REQUIRE_POLYFILL","polyfills","EXTERNAL_REQUIRE_NATIVE_POLYFILL","normalizeSlashes","p","replace","srcExts","mjsExts","filter","ext","test","nodejsSourceExtensions","jsIndex","reduce","index","i","splice","tsconfig","platforms","isTsconfigPathsEnabled","isFastResolverEnabled","Log","warn","assetRegistryPath","fs","realpathSync","resolve","resolveFrom","reactNativeWebAppContainer","isWebEnabled","includes","resolver","createFastResolver","preserveSymlinks","unstable_enableSymlinks","importMetroResolverFromProject","extraNodeModules","aliases","web","preferredMainFields","tsConfigResolve","paths","resolveWithTsConfigPaths","baseUrl","isInteractive","configWatcher","FileNotifier","startObserving","loadTsConfigPathsAsync","then","tsConfigPaths","Object","keys","length","installExitHooks","stopObserving","shimsFolder","withMetroResolvers","immutableContext","moduleName","context","environment","customResolverOptions","isNode","moduleId","isNodeExternal","getNodeExternalModuleId","originModulePath","sourceExts","nodeModulesPaths","mainFields","env","EXPO_METRO_NO_MAIN_FIELD_OVERRIDE","doResolve","resolveRequest","undefined","getPackageMainPath","packageJsonPath","package_","moduleCache","getPackage","getMain","optionalResolve","error","isResolutionError","isFailedToResolveNameError","isFailedToResolvePathError","result","sep","f","type","filePath","output","normalName","shimPath","existsSync","endsWith","input","alias","platformBundlers","webOutput","routerDirectory","process","EXPO_ROUTER_APP_ROOT","getAppRouterRelativeEntryPath","EXPO_PUBLIC_PROJECT_ROOT","EXPO_PUBLIC_USE_STATIC","transformer","_expoRouterRootDirectory","_expoRouterWebRendering","WebSupportProjectPrerequisite","assertAsync","setupNodeExternals","withMetroMultiPlatform","expoConfigPlatforms","entries","bundler","map","Array","isArray","Set","concat"],"mappings":"AAMA;;;;QAgEgBA,mBAAmB,GAAnBA,mBAAmB;QAqBnBC,oBAAoB,GAApBA,oBAAoB;QAiTpBC,8BAA8B,GAA9BA,8BAA8B;QAc9BC,iBAAiB,GAAjBA,iBAAiB;QAgBXC,2BAA2B,GAA3BA,2BAA2B;AApalC,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAGF,IAAA,KAAM,kCAAN,MAAM,EAAA;AACC,IAAA,YAAc,kCAAd,cAAc,EAAA;AAEH,IAAA,wBAA2B,WAA3B,2BAA2B,CAAA;AAOvD,IAAA,UAAa,WAAb,aAAa,CAAA;AACmD,IAAA,YAAe,WAAf,eAAe,CAAA;AACvC,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AACvB,IAAA,OAAU,WAAV,UAAU,CAAA;AACrB,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AACrC,IAAA,IAAc,WAAd,cAAc,CAAA;AACL,IAAA,aAA6B,WAA7B,6BAA6B,CAAA;AACtC,IAAA,I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AC;KAC3F;IAED,yCAAyC;IACzC5B,MAAM,CAACyC,QAAQ,CAACb,SAAS,GAAGgG,mBAAmB,CAAC;IAEhD,IAAIA,mBAAmB,CAACpF,QAAQ,CAAC,KAAK,CAAC,EAAE;QACvCxC,MAAM,GAAGD,gBAAgB,CAACC,MAAM,EAAEC,WAAW,CAAC,CAAC;KAChD;IAED,OAAOR,oBAAoB,CAACO,MAAM,EAAE;QAClCC,WAAW;QACX0B,QAAQ;QACRE,sBAAsB;QACtBD,SAAS,EAAEgG,mBAAmB;QAC9B9F,qBAAqB;KACtB,CAAC,CAAC;CACJ"}
|
|
@@ -10,16 +10,18 @@ exports.shouldEnableAsyncImports = shouldEnableAsyncImports;
|
|
|
10
10
|
exports.createBundleUrlPath = createBundleUrlPath;
|
|
11
11
|
exports.DEVELOPER_TOOL = void 0;
|
|
12
12
|
var _config = require("@expo/config");
|
|
13
|
+
var _paths = require("@expo/config/paths");
|
|
13
14
|
var _findYarnWorkspaceRoot = _interopRequireDefault(require("find-yarn-workspace-root"));
|
|
14
15
|
var _path = _interopRequireDefault(require("path"));
|
|
15
16
|
var _resolveFrom = _interopRequireDefault(require("resolve-from"));
|
|
16
17
|
var _url = require("url");
|
|
17
18
|
var _expoMiddleware = require("./ExpoMiddleware");
|
|
18
19
|
var _resolveAssets = require("./resolveAssets");
|
|
19
|
-
var _resolveEntryPoint = require("./resolveEntryPoint");
|
|
20
20
|
var _resolvePlatform = require("./resolvePlatform");
|
|
21
|
+
var _exportHermes = require("../../../export/exportHermes");
|
|
21
22
|
var Log = _interopRequireWildcard(require("../../../log"));
|
|
22
23
|
var _env = require("../../../utils/env");
|
|
24
|
+
var _errors = require("../../../utils/errors");
|
|
23
25
|
var _url1 = require("../../../utils/url");
|
|
24
26
|
var ProjectDevices = _interopRequireWildcard(require("../../project/devices"));
|
|
25
27
|
var _platformBundlers = require("../platformBundlers");
|
|
@@ -61,8 +63,17 @@ function getWorkspaceRoot(projectRoot) {
|
|
|
61
63
|
throw error;
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
const supportedPlatforms = [
|
|
67
|
+
"ios",
|
|
68
|
+
"android",
|
|
69
|
+
"web",
|
|
70
|
+
"none"
|
|
71
|
+
];
|
|
72
|
+
function getEntryWithServerRoot(projectRoot, props) {
|
|
73
|
+
if (!supportedPlatforms.includes(props.platform)) {
|
|
74
|
+
throw new _errors.CommandError(`Failed to resolve the project's entry file: The platform "${props.platform}" is not supported.`);
|
|
75
|
+
}
|
|
76
|
+
return _path.default.relative(getMetroServerRoot(projectRoot), (0, _paths).resolveEntryPoint(projectRoot, props));
|
|
66
77
|
}
|
|
67
78
|
function getMetroServerRoot(projectRoot) {
|
|
68
79
|
if (_env.env.EXPO_USE_METRO_WORKSPACE_ROOT) {
|
|
@@ -71,8 +82,8 @@ function getMetroServerRoot(projectRoot) {
|
|
|
71
82
|
}
|
|
72
83
|
return projectRoot;
|
|
73
84
|
}
|
|
74
|
-
function resolveMainModuleName(projectRoot,
|
|
75
|
-
const entryPoint = getEntryWithServerRoot(projectRoot,
|
|
85
|
+
function resolveMainModuleName(projectRoot, props) {
|
|
86
|
+
const entryPoint = getEntryWithServerRoot(projectRoot, props);
|
|
76
87
|
debug(`Resolved entry point: ${entryPoint} (project root: ${projectRoot})`);
|
|
77
88
|
return (0, _url1).stripExtension(entryPoint, "js");
|
|
78
89
|
}
|
|
@@ -86,7 +97,7 @@ function shouldEnableAsyncImports(projectRoot) {
|
|
|
86
97
|
// Expo Router automatically pulls this in, so we can check for it.
|
|
87
98
|
return _resolveFrom.default.silent(projectRoot, "@expo/metro-runtime") != null;
|
|
88
99
|
}
|
|
89
|
-
function createBundleUrlPath({ platform , mainModuleName , mode , minify =mode === "production" , environment , serializerOutput , serializerIncludeMaps , lazy }) {
|
|
100
|
+
function createBundleUrlPath({ platform , mainModuleName , mode , minify =mode === "production" , environment , serializerOutput , serializerIncludeMaps , lazy , engine }) {
|
|
90
101
|
const queryParams = new URLSearchParams({
|
|
91
102
|
platform: encodeURIComponent(platform),
|
|
92
103
|
dev: String(mode !== "production"),
|
|
@@ -99,6 +110,9 @@ function createBundleUrlPath({ platform , mainModuleName , mode , minify =mode =
|
|
|
99
110
|
if (minify) {
|
|
100
111
|
queryParams.append("minify", String(minify));
|
|
101
112
|
}
|
|
113
|
+
if (engine) {
|
|
114
|
+
queryParams.append("transform.engine", engine);
|
|
115
|
+
}
|
|
102
116
|
if (environment) {
|
|
103
117
|
queryParams.append("resolver.environment", environment);
|
|
104
118
|
queryParams.append("transform.environment", environment);
|
|
@@ -130,7 +144,11 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
|
|
|
130
144
|
// Read the config
|
|
131
145
|
const projectConfig = (0, _config).getConfig(this.projectRoot);
|
|
132
146
|
// Read from headers
|
|
133
|
-
const mainModuleName = this.resolveMainModuleName(
|
|
147
|
+
const mainModuleName = this.resolveMainModuleName({
|
|
148
|
+
pkg: projectConfig.pkg,
|
|
149
|
+
platform
|
|
150
|
+
});
|
|
151
|
+
const isHermesEnabled = (0, _exportHermes).isEnableHermesManaged(projectConfig.exp, platform);
|
|
134
152
|
// Create the manifest and set fields within it
|
|
135
153
|
const expoGoConfig = this.getExpoGoConfig({
|
|
136
154
|
mainModuleName,
|
|
@@ -143,7 +161,8 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
|
|
|
143
161
|
const bundleUrl = this._getBundleUrl({
|
|
144
162
|
platform,
|
|
145
163
|
mainModuleName,
|
|
146
|
-
hostname
|
|
164
|
+
hostname,
|
|
165
|
+
engine: isHermesEnabled ? "hermes" : undefined
|
|
147
166
|
});
|
|
148
167
|
// Resolve all assets and set them on the manifest as URLs
|
|
149
168
|
await this.mutateManifestWithAssetsAsync(projectConfig.exp, bundleUrl);
|
|
@@ -154,8 +173,8 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
|
|
|
154
173
|
exp: projectConfig.exp
|
|
155
174
|
};
|
|
156
175
|
}
|
|
157
|
-
/** Get the main entry module ID (file) relative to the project root. */ resolveMainModuleName(
|
|
158
|
-
let entryPoint = getEntryWithServerRoot(this.projectRoot,
|
|
176
|
+
/** Get the main entry module ID (file) relative to the project root. */ resolveMainModuleName(props) {
|
|
177
|
+
let entryPoint = getEntryWithServerRoot(this.projectRoot, props);
|
|
159
178
|
debug(`Resolved entry point: ${entryPoint} (project root: ${this.projectRoot})`);
|
|
160
179
|
// NOTE(Bacon): Webpack is currently hardcoded to index.bundle on native
|
|
161
180
|
// in the future (TODO) we should move this logic into a Webpack plugin and use
|
|
@@ -176,14 +195,15 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
|
|
|
176
195
|
);
|
|
177
196
|
}
|
|
178
197
|
}
|
|
179
|
-
/** Create the bundle URL (points to the single JS entry file). Exposed for testing. */ _getBundleUrl({ platform , mainModuleName , hostname }) {
|
|
198
|
+
/** Create the bundle URL (points to the single JS entry file). Exposed for testing. */ _getBundleUrl({ platform , mainModuleName , hostname , engine }) {
|
|
180
199
|
var _mode;
|
|
181
200
|
const path = createBundleUrlPath({
|
|
182
201
|
mode: (_mode = this.options.mode) != null ? _mode : "development",
|
|
183
202
|
minify: this.options.minify,
|
|
184
203
|
platform,
|
|
185
204
|
mainModuleName,
|
|
186
|
-
lazy: shouldEnableAsyncImports(this.projectRoot)
|
|
205
|
+
lazy: shouldEnableAsyncImports(this.projectRoot),
|
|
206
|
+
engine
|
|
187
207
|
});
|
|
188
208
|
return this.options.constructUrl({
|
|
189
209
|
scheme: "http",
|
|
@@ -191,7 +211,7 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
|
|
|
191
211
|
hostname
|
|
192
212
|
}) + path;
|
|
193
213
|
}
|
|
194
|
-
_getBundleUrlPath({ platform , mainModuleName }) {
|
|
214
|
+
_getBundleUrlPath({ platform , mainModuleName , engine }) {
|
|
195
215
|
const queryParams = new URLSearchParams({
|
|
196
216
|
platform: encodeURIComponent(platform),
|
|
197
217
|
dev: String(this.options.mode !== "production"),
|
|
@@ -201,6 +221,9 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
|
|
|
201
221
|
if (shouldEnableAsyncImports(this.projectRoot)) {
|
|
202
222
|
queryParams.append("lazy", String(true));
|
|
203
223
|
}
|
|
224
|
+
if (engine) {
|
|
225
|
+
queryParams.append("transform.engine", String(engine));
|
|
226
|
+
}
|
|
204
227
|
if (this.options.minify) {
|
|
205
228
|
queryParams.append("minify", String(this.options.minify));
|
|
206
229
|
}
|
|
@@ -249,10 +272,15 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
|
|
|
249
272
|
getWebBundleUrl() {
|
|
250
273
|
const platform = "web";
|
|
251
274
|
// Read from headers
|
|
252
|
-
const mainModuleName = this.resolveMainModuleName(
|
|
275
|
+
const mainModuleName = this.resolveMainModuleName({
|
|
276
|
+
pkg: this.initialProjectConfig.pkg,
|
|
277
|
+
platform
|
|
278
|
+
});
|
|
253
279
|
return this._getBundleUrlPath({
|
|
254
280
|
platform,
|
|
255
|
-
mainModuleName
|
|
281
|
+
mainModuleName,
|
|
282
|
+
// Hermes doesn't support more modern JS features than most, if not all, modern browser.
|
|
283
|
+
engine: "hermes"
|
|
256
284
|
});
|
|
257
285
|
}
|
|
258
286
|
/**
|