@expo/cli 56.0.6 → 56.1.1

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 (35) hide show
  1. package/build/bin/cli +1 -1
  2. package/build/src/events/index.js +1 -1
  3. package/build/src/export/embed/exportEmbedAsync.js +19 -0
  4. package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
  5. package/build/src/log.js +21 -3
  6. package/build/src/log.js.map +1 -1
  7. package/build/src/start/resolveOptions.js +2 -2
  8. package/build/src/start/resolveOptions.js.map +1 -1
  9. package/build/src/start/server/getStaticRenderFunctions.js +7 -19
  10. package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
  11. package/build/src/start/server/metro/MetroBundlerDevServer.js +12 -25
  12. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  13. package/build/src/start/server/metro/MetroTerminalReporter.js +58 -8
  14. package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
  15. package/build/src/start/server/metro/TerminalReporter.js +18 -0
  16. package/build/src/start/server/metro/TerminalReporter.js.map +1 -1
  17. package/build/src/start/server/metro/createFileMap-fork.js +2 -17
  18. package/build/src/start/server/metro/createFileMap-fork.js.map +1 -1
  19. package/build/src/start/server/metro/instantiateMetro.js +74 -3
  20. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  21. package/build/src/start/server/metro/runServer-fork.js +1 -8
  22. package/build/src/start/server/metro/runServer-fork.js.map +1 -1
  23. package/build/src/start/server/metro/withMetroMultiPlatform.js +17 -4
  24. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  25. package/build/src/start/server/middleware/metroOptions.js +3 -2
  26. package/build/src/start/server/middleware/metroOptions.js.map +1 -1
  27. package/build/src/start/server/serverLogLikeMetro.js +5 -28
  28. package/build/src/start/server/serverLogLikeMetro.js.map +1 -1
  29. package/build/src/utils/composeMetroIgnorePatterns.js +69 -0
  30. package/build/src/utils/composeMetroIgnorePatterns.js.map +1 -0
  31. package/build/src/utils/port.js +7 -0
  32. package/build/src/utils/port.js.map +1 -1
  33. package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
  34. package/build/src/utils/telemetry/utils/context.js +1 -1
  35. package/package.json +16 -18
package/build/bin/cli CHANGED
@@ -139,7 +139,7 @@ const args = (0, _arg().default)({
139
139
  });
140
140
  if (args['--version']) {
141
141
  // Version is added in the build script.
142
- console.log("56.0.6");
142
+ console.log("56.1.1");
143
143
  process.exit(0);
144
144
  }
145
145
  if (args['--non-interactive']) {
@@ -76,7 +76,7 @@ function getInitMetadata() {
76
76
  return {
77
77
  format: 'v0-jsonl',
78
78
  // Version is added in the build script.
79
- version: "56.0.6" ?? 'UNVERSIONED'
79
+ version: "56.1.1" ?? 'UNVERSIONED'
80
80
  };
81
81
  }
82
82
  function getWellKnownTemporaryLogFile(projectRoot, command) {
@@ -65,6 +65,20 @@ function _bundle() {
65
65
  };
66
66
  return data;
67
67
  }
68
+ function _packedMap() {
69
+ const data = require("@expo/metro-config/build/serializer/packedMap");
70
+ _packedMap = function() {
71
+ return data;
72
+ };
73
+ return data;
74
+ }
75
+ function _sourceMap() {
76
+ const data = require("@expo/metro-config/build/serializer/sourceMap");
77
+ _sourceMap = function() {
78
+ return data;
79
+ };
80
+ return data;
81
+ }
68
82
  function _getAssets() {
69
83
  const data = /*#__PURE__*/ _interop_require_default(require("@expo/metro-config/build/transform-worker/getAssets"));
70
84
  _getAssets = function() {
@@ -416,6 +430,11 @@ async function createMetroServerAndBundleRequestAsync(projectRoot, options) {
416
430
  watch: false
417
431
  })
418
432
  }));
433
+ // The dev server applies the same patch from `instantiateMetro.ts`;
434
+ // this is the export-embed / `expo-updates` path, where `data.map`
435
+ // would otherwise reach Metro's readers in the unwrapped wire shape.
436
+ (0, _packedMap().patchTransformFileForPackedMaps)(metro.getBundler().getBundler());
437
+ (0, _sourceMap().patchMetroSourceMapStringForPackedMaps)();
419
438
  return {
420
439
  server: metro,
421
440
  bundleRequest
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/export/embed/exportEmbedAsync.ts"],"sourcesContent":["/**\n * Copyright © 2023 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 { getConfig } from '@expo/config';\nimport { convertEntryPointToRelative } from '@expo/config/paths';\nimport Server from '@expo/metro/metro/Server';\nimport splitBundleOptions from '@expo/metro/metro/lib/splitBundleOptions';\nimport * as output from '@expo/metro/metro/shared/output/bundle';\nimport type { BundleOptions } from '@expo/metro/metro/shared/types';\nimport getMetroAssets from '@expo/metro-config/build/transform-worker/getAssets';\nimport assert from 'assert';\nimport fs from 'fs';\nimport { sync as globSync } from 'glob';\nimport path from 'path';\n\nimport type { Options } from './resolveOptions';\nimport { deserializeEagerKey, getExportEmbedOptionsKey } from './resolveOptions';\nimport { isExecutingFromXcodebuild, logMetroErrorInXcode } from './xcodeCompilerLogger';\nimport { Log } from '../../log';\nimport { DevServerManager } from '../../start/server/DevServerManager';\nimport { MetroBundlerDevServer } from '../../start/server/metro/MetroBundlerDevServer';\nimport { replaceMetroFileMap } from '../../start/server/metro/createFileMap-fork';\nimport { loadMetroConfigAsync } from '../../start/server/metro/instantiateMetro';\nimport { DOM_COMPONENTS_BUNDLE_DIR } from '../../start/server/middleware/DomComponentsMiddleware';\nimport { getMetroDirectBundleOptionsForExpoConfig } from '../../start/server/middleware/metroOptions';\nimport { stripAnsi } from '../../utils/ansi';\nimport { copyAsync, removeAsync } from '../../utils/dir';\nimport { env } from '../../utils/env';\nimport { setNodeEnv, loadEnvFiles } from '../../utils/nodeEnv';\nimport { exportDomComponentAsync } from '../exportDomComponents';\nimport { isEnableHermesManaged } from '../exportHermes';\nimport { persistMetroAssetsAsync } from '../persistMetroAssets';\nimport { copyPublicFolderAsync } from '../publicFolder';\nimport type { BundleAssetWithFileHashes, ExportAssetMap } from '../saveAssets';\nimport { persistMetroFilesAsync } from '../saveAssets';\nimport { exportStandaloneServerAsync } from './exportServer';\nimport { ensureProcessExitsAfterDelay } from '../../utils/exit';\n\nconst debug = require('debug')('expo:export:embed');\n\nfunction guessCopiedAppleBundlePath(bundleOutput: string) {\n // Ensure the path is familiar before guessing.\n if (\n !bundleOutput.match(/\\/Xcode\\/DerivedData\\/.*\\/Build\\/Products\\//) &&\n !bundleOutput.match(/\\/CoreSimulator\\/Devices\\/.*\\/data\\/Containers\\/Bundle\\/Application\\//)\n ) {\n debug('Bundling to non-standard location:', bundleOutput);\n return false;\n }\n const bundleName = path.basename(bundleOutput);\n const bundleParent = path.dirname(bundleOutput);\n const possiblePath = globSync(`*.app/${bundleName}`, {\n cwd: bundleParent,\n absolute: true,\n // bundle identifiers can start with dots.\n dot: true,\n })[0];\n debug('Possible path for previous bundle:', possiblePath);\n return possiblePath;\n}\n\nexport async function exportEmbedAsync(projectRoot: string, options: Options) {\n // The React Native build scripts always enable the cache reset but we shouldn't need this in CI environments.\n // By disabling it, we can eagerly bundle code before the build and reuse the cached artifacts in subsequent builds.\n if (env.CI && options.resetCache) {\n debug('CI environment detected, disabling automatic cache reset');\n options.resetCache = false;\n }\n\n setNodeEnv(options.dev ? 'development' : 'production');\n loadEnvFiles(projectRoot);\n\n // This is an optimized codepath that can occur during `npx expo run` and does not occur during builds from Xcode or Android Studio.\n // Here we reconcile a bundle pass that was run before the native build process. This order can fail faster and is show better errors since the logs won't be obscured by Xcode and Android Studio.\n // This path is also used for automatically deploying server bundles to a remote host.\n const eagerBundleOptions = env.__EXPO_EAGER_BUNDLE_OPTIONS\n ? deserializeEagerKey(env.__EXPO_EAGER_BUNDLE_OPTIONS)\n : null;\n if (eagerBundleOptions) {\n // Get the cache key for the current process to compare against the eager key.\n const inputKey = getExportEmbedOptionsKey(options);\n\n // If the app was bundled previously in the same process, then we should reuse the Metro cache.\n options.resetCache = false;\n\n if (eagerBundleOptions.key === inputKey) {\n // Copy the eager bundleOutput and assets to the new locations.\n await removeAsync(options.bundleOutput);\n\n copyAsync(eagerBundleOptions.options.bundleOutput, options.bundleOutput);\n\n if (eagerBundleOptions.options.assetsDest && options.assetsDest) {\n copyAsync(eagerBundleOptions.options.assetsDest, options.assetsDest);\n }\n\n console.log('info: Copied output to binary:', options.bundleOutput);\n return;\n }\n // TODO: sourcemapOutput is set on Android but not during eager. This is tolerable since it doesn't invalidate the Metro cache.\n console.log(' Eager key:', eagerBundleOptions.key);\n console.log('Request key:', inputKey);\n\n // TODO: We may want an analytic event here in the future to understand when this happens.\n console.warn('warning: Eager bundle does not match new options, bundling again.');\n }\n\n await exportEmbedInternalAsync(projectRoot, options);\n\n // Ensure the process closes after bundling\n ensureProcessExitsAfterDelay();\n}\n\nexport async function exportEmbedInternalAsync(projectRoot: string, options: Options) {\n // Ensure we delete the old bundle to trigger a failure if the bundle cannot be created.\n await removeAsync(options.bundleOutput);\n\n // The iOS bundle is copied in to the Xcode project, so we need to remove the old one\n // to prevent Xcode from loading the old one after a build failure.\n if (options.platform === 'ios') {\n const previousPath = guessCopiedAppleBundlePath(options.bundleOutput);\n if (previousPath && fs.existsSync(previousPath)) {\n debug('Removing previous iOS bundle:', previousPath);\n await removeAsync(previousPath);\n }\n }\n\n const { bundle, assets, files } = await exportEmbedBundleAndAssetsAsync(projectRoot, options);\n\n fs.mkdirSync(path.dirname(options.bundleOutput), { recursive: true, mode: 0o755 });\n\n // On Android, dom components proxy files should write to the assets directory instead of the res directory.\n // We use the bundleOutput directory to get the assets directory.\n const domComponentProxyOutputDir =\n options.platform === 'android' ? path.dirname(options.bundleOutput) : options.assetsDest;\n const hasDomComponents = domComponentProxyOutputDir && files.size > 0;\n\n // Persist bundle and source maps.\n await Promise.all([\n output.save(bundle, options, Log.log),\n\n // Write dom components proxy files.\n hasDomComponents ? persistMetroFilesAsync(files, domComponentProxyOutputDir) : null,\n // Copy public folder for dom components only if\n hasDomComponents\n ? copyPublicFolderAsync(\n path.resolve(projectRoot, env.EXPO_PUBLIC_FOLDER),\n path.join(domComponentProxyOutputDir, DOM_COMPONENTS_BUNDLE_DIR)\n )\n : null,\n\n // NOTE(EvanBacon): This may need to be adjusted in the future if want to support baseUrl on native\n // platforms when doing production embeds (unlikely).\n options.assetsDest\n ? persistMetroAssetsAsync(projectRoot, assets, {\n platform: options.platform,\n outputDirectory: options.assetsDest,\n iosAssetCatalogDirectory: options.assetCatalogDest,\n })\n : null,\n ]);\n}\n\nexport async function exportEmbedBundleAndAssetsAsync(\n projectRoot: string,\n options: Options\n): Promise<{\n bundle: Awaited<ReturnType<Server['build']>>;\n assets: readonly BundleAssetWithFileHashes[];\n files: ExportAssetMap;\n}> {\n const devServerManager = await DevServerManager.startMetroAsync(projectRoot, {\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n port: 8081,\n isExporting: true,\n location: {},\n resetDevServer: options.resetCache,\n maxWorkers: options.maxWorkers,\n });\n\n const devServer = devServerManager.getDefaultDevServer();\n assert(devServer instanceof MetroBundlerDevServer);\n\n const { exp, pkg } = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n const isHermes = isEnableHermesManaged(exp, options.platform);\n\n let sourceMapUrl = options.sourcemapOutput;\n if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {\n sourceMapUrl = path.basename(sourceMapUrl);\n }\n\n const files: ExportAssetMap = new Map();\n\n try {\n const bundles = await devServer.nativeExportBundleAsync(\n exp,\n {\n // TODO: Re-enable when we get bytecode chunk splitting working again.\n splitChunks: false, //devServer.isReactServerComponentsEnabled,\n mainModuleName: convertEntryPointToRelative(projectRoot, options.entryFile),\n platform: options.platform,\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n serializerIncludeMaps: !!sourceMapUrl,\n bytecode: options.bytecode ?? false,\n // source map inline\n reactCompiler: !!exp.experiments?.reactCompiler,\n },\n files,\n {\n sourceMapUrl,\n unstable_transformProfile: (options.unstableTransformProfile ||\n (isHermes ? 'hermes-stable' : 'default')) as BundleOptions['unstable_transformProfile'],\n }\n );\n\n // We optimistically build the server-side API routes code here, to ensure they're\n // valid or to enable parallel deployment in the future (TBD). This is disabled using\n // the explicit `--skip-server` flag.\n const apiRoutesEnabled =\n devServer.isReactServerComponentsEnabled || exp.web?.output === 'server';\n if (!options.skipServer && apiRoutesEnabled) {\n await exportStandaloneServerAsync(projectRoot, devServer, {\n exp,\n pkg,\n files,\n options,\n });\n }\n\n const expoDomComponentReferences = [\n ...new Set(\n bundles.artifacts\n .map((artifact) =>\n Array.isArray(artifact.metadata.expoDomComponentReferences)\n ? artifact.metadata.expoDomComponentReferences\n : []\n )\n .flat()\n ),\n ];\n if (expoDomComponentReferences.length > 0) {\n await Promise.all(\n // TODO: Make a version of this which uses `this.metro.getBundler().buildGraphForEntries([])` to bundle all the DOM components at once.\n expoDomComponentReferences.map(async (filePath) => {\n const { bundle } = await exportDomComponentAsync({\n filePath,\n projectRoot,\n dev: options.dev,\n devServer,\n isHermes,\n includeSourceMaps: !!sourceMapUrl,\n exp,\n files,\n });\n\n if (options.assetsDest) {\n // Save assets like a typical bundler, preserving the file paths on web.\n // This is saving web-style inside of a native app's binary.\n await persistMetroAssetsAsync(\n projectRoot,\n bundle.assets.map((asset) => ({\n ...asset,\n httpServerLocation: path.join(DOM_COMPONENTS_BUNDLE_DIR, asset.httpServerLocation),\n })),\n {\n files,\n platform: 'web',\n outputDirectory: options.assetsDest,\n }\n );\n }\n })\n );\n }\n\n return {\n files,\n bundle: {\n code: bundles.artifacts.filter((a: any) => a.type === 'js')[0]?.source!,\n // Can be optional when source maps aren't enabled.\n map: bundles.artifacts.filter((a: any) => a.type === 'map')[0]?.source.toString()!,\n },\n assets: bundles.assets,\n };\n } catch (error: any) {\n if (isError(error)) {\n // Log using Xcode error format so the errors are picked up by xcodebuild.\n // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script\n if (options.platform === 'ios') {\n // If the error is about to be presented in Xcode, strip the ansi characters from the message.\n if ('message' in error && isExecutingFromXcodebuild()) {\n error.message = stripAnsi(error.message) as string;\n }\n logMetroErrorInXcode(projectRoot, error);\n }\n }\n throw error;\n } finally {\n devServerManager.stopAsync();\n }\n}\n\n// Exports for expo-updates\nexport async function createMetroServerAndBundleRequestAsync(\n projectRoot: string,\n options: Pick<\n Options,\n | 'maxWorkers'\n | 'config'\n | 'platform'\n | 'sourcemapOutput'\n | 'sourcemapUseAbsolutePath'\n | 'entryFile'\n | 'minify'\n | 'dev'\n | 'resetCache'\n | 'unstableTransformProfile'\n >\n): Promise<{ server: Server; bundleRequest: BundleOptions }> {\n const exp = getConfig(projectRoot, { skipSDKVersionRequirement: true }).exp;\n\n // TODO: This is slow ~40ms\n const { config } = await loadMetroConfigAsync(\n projectRoot,\n {\n // TODO: This is always enabled in the native script and there's no way to disable it.\n resetCache: options.resetCache,\n maxWorkers: options.maxWorkers,\n },\n {\n exp,\n isExporting: true,\n getMetroBundler() {\n return metro.getBundler().getBundler();\n },\n }\n );\n\n const isHermes = isEnableHermesManaged(exp, options.platform);\n\n let sourceMapUrl = options.sourcemapOutput;\n if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {\n sourceMapUrl = path.basename(sourceMapUrl);\n }\n\n const directBundleOptions = getMetroDirectBundleOptionsForExpoConfig(projectRoot, exp, {\n splitChunks: false,\n // TODO(@kitten): This currently has to match a filename exactly\n mainModuleName: convertEntryPointToRelative(projectRoot, options.entryFile, null),\n platform: options.platform,\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n isExporting: true,\n // Never output bytecode in the exported bundle since that is hardcoded in the native run script.\n bytecode: false,\n hosted: false,\n });\n\n // TODO(cedric): check if we can use the proper `bundleType=bundle` and `entryPoint=mainModuleName` properties\n const bundleRequest: BundleOptions = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n ...directBundleOptions,\n\n // NOTE(@kitten): Cast non-optional defaults\n lazy: directBundleOptions.lazy ?? Server.DEFAULT_BUNDLE_OPTIONS.lazy,\n modulesOnly: directBundleOptions.modulesOnly ?? Server.DEFAULT_BUNDLE_OPTIONS.modulesOnly,\n runModule: directBundleOptions.runModule ?? Server.DEFAULT_BUNDLE_OPTIONS.runModule,\n\n sourceMapUrl,\n unstable_transformProfile: (options.unstableTransformProfile ||\n (isHermes ? 'hermes-stable' : 'default')) as BundleOptions['unstable_transformProfile'],\n };\n\n const { metro } = await replaceMetroFileMap(() => ({\n metro: new Server(config, {\n watch: false,\n }),\n }));\n\n return { server: metro, bundleRequest };\n}\n\nexport async function exportEmbedAssetsAsync(\n server: Server,\n bundleRequest: BundleOptions,\n projectRoot: string,\n options: Pick<Options, 'platform'>\n) {\n try {\n const { entryFile, onProgress, resolverOptions, transformOptions } = splitBundleOptions({\n ...bundleRequest,\n // @ts-ignore-error TODO(@kitten): Very unclear why this is here. Remove?\n bundleType: 'todo',\n });\n\n const dependencies = await server._bundler.getDependencies(\n // NOTE(@kitten): This isn't an `entryFile`, but instead a `mainModuleName`, that's been renamed\n // in `getMetroDirectBundleOptions`, where we've passed the already converted name\n [entryFile],\n transformOptions,\n resolverOptions,\n { onProgress, shallow: false, lazy: false }\n );\n\n const config = server._config;\n\n return getMetroAssets(dependencies, {\n processModuleFilter: config.serializer.processModuleFilter,\n assetPlugins: config.transformer.assetPlugins,\n platform: transformOptions.platform!,\n // Forked out of Metro because the `this._getServerRootDir()` doesn't match the development\n // behavior.\n projectRoot: config.projectRoot, // this._getServerRootDir(),\n publicPath: config.transformer.publicPath,\n isHosted: false,\n });\n } catch (error: any) {\n if (isError(error)) {\n // Log using Xcode error format so the errors are picked up by xcodebuild.\n // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script\n if (options.platform === 'ios') {\n // If the error is about to be presented in Xcode, strip the ansi characters from the message.\n if ('message' in error && isExecutingFromXcodebuild()) {\n error.message = stripAnsi(error.message) as string;\n }\n logMetroErrorInXcode(projectRoot, error);\n }\n }\n throw error;\n }\n}\n\nfunction isError(error: any): error is Error {\n return error instanceof Error;\n}\n"],"names":["createMetroServerAndBundleRequestAsync","exportEmbedAssetsAsync","exportEmbedAsync","exportEmbedBundleAndAssetsAsync","exportEmbedInternalAsync","debug","require","guessCopiedAppleBundlePath","bundleOutput","match","bundleName","path","basename","bundleParent","dirname","possiblePath","globSync","cwd","absolute","dot","projectRoot","options","env","CI","resetCache","setNodeEnv","dev","loadEnvFiles","eagerBundleOptions","__EXPO_EAGER_BUNDLE_OPTIONS","deserializeEagerKey","inputKey","getExportEmbedOptionsKey","key","removeAsync","copyAsync","assetsDest","console","log","warn","ensureProcessExitsAfterDelay","platform","previousPath","fs","existsSync","bundle","assets","files","mkdirSync","recursive","mode","domComponentProxyOutputDir","hasDomComponents","size","Promise","all","output","save","Log","persistMetroFilesAsync","copyPublicFolderAsync","resolve","EXPO_PUBLIC_FOLDER","join","DOM_COMPONENTS_BUNDLE_DIR","persistMetroAssetsAsync","outputDirectory","iosAssetCatalogDirectory","assetCatalogDest","devServerManager","DevServerManager","startMetroAsync","minify","port","isExporting","location","resetDevServer","maxWorkers","devServer","getDefaultDevServer","assert","MetroBundlerDevServer","exp","pkg","getConfig","skipSDKVersionRequirement","isHermes","isEnableHermesManaged","sourceMapUrl","sourcemapOutput","sourcemapUseAbsolutePath","Map","bundles","nativeExportBundleAsync","splitChunks","mainModuleName","convertEntryPointToRelative","entryFile","engine","undefined","serializerIncludeMaps","bytecode","reactCompiler","experiments","unstable_transformProfile","unstableTransformProfile","apiRoutesEnabled","isReactServerComponentsEnabled","web","skipServer","exportStandaloneServerAsync","expoDomComponentReferences","Set","artifacts","map","artifact","Array","isArray","metadata","flat","length","filePath","exportDomComponentAsync","includeSourceMaps","asset","httpServerLocation","code","filter","a","type","source","toString","error","isError","isExecutingFromXcodebuild","message","stripAnsi","logMetroErrorInXcode","stopAsync","config","loadMetroConfigAsync","getMetroBundler","metro","getBundler","directBundleOptions","getMetroDirectBundleOptionsForExpoConfig","hosted","bundleRequest","Server","DEFAULT_BUNDLE_OPTIONS","lazy","modulesOnly","runModule","replaceMetroFileMap","watch","server","onProgress","resolverOptions","transformOptions","splitBundleOptions","bundleType","dependencies","_bundler","getDependencies","shallow","_config","getMetroAssets","processModuleFilter","serializer","assetPlugins","transformer","publicPath","isHosted","Error"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;QA+SqBA;eAAAA;;QAgFAC;eAAAA;;QApUAC;eAAAA;;QAqGAC;eAAAA;;QAlDAC;eAAAA;;;;yBA7GI;;;;;;;yBACkB;;;;;;;gEACzB;;;;;;;gEACY;;;;;;;iEACP;;;;;;;gEAEG;;;;;;;gEACR;;;;;;;gEACJ;;;;;;;yBACkB;;;;;;;gEAChB;;;;;;gCAG6C;qCACE;qBAC5C;kCACa;uCACK;mCACF;kCACC;yCACK;8BACe;sBAC/B;qBACa;qBACnB;yBACqB;qCACD;8BACF;oCACE;8BACF;4BAEC;8BACK;sBACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE7C,MAAMC,QAAQC,QAAQ,SAAS;AAE/B,SAASC,2BAA2BC,YAAoB;IACtD,+CAA+C;IAC/C,IACE,CAACA,aAAaC,KAAK,CAAC,kDACpB,CAACD,aAAaC,KAAK,CAAC,0EACpB;QACAJ,MAAM,sCAAsCG;QAC5C,OAAO;IACT;IACA,MAAME,aAAaC,eAAI,CAACC,QAAQ,CAACJ;IACjC,MAAMK,eAAeF,eAAI,CAACG,OAAO,CAACN;IAClC,MAAMO,eAAeC,IAAAA,YAAQ,EAAC,CAAC,MAAM,EAAEN,YAAY,EAAE;QACnDO,KAAKJ;QACLK,UAAU;QACV,0CAA0C;QAC1CC,KAAK;IACP,EAAE,CAAC,EAAE;IACLd,MAAM,sCAAsCU;IAC5C,OAAOA;AACT;AAEO,eAAeb,iBAAiBkB,WAAmB,EAAEC,OAAgB;IAC1E,8GAA8G;IAC9G,oHAAoH;IACpH,IAAIC,QAAG,CAACC,EAAE,IAAIF,QAAQG,UAAU,EAAE;QAChCnB,MAAM;QACNgB,QAAQG,UAAU,GAAG;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AOO,QAAQ,CAACC,eAAe,CACxD,gGAAgG;QAChG,kFAAkF;QAClF;YAAClE;SAAU,EACX6D,kBACAD,iBACA;YAAED;YAAYQ,SAAS;YAAOd,MAAM;QAAM;QAG5C,MAAMX,SAASgB,OAAOU,OAAO;QAE7B,OAAOC,IAAAA,oBAAc,EAACL,cAAc;YAClCM,qBAAqB5B,OAAO6B,UAAU,CAACD,mBAAmB;YAC1DE,cAAc9B,OAAO+B,WAAW,CAACD,YAAY;YAC7ChI,UAAUqH,iBAAiBrH,QAAQ;YACnC,2FAA2F;YAC3F,YAAY;YACZrB,aAAauH,OAAOvH,WAAW;YAC/BuJ,YAAYhC,OAAO+B,WAAW,CAACC,UAAU;YACzCC,UAAU;QACZ;IACF,EAAE,OAAOxC,OAAY;QACnB,IAAIC,QAAQD,QAAQ;YAClB,0EAA0E;YAC1E,iIAAiI;YACjI,IAAI/G,QAAQoB,QAAQ,KAAK,OAAO;gBAC9B,8FAA8F;gBAC9F,IAAI,aAAa2F,SAASE,IAAAA,8CAAyB,KAAI;oBACrDF,MAAMG,OAAO,GAAGC,IAAAA,eAAS,EAACJ,MAAMG,OAAO;gBACzC;gBACAE,IAAAA,yCAAoB,EAACrH,aAAagH;YACpC;QACF;QACA,MAAMA;IACR;AACF;AAEA,SAASC,QAAQD,KAAU;IACzB,OAAOA,iBAAiByC;AAC1B"}
1
+ {"version":3,"sources":["../../../../src/export/embed/exportEmbedAsync.ts"],"sourcesContent":["/**\n * Copyright © 2023 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 { getConfig } from '@expo/config';\nimport { convertEntryPointToRelative } from '@expo/config/paths';\nimport Server from '@expo/metro/metro/Server';\nimport splitBundleOptions from '@expo/metro/metro/lib/splitBundleOptions';\nimport * as output from '@expo/metro/metro/shared/output/bundle';\nimport type { BundleOptions } from '@expo/metro/metro/shared/types';\nimport { patchTransformFileForPackedMaps } from '@expo/metro-config/build/serializer/packedMap';\nimport { patchMetroSourceMapStringForPackedMaps } from '@expo/metro-config/build/serializer/sourceMap';\nimport getMetroAssets from '@expo/metro-config/build/transform-worker/getAssets';\nimport assert from 'assert';\nimport fs from 'fs';\nimport { sync as globSync } from 'glob';\nimport path from 'path';\n\nimport type { Options } from './resolveOptions';\nimport { deserializeEagerKey, getExportEmbedOptionsKey } from './resolveOptions';\nimport { isExecutingFromXcodebuild, logMetroErrorInXcode } from './xcodeCompilerLogger';\nimport { Log } from '../../log';\nimport { DevServerManager } from '../../start/server/DevServerManager';\nimport { MetroBundlerDevServer } from '../../start/server/metro/MetroBundlerDevServer';\nimport { replaceMetroFileMap } from '../../start/server/metro/createFileMap-fork';\nimport { loadMetroConfigAsync } from '../../start/server/metro/instantiateMetro';\nimport { DOM_COMPONENTS_BUNDLE_DIR } from '../../start/server/middleware/DomComponentsMiddleware';\nimport { getMetroDirectBundleOptionsForExpoConfig } from '../../start/server/middleware/metroOptions';\nimport { stripAnsi } from '../../utils/ansi';\nimport { copyAsync, removeAsync } from '../../utils/dir';\nimport { env } from '../../utils/env';\nimport { setNodeEnv, loadEnvFiles } from '../../utils/nodeEnv';\nimport { exportDomComponentAsync } from '../exportDomComponents';\nimport { isEnableHermesManaged } from '../exportHermes';\nimport { persistMetroAssetsAsync } from '../persistMetroAssets';\nimport { copyPublicFolderAsync } from '../publicFolder';\nimport type { BundleAssetWithFileHashes, ExportAssetMap } from '../saveAssets';\nimport { persistMetroFilesAsync } from '../saveAssets';\nimport { exportStandaloneServerAsync } from './exportServer';\nimport { ensureProcessExitsAfterDelay } from '../../utils/exit';\n\nconst debug = require('debug')('expo:export:embed');\n\nfunction guessCopiedAppleBundlePath(bundleOutput: string) {\n // Ensure the path is familiar before guessing.\n if (\n !bundleOutput.match(/\\/Xcode\\/DerivedData\\/.*\\/Build\\/Products\\//) &&\n !bundleOutput.match(/\\/CoreSimulator\\/Devices\\/.*\\/data\\/Containers\\/Bundle\\/Application\\//)\n ) {\n debug('Bundling to non-standard location:', bundleOutput);\n return false;\n }\n const bundleName = path.basename(bundleOutput);\n const bundleParent = path.dirname(bundleOutput);\n const possiblePath = globSync(`*.app/${bundleName}`, {\n cwd: bundleParent,\n absolute: true,\n // bundle identifiers can start with dots.\n dot: true,\n })[0];\n debug('Possible path for previous bundle:', possiblePath);\n return possiblePath;\n}\n\nexport async function exportEmbedAsync(projectRoot: string, options: Options) {\n // The React Native build scripts always enable the cache reset but we shouldn't need this in CI environments.\n // By disabling it, we can eagerly bundle code before the build and reuse the cached artifacts in subsequent builds.\n if (env.CI && options.resetCache) {\n debug('CI environment detected, disabling automatic cache reset');\n options.resetCache = false;\n }\n\n setNodeEnv(options.dev ? 'development' : 'production');\n loadEnvFiles(projectRoot);\n\n // This is an optimized codepath that can occur during `npx expo run` and does not occur during builds from Xcode or Android Studio.\n // Here we reconcile a bundle pass that was run before the native build process. This order can fail faster and is show better errors since the logs won't be obscured by Xcode and Android Studio.\n // This path is also used for automatically deploying server bundles to a remote host.\n const eagerBundleOptions = env.__EXPO_EAGER_BUNDLE_OPTIONS\n ? deserializeEagerKey(env.__EXPO_EAGER_BUNDLE_OPTIONS)\n : null;\n if (eagerBundleOptions) {\n // Get the cache key for the current process to compare against the eager key.\n const inputKey = getExportEmbedOptionsKey(options);\n\n // If the app was bundled previously in the same process, then we should reuse the Metro cache.\n options.resetCache = false;\n\n if (eagerBundleOptions.key === inputKey) {\n // Copy the eager bundleOutput and assets to the new locations.\n await removeAsync(options.bundleOutput);\n\n copyAsync(eagerBundleOptions.options.bundleOutput, options.bundleOutput);\n\n if (eagerBundleOptions.options.assetsDest && options.assetsDest) {\n copyAsync(eagerBundleOptions.options.assetsDest, options.assetsDest);\n }\n\n console.log('info: Copied output to binary:', options.bundleOutput);\n return;\n }\n // TODO: sourcemapOutput is set on Android but not during eager. This is tolerable since it doesn't invalidate the Metro cache.\n console.log(' Eager key:', eagerBundleOptions.key);\n console.log('Request key:', inputKey);\n\n // TODO: We may want an analytic event here in the future to understand when this happens.\n console.warn('warning: Eager bundle does not match new options, bundling again.');\n }\n\n await exportEmbedInternalAsync(projectRoot, options);\n\n // Ensure the process closes after bundling\n ensureProcessExitsAfterDelay();\n}\n\nexport async function exportEmbedInternalAsync(projectRoot: string, options: Options) {\n // Ensure we delete the old bundle to trigger a failure if the bundle cannot be created.\n await removeAsync(options.bundleOutput);\n\n // The iOS bundle is copied in to the Xcode project, so we need to remove the old one\n // to prevent Xcode from loading the old one after a build failure.\n if (options.platform === 'ios') {\n const previousPath = guessCopiedAppleBundlePath(options.bundleOutput);\n if (previousPath && fs.existsSync(previousPath)) {\n debug('Removing previous iOS bundle:', previousPath);\n await removeAsync(previousPath);\n }\n }\n\n const { bundle, assets, files } = await exportEmbedBundleAndAssetsAsync(projectRoot, options);\n\n fs.mkdirSync(path.dirname(options.bundleOutput), { recursive: true, mode: 0o755 });\n\n // On Android, dom components proxy files should write to the assets directory instead of the res directory.\n // We use the bundleOutput directory to get the assets directory.\n const domComponentProxyOutputDir =\n options.platform === 'android' ? path.dirname(options.bundleOutput) : options.assetsDest;\n const hasDomComponents = domComponentProxyOutputDir && files.size > 0;\n\n // Persist bundle and source maps.\n await Promise.all([\n output.save(bundle, options, Log.log),\n\n // Write dom components proxy files.\n hasDomComponents ? persistMetroFilesAsync(files, domComponentProxyOutputDir) : null,\n // Copy public folder for dom components only if\n hasDomComponents\n ? copyPublicFolderAsync(\n path.resolve(projectRoot, env.EXPO_PUBLIC_FOLDER),\n path.join(domComponentProxyOutputDir, DOM_COMPONENTS_BUNDLE_DIR)\n )\n : null,\n\n // NOTE(EvanBacon): This may need to be adjusted in the future if want to support baseUrl on native\n // platforms when doing production embeds (unlikely).\n options.assetsDest\n ? persistMetroAssetsAsync(projectRoot, assets, {\n platform: options.platform,\n outputDirectory: options.assetsDest,\n iosAssetCatalogDirectory: options.assetCatalogDest,\n })\n : null,\n ]);\n}\n\nexport async function exportEmbedBundleAndAssetsAsync(\n projectRoot: string,\n options: Options\n): Promise<{\n bundle: Awaited<ReturnType<Server['build']>>;\n assets: readonly BundleAssetWithFileHashes[];\n files: ExportAssetMap;\n}> {\n const devServerManager = await DevServerManager.startMetroAsync(projectRoot, {\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n port: 8081,\n isExporting: true,\n location: {},\n resetDevServer: options.resetCache,\n maxWorkers: options.maxWorkers,\n });\n\n const devServer = devServerManager.getDefaultDevServer();\n assert(devServer instanceof MetroBundlerDevServer);\n\n const { exp, pkg } = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n const isHermes = isEnableHermesManaged(exp, options.platform);\n\n let sourceMapUrl = options.sourcemapOutput;\n if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {\n sourceMapUrl = path.basename(sourceMapUrl);\n }\n\n const files: ExportAssetMap = new Map();\n\n try {\n const bundles = await devServer.nativeExportBundleAsync(\n exp,\n {\n // TODO: Re-enable when we get bytecode chunk splitting working again.\n splitChunks: false, //devServer.isReactServerComponentsEnabled,\n mainModuleName: convertEntryPointToRelative(projectRoot, options.entryFile),\n platform: options.platform,\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n serializerIncludeMaps: !!sourceMapUrl,\n bytecode: options.bytecode ?? false,\n // source map inline\n reactCompiler: !!exp.experiments?.reactCompiler,\n },\n files,\n {\n sourceMapUrl,\n unstable_transformProfile: (options.unstableTransformProfile ||\n (isHermes ? 'hermes-stable' : 'default')) as BundleOptions['unstable_transformProfile'],\n }\n );\n\n // We optimistically build the server-side API routes code here, to ensure they're\n // valid or to enable parallel deployment in the future (TBD). This is disabled using\n // the explicit `--skip-server` flag.\n const apiRoutesEnabled =\n devServer.isReactServerComponentsEnabled || exp.web?.output === 'server';\n if (!options.skipServer && apiRoutesEnabled) {\n await exportStandaloneServerAsync(projectRoot, devServer, {\n exp,\n pkg,\n files,\n options,\n });\n }\n\n const expoDomComponentReferences = [\n ...new Set(\n bundles.artifacts\n .map((artifact) =>\n Array.isArray(artifact.metadata.expoDomComponentReferences)\n ? artifact.metadata.expoDomComponentReferences\n : []\n )\n .flat()\n ),\n ];\n if (expoDomComponentReferences.length > 0) {\n await Promise.all(\n // TODO: Make a version of this which uses `this.metro.getBundler().buildGraphForEntries([])` to bundle all the DOM components at once.\n expoDomComponentReferences.map(async (filePath) => {\n const { bundle } = await exportDomComponentAsync({\n filePath,\n projectRoot,\n dev: options.dev,\n devServer,\n isHermes,\n includeSourceMaps: !!sourceMapUrl,\n exp,\n files,\n });\n\n if (options.assetsDest) {\n // Save assets like a typical bundler, preserving the file paths on web.\n // This is saving web-style inside of a native app's binary.\n await persistMetroAssetsAsync(\n projectRoot,\n bundle.assets.map((asset) => ({\n ...asset,\n httpServerLocation: path.join(DOM_COMPONENTS_BUNDLE_DIR, asset.httpServerLocation),\n })),\n {\n files,\n platform: 'web',\n outputDirectory: options.assetsDest,\n }\n );\n }\n })\n );\n }\n\n return {\n files,\n bundle: {\n code: bundles.artifacts.filter((a: any) => a.type === 'js')[0]?.source!,\n // Can be optional when source maps aren't enabled.\n map: bundles.artifacts.filter((a: any) => a.type === 'map')[0]?.source.toString()!,\n },\n assets: bundles.assets,\n };\n } catch (error: any) {\n if (isError(error)) {\n // Log using Xcode error format so the errors are picked up by xcodebuild.\n // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script\n if (options.platform === 'ios') {\n // If the error is about to be presented in Xcode, strip the ansi characters from the message.\n if ('message' in error && isExecutingFromXcodebuild()) {\n error.message = stripAnsi(error.message) as string;\n }\n logMetroErrorInXcode(projectRoot, error);\n }\n }\n throw error;\n } finally {\n devServerManager.stopAsync();\n }\n}\n\n// Exports for expo-updates\nexport async function createMetroServerAndBundleRequestAsync(\n projectRoot: string,\n options: Pick<\n Options,\n | 'maxWorkers'\n | 'config'\n | 'platform'\n | 'sourcemapOutput'\n | 'sourcemapUseAbsolutePath'\n | 'entryFile'\n | 'minify'\n | 'dev'\n | 'resetCache'\n | 'unstableTransformProfile'\n >\n): Promise<{ server: Server; bundleRequest: BundleOptions }> {\n const exp = getConfig(projectRoot, { skipSDKVersionRequirement: true }).exp;\n\n // TODO: This is slow ~40ms\n const { config } = await loadMetroConfigAsync(\n projectRoot,\n {\n // TODO: This is always enabled in the native script and there's no way to disable it.\n resetCache: options.resetCache,\n maxWorkers: options.maxWorkers,\n },\n {\n exp,\n isExporting: true,\n getMetroBundler() {\n return metro.getBundler().getBundler();\n },\n }\n );\n\n const isHermes = isEnableHermesManaged(exp, options.platform);\n\n let sourceMapUrl = options.sourcemapOutput;\n if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {\n sourceMapUrl = path.basename(sourceMapUrl);\n }\n\n const directBundleOptions = getMetroDirectBundleOptionsForExpoConfig(projectRoot, exp, {\n splitChunks: false,\n // TODO(@kitten): This currently has to match a filename exactly\n mainModuleName: convertEntryPointToRelative(projectRoot, options.entryFile, null),\n platform: options.platform,\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n isExporting: true,\n // Never output bytecode in the exported bundle since that is hardcoded in the native run script.\n bytecode: false,\n hosted: false,\n });\n\n // TODO(cedric): check if we can use the proper `bundleType=bundle` and `entryPoint=mainModuleName` properties\n const bundleRequest: BundleOptions = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n ...directBundleOptions,\n\n // NOTE(@kitten): Cast non-optional defaults\n lazy: directBundleOptions.lazy ?? Server.DEFAULT_BUNDLE_OPTIONS.lazy,\n modulesOnly: directBundleOptions.modulesOnly ?? Server.DEFAULT_BUNDLE_OPTIONS.modulesOnly,\n runModule: directBundleOptions.runModule ?? Server.DEFAULT_BUNDLE_OPTIONS.runModule,\n\n sourceMapUrl,\n unstable_transformProfile: (options.unstableTransformProfile ||\n (isHermes ? 'hermes-stable' : 'default')) as BundleOptions['unstable_transformProfile'],\n };\n\n const { metro } = await replaceMetroFileMap(() => ({\n metro: new Server(config, {\n watch: false,\n }),\n }));\n\n // The dev server applies the same patch from `instantiateMetro.ts`;\n // this is the export-embed / `expo-updates` path, where `data.map`\n // would otherwise reach Metro's readers in the unwrapped wire shape.\n patchTransformFileForPackedMaps(metro.getBundler().getBundler());\n patchMetroSourceMapStringForPackedMaps();\n\n return { server: metro, bundleRequest };\n}\n\nexport async function exportEmbedAssetsAsync(\n server: Server,\n bundleRequest: BundleOptions,\n projectRoot: string,\n options: Pick<Options, 'platform'>\n) {\n try {\n const { entryFile, onProgress, resolverOptions, transformOptions } = splitBundleOptions({\n ...bundleRequest,\n // @ts-ignore-error TODO(@kitten): Very unclear why this is here. Remove?\n bundleType: 'todo',\n });\n\n const dependencies = await server._bundler.getDependencies(\n // NOTE(@kitten): This isn't an `entryFile`, but instead a `mainModuleName`, that's been renamed\n // in `getMetroDirectBundleOptions`, where we've passed the already converted name\n [entryFile],\n transformOptions,\n resolverOptions,\n { onProgress, shallow: false, lazy: false }\n );\n\n const config = server._config;\n\n return getMetroAssets(dependencies, {\n processModuleFilter: config.serializer.processModuleFilter,\n assetPlugins: config.transformer.assetPlugins,\n platform: transformOptions.platform!,\n // Forked out of Metro because the `this._getServerRootDir()` doesn't match the development\n // behavior.\n projectRoot: config.projectRoot, // this._getServerRootDir(),\n publicPath: config.transformer.publicPath,\n isHosted: false,\n });\n } catch (error: any) {\n if (isError(error)) {\n // Log using Xcode error format so the errors are picked up by xcodebuild.\n // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script\n if (options.platform === 'ios') {\n // If the error is about to be presented in Xcode, strip the ansi characters from the message.\n if ('message' in error && isExecutingFromXcodebuild()) {\n error.message = stripAnsi(error.message) as string;\n }\n logMetroErrorInXcode(projectRoot, error);\n }\n }\n throw error;\n }\n}\n\nfunction isError(error: any): error is Error {\n return error instanceof Error;\n}\n"],"names":["createMetroServerAndBundleRequestAsync","exportEmbedAssetsAsync","exportEmbedAsync","exportEmbedBundleAndAssetsAsync","exportEmbedInternalAsync","debug","require","guessCopiedAppleBundlePath","bundleOutput","match","bundleName","path","basename","bundleParent","dirname","possiblePath","globSync","cwd","absolute","dot","projectRoot","options","env","CI","resetCache","setNodeEnv","dev","loadEnvFiles","eagerBundleOptions","__EXPO_EAGER_BUNDLE_OPTIONS","deserializeEagerKey","inputKey","getExportEmbedOptionsKey","key","removeAsync","copyAsync","assetsDest","console","log","warn","ensureProcessExitsAfterDelay","platform","previousPath","fs","existsSync","bundle","assets","files","mkdirSync","recursive","mode","domComponentProxyOutputDir","hasDomComponents","size","Promise","all","output","save","Log","persistMetroFilesAsync","copyPublicFolderAsync","resolve","EXPO_PUBLIC_FOLDER","join","DOM_COMPONENTS_BUNDLE_DIR","persistMetroAssetsAsync","outputDirectory","iosAssetCatalogDirectory","assetCatalogDest","devServerManager","DevServerManager","startMetroAsync","minify","port","isExporting","location","resetDevServer","maxWorkers","devServer","getDefaultDevServer","assert","MetroBundlerDevServer","exp","pkg","getConfig","skipSDKVersionRequirement","isHermes","isEnableHermesManaged","sourceMapUrl","sourcemapOutput","sourcemapUseAbsolutePath","Map","bundles","nativeExportBundleAsync","splitChunks","mainModuleName","convertEntryPointToRelative","entryFile","engine","undefined","serializerIncludeMaps","bytecode","reactCompiler","experiments","unstable_transformProfile","unstableTransformProfile","apiRoutesEnabled","isReactServerComponentsEnabled","web","skipServer","exportStandaloneServerAsync","expoDomComponentReferences","Set","artifacts","map","artifact","Array","isArray","metadata","flat","length","filePath","exportDomComponentAsync","includeSourceMaps","asset","httpServerLocation","code","filter","a","type","source","toString","error","isError","isExecutingFromXcodebuild","message","stripAnsi","logMetroErrorInXcode","stopAsync","config","loadMetroConfigAsync","getMetroBundler","metro","getBundler","directBundleOptions","getMetroDirectBundleOptionsForExpoConfig","hosted","bundleRequest","Server","DEFAULT_BUNDLE_OPTIONS","lazy","modulesOnly","runModule","replaceMetroFileMap","watch","patchTransformFileForPackedMaps","patchMetroSourceMapStringForPackedMaps","server","onProgress","resolverOptions","transformOptions","splitBundleOptions","bundleType","dependencies","_bundler","getDependencies","shallow","_config","getMetroAssets","processModuleFilter","serializer","assetPlugins","transformer","publicPath","isHosted","Error"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;QAiTqBA;eAAAA;;QAsFAC;eAAAA;;QA1UAC;eAAAA;;QAqGAC;eAAAA;;QAlDAC;eAAAA;;;;yBA/GI;;;;;;;yBACkB;;;;;;;gEACzB;;;;;;;gEACY;;;;;;;iEACP;;;;;;;yBAEwB;;;;;;;yBACO;;;;;;;gEAC5B;;;;;;;gEACR;;;;;;;gEACJ;;;;;;;yBACkB;;;;;;;gEAChB;;;;;;gCAG6C;qCACE;qBAC5C;kCACa;uCACK;mCACF;kCACC;yCACK;8BACe;sBAC/B;qBACa;qBACnB;yBACqB;qCACD;8BACF;oCACE;8BACF;4BAEC;8BACK;sBACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE7C,MAAMC,QAAQC,QAAQ,SAAS;AAE/B,SAASC,2BAA2BC,YAAoB;IACtD,+CAA+C;IAC/C,IACE,CAACA,aAAaC,KAAK,CAAC,kDACpB,CAACD,aAAaC,KAAK,CAAC,0EACpB;QACAJ,MAAM,sCAAsCG;QAC5C,OAAO;IACT;IACA,MAAME,aAAaC,eAAI,CAACC,QAAQ,CAACJ;IACjC,MAAMK,eAAeF,eAAI,CAACG,OAAO,CAACN;IAClC,MAAMO,eAAeC,IAAAA,YAAQ,EAAC,CAAC,MAAM,EAAEN,YAAY,EAAE;QACnDO,KAAKJ;QACLK,UAAU;QACV,0CAA0C;QAC1CC,KAAK;IACP,EAAE,CAAC,EAAE;IACLd,MAAM,sCAAsCU;IAC5C,OAAOA;AACT;AAEO,eAAeb,iBAAiBkB,WAAmB,EAAEC,OAAgB;IAC1E,8GAA8G;IAC9G,oHAAoH;IACpH,IAAIC,QAAG,CAACC,EAAE,IAAIF,QAAQG,UAAU,EAAE;QAChCnB,MAAM;QACNgB,QAAQG,UAAU,GAAG;IACvB;IAEAC,IAAAA,mBAAU,EAACJ,QAAQK,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YACtF,GAAGd,aAAa;YAChB,yEAAyE;YACzEe,YAAY;QACd;QAEA,MAAMC,eAAe,MAAMN,OAAOO,QAAQ,CAACC,eAAe,CACxD,gGAAgG;QAChG,kFAAkF;QAClF;YAACpE;SAAU,EACX+D,kBACAD,iBACA;YAAED;YAAYQ,SAAS;YAAOhB,MAAM;QAAM;QAG5C,MAAMX,SAASkB,OAAOU,OAAO;QAE7B,OAAOC,IAAAA,oBAAc,EAACL,cAAc;YAClCM,qBAAqB9B,OAAO+B,UAAU,CAACD,mBAAmB;YAC1DE,cAAchC,OAAOiC,WAAW,CAACD,YAAY;YAC7ClI,UAAUuH,iBAAiBvH,QAAQ;YACnC,2FAA2F;YAC3F,YAAY;YACZrB,aAAauH,OAAOvH,WAAW;YAC/ByJ,YAAYlC,OAAOiC,WAAW,CAACC,UAAU;YACzCC,UAAU;QACZ;IACF,EAAE,OAAO1C,OAAY;QACnB,IAAIC,QAAQD,QAAQ;YAClB,0EAA0E;YAC1E,iIAAiI;YACjI,IAAI/G,QAAQoB,QAAQ,KAAK,OAAO;gBAC9B,8FAA8F;gBAC9F,IAAI,aAAa2F,SAASE,IAAAA,8CAAyB,KAAI;oBACrDF,MAAMG,OAAO,GAAGC,IAAAA,eAAS,EAACJ,MAAMG,OAAO;gBACzC;gBACAE,IAAAA,yCAAoB,EAACrH,aAAagH;YACpC;QACF;QACA,MAAMA;IACR;AACF;AAEA,SAASC,QAAQD,KAAU;IACzB,OAAOA,iBAAiB2C;AAC1B"}
package/build/src/log.js CHANGED
@@ -52,6 +52,9 @@ function _interop_require_default(obj) {
52
52
  default: obj
53
53
  };
54
54
  }
55
+ // NOTE(@kitten): LogRespectingTerminal in instantiateMetro regressed on fatal errors and
56
+ // logs may be swallowed before exiting. We redirect them to a direct write when we're about to exit
57
+ let isExiting = false;
55
58
  function time(label) {
56
59
  console.time(label);
57
60
  }
@@ -59,6 +62,14 @@ function timeEnd(label) {
59
62
  console.timeEnd(label);
60
63
  }
61
64
  function error(...message) {
65
+ if (isExiting) {
66
+ // `console.error` may be patched to route through an async stderr queue
67
+ // (see LogRespectingTerminal in instantiateMetro.ts). On the exit path
68
+ // that queue has no chance to drain before `process.exit`, so write
69
+ // synchronously to bypass it.
70
+ process.stderr.write(message.join(' ') + '\n');
71
+ return;
72
+ }
62
73
  console.error(...message);
63
74
  }
64
75
  function exception(e) {
@@ -66,9 +77,17 @@ function exception(e) {
66
77
  error(_chalk().default.red(e.toString()) + (env.EXPO_DEBUG ? '\n' + _chalk().default.gray(e.stack) : ''));
67
78
  }
68
79
  function warn(...message) {
80
+ if (isExiting) {
81
+ process.stderr.write(message.map((value)=>_chalk().default.yellow(value)).join(' ') + '\n');
82
+ return;
83
+ }
69
84
  console.warn(...message.map((value)=>_chalk().default.yellow(value)));
70
85
  }
71
86
  function log(...message) {
87
+ if (isExiting) {
88
+ process.stdout.write(message.join(' ') + '\n');
89
+ return;
90
+ }
72
91
  console.log(...message);
73
92
  }
74
93
  function debug(...message) {
@@ -78,11 +97,10 @@ function clear() {
78
97
  process.stdout.write(process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H');
79
98
  }
80
99
  function exit(message, code = 1) {
100
+ isExiting = true;
81
101
  if (message instanceof Error) {
82
102
  exception(message);
83
- process.exit(code);
84
- }
85
- if (message) {
103
+ } else if (message) {
86
104
  if (code === 0) {
87
105
  log(message);
88
106
  } else {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/log.ts"],"sourcesContent":["import chalk from 'chalk';\n\nexport function time(label?: string): void {\n console.time(label);\n}\n\nexport function timeEnd(label?: string): void {\n console.timeEnd(label);\n}\n\nexport function error(...message: string[]): void {\n console.error(...message);\n}\n\n/** Print an error and provide additional info (the stack trace) in debug mode. */\nexport function exception(e: Error): void {\n const { env } = require('./utils/env');\n error(chalk.red(e.toString()) + (env.EXPO_DEBUG ? '\\n' + chalk.gray(e.stack) : ''));\n}\n\nexport function warn(...message: string[]): void {\n console.warn(...message.map((value) => chalk.yellow(value)));\n}\n\nexport function log(...message: string[]): void {\n console.log(...message);\n}\n\n/** @deprecated use `debug` package with the `expo:` prefix instead. */\nexport function debug(...message: any[]): void {\n if (require('./utils/env').env.EXPO_DEBUG) console.log(...message);\n}\n\n/** Clear the terminal of all text. */\nexport function clear(): void {\n process.stdout.write(process.platform === 'win32' ? '\\x1B[2J\\x1B[0f' : '\\x1B[2J\\x1B[3J\\x1B[H');\n}\n\n/** Log a message and exit the current process. If the `code` is non-zero then `console.error` will be used instead of `console.log`. */\nexport function exit(message: string | Error, code: number = 1): never {\n if (message instanceof Error) {\n exception(message);\n process.exit(code);\n }\n\n if (message) {\n if (code === 0) {\n log(message);\n } else {\n error(message);\n }\n }\n\n process.exit(code);\n}\n\n// The re-export makes auto importing easier.\nexport const Log = {\n time,\n timeEnd,\n error,\n exception,\n warn,\n log,\n debug,\n clear,\n exit,\n};\n"],"names":["Log","clear","debug","error","exception","exit","log","time","timeEnd","warn","label","console","message","e","env","require","chalk","red","toString","EXPO_DEBUG","gray","stack","map","value","yellow","process","stdout","write","platform","code","Error"],"mappings":";;;;;;;;;;;QAyDaA;eAAAA;;QAvBGC;eAAAA;;QALAC;eAAAA;;QAnBAC;eAAAA;;QAKAC;eAAAA;;QAwBAC;eAAAA;;QAfAC;eAAAA;;QAtBAC;eAAAA;;QAIAC;eAAAA;;QAcAC;eAAAA;;;;gEApBE;;;;;;;;;;;AAEX,SAASF,KAAKG,KAAc;IACjCC,QAAQJ,IAAI,CAACG;AACf;AAEO,SAASF,QAAQE,KAAc;IACpCC,QAAQH,OAAO,CAACE;AAClB;AAEO,SAASP,MAAM,GAAGS,OAAiB;IACxCD,QAAQR,KAAK,IAAIS;AACnB;AAGO,SAASR,UAAUS,CAAQ;IAChC,MAAM,EAAEC,GAAG,EAAE,GAAGC,QAAQ;IACxBZ,MAAMa,gBAAK,CAACC,GAAG,CAACJ,EAAEK,QAAQ,MAAOJ,CAAAA,IAAIK,UAAU,GAAG,OAAOH,gBAAK,CAACI,IAAI,CAACP,EAAEQ,KAAK,IAAI,EAAC;AAClF;AAEO,SAASZ,KAAK,GAAGG,OAAiB;IACvCD,QAAQF,IAAI,IAAIG,QAAQU,GAAG,CAAC,CAACC,QAAUP,gBAAK,CAACQ,MAAM,CAACD;AACtD;AAEO,SAASjB,IAAI,GAAGM,OAAiB;IACtCD,QAAQL,GAAG,IAAIM;AACjB;AAGO,SAASV,MAAM,GAAGU,OAAc;IACrC,IAAIG,QAAQ,eAAeD,GAAG,CAACK,UAAU,EAAER,QAAQL,GAAG,IAAIM;AAC5D;AAGO,SAASX;IACdwB,QAAQC,MAAM,CAACC,KAAK,CAACF,QAAQG,QAAQ,KAAK,UAAU,mBAAmB;AACzE;AAGO,SAASvB,KAAKO,OAAuB,EAAEiB,OAAe,CAAC;IAC5D,IAAIjB,mBAAmBkB,OAAO;QAC5B1B,UAAUQ;QACVa,QAAQpB,IAAI,CAACwB;IACf;IAEA,IAAIjB,SAAS;QACX,IAAIiB,SAAS,GAAG;YACdvB,IAAIM;QACN,OAAO;YACLT,MAAMS;QACR;IACF;IAEAa,QAAQpB,IAAI,CAACwB;AACf;AAGO,MAAM7B,MAAM;IACjBO;IACAC;IACAL;IACAC;IACAK;IACAH;IACAJ;IACAD;IACAI;AACF"}
1
+ {"version":3,"sources":["../../src/log.ts"],"sourcesContent":["import chalk from 'chalk';\n\n// NOTE(@kitten): LogRespectingTerminal in instantiateMetro regressed on fatal errors and\n// logs may be swallowed before exiting. We redirect them to a direct write when we're about to exit\nlet isExiting = false;\n\nexport function time(label?: string): void {\n console.time(label);\n}\n\nexport function timeEnd(label?: string): void {\n console.timeEnd(label);\n}\n\nexport function error(...message: string[]): void {\n if (isExiting) {\n // `console.error` may be patched to route through an async stderr queue\n // (see LogRespectingTerminal in instantiateMetro.ts). On the exit path\n // that queue has no chance to drain before `process.exit`, so write\n // synchronously to bypass it.\n process.stderr.write(message.join(' ') + '\\n');\n return;\n }\n console.error(...message);\n}\n\n/** Print an error and provide additional info (the stack trace) in debug mode. */\nexport function exception(e: Error): void {\n const { env } = require('./utils/env');\n error(chalk.red(e.toString()) + (env.EXPO_DEBUG ? '\\n' + chalk.gray(e.stack) : ''));\n}\n\nexport function warn(...message: string[]): void {\n if (isExiting) {\n process.stderr.write(message.map((value) => chalk.yellow(value)).join(' ') + '\\n');\n return;\n }\n console.warn(...message.map((value) => chalk.yellow(value)));\n}\n\nexport function log(...message: string[]): void {\n if (isExiting) {\n process.stdout.write(message.join(' ') + '\\n');\n return;\n }\n console.log(...message);\n}\n\n/** @deprecated use `debug` package with the `expo:` prefix instead. */\nexport function debug(...message: any[]): void {\n if (require('./utils/env').env.EXPO_DEBUG) console.log(...message);\n}\n\n/** Clear the terminal of all text. */\nexport function clear(): void {\n process.stdout.write(process.platform === 'win32' ? '\\x1B[2J\\x1B[0f' : '\\x1B[2J\\x1B[3J\\x1B[H');\n}\n\n/** Log a message and exit the current process. If the `code` is non-zero then `console.error` will be used instead of `console.log`. */\nexport function exit(message: string | Error, code: number = 1): never {\n isExiting = true;\n if (message instanceof Error) {\n exception(message);\n } else if (message) {\n if (code === 0) {\n log(message);\n } else {\n error(message);\n }\n }\n process.exit(code);\n}\n\n// The re-export makes auto importing easier.\nexport const Log = {\n time,\n timeEnd,\n error,\n exception,\n warn,\n log,\n debug,\n clear,\n exit,\n};\n"],"names":["Log","clear","debug","error","exception","exit","log","time","timeEnd","warn","isExiting","label","console","message","process","stderr","write","join","e","env","require","chalk","red","toString","EXPO_DEBUG","gray","stack","map","value","yellow","stdout","platform","code","Error"],"mappings":";;;;;;;;;;;QA0EaA;eAAAA;;QApBGC;eAAAA;;QALAC;eAAAA;;QAnCAC;eAAAA;;QAaAC;eAAAA;;QAgCAC;eAAAA;;QAnBAC;eAAAA;;QAlCAC;eAAAA;;QAIAC;eAAAA;;QAsBAC;eAAAA;;;;gEAhCE;;;;;;;;;;;AAElB,yFAAyF;AACzF,oGAAoG;AACpG,IAAIC,YAAY;AAET,SAASH,K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Ae,CAAC;IAC5DtB,YAAY;IACZ,IAAIG,mBAAmBoB,OAAO;QAC5B7B,UAAUS;IACZ,OAAO,IAAIA,SAAS;QAClB,IAAImB,SAAS,GAAG;YACd1B,IAAIO;QACN,OAAO;YACLV,MAAMU;QACR;IACF;IACAC,QAAQT,IAAI,CAAC2B;AACf;AAGO,MAAMhC,MAAM;IACjBO;IACAC;IACAL;IACAC;IACAK;IACAH;IACAJ;IACAD;IACAI;AACF"}
@@ -152,7 +152,7 @@ async function resolvePortsAsync(projectRoot, options, settings) {
152
152
  // Default web port
153
153
  fallbackPort: 19006
154
154
  });
155
- if (!webpackPort) {
155
+ if (webpackPort == null) {
156
156
  throw new _errors.AbortCommandError();
157
157
  }
158
158
  multiBundlerSettings.webpackPort = webpackPort;
@@ -162,7 +162,7 @@ async function resolvePortsAsync(projectRoot, options, settings) {
162
162
  defaultPort: options.port,
163
163
  fallbackPort
164
164
  });
165
- if (!metroPort) {
165
+ if (metroPort == null) {
166
166
  throw new _errors.AbortCommandError();
167
167
  }
168
168
  multiBundlerSettings.metroPort = metroPort;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/start/resolveOptions.ts"],"sourcesContent":["import assert from 'assert';\nimport chalk from 'chalk';\n\nimport { canResolveDevClient, hasDirectDevClientDependency } from './detectDevClient';\nimport { Log } from '../log';\nimport { envIsWebcontainer } from '../utils/env';\nimport { AbortCommandError, CommandError } from '../utils/errors';\nimport { resolvePortAsync } from '../utils/port';\n\nexport type Options = {\n privateKeyPath: string | null;\n android: boolean;\n web: boolean;\n ios: boolean;\n offline: boolean;\n clear: boolean;\n dev: boolean;\n https: boolean;\n maxWorkers: number;\n port: number;\n /** Should instruct the bundler to create minified bundles. */\n minify: boolean;\n devClient: boolean;\n scheme: string | null;\n host: 'localhost' | 'lan' | 'tunnel';\n};\n\nexport async function resolveOptionsAsync(projectRoot: string, args: any): Promise<Options> {\n if (args['--dev-client'] && args['--go']) {\n throw new CommandError('BAD_ARGS', 'Cannot use both --dev-client and --go together.');\n }\n const host = resolveHostType({\n host: args['--host'],\n offline: args['--offline'],\n lan: args['--lan'],\n localhost: args['--localhost'],\n tunnel: args['--tunnel'],\n });\n\n if (args['--https']) {\n Log.warn(chalk`{bold --https} option is deprecated in favor of {bold --tunnel}`);\n }\n\n // User can force the default target by passing either `--dev-client` or `--go`. They can also\n // swap between them during development by pressing `s`.\n const isUserDefinedDevClient =\n !!args['--dev-client'] || (args['--go'] == null ? false : !args['--go']);\n\n // If the user didn't specify `--dev-client` or `--go` we check if they have the dev client package\n // in their package.json.\n const isAutoDevClient =\n args['--dev-client'] == null &&\n args['--go'] == null &&\n hasDirectDevClientDependency(projectRoot);\n\n const isDevClient = isAutoDevClient || isUserDefinedDevClient;\n\n const scheme = await resolveSchemeAsync(projectRoot, {\n scheme: args['--scheme'],\n devClient: isDevClient,\n });\n\n return {\n privateKeyPath: args['--private-key-path'] ?? null,\n\n android: !!args['--android'],\n web: !!args['--web'],\n ios: !!args['--ios'],\n offline: !!args['--offline'],\n\n clear: !!args['--clear'],\n dev: !args['--no-dev'],\n https: !!args['--https'],\n maxWorkers: args['--max-workers'],\n port: args['--port'],\n minify: !!args['--minify'],\n\n devClient: isDevClient,\n\n scheme,\n host,\n };\n}\n\nexport async function resolveSchemeAsync(\n projectRoot: string,\n options: { scheme?: string; devClient?: boolean }\n): Promise<string | null> {\n if (typeof options.scheme === 'string') {\n // Use the custom scheme\n return options.scheme ?? null;\n }\n\n if (options.devClient || canResolveDevClient(projectRoot)) {\n const { getOptionalDevClientSchemeAsync } =\n require('../utils/scheme') as typeof import('../utils/scheme');\n // Attempt to find the scheme or warn the user how to setup a custom scheme\n const resolvedScheme = await getOptionalDevClientSchemeAsync(projectRoot);\n if (!resolvedScheme.scheme) {\n if (resolvedScheme.resolution === 'shared') {\n // This can happen if one of the native projects has no URI schemes defined in it.\n // Normally, this should never happen.\n Log.warn(\n chalk`Could not find a shared URI scheme for the dev client between the local {bold /ios} and {bold /android} directories. App launches (QR code, interstitial, terminal keys) may not work as expected. You can configure a custom scheme using the {bold --scheme} option, or by running {bold npx expo prebuild} to regenerate the native directories with URI schemes.`\n );\n } else if (['ios', 'android'].includes(resolvedScheme.resolution)) {\n Log.warn(\n chalk`The {bold /${resolvedScheme.resolution}} project does not contain any URI schemes. Expo CLI will not be able to use links to launch the project. You can configure a custom URI scheme using the {bold --scheme} option.`\n );\n }\n }\n return resolvedScheme.scheme;\n } else {\n // Ensure this is reset when users don't use `--scheme`, `--dev-client` and don't have the `expo-dev-client` package installed.\n return null;\n }\n}\n\n/** Resolve and assert host type options. */\nexport function resolveHostType(options: {\n host?: string;\n offline?: boolean;\n lan?: boolean;\n localhost?: boolean;\n tunnel?: boolean;\n}): 'lan' | 'tunnel' | 'localhost' {\n if (\n [options.offline, options.host, options.lan, options.localhost, options.tunnel].filter((i) => i)\n .length > 1\n ) {\n throw new CommandError(\n 'BAD_ARGS',\n 'Specify at most one of: --offline, --host, --tunnel, --lan, --localhost'\n );\n }\n\n if (options.offline) {\n // Force `lan` in offline mode.\n return 'lan';\n } else if (options.host) {\n assert.match(options.host, /^(lan|tunnel|localhost)$/);\n return options.host as 'lan' | 'tunnel' | 'localhost';\n } else if (options.tunnel) {\n return 'tunnel';\n } else if (options.lan) {\n return 'lan';\n } else if (options.localhost) {\n return 'localhost';\n }\n\n // If no option is provided, and we are running in Stackblitz, enable tunnel by default\n if (envIsWebcontainer()) {\n return 'tunnel';\n }\n\n return 'lan';\n}\n\n/** Resolve the port options for all supported bundlers. */\nexport async function resolvePortsAsync(\n projectRoot: string,\n options: Partial<Pick<Options, 'port' | 'devClient'>>,\n settings: { webOnly?: boolean }\n) {\n const multiBundlerSettings: { webpackPort?: number; metroPort?: number } = {};\n\n if (settings.webOnly) {\n const webpackPort = await resolvePortAsync(projectRoot, {\n defaultPort: options.port,\n // Default web port\n fallbackPort: 19006,\n });\n if (!webpackPort) {\n throw new AbortCommandError();\n }\n multiBundlerSettings.webpackPort = webpackPort;\n } else {\n const fallbackPort = process.env.RCT_METRO_PORT\n ? parseInt(process.env.RCT_METRO_PORT, 10)\n : 8081;\n const metroPort = await resolvePortAsync(projectRoot, {\n defaultPort: options.port,\n fallbackPort,\n });\n if (!metroPort) {\n throw new AbortCommandError();\n }\n multiBundlerSettings.metroPort = metroPort;\n }\n\n return multiBundlerSettings;\n}\n"],"names":["resolveHostType","resolveOptionsAsync","resolvePortsAsync","resolveSchemeAsync","projectRoot","args","CommandError","host","offline","lan","localhost","tunnel","Log","warn","chalk","isUserDefinedDevClient","isAutoDevClient","hasDirectDevClientDependency","isDevClient","scheme","devClient","privateKeyPath","android","web","ios","clear","dev","https","maxWorkers","port","minify","options","canResolveDevClient","getOptionalDevClientSchemeAsync","require","resolvedScheme","resolution","includes","filter","i","length","assert","match","envIsWebcontainer","settings","multiBundlerSettings","webOnly","webpackPort","resolvePortAsync","defaultPort","fallbackPort","AbortCommandError","process","env","RCT_METRO_PORT","parseInt","metroPort"],"mappings":";;;;;;;;;;;QAuHgBA;eAAAA;;QA5FMC;eAAAA;;QAoIAC;eAAAA;;QA3EAC;eAAAA;;;;gEApFH;;;;;;;gEACD;;;;;;iCAEgD;qBAC9C;qBACc;wBACc;sBACf;;;;;;AAoB1B,eAAeF,oBAAoBG,WAAmB,EAAEC,IAAS;IACtE,IAAIA,IAAI,CAAC,eAAe,IAAIA,IAAI,CAAC,OAAO,EAAE;QACxC,MAAM,IAAIC,oBAAY,CAAC,YAAY;IACrC;IACA,MAAMC,OAAOP,gBAAgB;QAC3BO,MAAMF,IAAI,CAAC,SAAS;QACpBG,SAASH,IAAI,CAAC,YAAY;QAC1BI,KAAKJ,IAAI,CAAC,QAAQ;QAClBK,WAAWL,IAAI,CAAC,cAAc;QAC9BM,QAAQN,IAAI,CAAC,WAAW;IAC1B;IAEA,IAAIA,IAAI,CAAC,UAAU,EAAE;QACnBO,QAAG,CAACC,IAAI,CAACC,IAAAA,gBAAK,CAAA,CAAC,+DAA+D,CAAC;IACjF;IAEA,8FAA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rDa,QAA+B;IAE/B,MAAMC,uBAAqE,CAAC;IAE5E,IAAID,SAASE,OAAO,EAAE;QACpB,MAAMC,cAAc,MAAMC,IAAAA,sBAAgB,EAAC5C,aAAa;YACtD6C,aAAalB,QAAQF,IAAI;YACzB,mBAAmB;YACnBqB,cAAc;QAChB;QACA,IAAI,CAACH,aAAa;YAChB,MAAM,IAAII,yBAAiB;QAC7B;QACAN,qBAAqBE,WAAW,GAAGA;IACrC,OAAO;QACL,MAAMG,eAAeE,QAAQC,GAAG,CAACC,cAAc,GAC3CC,SAASH,QAAQC,GAAG,CAACC,cAAc,EAAE,MACrC;QACJ,MAAME,YAAY,MAAMR,IAAAA,sBAAgB,EAAC5C,aAAa;YACpD6C,aAAalB,QAAQF,IAAI;YACzBqB;QACF;QACA,IAAI,CAACM,WAAW;YACd,MAAM,IAAIL,yBAAiB;QAC7B;QACAN,qBAAqBW,SAAS,GAAGA;IACnC;IAEA,OAAOX;AACT"}
1
+ {"version":3,"sources":["../../../src/start/resolveOptions.ts"],"sourcesContent":["import assert from 'assert';\nimport chalk from 'chalk';\n\nimport { canResolveDevClient, hasDirectDevClientDependency } from './detectDevClient';\nimport { Log } from '../log';\nimport { envIsWebcontainer } from '../utils/env';\nimport { AbortCommandError, CommandError } from '../utils/errors';\nimport { resolvePortAsync } from '../utils/port';\n\nexport type Options = {\n privateKeyPath: string | null;\n android: boolean;\n web: boolean;\n ios: boolean;\n offline: boolean;\n clear: boolean;\n dev: boolean;\n https: boolean;\n maxWorkers: number;\n port: number;\n /** Should instruct the bundler to create minified bundles. */\n minify: boolean;\n devClient: boolean;\n scheme: string | null;\n host: 'localhost' | 'lan' | 'tunnel';\n};\n\nexport async function resolveOptionsAsync(projectRoot: string, args: any): Promise<Options> {\n if (args['--dev-client'] && args['--go']) {\n throw new CommandError('BAD_ARGS', 'Cannot use both --dev-client and --go together.');\n }\n const host = resolveHostType({\n host: args['--host'],\n offline: args['--offline'],\n lan: args['--lan'],\n localhost: args['--localhost'],\n tunnel: args['--tunnel'],\n });\n\n if (args['--https']) {\n Log.warn(chalk`{bold --https} option is deprecated in favor of {bold --tunnel}`);\n }\n\n // User can force the default target by passing either `--dev-client` or `--go`. They can also\n // swap between them during development by pressing `s`.\n const isUserDefinedDevClient =\n !!args['--dev-client'] || (args['--go'] == null ? false : !args['--go']);\n\n // If the user didn't specify `--dev-client` or `--go` we check if they have the dev client package\n // in their package.json.\n const isAutoDevClient =\n args['--dev-client'] == null &&\n args['--go'] == null &&\n hasDirectDevClientDependency(projectRoot);\n\n const isDevClient = isAutoDevClient || isUserDefinedDevClient;\n\n const scheme = await resolveSchemeAsync(projectRoot, {\n scheme: args['--scheme'],\n devClient: isDevClient,\n });\n\n return {\n privateKeyPath: args['--private-key-path'] ?? null,\n\n android: !!args['--android'],\n web: !!args['--web'],\n ios: !!args['--ios'],\n offline: !!args['--offline'],\n\n clear: !!args['--clear'],\n dev: !args['--no-dev'],\n https: !!args['--https'],\n maxWorkers: args['--max-workers'],\n port: args['--port'],\n minify: !!args['--minify'],\n\n devClient: isDevClient,\n\n scheme,\n host,\n };\n}\n\nexport async function resolveSchemeAsync(\n projectRoot: string,\n options: { scheme?: string; devClient?: boolean }\n): Promise<string | null> {\n if (typeof options.scheme === 'string') {\n // Use the custom scheme\n return options.scheme ?? null;\n }\n\n if (options.devClient || canResolveDevClient(projectRoot)) {\n const { getOptionalDevClientSchemeAsync } =\n require('../utils/scheme') as typeof import('../utils/scheme');\n // Attempt to find the scheme or warn the user how to setup a custom scheme\n const resolvedScheme = await getOptionalDevClientSchemeAsync(projectRoot);\n if (!resolvedScheme.scheme) {\n if (resolvedScheme.resolution === 'shared') {\n // This can happen if one of the native projects has no URI schemes defined in it.\n // Normally, this should never happen.\n Log.warn(\n chalk`Could not find a shared URI scheme for the dev client between the local {bold /ios} and {bold /android} directories. App launches (QR code, interstitial, terminal keys) may not work as expected. You can configure a custom scheme using the {bold --scheme} option, or by running {bold npx expo prebuild} to regenerate the native directories with URI schemes.`\n );\n } else if (['ios', 'android'].includes(resolvedScheme.resolution)) {\n Log.warn(\n chalk`The {bold /${resolvedScheme.resolution}} project does not contain any URI schemes. Expo CLI will not be able to use links to launch the project. You can configure a custom URI scheme using the {bold --scheme} option.`\n );\n }\n }\n return resolvedScheme.scheme;\n } else {\n // Ensure this is reset when users don't use `--scheme`, `--dev-client` and don't have the `expo-dev-client` package installed.\n return null;\n }\n}\n\n/** Resolve and assert host type options. */\nexport function resolveHostType(options: {\n host?: string;\n offline?: boolean;\n lan?: boolean;\n localhost?: boolean;\n tunnel?: boolean;\n}): 'lan' | 'tunnel' | 'localhost' {\n if (\n [options.offline, options.host, options.lan, options.localhost, options.tunnel].filter((i) => i)\n .length > 1\n ) {\n throw new CommandError(\n 'BAD_ARGS',\n 'Specify at most one of: --offline, --host, --tunnel, --lan, --localhost'\n );\n }\n\n if (options.offline) {\n // Force `lan` in offline mode.\n return 'lan';\n } else if (options.host) {\n assert.match(options.host, /^(lan|tunnel|localhost)$/);\n return options.host as 'lan' | 'tunnel' | 'localhost';\n } else if (options.tunnel) {\n return 'tunnel';\n } else if (options.lan) {\n return 'lan';\n } else if (options.localhost) {\n return 'localhost';\n }\n\n // If no option is provided, and we are running in Stackblitz, enable tunnel by default\n if (envIsWebcontainer()) {\n return 'tunnel';\n }\n\n return 'lan';\n}\n\n/** Resolve the port options for all supported bundlers. */\nexport async function resolvePortsAsync(\n projectRoot: string,\n options: Partial<Pick<Options, 'port' | 'devClient'>>,\n settings: { webOnly?: boolean }\n) {\n const multiBundlerSettings: { webpackPort?: number; metroPort?: number } = {};\n\n if (settings.webOnly) {\n const webpackPort = await resolvePortAsync(projectRoot, {\n defaultPort: options.port,\n // Default web port\n fallbackPort: 19006,\n });\n if (webpackPort == null) {\n throw new AbortCommandError();\n }\n multiBundlerSettings.webpackPort = webpackPort;\n } else {\n const fallbackPort = process.env.RCT_METRO_PORT\n ? parseInt(process.env.RCT_METRO_PORT, 10)\n : 8081;\n const metroPort = await resolvePortAsync(projectRoot, {\n defaultPort: options.port,\n fallbackPort,\n });\n if (metroPort == null) {\n throw new AbortCommandError();\n }\n multiBundlerSettings.metroPort = metroPort;\n }\n\n return multiBundlerSettings;\n}\n"],"names":["resolveHostType","resolveOptionsAsync","resolvePortsAsync","resolveSchemeAsync","projectRoot","args","CommandError","host","offline","lan","localhost","tunnel","Log","warn","chalk","isUserDefinedDevClient","isAutoDevClient","hasDirectDevClientDependency","isDevClient","scheme","devClient","privateKeyPath","android","web","ios","clear","dev","https","maxWorkers","port","minify","options","canResolveDevClient","getOptionalDevClientSchemeAsync","require","resolvedScheme","resolution","includes","filter","i","length","assert","match","envIsWebcontainer","settings","multiBundlerSettings","webOnly","webpackPort","resolvePortAsync","defaultPort","fallbackPort","AbortCommandError","process","env","RCT_METRO_PORT","parseInt","metroPort"],"mappings":";;;;;;;;;;;QAuHgBA;eAAAA;;QA5FMC;eAAAA;;QAoIAC;eAAAA;;QA3EAC;eAAAA;;;;gEApFH;;;;;;;gEACD;;;;;;iCAEgD;qBAC9C;qBACc;wBACc;sBACf;;;;;;AAoB1B,eAAeF,oBAAoBG,WAAmB,EAAEC,IAAS;IACtE,IAAIA,IAAI,CAAC,eAAe,IAAIA,IAAI,CAAC,OAAO,EAAE;QACxC,MAAM,IAAIC,oBAAY,CAAC,YAAY;IACrC;IACA,MAAMC,OAAOP,gBAAgB;QAC3BO,MAAMF,IAAI,CAAC,SAAS;QACpBG,SAASH,IAAI,CAAC,YAAY;QAC1BI,KAAKJ,IAAI,CAAC,QAAQ;QAClBK,WAAWL,IAAI,CAAC,cAAc;QAC9BM,QAAQN,IAAI,CAAC,WAAW;IAC1B;IAEA,IAAIA,IAAI,CAAC,UAAU,EAAE;QACnBO,QAAG,CAACC,IAAI,CAACC,IAAAA,gBAAK,CAAA,CAAC,+DAA+D,CAAC;IACjF;IAEA,8FAA8F;IAC9F,wDAAwD;IACxD,MAAMC,yBACJ,CAAC,CAACV,IAAI,CAAC,eAAe,IAAKA,CAAAA,IA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AAc,MAAMC,IAAAA,sBAAgB,EAAC5C,aAAa;YACtD6C,aAAalB,QAAQF,IAAI;YACzB,mBAAmB;YACnBqB,cAAc;QAChB;QACA,IAAIH,eAAe,MAAM;YACvB,MAAM,IAAII,yBAAiB;QAC7B;QACAN,qBAAqBE,WAAW,GAAGA;IACrC,OAAO;QACL,MAAMG,eAAeE,QAAQC,GAAG,CAACC,cAAc,GAC3CC,SAASH,QAAQC,GAAG,CAACC,cAAc,EAAE,MACrC;QACJ,MAAME,YAAY,MAAMR,IAAAA,sBAAgB,EAAC5C,aAAa;YACpD6C,aAAalB,QAAQF,IAAI;YACzBqB;QACF;QACA,IAAIM,aAAa,MAAM;YACrB,MAAM,IAAIL,yBAAiB;QAC7B;QACAN,qBAAqBW,SAAS,GAAGA;IACnC;IAEA,OAAOX;AACT"}
@@ -14,9 +14,6 @@ function _export(target, all) {
14
14
  });
15
15
  }
16
16
  _export(exports, {
17
- get cachedSourceMaps () {
18
- return cachedSourceMaps;
19
- },
20
17
  get createMetroEndpointAsync () {
21
18
  return createMetroEndpointAsync;
22
19
  },
@@ -68,18 +65,6 @@ function _interop_require_default(obj) {
68
65
  };
69
66
  }
70
67
  const debug = require('debug')('expo:start:server:getStaticRenderFunctions');
71
- const cachedSourceMaps = new Map();
72
- // Detect if running in Bun
73
- if (!process.isBun) {
74
- require('source-map-support').install({
75
- retrieveSourceMap (source) {
76
- if (cachedSourceMaps.has(source)) {
77
- return cachedSourceMaps.get(source);
78
- }
79
- return null;
80
- }
81
- });
82
- }
83
68
  async function ensureFileInRootDirectory(projectRoot, otherFile) {
84
69
  // Cannot be accessed using Metro's server API, we need to move the file
85
70
  // into the project root and try again.
@@ -120,9 +105,9 @@ async function createMetroEndpointAsync(projectRoot, devServerUrl, absoluteFileP
120
105
  }
121
106
  return url;
122
107
  }
123
- function evalMetroAndWrapFunctions(projectRoot, script, filename, isExporting) {
108
+ function evalMetroAndWrapFunctions(projectRoot, script, filename, sourceMap, isExporting) {
124
109
  // TODO: Add back stack trace logic that hides traces from metro-runtime and other internal modules.
125
- const contents = evalMetroNoHandling(projectRoot, script, filename);
110
+ const contents = evalMetroNoHandling(projectRoot, script, filename, sourceMap);
126
111
  if (!contents) {
127
112
  // This can happen if ErrorUtils isn't working correctly on web and failing to throw an error when a module throws.
128
113
  // This is unexpected behavior and should not be pretty formatted, therefore we're avoiding CommandError.
@@ -155,7 +140,7 @@ function evalMetroAndWrapFunctions(projectRoot, script, filename, isExporting) {
155
140
  return acc;
156
141
  }, {});
157
142
  }
158
- function evalMetroNoHandling(projectRoot, src, filename) {
143
+ function evalMetroNoHandling(projectRoot, src, filename, sourceMap) {
159
144
  (0, _serverLogLikeMetro.augmentLogs)(projectRoot);
160
145
  // NOTE(@kitten): `require-from-string` derives a base path from the filename we pass it,
161
146
  // but doesn't validate that the filename exists. These debug messages should help identify
@@ -165,7 +150,10 @@ function evalMetroNoHandling(projectRoot, src, filename) {
165
150
  } else if (!(0, _filePath.toPosixPath)(_path().default.dirname(filename)).startsWith((0, _filePath.toPosixPath)(projectRoot))) {
166
151
  debug(`evalMetroNoHandling received filename outside of the project root: ${filename}`);
167
152
  }
168
- return (0, _profile.profile)(_requireutils().evalModule, 'eval-metro-bundle')(src, filename);
153
+ return (0, _profile.profile)(_requireutils().evalModule, 'eval-metro-bundle')(src, filename, {
154
+ cache: false,
155
+ sourceMap
156
+ });
169
157
  }
170
158
 
171
159
  //# sourceMappingURL=getStaticRenderFunctions.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/getStaticRenderFunctions.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 { getMetroServerRoot } from '@expo/config/paths';\nimport { evalModule } from '@expo/require-utils';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { IS_METRO_BUNDLE_ERROR_SYMBOL, logMetroError } from './metro/metroErrorInterface';\nimport type { ExpoMetroOptions } from './middleware/metroOptions';\nimport { createBundleUrlPath } from './middleware/metroOptions';\nimport { augmentLogs } from './serverLogLikeMetro';\nimport { delayAsync } from '../../utils/delay';\nimport { SilentError } from '../../utils/errors';\nimport { toPosixPath } from '../../utils/filePath';\nimport { profile } from '../../utils/profile';\n\nconst debug = require('debug')('expo:start:server:getStaticRenderFunctions') as typeof console.log;\n\n/** The list of input keys will become optional, everything else will remain the same. */\nexport type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n\nexport const cachedSourceMaps: Map<string, { url: string; map: string }> = new Map();\n\n// Support unhandled rejections\n\ndeclare global {\n namespace NodeJS {\n interface Process {\n isBun?: boolean;\n }\n }\n}\n\n// Detect if running in Bun\nif (!process.isBun) {\n require('source-map-support').install({\n retrieveSourceMap(source: string) {\n if (cachedSourceMaps.has(source)) {\n return cachedSourceMaps.get(source);\n }\n return null;\n },\n });\n}\n\nasync function ensureFileInRootDirectory(projectRoot: string, otherFile: string) {\n // Cannot be accessed using Metro's server API, we need to move the file\n // into the project root and try again.\n if (!path.relative(projectRoot, otherFile).startsWith('..' + path.sep)) {\n return otherFile;\n }\n\n // Copy the file into the project to ensure it works in monorepos.\n // This means the file cannot have any relative imports.\n const tempDir = path.join(projectRoot, '.expo/static-tmp');\n await fs.promises.mkdir(tempDir, { recursive: true });\n const moduleId = path.join(tempDir, path.basename(otherFile));\n await fs.promises.writeFile(moduleId, await fs.promises.readFile(otherFile, 'utf8'));\n // Sleep to give watchman time to register the file.\n await delayAsync(50);\n return moduleId;\n}\n\nexport async function createMetroEndpointAsync(\n projectRoot: string,\n devServerUrl: string,\n absoluteFilePath: string,\n props: PickPartial<ExpoMetroOptions, 'mainModuleName' | 'bytecode'>\n): Promise<string> {\n const root = getMetroServerRoot(projectRoot);\n const safeOtherFile = await ensureFileInRootDirectory(projectRoot, absoluteFilePath);\n const serverPath = path.relative(root, safeOtherFile).replace(/\\.[jt]sx?$/, '');\n\n const urlFragment = createBundleUrlPath({\n mainModuleName: serverPath,\n lazy: false,\n asyncRoutes: false,\n inlineSourceMap: false,\n engine: 'hermes',\n minify: false,\n bytecode: false,\n ...props,\n });\n\n let url: string;\n if (devServerUrl) {\n url = new URL(urlFragment.replace(/^\\//, ''), devServerUrl).toString();\n } else {\n url = '/' + urlFragment.replace(/^\\/+/, '');\n }\n return url;\n}\n\nexport function evalMetroAndWrapFunctions<T = Record<string, any>>(\n projectRoot: string,\n script: string,\n filename: string,\n isExporting: boolean\n): T {\n // TODO: Add back stack trace logic that hides traces from metro-runtime and other internal modules.\n const contents = evalMetroNoHandling(projectRoot, script, filename);\n\n if (!contents) {\n // This can happen if ErrorUtils isn't working correctly on web and failing to throw an error when a module throws.\n // This is unexpected behavior and should not be pretty formatted, therefore we're avoiding CommandError.\n throw new Error(\n '[Expo SSR] Module returned undefined, this could be due to a misconfiguration in Metro error handling'\n );\n }\n // wrap each function with a try/catch that uses Metro's error formatter\n return Object.keys(contents).reduce((acc, key) => {\n const fn = contents[key];\n if (typeof fn !== 'function') {\n return { ...acc, [key]: fn };\n }\n\n acc[key] = async function (...props: any[]) {\n try {\n return await fn.apply(this, props);\n } catch (error: any) {\n await logMetroError(projectRoot, { error });\n\n if (isExporting || error[IS_METRO_BUNDLE_ERROR_SYMBOL]) {\n throw error;\n } else {\n // TODO: When does this happen?\n throw new SilentError(error);\n }\n }\n };\n return acc;\n }, {} as any);\n}\n\nexport function evalMetroNoHandling(projectRoot: string, src: string, filename: string) {\n augmentLogs(projectRoot);\n\n // NOTE(@kitten): `require-from-string` derives a base path from the filename we pass it,\n // but doesn't validate that the filename exists. These debug messages should help identify\n // these problems, if they occur in user projects without reproductions\n if (!fs.existsSync(path.dirname(filename))) {\n debug(`evalMetroNoHandling received filename in a directory that does not exist: ${filename}`);\n } else if (!toPosixPath(path.dirname(filename)).startsWith(toPosixPath(projectRoot))) {\n debug(`evalMetroNoHandling received filename outside of the project root: ${filename}`);\n }\n\n return profile(evalModule, 'eval-metro-bundle')(src, filename);\n}\n"],"names":["cachedSourceMaps","createMetroEndpointAsync","evalMetroAndWrapFunctions","evalMetroNoHandling","debug","require","Map","process","isBun","install","retrieveSourceMap","source","has","get","ensureFileInRootDirectory","projectRoot","otherFile","path","relative","startsWith","sep","tempDir","join","fs","promises","mkdir","recursive","moduleId","basename","writeFile","readFile","delayAsync","devServerUrl","absoluteFilePath","props","root","getMetroServerRoot","safeOtherFile","serverPath","replace","urlFragment","createBundleUrlPath","mainModuleName","lazy","asyncRoutes","inlineSourceMap","engine","minify","bytecode","url","URL","toString","script","filename","isExporting","contents","Error","Object","keys","reduce","acc","key","fn","apply","error","logMetroError","IS_METRO_BUNDLE_ERROR_SYMBOL","SilentError","src","augmentLogs","existsSync","dirname","toPosixPath","profile","evalModule"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;QAoBYA;eAAAA;;QA0CSC;eAAAA;;QA8BNC;eAAAA;;QAyCAC;eAAAA;;;;yBApImB;;;;;;;yBACR;;;;;;;gEACZ;;;;;;;gEACE;;;;;;qCAE2C;8BAExB;oCACR;uBACD;wBACC;0BACA;yBACJ;;;;;;AAExB,MAAMC,QAAQC,QAAQ,SAAS;AAKxB,MAAML,mBAA8D,IAAIM;AAY/E,2BAA2B;AAC3B,IAAI,CAACC,QAAQC,KAAK,EAAE;IAClBH,QAAQ,sBAAsBI,OAAO,CAAC;QACpCC,mBAAkBC,MAAc;YAC9B,IAAIX,iBAAiBY,GAAG,CAACD,SAAS;gBAChC,OAAOX,iBAAiBa,GAAG,CAACF;YAC9B;YACA,OAAO;QACT;IACF;AACF;AAEA,eAAeG,0BAA0BC,WAAmB,EAAEC,SAAiB;IAC7E,wEAAwE;IACxE,uCAAuC;IACvC,IAAI,CAACC,eAAI,CAACC,QAAQ,CAACH,aAAaC,WAAWG,UAAU,CAAC,OAAOF,eAAI,CAACG,GAAG,GAAG;QACtE,OAAOJ;IACT;IAEA,kEAAkE;IAClE,wDAAwD;IACxD,MAAMK,UAAUJ,eAAI,CAACK,IAAI,CAACP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KAAKC;QACxC,MAAMC,KAAKP,QAAQ,CAACM,IAAI;QACxB,IAAI,OAAOC,OAAO,YAAY;YAC5B,OAAO;gBAAE,GAAGF,GAAG;gBAAE,CAACC,IAAI,EAAEC;YAAG;QAC7B;QAEAF,GAAG,CAACC,IAAI,GAAG,eAAgB,GAAG3B,KAAY;YACxC,IAAI;gBACF,OAAO,MAAM4B,GAAGC,KAAK,CAAC,IAAI,EAAE7B;YAC9B,EAAE,OAAO8B,OAAY;gBACnB,MAAMC,IAAAA,kCAAa,EAAClD,aAAa;oBAAEiD;gBAAM;gBAEzC,IAAIV,eAAeU,KAAK,CAACE,iDAA4B,CAAC,EAAE;oBACtD,MAAMF;gBACR,OAAO;oBACL,+BAA+B;oBAC/B,MAAM,IAAIG,mBAAW,CAACH;gBACxB;YACF;QACF;QACA,OAAOJ;IACT,GAAG,CAAC;AACN;AAEO,SAASzD,oBAAoBY,WAAmB,EAAEqD,GAAW,EAAEf,QAAgB;IACpFgB,IAAAA,+BAAW,EAACtD;IAEZ,yFAAyF;IACzF,2FAA2F;IAC3F,uEAAuE;IACvE,IAAI,CAACQ,aAAE,CAAC+C,UAAU,CAACrD,eAAI,CAACsD,OAAO,CAAClB,YAAY;QAC1CjD,MAAM,CAAC,0EAA0E,EAAEiD,UAAU;IAC/F,OAAO,IAAI,CAACmB,IAAAA,qBAAW,EAACvD,eAAI,CAACsD,OAAO,CAAClB,WAAWlC,UAAU,CAACqD,IAAAA,qBAAW,EAACzD,eAAe;QACpFX,MAAM,CAAC,mEAAmE,EAAEiD,UAAU;IACxF;IAEA,OAAOoB,IAAAA,gBAAO,EAACC,0BAAU,EAAE,qBAAqBN,KAAKf;AACvD"}
1
+ {"version":3,"sources":["../../../../src/start/server/getStaticRenderFunctions.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 { getMetroServerRoot } from '@expo/config/paths';\nimport { evalModule } from '@expo/require-utils';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { IS_METRO_BUNDLE_ERROR_SYMBOL, logMetroError } from './metro/metroErrorInterface';\nimport type { ExpoMetroOptions } from './middleware/metroOptions';\nimport { createBundleUrlPath } from './middleware/metroOptions';\nimport { augmentLogs } from './serverLogLikeMetro';\nimport { delayAsync } from '../../utils/delay';\nimport { SilentError } from '../../utils/errors';\nimport { toPosixPath } from '../../utils/filePath';\nimport { profile } from '../../utils/profile';\n\nconst debug = require('debug')('expo:start:server:getStaticRenderFunctions') as typeof console.log;\n\n/** The list of input keys will become optional, everything else will remain the same. */\nexport type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n\nasync function ensureFileInRootDirectory(projectRoot: string, otherFile: string) {\n // Cannot be accessed using Metro's server API, we need to move the file\n // into the project root and try again.\n if (!path.relative(projectRoot, otherFile).startsWith('..' + path.sep)) {\n return otherFile;\n }\n\n // Copy the file into the project to ensure it works in monorepos.\n // This means the file cannot have any relative imports.\n const tempDir = path.join(projectRoot, '.expo/static-tmp');\n await fs.promises.mkdir(tempDir, { recursive: true });\n const moduleId = path.join(tempDir, path.basename(otherFile));\n await fs.promises.writeFile(moduleId, await fs.promises.readFile(otherFile, 'utf8'));\n // Sleep to give watchman time to register the file.\n await delayAsync(50);\n return moduleId;\n}\n\nexport async function createMetroEndpointAsync(\n projectRoot: string,\n devServerUrl: string,\n absoluteFilePath: string,\n props: PickPartial<ExpoMetroOptions, 'mainModuleName' | 'bytecode'>\n): Promise<string> {\n const root = getMetroServerRoot(projectRoot);\n const safeOtherFile = await ensureFileInRootDirectory(projectRoot, absoluteFilePath);\n const serverPath = path.relative(root, safeOtherFile).replace(/\\.[jt]sx?$/, '');\n\n const urlFragment = createBundleUrlPath({\n mainModuleName: serverPath,\n lazy: false,\n asyncRoutes: false,\n inlineSourceMap: false,\n engine: 'hermes',\n minify: false,\n bytecode: false,\n ...props,\n });\n\n let url: string;\n if (devServerUrl) {\n url = new URL(urlFragment.replace(/^\\//, ''), devServerUrl).toString();\n } else {\n url = '/' + urlFragment.replace(/^\\/+/, '');\n }\n return url;\n}\n\nexport function evalMetroAndWrapFunctions<T = Record<string, any>>(\n projectRoot: string,\n script: string,\n filename: string,\n sourceMap: string | undefined,\n isExporting: boolean\n): T {\n // TODO: Add back stack trace logic that hides traces from metro-runtime and other internal modules.\n const contents = evalMetroNoHandling(projectRoot, script, filename, sourceMap);\n\n if (!contents) {\n // This can happen if ErrorUtils isn't working correctly on web and failing to throw an error when a module throws.\n // This is unexpected behavior and should not be pretty formatted, therefore we're avoiding CommandError.\n throw new Error(\n '[Expo SSR] Module returned undefined, this could be due to a misconfiguration in Metro error handling'\n );\n }\n // wrap each function with a try/catch that uses Metro's error formatter\n return Object.keys(contents).reduce((acc, key) => {\n const fn = contents[key];\n if (typeof fn !== 'function') {\n return { ...acc, [key]: fn };\n }\n\n acc[key] = async function (...props: any[]) {\n try {\n return await fn.apply(this, props);\n } catch (error: any) {\n await logMetroError(projectRoot, { error });\n\n if (isExporting || error[IS_METRO_BUNDLE_ERROR_SYMBOL]) {\n throw error;\n } else {\n // TODO: When does this happen?\n throw new SilentError(error);\n }\n }\n };\n return acc;\n }, {} as any);\n}\n\nexport function evalMetroNoHandling(\n projectRoot: string,\n src: string,\n filename: string,\n sourceMap?: string\n) {\n augmentLogs(projectRoot);\n\n // NOTE(@kitten): `require-from-string` derives a base path from the filename we pass it,\n // but doesn't validate that the filename exists. These debug messages should help identify\n // these problems, if they occur in user projects without reproductions\n if (!fs.existsSync(path.dirname(filename))) {\n debug(`evalMetroNoHandling received filename in a directory that does not exist: ${filename}`);\n } else if (!toPosixPath(path.dirname(filename)).startsWith(toPosixPath(projectRoot))) {\n debug(`evalMetroNoHandling received filename outside of the project root: ${filename}`);\n }\n\n return profile(evalModule, 'eval-metro-bundle')(src, filename, {\n cache: false,\n sourceMap,\n });\n}\n"],"names":["createMetroEndpointAsync","evalMetroAndWrapFunctions","evalMetroNoHandling","debug","require","ensureFileInRootDirectory","projectRoot","otherFile","path","relative","startsWith","sep","tempDir","join","fs","promises","mkdir","recursive","moduleId","basename","writeFile","readFile","delayAsync","devServerUrl","absoluteFilePath","props","root","getMetroServerRoot","safeOtherFile","serverPath","replace","urlFragment","createBundleUrlPath","mainModuleName","lazy","asyncRoutes","inlineSourceMap","engine","minify","bytecode","url","URL","toString","script","filename","sourceMap","isExporting","contents","Error","Object","keys","reduce","acc","key","fn","apply","error","logMetroError","IS_METRO_BUNDLE_ERROR_SYMBOL","SilentError","src","augmentLogs","existsSync","dirname","toPosixPath","profile","evalModule","cache"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;QAsCqBA;eAAAA;;QA8BNC;eAAAA;;QA0CAC;eAAAA;;;;yBA7GmB;;;;;;;yBACR;;;;;;;gEACZ;;;;;;;gEACE;;;;;;qCAE2C;8BAExB;oCACR;uBACD;wBACC;0BACA;yBACJ;;;;;;AAExB,MAAMC,QAAQC,QAAQ,SAAS;AAK/B,eAAeC,0BAA0BC,WAAmB,EAAEC,SAAiB;IAC7E,wEAAwE;IACxE,uCAAuC;IACvC,IAAI,CAACC,eAAI,CAACC,QAAQ,CAACH,aAAaC,WAAWG,UAAU,CAAC,OAAOF,eAAI,CAACG,GAAG,GAAG;QACtE,OAAOJ;IACT;IAEA,kEAAkE;IAClE,wDAAwD;IACxD,MAAMK,UAAUJ,eAAI,CAACK,IAAI,CAACP,aAAa;IACvC,MAAMQ,aAAE,CAACC,QAAQ,CAACC,KAAK,CAACJ,SAAS;QAAEK,WAAW;IAAK;IACnD,MAAMC,WAAWV,eAAI,CAACK,IAAI,CAACD,SAASJ,eAAI,CAACW,QAAQ,CAACZ;IAClD,MAAMO,aAAE,CAACC,QAAQ,CAACK,SAAS,CAACF,UAAU,MAAMJ,aAAE,CAACC,QAAQ,CAACM,QAAQ,CAACd,WAAW;IAC5E,oDAAoD;IACpD,MAAMe,IAAAA,iBAAU,EAAC;IACjB,OAAOJ;AACT;AAEO,eAAelB,y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aAAa;oBAAEkD;gBAAM;gBAEzC,IAAIV,eAAeU,KAAK,CAACE,iDAA4B,CAAC,EAAE;oBACtD,MAAMF;gBACR,OAAO;oBACL,+BAA+B;oBAC/B,MAAM,IAAIG,mBAAW,CAACH;gBACxB;YACF;QACF;QACA,OAAOJ;IACT,GAAG,CAAC;AACN;AAEO,SAASlD,oBACdI,WAAmB,EACnBsD,GAAW,EACXhB,QAAgB,EAChBC,SAAkB;IAElBgB,IAAAA,+BAAW,EAACvD;IAEZ,yFAAyF;IACzF,2FAA2F;IAC3F,uEAAuE;IACvE,IAAI,CAACQ,aAAE,CAACgD,UAAU,CAACtD,eAAI,CAACuD,OAAO,CAACnB,YAAY;QAC1CzC,MAAM,CAAC,0EAA0E,EAAEyC,UAAU;IAC/F,OAAO,IAAI,CAACoB,IAAAA,qBAAW,EAACxD,eAAI,CAACuD,OAAO,CAACnB,WAAWlC,UAAU,CAACsD,IAAAA,qBAAW,EAAC1D,eAAe;QACpFH,MAAM,CAAC,mEAAmE,EAAEyC,UAAU;IACxF;IAEA,OAAOqB,IAAAA,gBAAO,EAACC,0BAAU,EAAE,qBAAqBN,KAAKhB,UAAU;QAC7DuB,OAAO;QACPtB;IACF;AACF"}
@@ -42,13 +42,6 @@ function _baseJSBundle() {
42
42
  };
43
43
  return data;
44
44
  }
45
- function _sourceMapGenerator() {
46
- const data = require("@expo/metro/metro/DeltaBundler/Serializers/sourceMapGenerator");
47
- _sourceMapGenerator = function() {
48
- return data;
49
- };
50
- return data;
51
- }
52
45
  function _bundleToString() {
53
46
  const data = /*#__PURE__*/ _interop_require_default(require("@expo/metro/metro/lib/bundleToString"));
54
47
  _bundleToString = function() {
@@ -63,6 +56,13 @@ function _getGraphId() {
63
56
  };
64
57
  return data;
65
58
  }
59
+ function _sourceMap() {
60
+ const data = require("@expo/metro-config/build/serializer/sourceMap");
61
+ _sourceMap = function() {
62
+ return data;
63
+ };
64
+ return data;
65
+ }
66
66
  function _assert() {
67
67
  const data = /*#__PURE__*/ _interop_require_default(require("assert"));
68
68
  _assert = function() {
@@ -666,7 +666,8 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
666
666
  modulesOnly: expoBundleOptions.modulesOnly ?? false,
667
667
  runModule: expoBundleOptions.runModule ?? true,
668
668
  sourceUrl: expoBundleOptions.sourceUrl,
669
- sourceMapUrl: extraOptions.sourceMapUrl ?? expoBundleOptions.sourceMapUrl
669
+ sourceMapUrl: extraOptions.sourceMapUrl ?? expoBundleOptions.sourceMapUrl,
670
+ excludeSource: expoBundleOptions.serializerOptions.excludeSource ?? false
670
671
  },
671
672
  transformOptions
672
673
  });
@@ -703,15 +704,6 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
703
704
  // https://github.com/facebook/metro/blob/2405f2f6c37a1b641cc379b9c733b1eff0c1c2a1/packages/metro/src/lib/parseOptionsFromUrl.js#L55-L87
704
705
  const { filename, bundle, map, ...rest } = await this.metroLoadModuleContents(filePath, opts);
705
706
  const scriptContents = wrapBundle(bundle);
706
- if (map) {
707
- debug('Registering SSR source map for:', filename);
708
- _getStaticRenderFunctions.cachedSourceMaps.set(filename, {
709
- url: this.projectRoot,
710
- map
711
- });
712
- } else {
713
- debug('No SSR source map found for:', filename);
714
- }
715
707
  return {
716
708
  ...rest,
717
709
  src: scriptContents,
@@ -1305,7 +1297,7 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
1305
1297
  if (!(apiRoute == null ? void 0 : apiRoute.src)) {
1306
1298
  return null;
1307
1299
  }
1308
- return (0, _getStaticRenderFunctions.evalMetroNoHandling)(this.projectRoot, apiRoute.src, apiRoute.filename);
1300
+ return (0, _getStaticRenderFunctions.evalMetroNoHandling)(this.projectRoot, apiRoute.src, apiRoute.filename, apiRoute.map);
1309
1301
  } catch (error) {
1310
1302
  // Format any errors that were thrown in the global scope of the evaluation.
1311
1303
  if (error instanceof Error) {
@@ -1617,7 +1609,7 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
1617
1609
  if (serializerOptions.modulesOnly) {
1618
1610
  prepend = [];
1619
1611
  }
1620
- bundleMap = await sourceMapStringAsync([
1612
+ bundleMap = await (0, _sourceMap().sourceMapStringNonBlocking)([
1621
1613
  //
1622
1614
  ...prepend,
1623
1615
  ...this.metro._getSortedModules(graph)
@@ -1691,7 +1683,7 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
1691
1683
  const url = new URL(relativePath, this.getDevServerUrlOrAssert());
1692
1684
  this.setupHmr(url);
1693
1685
  }
1694
- return (0, _getStaticRenderFunctions.evalMetroAndWrapFunctions)(this.projectRoot, res.src, res.filename, specificOptions.isExporting ?? this.instanceMetroOptions.isExporting);
1686
+ return (0, _getStaticRenderFunctions.evalMetroAndWrapFunctions)(this.projectRoot, res.src, res.filename, res.map, specificOptions.isExporting ?? this.instanceMetroOptions.isExporting);
1695
1687
  }, this.rscRenderer = null, this.onReloadRscEvent = null, // API Routes
1696
1688
  this.pendingRouteOperations = new Map(), this.watchedLoaderFiles = new Set();
1697
1689
  }
@@ -1705,11 +1697,6 @@ function wrapBundle(str) {
1705
1697
  // Use gm to apply to the last require line. This is needed when the bundle has side-effects.
1706
1698
  return str.replace(/^(__r\(.*\);)$/gm, 'module.exports = $1');
1707
1699
  }
1708
- async function sourceMapStringAsync(modules, options) {
1709
- return (await (0, _sourceMapGenerator().sourceMapGeneratorNonBlocking)(modules, options)).toString(undefined, {
1710
- excludeSource: options.excludeSource
1711
- });
1712
- }
1713
1700
  function unique(array) {
1714
1701
  return Array.from(new Set(array));
1715
1702
  }