@expo/cli 0.13.1 → 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.
Files changed (89) hide show
  1. package/build/bin/cli +27 -25
  2. package/build/bin/cli.map +1 -1
  3. package/build/src/config/configAsync.js +1 -1
  4. package/build/src/config/configAsync.js.map +1 -1
  5. package/build/src/config/index.js +2 -2
  6. package/build/src/config/index.js.map +1 -1
  7. package/build/src/customize/generate.js +1 -1
  8. package/build/src/customize/generate.js.map +1 -1
  9. package/build/src/customize/typescript.js +3 -3
  10. package/build/src/customize/typescript.js.map +1 -1
  11. package/build/src/export/createMetadataJson.js.map +1 -1
  12. package/build/src/export/embed/index.js +4 -4
  13. package/build/src/export/embed/index.js.map +1 -1
  14. package/build/src/export/exportApp.js +10 -5
  15. package/build/src/export/exportApp.js.map +1 -1
  16. package/build/src/export/exportHermes.js +20 -10
  17. package/build/src/export/exportHermes.js.map +1 -1
  18. package/build/src/export/exportStaticAsync.js +55 -39
  19. package/build/src/export/exportStaticAsync.js.map +1 -1
  20. package/build/src/export/fork-bundleAsync.js +44 -13
  21. package/build/src/export/fork-bundleAsync.js.map +1 -1
  22. package/build/src/export/getPublicExpoManifest.js +2 -2
  23. package/build/src/export/getPublicExpoManifest.js.map +1 -1
  24. package/build/src/export/index.js +2 -2
  25. package/build/src/export/index.js.map +1 -1
  26. package/build/src/export/web/index.js +2 -2
  27. package/build/src/export/web/index.js.map +1 -1
  28. package/build/src/export/writeContents.js +3 -1
  29. package/build/src/export/writeContents.js.map +1 -1
  30. package/build/src/install/installAsync.js +1 -1
  31. package/build/src/install/installAsync.js.map +1 -1
  32. package/build/src/login/index.js +1 -1
  33. package/build/src/login/index.js.map +1 -1
  34. package/build/src/logout/index.js +1 -1
  35. package/build/src/logout/index.js.map +1 -1
  36. package/build/src/prebuild/index.js +3 -3
  37. package/build/src/prebuild/index.js.map +1 -1
  38. package/build/src/prebuild/prebuildAsync.js +2 -2
  39. package/build/src/prebuild/prebuildAsync.js.map +1 -1
  40. package/build/src/register/index.js +1 -1
  41. package/build/src/register/index.js.map +1 -1
  42. package/build/src/run/android/index.js +2 -2
  43. package/build/src/run/android/index.js.map +1 -1
  44. package/build/src/run/ios/appleDevice/AppleDevice.js +35 -2
  45. package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -1
  46. package/build/src/run/ios/index.js +2 -2
  47. package/build/src/run/ios/index.js.map +1 -1
  48. package/build/src/start/index.js +3 -3
  49. package/build/src/start/index.js.map +1 -1
  50. package/build/src/start/server/getStaticRenderFunctions.js +4 -1
  51. package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
  52. package/build/src/start/server/metro/MetroBundlerDevServer.js +70 -49
  53. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  54. package/build/src/start/server/metro/bundleApiRoutes.js +0 -16
  55. package/build/src/start/server/metro/bundleApiRoutes.js.map +1 -1
  56. package/build/src/start/server/metro/createExpoMetroResolver.js +170 -0
  57. package/build/src/start/server/metro/createExpoMetroResolver.js.map +1 -0
  58. package/build/src/start/server/metro/fetchRouterManifest.js.map +1 -1
  59. package/build/src/start/server/metro/formatFileCandidates.js +72 -0
  60. package/build/src/start/server/metro/formatFileCandidates.js.map +1 -0
  61. package/build/src/start/server/metro/instantiateMetro.js +6 -7
  62. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  63. package/build/src/start/server/metro/metroErrorInterface.js +2 -1
  64. package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
  65. package/build/src/start/server/metro/router.js +2 -2
  66. package/build/src/start/server/metro/router.js.map +1 -1
  67. package/build/src/start/server/metro/withMetroMultiPlatform.js +31 -14
  68. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  69. package/build/src/start/server/middleware/ManifestMiddleware.js +43 -15
  70. package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
  71. package/build/src/start/server/middleware/resolveAssets.js.map +1 -1
  72. package/build/src/start/server/type-generation/expo-env.js +1 -1
  73. package/build/src/start/server/type-generation/expo-env.js.map +1 -1
  74. package/build/src/start/server/type-generation/routes.js +1 -0
  75. package/build/src/start/server/type-generation/routes.js.map +1 -1
  76. package/build/src/utils/analytics/rudderstackClient.js +2 -2
  77. package/build/src/utils/cocoapods.js +1 -0
  78. package/build/src/utils/cocoapods.js.map +1 -1
  79. package/build/src/utils/env.js +3 -0
  80. package/build/src/utils/env.js.map +1 -1
  81. package/build/src/whoami/index.js +1 -1
  82. package/build/src/whoami/index.js.map +1 -1
  83. package/package.json +7 -8
  84. package/static/shims/react-native-web/dist/cjs/exports/BackHandler/index.js +10 -0
  85. package/static/shims/react-native-web/dist/exports/BackHandler/index.js +7 -0
  86. package/build/src/export/createBundles.js +0 -37
  87. package/build/src/export/createBundles.js.map +0 -1
  88. package/build/src/start/server/middleware/resolveEntryPoint.js +0 -42
  89. package/build/src/start/server/middleware/resolveEntryPoint.js.map +0 -1
@@ -46,8 +46,7 @@ function gteSdkVersion(exp, sdkVersion) {
46
46
  }
47
47
  }
48
48
  async function loadMetroConfigAsync(projectRoot, options, { exp =(0, _config).getConfig(projectRoot, {
49
- skipSDKVersionRequirement: true,
50
- skipPlugins: true
49
+ skipSDKVersionRequirement: true
51
50
  }).exp , isExporting }) {
52
51
  var ref, ref1;
53
52
  let reportEvent;
@@ -89,13 +88,14 @@ async function loadMetroConfigAsync(projectRoot, options, { exp =(0, _config).ge
89
88
  }
90
89
  }
91
90
  const platformBundlers = (0, _platformBundlers).getPlatformBundlers(exp);
92
- var ref6;
91
+ var ref6, ref7;
93
92
  config = await (0, _withMetroMultiPlatform).withMetroMultiPlatformAsync(projectRoot, {
94
93
  routerDirectory: (0, _router).getRouterDirectoryModuleIdWithManifest(projectRoot, exp),
95
94
  config,
96
95
  platformBundlers,
97
- isTsconfigPathsEnabled: !!((ref = exp.experiments) == null ? void 0 : ref.tsconfigPaths),
98
- webOutput: (ref6 = (ref1 = exp.web) == null ? void 0 : ref1.output) != null ? ref6 : "single"
96
+ isTsconfigPathsEnabled: (ref6 = (ref = exp.experiments) == null ? void 0 : ref.tsconfigPaths) != null ? ref6 : true,
97
+ webOutput: (ref7 = (ref1 = exp.web) == null ? void 0 : ref1.output) != null ? ref7 : "single",
98
+ isFastResolverEnabled: _env.env.EXPO_USE_FAST_RESOLVER
99
99
  });
100
100
  (0, _rudderstackClient).logEventAsync("metro config", (0, _getMetroProperties).getMetroProperties(projectRoot, exp, config));
101
101
  return {
@@ -109,8 +109,7 @@ async function instantiateMetroAsync(metroBundler, options, { isExporting }) {
109
109
  const projectRoot = metroBundler.projectRoot;
110
110
  // TODO: When we bring expo/metro-config into the expo/expo repo, then we can upstream this.
111
111
  const { exp } = (0, _config).getConfig(projectRoot, {
112
- skipSDKVersionRequirement: true,
113
- skipPlugins: true
112
+ skipSDKVersionRequirement: true
114
113
  });
115
114
  const { config: metroConfig , setEventReporter } = await loadMetroConfigAsync(projectRoot, options, {
116
115
  exp,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/instantiateMetro.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport type { LoadOptions } from '@expo/metro-config';\nimport chalk from 'chalk';\nimport { Server as ConnectServer } from 'connect';\nimport http from 'http';\nimport type Metro from 'metro';\nimport { Terminal } from 'metro-core';\nimport semver from 'semver';\nimport { URL } from 'url';\n\nimport { MetroBundlerDevServer } from './MetroBundlerDevServer';\nimport { MetroTerminalReporter } from './MetroTerminalReporter';\nimport { importCliServerApiFromProject, importExpoMetroConfig } from './resolveFromProject';\nimport { getRouterDirectoryModuleIdWithManifest } from './router';\nimport { runServer } from './runServer-fork';\nimport { withMetroMultiPlatformAsync } from './withMetroMultiPlatform';\nimport { MetroDevServerOptions } from '../../../export/fork-bundleAsync';\nimport { Log } from '../../../log';\nimport { getMetroProperties } from '../../../utils/analytics/getMetroProperties';\nimport { createDebuggerTelemetryMiddleware } from '../../../utils/analytics/metroDebuggerMiddleware';\nimport { logEventAsync } from '../../../utils/analytics/rudderstackClient';\nimport { env } from '../../../utils/env';\nimport { getMetroServerRoot } from '../middleware/ManifestMiddleware';\nimport createJsInspectorMiddleware from '../middleware/inspector/createJsInspectorMiddleware';\nimport { prependMiddleware, replaceMiddlewareWith } from '../middleware/mutations';\nimport { remoteDevtoolsCorsMiddleware } from '../middleware/remoteDevtoolsCorsMiddleware';\nimport { remoteDevtoolsSecurityHeadersMiddleware } from '../middleware/remoteDevtoolsSecurityHeadersMiddleware';\nimport { ServerNext, ServerRequest, ServerResponse } from '../middleware/server.types';\nimport { suppressRemoteDebuggingErrorMiddleware } from '../middleware/suppressErrorMiddleware';\nimport { getPlatformBundlers } from '../platformBundlers';\n\n// From expo/dev-server but with ability to use custom logger.\ntype MessageSocket = {\n broadcast: (method: string, params?: Record<string, any> | undefined) => void;\n};\n\nfunction gteSdkVersion(exp: Pick<ExpoConfig, 'sdkVersion'>, sdkVersion: string): boolean {\n if (!exp.sdkVersion) {\n return false;\n }\n\n if (exp.sdkVersion === 'UNVERSIONED') {\n return true;\n }\n\n try {\n return semver.gte(exp.sdkVersion, sdkVersion);\n } catch {\n throw new Error(`${exp.sdkVersion} is not a valid version. Must be in the form of x.y.z`);\n }\n}\n\nexport async function loadMetroConfigAsync(\n projectRoot: string,\n options: LoadOptions,\n {\n exp = getConfig(projectRoot, { skipSDKVersionRequirement: true, skipPlugins: true }).exp,\n isExporting,\n }: { exp?: ExpoConfig; isExporting: boolean }\n) {\n let reportEvent: ((event: any) => void) | undefined;\n const serverRoot = getMetroServerRoot(projectRoot);\n\n const terminal = new Terminal(process.stdout);\n const terminalReporter = new MetroTerminalReporter(serverRoot, terminal);\n\n const reporter = {\n update(event: any) {\n terminalReporter.update(event);\n if (reportEvent) {\n reportEvent(event);\n }\n },\n };\n\n const ExpoMetroConfig = importExpoMetroConfig(projectRoot);\n let config = await ExpoMetroConfig.loadAsync(projectRoot, { reporter, ...options });\n\n if (\n // Requires SDK 50 for expo-assets hashAssetPlugin change.\n !exp.sdkVersion ||\n gteSdkVersion(exp, '50.0.0')\n ) {\n if (isExporting) {\n // This token will be used in the asset plugin to ensure the path is correct for writing locally.\n // @ts-expect-error: typed as readonly.\n config.transformer.publicPath = `/assets?export_path=${\n (exp.experiments?.basePath ?? '') + '/assets'\n }`;\n } else {\n // @ts-expect-error: typed as readonly\n config.transformer.publicPath = '/assets/?unstable_path=.';\n }\n } else {\n if (isExporting && exp.experiments?.basePath) {\n // This token will be used in the asset plugin to ensure the path is correct for writing locally.\n // @ts-expect-error: typed as readonly.\n config.transformer.publicPath = exp.experiments?.basePath;\n }\n }\n\n const platformBundlers = getPlatformBundlers(exp);\n\n config = await withMetroMultiPlatformAsync(projectRoot, {\n routerDirectory: getRouterDirectoryModuleIdWithManifest(projectRoot, exp),\n config,\n platformBundlers,\n isTsconfigPathsEnabled: !!exp.experiments?.tsconfigPaths,\n webOutput: exp.web?.output ?? 'single',\n });\n\n logEventAsync('metro config', getMetroProperties(projectRoot, exp, config));\n\n return {\n config,\n setEventReporter: (logger: (event: any) => void) => (reportEvent = logger),\n reporter: terminalReporter,\n };\n}\n\n/** The most generic possible setup for Metro bundler. */\nexport async function instantiateMetroAsync(\n metroBundler: MetroBundlerDevServer,\n options: Omit<MetroDevServerOptions, 'logger'>,\n { isExporting }: { isExporting: boolean }\n): Promise<{\n metro: Metro.Server;\n server: http.Server;\n middleware: any;\n messageSocket: MessageSocket;\n}> {\n const projectRoot = metroBundler.projectRoot;\n\n // TODO: When we bring expo/metro-config into the expo/expo repo, then we can upstream this.\n const { exp } = getConfig(projectRoot, {\n skipSDKVersionRequirement: true,\n skipPlugins: true,\n });\n\n const { config: metroConfig, setEventReporter } = await loadMetroConfigAsync(\n projectRoot,\n options,\n { exp, isExporting }\n );\n\n const { createDevServerMiddleware, securityHeadersMiddleware } =\n importCliServerApiFromProject(projectRoot);\n\n const { middleware, messageSocketEndpoint, eventsSocketEndpoint, websocketEndpoints } =\n createDevServerMiddleware({\n port: metroConfig.server.port,\n watchFolders: metroConfig.watchFolders,\n });\n\n // securityHeadersMiddleware does not support cross-origin requests for remote devtools to get the sourcemap.\n // We replace with the enhanced version.\n replaceMiddlewareWith(\n middleware as ConnectServer,\n securityHeadersMiddleware,\n remoteDevtoolsSecurityHeadersMiddleware\n );\n\n middleware.use(remoteDevtoolsCorsMiddleware);\n\n prependMiddleware(middleware, suppressRemoteDebuggingErrorMiddleware);\n\n middleware.use('/inspector', createJsInspectorMiddleware());\n\n // TODO: We can probably drop this now.\n const customEnhanceMiddleware = metroConfig.server.enhanceMiddleware;\n // @ts-expect-error: can't mutate readonly config\n metroConfig.server.enhanceMiddleware = (metroMiddleware: any, server: Metro.Server) => {\n if (customEnhanceMiddleware) {\n metroMiddleware = customEnhanceMiddleware(metroMiddleware, server);\n }\n return middleware.use(metroMiddleware);\n };\n\n middleware.use(createDebuggerTelemetryMiddleware(projectRoot, exp));\n\n const { server, metro } = await runServer(metroBundler, metroConfig, {\n hmrEnabled: true,\n // @ts-expect-error: Inconsistent `websocketEndpoints` type between metro and @react-native-community/cli-server-api\n websocketEndpoints,\n watch: isWatchEnabled(),\n });\n\n prependMiddleware(middleware, (req: ServerRequest, res: ServerResponse, next: ServerNext) => {\n // If the URL is a Metro asset request, then we need to skip all other middleware to prevent\n // the community CLI's serve-static from hosting `/assets/index.html` in place of all assets if it exists.\n // /assets/?unstable_path=.\n if (req.url) {\n const url = new URL(req.url!, 'http://localhost:8000');\n if (url.pathname.match(/^\\/assets\\/?/) && url.searchParams.get('unstable_path') != null) {\n return metro.processRequest(req, res, next);\n }\n }\n return next();\n });\n\n setEventReporter(eventsSocketEndpoint.reportEvent);\n\n return {\n metro,\n server,\n middleware,\n messageSocket: messageSocketEndpoint,\n };\n}\n\n/**\n * Simplify and communicate if Metro is running without watching file updates,.\n * Exposed for testing.\n */\nexport function isWatchEnabled() {\n if (env.CI) {\n Log.log(\n chalk`Metro is running in CI mode, reloads are disabled. Remove {bold CI=true} to enable watch mode.`\n );\n }\n\n return !env.CI;\n}\n"],"names":["loadMetroConfigAsync","instantiateMetroAsync","isWatchEnabled","gteSdkVersion","exp","sdkVersion","semver","gte","Error","projectRoot","options","getConfig","skipSDKVersionRequirement","skipPlugins","isExporting","reportEvent","serverRoot","getMetroServerRoot","terminal","Terminal","process","stdout","terminalReporter","MetroTerminalReporter","reporter","update","event","ExpoMetroConfig","importExpoMetroConfig","config","loadAsync","transformer","publicPath","experiments","basePath","platformBundlers","getPlatformBundlers","withMetroMultiPlatformAsync","routerDirectory","getRouterDirectoryModuleIdWithManifest","isTsconfigPathsEnabled","tsconfigPaths","webOutput","web","output","logEventAsync","getMetroProperties","setEventReporter","logger","metroBundler","metroConfig","createDevServerMiddleware","securityHeadersMiddleware","importCliServerApiFromProject","middleware","messageSocketEndpoint","eventsSocketEndpoint","websocketEndpoints","port","server","watchFolders","replaceMiddlewareWith","remoteDevtoolsSecurityHeadersMiddleware","use","remoteDevtoolsCorsMiddleware","prependMiddleware","suppressRemoteDebuggingErrorMiddleware","createJsInspectorMiddleware","customEnhanceMiddleware","enhanceMiddleware","metroMiddleware","createDebuggerTelemetryMiddleware","metro","runServer","hmrEnabled","watch","req","res","next","url","URL","pathname","match","searchParams","get","processRequest","messageSocket","env","CI","Log","log","chalk"],"mappings":"AAAA;;;;QAoDsBA,oBAAoB,GAApBA,oBAAoB;QAqEpBC,qBAAqB,GAArBA,qBAAqB;QA6F3BC,cAAc,GAAdA,cAAc;AAtNQ,IAAA,OAAc,WAAd,cAAc,CAAA;AAElC,IAAA,MAAO,kCAAP,OAAO,EAAA;AAIA,IAAA,UAAY,WAAZ,YAAY,CAAA;AAClB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACP,IAAA,IAAK,WAAL,KAAK,CAAA;AAGa,IAAA,sBAAyB,WAAzB,yBAAyB,CAAA;AACM,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AACpC,IAAA,OAAU,WAAV,UAAU,CAAA;AACvC,IAAA,cAAkB,WAAlB,kBAAkB,C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ACG,GAAG,EAAG,uBAAuB,CAAC,AAAC;YACvD,IAAIA,GAAG,CAACE,QAAQ,CAACC,KAAK,gBAAgB,IAAIH,GAAG,CAACI,YAAY,CAACC,GAAG,CAAC,eAAe,CAAC,IAAI,IAAI,EAAE;gBACvF,OAAOZ,KAAK,CAACa,cAAc,CAACT,GAAG,EAAEC,GAAG,EAAEC,IAAI,CAAC,CAAC;aAC7C;SACF;QACD,OAAOA,IAAI,EAAE,CAAC;KACf,CAAC,CAAC;IAEH/B,gBAAgB,CAACS,oBAAoB,CAACzC,WAAW,CAAC,CAAC;IAEnD,OAAO;QACLyD,KAAK;QACLb,MAAM,EAANA,OAAM;QACNL,UAAU;QACVgC,aAAa,EAAE/B,qBAAqB;KACrC,CAAC;CACH;AAMM,SAASrD,cAAc,GAAG;IAC/B,IAAIqF,IAAG,IAAA,CAACC,EAAE,EAAE;QACVC,IAAG,IAAA,CAACC,GAAG,CACLC,MAAK,QAAA,CAAC,8FAA8F,CAAC,CACtG,CAAC;KACH;IAED,OAAO,CAACJ,IAAG,IAAA,CAACC,EAAE,CAAC;CAChB"}
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/instantiateMetro.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport type { LoadOptions } from '@expo/metro-config';\nimport chalk from 'chalk';\nimport { Server as ConnectServer } from 'connect';\nimport http from 'http';\nimport type Metro from 'metro';\nimport { Terminal } from 'metro-core';\nimport semver from 'semver';\nimport { URL } from 'url';\n\nimport { MetroBundlerDevServer } from './MetroBundlerDevServer';\nimport { MetroTerminalReporter } from './MetroTerminalReporter';\nimport { importCliServerApiFromProject, importExpoMetroConfig } from './resolveFromProject';\nimport { getRouterDirectoryModuleIdWithManifest } from './router';\nimport { runServer } from './runServer-fork';\nimport { withMetroMultiPlatformAsync } from './withMetroMultiPlatform';\nimport { MetroDevServerOptions } from '../../../export/fork-bundleAsync';\nimport { Log } from '../../../log';\nimport { getMetroProperties } from '../../../utils/analytics/getMetroProperties';\nimport { createDebuggerTelemetryMiddleware } from '../../../utils/analytics/metroDebuggerMiddleware';\nimport { logEventAsync } from '../../../utils/analytics/rudderstackClient';\nimport { env } from '../../../utils/env';\nimport { getMetroServerRoot } from '../middleware/ManifestMiddleware';\nimport createJsInspectorMiddleware from '../middleware/inspector/createJsInspectorMiddleware';\nimport { prependMiddleware, replaceMiddlewareWith } from '../middleware/mutations';\nimport { remoteDevtoolsCorsMiddleware } from '../middleware/remoteDevtoolsCorsMiddleware';\nimport { remoteDevtoolsSecurityHeadersMiddleware } from '../middleware/remoteDevtoolsSecurityHeadersMiddleware';\nimport { ServerNext, ServerRequest, ServerResponse } from '../middleware/server.types';\nimport { suppressRemoteDebuggingErrorMiddleware } from '../middleware/suppressErrorMiddleware';\nimport { getPlatformBundlers } from '../platformBundlers';\n\n// From expo/dev-server but with ability to use custom logger.\ntype MessageSocket = {\n broadcast: (method: string, params?: Record<string, any> | undefined) => void;\n};\n\nfunction gteSdkVersion(exp: Pick<ExpoConfig, 'sdkVersion'>, sdkVersion: string): boolean {\n if (!exp.sdkVersion) {\n return false;\n }\n\n if (exp.sdkVersion === 'UNVERSIONED') {\n return true;\n }\n\n try {\n return semver.gte(exp.sdkVersion, sdkVersion);\n } catch {\n throw new Error(`${exp.sdkVersion} is not a valid version. Must be in the form of x.y.z`);\n }\n}\n\nexport async function loadMetroConfigAsync(\n projectRoot: string,\n options: LoadOptions,\n {\n exp = getConfig(projectRoot, { skipSDKVersionRequirement: true }).exp,\n isExporting,\n }: { exp?: ExpoConfig; isExporting: boolean }\n) {\n let reportEvent: ((event: any) => void) | undefined;\n const serverRoot = getMetroServerRoot(projectRoot);\n\n const terminal = new Terminal(process.stdout);\n const terminalReporter = new MetroTerminalReporter(serverRoot, terminal);\n\n const reporter = {\n update(event: any) {\n terminalReporter.update(event);\n if (reportEvent) {\n reportEvent(event);\n }\n },\n };\n\n const ExpoMetroConfig = importExpoMetroConfig(projectRoot);\n let config = await ExpoMetroConfig.loadAsync(projectRoot, { reporter, ...options });\n\n if (\n // Requires SDK 50 for expo-assets hashAssetPlugin change.\n !exp.sdkVersion ||\n gteSdkVersion(exp, '50.0.0')\n ) {\n if (isExporting) {\n // This token will be used in the asset plugin to ensure the path is correct for writing locally.\n // @ts-expect-error: typed as readonly.\n config.transformer.publicPath = `/assets?export_path=${\n (exp.experiments?.basePath ?? '') + '/assets'\n }`;\n } else {\n // @ts-expect-error: typed as readonly\n config.transformer.publicPath = '/assets/?unstable_path=.';\n }\n } else {\n if (isExporting && exp.experiments?.basePath) {\n // This token will be used in the asset plugin to ensure the path is correct for writing locally.\n // @ts-expect-error: typed as readonly.\n config.transformer.publicPath = exp.experiments?.basePath;\n }\n }\n\n const platformBundlers = getPlatformBundlers(exp);\n\n config = await withMetroMultiPlatformAsync(projectRoot, {\n routerDirectory: getRouterDirectoryModuleIdWithManifest(projectRoot, exp),\n config,\n platformBundlers,\n isTsconfigPathsEnabled: exp.experiments?.tsconfigPaths ?? true,\n webOutput: exp.web?.output ?? 'single',\n isFastResolverEnabled: env.EXPO_USE_FAST_RESOLVER,\n });\n\n logEventAsync('metro config', getMetroProperties(projectRoot, exp, config));\n\n return {\n config,\n setEventReporter: (logger: (event: any) => void) => (reportEvent = logger),\n reporter: terminalReporter,\n };\n}\n\n/** The most generic possible setup for Metro bundler. */\nexport async function instantiateMetroAsync(\n metroBundler: MetroBundlerDevServer,\n options: Omit<MetroDevServerOptions, 'logger'>,\n { isExporting }: { isExporting: boolean }\n): Promise<{\n metro: Metro.Server;\n server: http.Server;\n middleware: any;\n messageSocket: MessageSocket;\n}> {\n const projectRoot = metroBundler.projectRoot;\n\n // TODO: When we bring expo/metro-config into the expo/expo repo, then we can upstream this.\n const { exp } = getConfig(projectRoot, {\n skipSDKVersionRequirement: true,\n });\n\n const { config: metroConfig, setEventReporter } = await loadMetroConfigAsync(\n projectRoot,\n options,\n { exp, isExporting }\n );\n\n const { createDevServerMiddleware, securityHeadersMiddleware } =\n importCliServerApiFromProject(projectRoot);\n\n const { middleware, messageSocketEndpoint, eventsSocketEndpoint, websocketEndpoints } =\n createDevServerMiddleware({\n port: metroConfig.server.port,\n watchFolders: metroConfig.watchFolders,\n });\n\n // securityHeadersMiddleware does not support cross-origin requests for remote devtools to get the sourcemap.\n // We replace with the enhanced version.\n replaceMiddlewareWith(\n middleware as ConnectServer,\n securityHeadersMiddleware,\n remoteDevtoolsSecurityHeadersMiddleware\n );\n\n middleware.use(remoteDevtoolsCorsMiddleware);\n\n prependMiddleware(middleware, suppressRemoteDebuggingErrorMiddleware);\n\n middleware.use('/inspector', createJsInspectorMiddleware());\n\n // TODO: We can probably drop this now.\n const customEnhanceMiddleware = metroConfig.server.enhanceMiddleware;\n // @ts-expect-error: can't mutate readonly config\n metroConfig.server.enhanceMiddleware = (metroMiddleware: any, server: Metro.Server) => {\n if (customEnhanceMiddleware) {\n metroMiddleware = customEnhanceMiddleware(metroMiddleware, server);\n }\n return middleware.use(metroMiddleware);\n };\n\n middleware.use(createDebuggerTelemetryMiddleware(projectRoot, exp));\n\n const { server, metro } = await runServer(metroBundler, metroConfig, {\n hmrEnabled: true,\n // @ts-expect-error: Inconsistent `websocketEndpoints` type between metro and @react-native-community/cli-server-api\n websocketEndpoints,\n watch: isWatchEnabled(),\n });\n\n prependMiddleware(middleware, (req: ServerRequest, res: ServerResponse, next: ServerNext) => {\n // If the URL is a Metro asset request, then we need to skip all other middleware to prevent\n // the community CLI's serve-static from hosting `/assets/index.html` in place of all assets if it exists.\n // /assets/?unstable_path=.\n if (req.url) {\n const url = new URL(req.url!, 'http://localhost:8000');\n if (url.pathname.match(/^\\/assets\\/?/) && url.searchParams.get('unstable_path') != null) {\n return metro.processRequest(req, res, next);\n }\n }\n return next();\n });\n\n setEventReporter(eventsSocketEndpoint.reportEvent);\n\n return {\n metro,\n server,\n middleware,\n messageSocket: messageSocketEndpoint,\n };\n}\n\n/**\n * Simplify and communicate if Metro is running without watching file updates,.\n * Exposed for testing.\n */\nexport function isWatchEnabled() {\n if (env.CI) {\n Log.log(\n chalk`Metro is running in CI mode, reloads are disabled. Remove {bold CI=true} to enable watch mode.`\n );\n }\n\n return !env.CI;\n}\n"],"names":["loadMetroConfigAsync","instantiateMetroAsync","isWatchEnabled","gteSdkVersion","exp","sdkVersion","semver","gte","Error","projectRoot","options","getConfig","skipSDKVersionRequirement","isExporting","reportEvent","serverRoot","getMetroServerRoot","terminal","Terminal","process","stdout","terminalReporter","MetroTerminalReporter","reporter","update","event","ExpoMetroConfig","importExpoMetroConfig","config","loadAsync","transformer","publicPath","experiments","basePath","platformBundlers","getPlatformBundlers","withMetroMultiPlatformAsync","routerDirectory","getRouterDirectoryModuleIdWithManifest","isTsconfigPathsEnabled","tsconfigPaths","webOutput","web","output","isFastResolverEnabled","env","EXPO_USE_FAST_RESOLVER","logEventAsync","getMetroProperties","setEventReporter","logger","metroBundler","metroConfig","createDevServerMiddleware","securityHeadersMiddleware","importCliServerApiFromProject","middleware","messageSocketEndpoint","eventsSocketEndpoint","websocketEndpoints","port","server","watchFolders","replaceMiddlewareWith","remoteDevtoolsSecurityHeadersMiddleware","use","remoteDevtoolsCorsMiddleware","prependMiddleware","suppressRemoteDebuggingErrorMiddleware","createJsInspectorMiddleware","customEnhanceMiddleware","enhanceMiddleware","metroMiddleware","createDebuggerTelemetryMiddleware","metro","runServer","hmrEnabled","watch","req","res","next","url","URL","pathname","match","searchParams","get","processRequest","messageSocket","CI","Log","log","chalk"],"mappings":"AAAA;;;;QAoDsBA,oBAAoB,GAApBA,oBAAoB;QAsEpBC,qBAAqB,GAArBA,qBAAqB;QA4F3BC,cAAc,GAAdA,cAAc;AAtNQ,IAAA,OAAc,WAAd,cAAc,CAAA;AAElC,IAAA,MAAO,kCAAP,OAAO,EAAA;AAIA,IAAA,UAAY,WAAZ,YAAY,CAAA;AAClB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACP,IAAA,IAAK,WAAL,KAAK,CAAA;AAGa,IAAA,sBAAyB,WAAzB,yBAA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B,EAAEC,IAAgB,GAAK;QAC3F,4FAA4F;QAC5F,0GAA0G;QAC1G,2BAA2B;QAC3B,IAAIF,GAAG,CAACG,GAAG,EAAE;YACX,MAAMA,GAAG,GAAG,IAAIC,IAAG,IAAA,CAACJ,GAAG,CAACG,GAAG,EAAG,uBAAuB,CAAC,AAAC;YACvD,IAAIA,GAAG,CAACE,QAAQ,CAACC,KAAK,gBAAgB,IAAIH,GAAG,CAACI,YAAY,CAACC,GAAG,CAAC,eAAe,CAAC,IAAI,IAAI,EAAE;gBACvF,OAAOZ,KAAK,CAACa,cAAc,CAACT,GAAG,EAAEC,GAAG,EAAEC,IAAI,CAAC,CAAC;aAC7C;SACF;QACD,OAAOA,IAAI,EAAE,CAAC;KACf,CAAC,CAAC;IAEH/B,gBAAgB,CAACS,oBAAoB,CAAC5C,WAAW,CAAC,CAAC;IAEnD,OAAO;QACL4D,KAAK;QACLb,MAAM,EAANA,OAAM;QACNL,UAAU;QACVgC,aAAa,EAAE/B,qBAAqB;KACrC,CAAC;CACH;AAMM,SAASvD,cAAc,GAAG;IAC/B,IAAI2C,IAAG,IAAA,CAAC4C,EAAE,EAAE;QACVC,IAAG,IAAA,CAACC,GAAG,CACLC,MAAK,QAAA,CAAC,8FAA8F,CAAC,CACtG,CAAC;KACH;IAED,OAAO,CAAC/C,IAAG,IAAA,CAAC4C,EAAE,CAAC;CAChB"}
@@ -38,7 +38,8 @@ async function logMetroErrorWithStack(projectRoot, { stack , codeFrame , error
38
38
  var ref;
39
39
  const maxWarningLineLength = Math.max(200, process.stdout.columns);
40
40
  const lineText = codeFrame.content;
41
- const isPreviewTooLong = lineText.length > maxWarningLineLength;
41
+ const isPreviewTooLong = codeFrame.content.split("\n").some((line)=>line.length > maxWarningLineLength
42
+ );
42
43
  const column = (ref = codeFrame.location) == null ? void 0 : ref.column;
43
44
  // When the preview is too long, we skip reading the file and attempting to apply
44
45
  // code coloring, this is because it can get very slow.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/metroErrorInterface.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 resolveFrom from 'resolve-from';\nimport { StackFrame } from 'stacktrace-parser';\nimport terminalLink from 'terminal-link';\n\nimport { Log } from '../../../log';\nimport { createMetroEndpointAsync } from '../getStaticRenderFunctions';\n// import type { CodeFrame, MetroStackFrame } from '@expo/metro-runtime/symbolicate';\n\ntype CodeFrame = {\n content: string;\n location?: {\n row: number;\n column: number;\n [key: string]: any;\n };\n fileName: string;\n};\n\ntype MetroStackFrame = StackFrame & { collapse?: boolean };\n\nfunction fill(width: number): string {\n return Array(width).join(' ');\n}\n\nfunction formatPaths(config: { filePath: string | null; line?: number; col?: number }) {\n const filePath = chalk.reset(config.filePath);\n return (\n chalk.dim('(') +\n filePath +\n chalk.dim(`:${[config.line, config.col].filter(Boolean).join(':')})`)\n );\n}\n\nexport async function logMetroErrorWithStack(\n projectRoot: string,\n {\n stack,\n codeFrame,\n error,\n }: {\n stack: MetroStackFrame[];\n codeFrame: CodeFrame;\n error: Error;\n }\n) {\n // process.stdout.write('\\u001b[0m'); // Reset attributes\n // process.stdout.write('\\u001bc'); // Reset the terminal\n\n const { getStackFormattedLocation } = require(\n resolveFrom(projectRoot, '@expo/metro-runtime/symbolicate')\n );\n\n Log.log();\n Log.log(chalk.red('Metro error: ') + error.message);\n Log.log();\n\n if (codeFrame) {\n const maxWarningLineLength = Math.max(200, process.stdout.columns);\n\n const lineText = codeFrame.content;\n const isPreviewTooLong = lineText.length > maxWarningLineLength;\n const column = codeFrame.location?.column;\n // When the preview is too long, we skip reading the file and attempting to apply\n // code coloring, this is because it can get very slow.\n if (isPreviewTooLong) {\n let previewLine = '';\n let cursorLine = '';\n\n const formattedPath = formatPaths({\n filePath: codeFrame.fileName,\n line: codeFrame.location?.row,\n col: codeFrame.location?.column,\n });\n // Create a curtailed preview line like:\n // `...transition:'fade'},k._updatePropsStack=function(){clearImmediate(k._updateImmediate),k._updateImmediate...`\n // If there is no text preview or column number, we can't do anything.\n if (lineText && column != null) {\n const rangeWindow = Math.round(\n Math.max(codeFrame.fileName?.length ?? 0, Math.max(80, process.stdout.columns)) / 2\n );\n let minBounds = Math.max(0, column - rangeWindow);\n const maxBounds = Math.min(minBounds + rangeWindow * 2, lineText.length);\n previewLine = lineText.slice(minBounds, maxBounds);\n\n // If we splice content off the start, then we should append `...`.\n // This is unlikely to happen since we limit the activation size.\n if (minBounds > 0) {\n // Adjust the min bounds so the cursor is aligned after we add the \"...\"\n minBounds -= 3;\n previewLine = chalk.dim('...') + previewLine;\n }\n if (maxBounds < lineText.length) {\n previewLine += chalk.dim('...');\n }\n\n // If the column property could be found, then use that to fix the cursor location which is often broken in regex.\n cursorLine = (column == null ? '' : fill(column) + chalk.reset('^')).slice(minBounds);\n\n Log.log(\n [formattedPath, '', previewLine, cursorLine, chalk.dim('(error truncated)')].join('\\n')\n );\n }\n } else {\n Log.log(codeFrame.content);\n }\n }\n\n if (stack?.length) {\n Log.log();\n Log.log(chalk.bold`Call Stack`);\n\n const stackProps = stack.map((frame) => {\n return {\n title: frame.methodName,\n subtitle: getStackFormattedLocation(projectRoot, frame),\n collapse: frame.collapse,\n };\n });\n\n stackProps.forEach((frame) => {\n const position = terminalLink.isSupported\n ? terminalLink(frame.subtitle, frame.subtitle)\n : frame.subtitle;\n let lineItem = chalk.gray(` ${frame.title} (${position})`);\n if (frame.collapse) {\n lineItem = chalk.dim(lineItem);\n }\n Log.log(lineItem);\n });\n } else {\n Log.log(chalk.gray(` ${error.stack}`));\n }\n}\n\nexport async function logMetroError(projectRoot: string, { error }: { error: Error }) {\n const { LogBoxLog, parseErrorStack } = require(\n resolveFrom(projectRoot, '@expo/metro-runtime/symbolicate')\n );\n\n const stack = parseErrorStack(error.stack);\n\n const log = new LogBoxLog({\n level: 'static',\n message: {\n content: error.message,\n substitutions: [],\n },\n isComponentError: false,\n stack,\n category: 'static',\n componentStack: [],\n });\n\n await new Promise((res) => log.symbolicate('stack', res));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nexport function logFromError({ error, projectRoot }: { error: Error; projectRoot: string }): {\n symbolicated: any;\n symbolicate: (type: string, callback: () => void) => void;\n codeFrame: CodeFrame;\n} {\n const { LogBoxLog, parseErrorStack } = require(\n resolveFrom(projectRoot, '@expo/metro-runtime/symbolicate')\n );\n\n const stack = parseErrorStack(error.stack);\n\n return new LogBoxLog({\n level: 'static',\n message: {\n content: error.message,\n substitutions: [],\n },\n isComponentError: false,\n stack,\n category: 'static',\n componentStack: [],\n });\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nexport async function logMetroErrorAsync({\n error,\n projectRoot,\n}: {\n error: Error;\n projectRoot: string;\n}) {\n const log = logFromError({ projectRoot, error });\n\n await new Promise<void>((res) => log.symbolicate('stack', res));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nexport async function getErrorOverlayHtmlAsync({\n error,\n projectRoot,\n}: {\n error: Error;\n projectRoot: string;\n}) {\n const log = logFromError({ projectRoot, error });\n\n await new Promise<void>((res) => log.symbolicate('stack', res));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n\n const logBoxContext = {\n selectedLogIndex: 0,\n isDisabled: false,\n logs: [log],\n };\n const html = `<html><head><style>#root,body,html{height:100%}body{overflow:hidden}#root{display:flex}</style></head><body><div id=\"root\"></div><script id=\"_expo-static-error\" type=\"application/json\">${JSON.stringify(\n logBoxContext\n )}</script></body></html>`;\n\n const errorOverlayEntry = await createMetroEndpointAsync(\n projectRoot,\n // Keep the URL relative\n '',\n resolveFrom(projectRoot, 'expo-router/_error'),\n {\n dev: true,\n platform: 'web',\n minify: false,\n environment: 'node',\n }\n );\n\n const htmlWithJs = html.replace('</body>', `<script src=${errorOverlayEntry}></script></body>`);\n return htmlWithJs;\n}\n"],"names":["logMetroErrorWithStack","logMetroError","logFromError","logMetroErrorAsync","getErrorOverlayHtmlAsync","fill","width","Array","join","formatPaths","config","filePath","chalk","reset","dim","line","col","filter","Boolean","projectRoot","stack","codeFrame","error","getStackFormattedLocation","require","resolveFrom","Log","log","red","message","maxWarningLineLength","Math","max","process","stdout","columns","lineText","content","isPreviewTooLong","length","column","location","previewLine","cursorLine","formattedPath","fileName","row","rangeWindow","round","minBounds","maxBounds","min","slice","bold","stackProps","map","frame","title","methodName","subtitle","collapse","forEach","position","terminalLink","isSupported","lineItem","gray","LogBoxLog","parseErrorStack","level","substitutions","isComponentError","category","componentStack","Promise","res","symbolicate","symbolicated","logBoxContext","selectedLogIndex","isDisabled","logs","html","JSON","stringify","errorOverlayEntry","createMetroEndpointAsync","dev","platform","minify","environment","htmlWithJs","replace"],"mappings":"AAMA;;;;QAkCsBA,sBAAsB,GAAtBA,sBAAsB;QAqGtBC,aAAa,GAAbA,aAAa;QA6BnBC,YAAY,GAAZA,YAAY;QAyBNC,kBAAkB,GAAlBA,kBAAkB;QAmBlBC,wBAAwB,GAAxBA,wBAAwB;AAhN5B,IAAA,MAAO,kCAAP,OAAO,EAAA;AACD,IAAA,YAAc,kCAAd,cAAc,EAAA;AAEb,IAAA,aAAe,kCAAf,eAAe,EAAA;AAEpB,IAAA,IAAc,WAAd,cAAc,CAAA;AACO,IAAA,yBAA6B,WAA7B,6BAA6B,CAAA;;;;;;AAetE,SAASC,IAAI,CAACC,KAAa,EAAU;IACnC,OAAOC,KAAK,CAACD,KAAK,CAAC,CAACE,IAAI,CAAC,GAAG,CAAC,CAAC;CAC/B;AAED,SAASC,WAAW,CAACC,MAAgE,EAAE;IACrF,MAAMC,QAAQ,GAAGC,MA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AuB,GAAvBA,QAAAA,GAAgB,CAAEP,KAAK,SAAA,GAAvBO,KAAAA,CAAuB,QAAEP,KAAK,AAAP,YAAvBO,KAA8B,GAAI,EAAE;QAC3CN,SAAS,EAAEM,GAAG,CAACN,SAAS;QACxBC,KAAK;KACN,CAAC,CAAC;IAEH,MAAMwD,aAAa,GAAG;QACpBC,gBAAgB,EAAE,CAAC;QACnBC,UAAU,EAAE,KAAK;QACjBC,IAAI,EAAE;YAACtD,GAAG;SAAC;KACZ,AAAC;IACF,MAAMuD,IAAI,GAAG,CAAC,yLAAyL,EAAEC,IAAI,CAACC,SAAS,CACrNN,aAAa,CACd,CAAC,uBAAuB,CAAC,AAAC;IAE3B,MAAMO,iBAAiB,GAAG,MAAMC,CAAAA,GAAAA,yBAAwB,AAWvD,CAAA,yBAXuD,CACtDnE,WAAW,EACX,wBAAwB;IACxB,EAAE,EACFM,CAAAA,GAAAA,YAAW,AAAmC,CAAA,QAAnC,CAACN,WAAW,EAAE,oBAAoB,CAAC,EAC9C;QACEoE,GAAG,EAAE,IAAI;QACTC,QAAQ,EAAE,KAAK;QACfC,MAAM,EAAE,KAAK;QACbC,WAAW,EAAE,MAAM;KACpB,CACF,AAAC;IAEF,MAAMC,UAAU,GAAGT,IAAI,CAACU,OAAO,CAAC,SAAS,EAAE,CAAC,YAAY,EAAEP,iBAAiB,CAAC,iBAAiB,CAAC,CAAC,AAAC;IAChG,OAAOM,UAAU,CAAC;CACnB"}
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/metroErrorInterface.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 resolveFrom from 'resolve-from';\nimport { StackFrame } from 'stacktrace-parser';\nimport terminalLink from 'terminal-link';\n\nimport { Log } from '../../../log';\nimport { createMetroEndpointAsync } from '../getStaticRenderFunctions';\n// import type { CodeFrame, MetroStackFrame } from '@expo/metro-runtime/symbolicate';\n\ntype CodeFrame = {\n content: string;\n location?: {\n row: number;\n column: number;\n [key: string]: any;\n };\n fileName: string;\n};\n\ntype MetroStackFrame = StackFrame & { collapse?: boolean };\n\nfunction fill(width: number): string {\n return Array(width).join(' ');\n}\n\nfunction formatPaths(config: { filePath: string | null; line?: number; col?: number }) {\n const filePath = chalk.reset(config.filePath);\n return (\n chalk.dim('(') +\n filePath +\n chalk.dim(`:${[config.line, config.col].filter(Boolean).join(':')})`)\n );\n}\n\nexport async function logMetroErrorWithStack(\n projectRoot: string,\n {\n stack,\n codeFrame,\n error,\n }: {\n stack: MetroStackFrame[];\n codeFrame: CodeFrame;\n error: Error;\n }\n) {\n // process.stdout.write('\\u001b[0m'); // Reset attributes\n // process.stdout.write('\\u001bc'); // Reset the terminal\n\n const { getStackFormattedLocation } = require(\n resolveFrom(projectRoot, '@expo/metro-runtime/symbolicate')\n );\n\n Log.log();\n Log.log(chalk.red('Metro error: ') + error.message);\n Log.log();\n\n if (codeFrame) {\n const maxWarningLineLength = Math.max(200, process.stdout.columns);\n\n const lineText = codeFrame.content;\n const isPreviewTooLong = codeFrame.content\n .split('\\n')\n .some((line) => line.length > maxWarningLineLength);\n const column = codeFrame.location?.column;\n // When the preview is too long, we skip reading the file and attempting to apply\n // code coloring, this is because it can get very slow.\n if (isPreviewTooLong) {\n let previewLine = '';\n let cursorLine = '';\n\n const formattedPath = formatPaths({\n filePath: codeFrame.fileName,\n line: codeFrame.location?.row,\n col: codeFrame.location?.column,\n });\n // Create a curtailed preview line like:\n // `...transition:'fade'},k._updatePropsStack=function(){clearImmediate(k._updateImmediate),k._updateImmediate...`\n // If there is no text preview or column number, we can't do anything.\n if (lineText && column != null) {\n const rangeWindow = Math.round(\n Math.max(codeFrame.fileName?.length ?? 0, Math.max(80, process.stdout.columns)) / 2\n );\n let minBounds = Math.max(0, column - rangeWindow);\n const maxBounds = Math.min(minBounds + rangeWindow * 2, lineText.length);\n previewLine = lineText.slice(minBounds, maxBounds);\n\n // If we splice content off the start, then we should append `...`.\n // This is unlikely to happen since we limit the activation size.\n if (minBounds > 0) {\n // Adjust the min bounds so the cursor is aligned after we add the \"...\"\n minBounds -= 3;\n previewLine = chalk.dim('...') + previewLine;\n }\n if (maxBounds < lineText.length) {\n previewLine += chalk.dim('...');\n }\n\n // If the column property could be found, then use that to fix the cursor location which is often broken in regex.\n cursorLine = (column == null ? '' : fill(column) + chalk.reset('^')).slice(minBounds);\n\n Log.log(\n [formattedPath, '', previewLine, cursorLine, chalk.dim('(error truncated)')].join('\\n')\n );\n }\n } else {\n Log.log(codeFrame.content);\n }\n }\n\n if (stack?.length) {\n Log.log();\n Log.log(chalk.bold`Call Stack`);\n\n const stackProps = stack.map((frame) => {\n return {\n title: frame.methodName,\n subtitle: getStackFormattedLocation(projectRoot, frame),\n collapse: frame.collapse,\n };\n });\n\n stackProps.forEach((frame) => {\n const position = terminalLink.isSupported\n ? terminalLink(frame.subtitle, frame.subtitle)\n : frame.subtitle;\n let lineItem = chalk.gray(` ${frame.title} (${position})`);\n if (frame.collapse) {\n lineItem = chalk.dim(lineItem);\n }\n Log.log(lineItem);\n });\n } else {\n Log.log(chalk.gray(` ${error.stack}`));\n }\n}\n\nexport async function logMetroError(projectRoot: string, { error }: { error: Error }) {\n const { LogBoxLog, parseErrorStack } = require(\n resolveFrom(projectRoot, '@expo/metro-runtime/symbolicate')\n );\n\n const stack = parseErrorStack(error.stack);\n\n const log = new LogBoxLog({\n level: 'static',\n message: {\n content: error.message,\n substitutions: [],\n },\n isComponentError: false,\n stack,\n category: 'static',\n componentStack: [],\n });\n\n await new Promise((res) => log.symbolicate('stack', res));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nexport function logFromError({ error, projectRoot }: { error: Error; projectRoot: string }): {\n symbolicated: any;\n symbolicate: (type: string, callback: () => void) => void;\n codeFrame: CodeFrame;\n} {\n const { LogBoxLog, parseErrorStack } = require(\n resolveFrom(projectRoot, '@expo/metro-runtime/symbolicate')\n );\n\n const stack = parseErrorStack(error.stack);\n\n return new LogBoxLog({\n level: 'static',\n message: {\n content: error.message,\n substitutions: [],\n },\n isComponentError: false,\n stack,\n category: 'static',\n componentStack: [],\n });\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nexport async function logMetroErrorAsync({\n error,\n projectRoot,\n}: {\n error: Error;\n projectRoot: string;\n}) {\n const log = logFromError({ projectRoot, error });\n\n await new Promise<void>((res) => log.symbolicate('stack', res));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nexport async function getErrorOverlayHtmlAsync({\n error,\n projectRoot,\n}: {\n error: Error;\n projectRoot: string;\n}) {\n const log = logFromError({ projectRoot, error });\n\n await new Promise<void>((res) => log.symbolicate('stack', res));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n\n const logBoxContext = {\n selectedLogIndex: 0,\n isDisabled: false,\n logs: [log],\n };\n const html = `<html><head><style>#root,body,html{height:100%}body{overflow:hidden}#root{display:flex}</style></head><body><div id=\"root\"></div><script id=\"_expo-static-error\" type=\"application/json\">${JSON.stringify(\n logBoxContext\n )}</script></body></html>`;\n\n const errorOverlayEntry = await createMetroEndpointAsync(\n projectRoot,\n // Keep the URL relative\n '',\n resolveFrom(projectRoot, 'expo-router/_error'),\n {\n dev: true,\n platform: 'web',\n minify: false,\n environment: 'node',\n }\n );\n\n const htmlWithJs = html.replace('</body>', `<script src=${errorOverlayEntry}></script></body>`);\n return htmlWithJs;\n}\n"],"names":["logMetroErrorWithStack","logMetroError","logFromError","logMetroErrorAsync","getErrorOverlayHtmlAsync","fill","width","Array","join","formatPaths","config","filePath","chalk","reset","dim","line","col","filter","Boolean","projectRoot","stack","codeFrame","error","getStackFormattedLocation","require","resolveFrom","Log","log","red","message","maxWarningLineLength","Math","max","process","stdout","columns","lineText","content","isPreviewTooLong","split","some","length","column","location","previewLine","cursorLine","formattedPath","fileName","row","rangeWindow","round","minBounds","maxBounds","min","slice","bold","stackProps","map","frame","title","methodName","subtitle","collapse","forEach","position","terminalLink","isSupported","lineItem","gray","LogBoxLog","parseErrorStack","level","substitutions","isComponentError","category","componentStack","Promise","res","symbolicate","symbolicated","logBoxContext","selectedLogIndex","isDisabled","logs","html","JSON","stringify","errorOverlayEntry","createMetroEndpointAsync","dev","platform","minify","environment","htmlWithJs","replace"],"mappings":"AAMA;;;;QAkCsBA,sBAAsB,GAAtBA,sBAAsB;QAuGtBC,aAAa,GAAbA,aAAa;QA6BnBC,YAAY,GAAZA,YAAY;QAyBNC,kBAAkB,GAAlBA,kBAAkB;QAmBlBC,wBAAwB,GAAxBA,wBAAwB;AAlN5B,IAAA,MAAO,kCAAP,OAAO,EAAA;AACD,IAAA,YAAc,kCAAd,cAAc,EAAA;AAEb,IAAA,aAAe,kCAAf,eAAe,EAAA;AAEpB,IAAA,IAAc,WAAd,cAAc,CAAA;AACO,IAAA,yBAA6B,WAA7B,6BAA6B,CAAA;;;;;;AAetE,SAASC,IAAI,CAACC,KAAa,EAAU;IACnC,OAAOC,KAAK,CAACD,KAAK,CAAC,CAACE,IAAI,CAAC,GAAG,CAAC,CAAC;CAC/B;AAED,SAASC,WAAW,CAACC,MAAgE,EAAE;IACrF,MAAMC,QAAQ,GAAGC,MAAK,QAAA,CAACC,KAAK,CAACH,MAAM,CAACC,QAAQ,CAAC,AAAC;IAC9C,OACEC,MAAK,QAAA,CAACE,GAAG,CAAC,GAAG,CAAC,GACdH,QAAQ,GACRC,MAAK,QAAA,CAACE,GAAG,CAAC,CAAC,CAAC,EAAE;QAACJ,MAAM,CAACK,IAAI;QAAEL,MAAM,CAACM,GAAG;KAAC,CAACC,MAAM,CAACC,OAAO,CAAC,CAACV,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AK;KACN,CAAC,CAAC;IAEH,MAAM0D,aAAa,GAAG;QACpBC,gBAAgB,EAAE,CAAC;QACnBC,UAAU,EAAE,KAAK;QACjBC,IAAI,EAAE;YAACxD,GAAG;SAAC;KACZ,AAAC;IACF,MAAMyD,IAAI,GAAG,CAAC,yLAAyL,EAAEC,IAAI,CAACC,SAAS,CACrNN,aAAa,CACd,CAAC,uBAAuB,CAAC,AAAC;IAE3B,MAAMO,iBAAiB,GAAG,MAAMC,CAAAA,GAAAA,yBAAwB,AAWvD,CAAA,yBAXuD,CACtDrE,WAAW,EACX,wBAAwB;IACxB,EAAE,EACFM,CAAAA,GAAAA,YAAW,AAAmC,CAAA,QAAnC,CAACN,WAAW,EAAE,oBAAoB,CAAC,EAC9C;QACEsE,GAAG,EAAE,IAAI;QACTC,QAAQ,EAAE,KAAK;QACfC,MAAM,EAAE,KAAK;QACbC,WAAW,EAAE,MAAM;KACpB,CACF,AAAC;IAEF,MAAMC,UAAU,GAAGT,IAAI,CAACU,OAAO,CAAC,SAAS,EAAE,CAAC,YAAY,EAAEP,iBAAiB,CAAC,iBAAiB,CAAC,CAAC,AAAC;IAChG,OAAOM,UAAU,CAAC;CACnB"}
@@ -31,7 +31,7 @@ function getAppRouterRelativeEntryPath(projectRoot, routerDirectory = getRouterD
31
31
  // It doesn't matter if the app folder exists.
32
32
  const appFolder = _path.default.join(projectRoot, routerDirectory);
33
33
  const appRoot = _path.default.relative(_path.default.dirname(routerEntry), appFolder);
34
- debug("routerEntry", routerEntry, appFolder, appRoot);
34
+ debug("expo-router entry", routerEntry, appFolder, appRoot);
35
35
  return appRoot;
36
36
  }
37
37
  /** If the `expo-router` package is not installed, then use the `expo` package to determine where the node modules are relative to the project. */ function getFallbackEntryRoot(projectRoot) {
@@ -55,7 +55,7 @@ function getRouterDirectory(projectRoot) {
55
55
  _log.Log.log(_chalk.default.gray("Using src/app as the root directory for Expo Router."));
56
56
  return "src/app";
57
57
  }
58
- _log.Log.debug("Using app as the root directory for Expo Router.");
58
+ debug("Using app as the root directory for Expo Router.");
59
59
  return "app";
60
60
  }
61
61
  function isApiRouteConvention(name) {
@@ -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('routerEntry', 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 Log.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,oB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Fa,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"}
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,WA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ACHE,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
- const { resolve } = (0, _resolveFromProject).importMetroResolverFromProject(projectRoot);
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 resolve({
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, ref1;
298
- return input.platform === alias.platform && ((ref = input.result) == null ? void 0 : ref.type) === "sourceFile" && typeof ((ref1 = input.result) == null ? void 0 : ref1.filePath) === "string" && normalizeSlashes(input.result.filePath).endsWith(alias.output);
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":"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ro/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,IAAoB,WAApB,oBAAoB,CAAA;AACP,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AACxB,IAAA,YAA4B,WAA5B,4BAA4B,CAAA;AACJ,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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