@expo/cli 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/build/bin/cli +13 -5
  2. package/build/bin/cli.map +1 -1
  3. package/build/src/api/getVersions.js.map +1 -1
  4. package/build/src/api/rest/cache/response.js.map +1 -1
  5. package/build/src/api/rest/client.js +2 -2
  6. package/build/src/api/rest/client.js.map +1 -1
  7. package/build/src/api/user/actions.js +1 -1
  8. package/build/src/api/user/actions.js.map +1 -1
  9. package/build/src/customize/typescript.js +3 -1
  10. package/build/src/customize/typescript.js.map +1 -1
  11. package/build/src/export/createMetadataJson.js +5 -3
  12. package/build/src/export/createMetadataJson.js.map +1 -1
  13. package/build/src/export/embed/exportEmbedAsync.js +92 -18
  14. package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
  15. package/build/src/export/embed/resolveOptions.js +3 -3
  16. package/build/src/export/embed/resolveOptions.js.map +1 -1
  17. package/build/src/export/embed/xcodeCompilerLogger.js +97 -0
  18. package/build/src/export/embed/xcodeCompilerLogger.js.map +1 -0
  19. package/build/src/export/exportApp.js +106 -130
  20. package/build/src/export/exportApp.js.map +1 -1
  21. package/build/src/export/exportAssets.js +93 -38
  22. package/build/src/export/exportAssets.js.map +1 -1
  23. package/build/src/export/exportAsync.js +1 -1
  24. package/build/src/export/exportAsync.js.map +1 -1
  25. package/build/src/export/exportHermes.js +0 -90
  26. package/build/src/export/exportHermes.js.map +1 -1
  27. package/build/src/export/exportStaticAsync.js +165 -101
  28. package/build/src/export/exportStaticAsync.js.map +1 -1
  29. package/build/src/export/favicon.js +13 -5
  30. package/build/src/export/favicon.js.map +1 -1
  31. package/build/src/export/fork-bundleAsync.js +84 -57
  32. package/build/src/export/fork-bundleAsync.js.map +1 -1
  33. package/build/src/export/index.js +9 -7
  34. package/build/src/export/index.js.map +1 -1
  35. package/build/src/export/metroAssetLocalPath.js +101 -0
  36. package/build/src/export/metroAssetLocalPath.js.map +1 -0
  37. package/build/src/export/persistMetroAssets.js +115 -31
  38. package/build/src/export/persistMetroAssets.js.map +1 -1
  39. package/build/src/export/publicFolder.js +7 -0
  40. package/build/src/export/publicFolder.js.map +1 -1
  41. package/build/src/export/resolveOptions.js +1 -1
  42. package/build/src/export/resolveOptions.js.map +1 -1
  43. package/build/src/export/saveAssets.js +168 -43
  44. package/build/src/export/saveAssets.js.map +1 -1
  45. package/build/src/export/web/exportWebAsync.js +1 -1
  46. package/build/src/export/web/exportWebAsync.js.map +1 -1
  47. package/build/src/export/writeContents.js +8 -106
  48. package/build/src/export/writeContents.js.map +1 -1
  49. package/build/src/install/applyPlugins.js +52 -0
  50. package/build/src/install/applyPlugins.js.map +1 -0
  51. package/build/src/install/checkPackages.js +2 -2
  52. package/build/src/install/checkPackages.js.map +1 -1
  53. package/build/src/install/fixPackages.js +84 -0
  54. package/build/src/install/fixPackages.js.map +1 -0
  55. package/build/src/install/installAsync.js +50 -60
  56. package/build/src/install/installAsync.js.map +1 -1
  57. package/build/src/install/installExpoPackage.js +79 -0
  58. package/build/src/install/installExpoPackage.js.map +1 -0
  59. package/build/src/prebuild/clearNativeFolder.js +1 -1
  60. package/build/src/prebuild/clearNativeFolder.js.map +1 -1
  61. package/build/src/prebuild/configureProjectAsync.js +3 -3
  62. package/build/src/prebuild/configureProjectAsync.js.map +1 -1
  63. package/build/src/prebuild/copyTemplateFiles.js +21 -30
  64. package/build/src/prebuild/copyTemplateFiles.js.map +1 -1
  65. package/build/src/prebuild/prebuildAsync.js +45 -16
  66. package/build/src/prebuild/prebuildAsync.js.map +1 -1
  67. package/build/src/prebuild/resolveOptions.js +2 -2
  68. package/build/src/prebuild/resolveOptions.js.map +1 -1
  69. package/build/src/prebuild/updateFromTemplate.js +6 -6
  70. package/build/src/prebuild/updateFromTemplate.js.map +1 -1
  71. package/build/src/prebuild/updatePackageJson.js +49 -36
  72. package/build/src/prebuild/updatePackageJson.js.map +1 -1
  73. package/build/src/prebuild/validateTemplatePlatforms.js +2 -2
  74. package/build/src/prebuild/validateTemplatePlatforms.js.map +1 -1
  75. package/build/src/run/hints.js +4 -0
  76. package/build/src/run/hints.js.map +1 -1
  77. package/build/src/run/index.js +101 -0
  78. package/build/src/run/index.js.map +1 -0
  79. package/build/src/start/doctor/dependencies/bundledNativeModules.js +2 -2
  80. package/build/src/start/doctor/dependencies/bundledNativeModules.js.map +1 -1
  81. package/build/src/start/doctor/dependencies/getVersionedPackages.js +22 -7
  82. package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
  83. package/build/src/start/doctor/dependencies/resolvePackages.js +66 -0
  84. package/build/src/start/doctor/dependencies/resolvePackages.js.map +1 -0
  85. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +22 -33
  86. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
  87. package/build/src/start/interface/interactiveActions.js +54 -19
  88. package/build/src/start/interface/interactiveActions.js.map +1 -1
  89. package/build/src/start/server/BundlerDevServer.js +14 -10
  90. package/build/src/start/server/BundlerDevServer.js.map +1 -1
  91. package/build/src/start/server/DevServerManager.js +6 -1
  92. package/build/src/start/server/DevServerManager.js.map +1 -1
  93. package/build/src/start/server/DevToolsPluginManager.js +63 -0
  94. package/build/src/start/server/DevToolsPluginManager.js.map +1 -0
  95. package/build/src/start/server/getStaticRenderFunctions.js +25 -23
  96. package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
  97. package/build/src/start/server/metro/MetroBundlerDevServer.js +76 -69
  98. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  99. package/build/src/start/server/metro/MetroTerminalReporter.js +6 -2
  100. package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
  101. package/build/src/start/server/metro/TerminalReporter.js +18 -1
  102. package/build/src/start/server/metro/TerminalReporter.js.map +1 -1
  103. package/build/src/start/server/metro/bundleApiRoutes.js +5 -3
  104. package/build/src/start/server/metro/bundleApiRoutes.js.map +1 -1
  105. package/build/src/start/server/metro/createExpoMetroResolver.js +80 -46
  106. package/build/src/start/server/metro/createExpoMetroResolver.js.map +1 -1
  107. package/build/src/start/server/metro/createJResolver.js +152 -0
  108. package/build/src/start/server/metro/createJResolver.js.map +1 -0
  109. package/build/src/start/server/metro/createServerRouteMiddleware.js +15 -2
  110. package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
  111. package/build/src/start/server/metro/{inspector-proxy/device.js → debugging/InspectorDevice.js} +10 -38
  112. package/build/src/start/server/metro/debugging/InspectorDevice.js.map +1 -0
  113. package/build/src/start/server/metro/debugging/InspectorProxy.js +116 -0
  114. package/build/src/start/server/metro/debugging/InspectorProxy.js.map +1 -0
  115. package/build/src/start/server/metro/debugging/createDebugMiddleware.js +45 -0
  116. package/build/src/start/server/metro/debugging/createDebugMiddleware.js.map +1 -0
  117. package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/NetworkResponse.js +3 -4
  118. package/build/src/start/server/metro/debugging/inspectorHandlers/NetworkResponse.js.map +1 -0
  119. package/build/src/start/server/metro/debugging/inspectorHandlers/PageReload.js.map +1 -0
  120. package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/VscodeDebuggerGetPossibleBreakpoints.js +5 -6
  121. package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeDebuggerGetPossibleBreakpoints.js.map +1 -0
  122. package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/VscodeDebuggerScriptParsed.js +3 -2
  123. package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeDebuggerScriptParsed.js.map +1 -0
  124. package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/VscodeDebuggerSetBreakpointByUrl.js +3 -2
  125. package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeDebuggerSetBreakpointByUrl.js.map +1 -0
  126. package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeRuntimeCallFunctionOn.js +24 -0
  127. package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeRuntimeCallFunctionOn.js.map +1 -0
  128. package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/VscodeRuntimeGetProperties.js +5 -4
  129. package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeRuntimeGetProperties.js.map +1 -0
  130. package/build/src/start/server/metro/debugging/inspectorHandlers/types.js.map +1 -0
  131. package/build/src/start/server/metro/debugging/inspectorHandlers/utils.js +20 -0
  132. package/build/src/start/server/metro/debugging/inspectorHandlers/utils.js.map +1 -0
  133. package/build/src/start/server/metro/externals.js +25 -3
  134. package/build/src/start/server/metro/externals.js.map +1 -1
  135. package/build/src/start/server/metro/getCssModulesFromBundler.js.map +1 -1
  136. package/build/src/start/server/metro/instantiateMetro.js +40 -15
  137. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  138. package/build/src/start/server/metro/metroErrorInterface.js +3 -2
  139. package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
  140. package/build/src/start/server/metro/router.js +5 -6
  141. package/build/src/start/server/metro/router.js.map +1 -1
  142. package/build/src/start/server/metro/runServer-fork.js +17 -27
  143. package/build/src/start/server/metro/runServer-fork.js.map +1 -1
  144. package/build/src/start/server/metro/serializeHtml.js +59 -0
  145. package/build/src/start/server/metro/serializeHtml.js.map +1 -0
  146. package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js +1 -2
  147. package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js.map +1 -1
  148. package/build/src/start/server/metro/withMetroMultiPlatform.js +237 -214
  149. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  150. package/build/src/start/server/metro/withMetroResolvers.js +114 -40
  151. package/build/src/start/server/metro/withMetroResolvers.js.map +1 -1
  152. package/build/src/start/server/middleware/DevToolsPluginMiddleware.js +61 -0
  153. package/build/src/start/server/middleware/DevToolsPluginMiddleware.js.map +1 -0
  154. package/build/src/start/server/middleware/ExpoMiddleware.js +2 -2
  155. package/build/src/start/server/middleware/ExpoMiddleware.js.map +1 -1
  156. package/build/src/start/server/middleware/ManifestMiddleware.js +22 -66
  157. package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
  158. package/build/src/start/server/middleware/inspector/JsInspector.js +23 -2
  159. package/build/src/start/server/middleware/inspector/JsInspector.js.map +1 -1
  160. package/build/src/start/server/middleware/inspector/LaunchBrowser.js +30 -26
  161. package/build/src/start/server/middleware/inspector/LaunchBrowser.js.map +1 -1
  162. package/build/src/start/server/middleware/inspector/LaunchBrowser.types.js +7 -7
  163. package/build/src/start/server/middleware/inspector/LaunchBrowser.types.js.map +1 -1
  164. package/build/src/start/server/middleware/inspector/LaunchBrowserImplLinux.js +5 -2
  165. package/build/src/start/server/middleware/inspector/LaunchBrowserImplLinux.js.map +1 -1
  166. package/build/src/start/server/middleware/inspector/LaunchBrowserImplMacOS.js +3 -2
  167. package/build/src/start/server/middleware/inspector/LaunchBrowserImplMacOS.js.map +1 -1
  168. package/build/src/start/server/middleware/inspector/LaunchBrowserImplWindows.js +8 -7
  169. package/build/src/start/server/middleware/inspector/LaunchBrowserImplWindows.js.map +1 -1
  170. package/build/src/start/server/middleware/metroOptions.js +176 -0
  171. package/build/src/start/server/middleware/metroOptions.js.map +1 -0
  172. package/build/src/start/server/type-generation/__typetests__/fixtures/basic.js.map +1 -1
  173. package/build/src/start/server/type-generation/__typetests__/route.test.js +11 -3
  174. package/build/src/start/server/type-generation/__typetests__/route.test.js.map +1 -1
  175. package/build/src/start/server/type-generation/routes.js +6 -4
  176. package/build/src/start/server/type-generation/routes.js.map +1 -1
  177. package/build/src/start/server/type-generation/startTypescriptTypeGeneration.js +1 -1
  178. package/build/src/start/server/type-generation/startTypescriptTypeGeneration.js.map +1 -1
  179. package/build/src/utils/analytics/getMetroDebugProperties.js +1 -2
  180. package/build/src/utils/analytics/getMetroDebugProperties.js.map +1 -1
  181. package/build/src/utils/analytics/getMetroProperties.js +1 -2
  182. package/build/src/utils/analytics/getMetroProperties.js.map +1 -1
  183. package/build/src/utils/analytics/rudderstackClient.js +2 -2
  184. package/build/src/utils/args.js +4 -2
  185. package/build/src/utils/args.js.map +1 -1
  186. package/build/src/utils/cocoapods.js +1 -1
  187. package/build/src/utils/cocoapods.js.map +1 -1
  188. package/build/src/utils/codesigning.js +11 -1
  189. package/build/src/utils/codesigning.js.map +1 -1
  190. package/build/src/utils/dir.js +18 -8
  191. package/build/src/utils/dir.js.map +1 -1
  192. package/build/src/utils/env.js +10 -1
  193. package/build/src/utils/env.js.map +1 -1
  194. package/build/src/utils/getOrPromptApplicationId.js +2 -4
  195. package/build/src/utils/getOrPromptApplicationId.js.map +1 -1
  196. package/build/src/utils/prompts.js +1 -28
  197. package/build/src/utils/prompts.js.map +1 -1
  198. package/build/src/utils/tsconfig/loadTsConfigPaths.js +3 -11
  199. package/build/src/utils/tsconfig/loadTsConfigPaths.js.map +1 -1
  200. package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js +22 -12
  201. package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js.map +1 -1
  202. package/package.json +19 -18
  203. package/static/shims/react-native-web/dist/cjs/exports/AppRegistry/AppContainer.js +13 -0
  204. package/static/shims/react-native-web/dist/exports/AppRegistry/AppContainer.js +12 -0
  205. package/static/template/index.html +14 -95
  206. package/build/src/export/printBundleSizes.js +0 -101
  207. package/build/src/export/printBundleSizes.js.map +0 -1
  208. package/build/src/start/server/metro/inspector-proxy/device.js.map +0 -1
  209. package/build/src/start/server/metro/inspector-proxy/handlers/NetworkResponse.js.map +0 -1
  210. package/build/src/start/server/metro/inspector-proxy/handlers/PageReload.js.map +0 -1
  211. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerGetPossibleBreakpoints.js.map +0 -1
  212. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerScriptParsed.js.map +0 -1
  213. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerSetBreakpointByUrl.js.map +0 -1
  214. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeGetProperties.js.map +0 -1
  215. package/build/src/start/server/metro/inspector-proxy/handlers/types.js.map +0 -1
  216. package/build/src/start/server/metro/inspector-proxy/index.js +0 -27
  217. package/build/src/start/server/metro/inspector-proxy/index.js.map +0 -1
  218. package/build/src/start/server/metro/inspector-proxy/proxy.js +0 -169
  219. package/build/src/start/server/metro/inspector-proxy/proxy.js.map +0 -1
  220. package/build/src/start/server/metro/resolveFromProject.js +0 -90
  221. package/build/src/start/server/metro/resolveFromProject.js.map +0 -1
  222. package/build/src/start/server/middleware/inspector/createJsInspectorMiddleware.js +0 -64
  223. package/build/src/start/server/middleware/inspector/createJsInspectorMiddleware.js.map +0 -1
  224. /package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/PageReload.js +0 -0
  225. /package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/types.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/MetroTerminalReporter.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { Terminal } from 'metro-core';\nimport path from 'path';\n\nimport { logWarning, TerminalReporter } from './TerminalReporter';\nimport { BuildPhase, BundleDetails, BundleProgress, SnippetError } from './TerminalReporter.types';\nimport { NODE_STDLIB_MODULES } from './externals';\nimport { learnMore } from '../../../utils/link';\n\nconst MAX_PROGRESS_BAR_CHAR_WIDTH = 16;\nconst DARK_BLOCK_CHAR = '\\u2593';\nconst LIGHT_BLOCK_CHAR = '\\u2591';\n/**\n * Extends the default Metro logger and adds some additional features.\n * Also removes the giant Metro logo from the output.\n */\nexport class MetroTerminalReporter extends TerminalReporter {\n constructor(\n public projectRoot: string,\n terminal: Terminal\n ) {\n super(terminal);\n }\n\n // Used for testing\n _getElapsedTime(startTime: number): number {\n return Date.now() - startTime;\n }\n /**\n * Extends the bundle progress to include the current platform that we're bundling.\n *\n * @returns `iOS path/to/bundle.js ▓▓▓▓▓░░░░░░░░░░░ 36.6% (4790/7922)`\n */\n _getBundleStatusMessage(progress: BundleProgress, phase: BuildPhase): string {\n const env = getEnvironmentForBuildDetails(progress.bundleDetails);\n const platform = env || getPlatformTagForBuildDetails(progress.bundleDetails);\n const inProgress = phase === 'in_progress';\n\n if (!inProgress) {\n const status = phase === 'done' ? `Bundling complete ` : `Bundling failed `;\n const color = phase === 'done' ? chalk.green : chalk.red;\n\n const startTime = this._bundleTimers.get(progress.bundleDetails.buildID!);\n const time = startTime != null ? chalk.dim(this._getElapsedTime(startTime) + 'ms') : '';\n // iOS Bundling complete 150ms\n return color(platform + status) + time;\n }\n\n const localPath = progress.bundleDetails.entryFile.startsWith(path.sep)\n ? path.relative(this.projectRoot, progress.bundleDetails.entryFile)\n : progress.bundleDetails.entryFile;\n\n const filledBar = Math.floor(progress.ratio * MAX_PROGRESS_BAR_CHAR_WIDTH);\n\n const _progress = inProgress\n ? chalk.green.bgGreen(DARK_BLOCK_CHAR.repeat(filledBar)) +\n chalk.bgWhite.white(LIGHT_BLOCK_CHAR.repeat(MAX_PROGRESS_BAR_CHAR_WIDTH - filledBar)) +\n chalk.bold(` ${(100 * progress.ratio).toFixed(1).padStart(4)}% `) +\n chalk.dim(\n `(${progress.transformedFileCount\n .toString()\n .padStart(progress.totalFileCount.toString().length)}/${progress.totalFileCount})`\n )\n : '';\n\n return (\n platform +\n chalk.reset.dim(`${path.dirname(localPath)}/`) +\n chalk.bold(path.basename(localPath)) +\n ' ' +\n _progress\n );\n }\n\n _logInitializing(port: number, hasReducedPerformance: boolean): void {\n // Don't print a giant logo...\n this.terminal.log('Starting Metro Bundler');\n }\n\n shouldFilterClientLog(event: {\n type: 'client_log';\n level: 'trace' | 'info' | 'warn' | 'log' | 'group' | 'groupCollapsed' | 'groupEnd' | 'debug';\n data: unknown[];\n }): boolean {\n return isAppRegistryStartupMessage(event.data);\n }\n\n /** Print the cache clear message. */\n transformCacheReset(): void {\n logWarning(\n this.terminal,\n chalk`Bundler cache is empty, rebuilding {dim (this may take a minute)}`\n );\n }\n\n /** One of the first logs that will be printed */\n dependencyGraphLoading(hasReducedPerformance: boolean): void {\n // this.terminal.log('Dependency graph is loading...');\n if (hasReducedPerformance) {\n // Extends https://github.com/facebook/metro/blob/347b1d7ed87995d7951aaa9fd597c04b06013dac/packages/metro/src/lib/TerminalReporter.js#L283-L290\n this.terminal.log(\n chalk.red(\n [\n 'Metro is operating with reduced performance.',\n 'Please fix the problem above and restart Metro.',\n ].join('\\n')\n )\n );\n }\n }\n\n _logBundlingError(error: SnippetError): void {\n const moduleResolutionError = formatUsingNodeStandardLibraryError(this.projectRoot, error);\n const cause = error.cause as undefined | { _expoImportStack?: string };\n if (moduleResolutionError) {\n let message = maybeAppendCodeFrame(moduleResolutionError, error.message);\n if (cause?._expoImportStack) {\n message += `\\n\\n${cause?._expoImportStack}`;\n }\n return this.terminal.log(message);\n }\n if (cause?._expoImportStack) {\n error.message += `\\n\\n${cause._expoImportStack}`;\n }\n return super._logBundlingError(error);\n }\n}\n\n/**\n * Formats an error where the user is attempting to import a module from the Node.js standard library.\n * Exposed for testing.\n *\n * @param error\n * @returns error message or null if not a module resolution error\n */\nexport function formatUsingNodeStandardLibraryError(\n projectRoot: string,\n error: SnippetError\n): string | null {\n if (!error.message) {\n return null;\n }\n const { targetModuleName, originModulePath } = error;\n if (!targetModuleName || !originModulePath) {\n return null;\n }\n const relativePath = path.relative(projectRoot, originModulePath);\n\n const DOCS_PAGE_URL =\n 'https://docs.expo.dev/workflow/using-libraries/#using-third-party-libraries';\n\n if (isNodeStdLibraryModule(targetModuleName)) {\n if (originModulePath.includes('node_modules')) {\n return [\n `The package at \"${chalk.bold(\n relativePath\n )}\" attempted to import the Node standard library module \"${chalk.bold(\n targetModuleName\n )}\".`,\n `It failed because the native React runtime does not include the Node standard library.`,\n learnMore(DOCS_PAGE_URL),\n ].join('\\n');\n } else {\n return [\n `You attempted to import the Node standard library module \"${chalk.bold(\n targetModuleName\n )}\" from \"${chalk.bold(relativePath)}\".`,\n `It failed because the native React runtime does not include the Node standard library.`,\n learnMore(DOCS_PAGE_URL),\n ].join('\\n');\n }\n }\n return `Unable to resolve \"${targetModuleName}\" from \"${relativePath}\"`;\n}\n\nexport function isNodeStdLibraryModule(moduleName: string): boolean {\n return /^node:/.test(moduleName) || NODE_STDLIB_MODULES.includes(moduleName);\n}\n\n/** If the code frame can be found then append it to the existing message. */\nfunction maybeAppendCodeFrame(message: string, rawMessage: string): string {\n const codeFrame = stripMetroInfo(rawMessage);\n if (codeFrame) {\n message += '\\n' + codeFrame;\n }\n return message;\n}\n\n/**\n * Remove the Metro cache clearing steps if they exist.\n * In future versions we won't need this.\n * Returns the remaining code frame logs.\n */\nexport function stripMetroInfo(errorMessage: string): string | null {\n // Newer versions of Metro don't include the list.\n if (!errorMessage.includes('4. Remove the cache')) {\n return null;\n }\n const lines = errorMessage.split('\\n');\n const index = lines.findIndex((line) => line.includes('4. Remove the cache'));\n if (index === -1) {\n return null;\n }\n return lines.slice(index + 1).join('\\n');\n}\n\n/** @returns if the message matches the initial startup log */\nfunction isAppRegistryStartupMessage(body: any[]): boolean {\n return (\n body.length === 1 &&\n (/^Running application \"main\" with appParams:/.test(body[0]) ||\n /^Running \"main\" with \\{/.test(body[0]))\n );\n}\n\n/** @returns platform specific tag for a `BundleDetails` object */\nfunction getPlatformTagForBuildDetails(bundleDetails?: BundleDetails | null): string {\n const platform = bundleDetails?.platform ?? null;\n if (platform) {\n const formatted = { ios: 'iOS', android: 'Android', web: 'Web' }[platform] || platform;\n return `${chalk.bold(formatted)} `;\n }\n\n return '';\n}\n/** @returns platform specific tag for a `BundleDetails` object */\nfunction getEnvironmentForBuildDetails(bundleDetails?: BundleDetails | null): string {\n // Expo CLI will pass `customTransformOptions.environment = 'node'` when bundling for the server.\n const env = bundleDetails?.customTransformOptions?.environment ?? null;\n if (env === 'node') {\n return `${chalk.bold('Server')} `;\n }\n\n return '';\n}\n"],"names":["formatUsingNodeStandardLibraryError","isNodeStdLibraryModule","stripMetroInfo","MAX_PROGRESS_BAR_CHAR_WIDTH","DARK_BLOCK_CHAR","LIGHT_BLOCK_CHAR","MetroTerminalReporter","TerminalReporter","constructor","projectRoot","terminal","_getElapsedTime","startTime","Date","now","_getBundleStatusMessage","progress","phase","env","getEnvironmentForBuildDetails","bundleDetails","platform","getPlatformTagForBuildDetails","inProgress","status","color","chalk","green","red","_bundleTimers","get","buildID","time","dim","localPath","entryFile","startsWith","path","sep","relative","filledBar","Math","floor","ratio","_progress","bgGreen","repeat","bgWhite","white","bold","toFixed","padStart","transformedFileCount","toString","totalFileCount","length","reset","dirname","basename","_logInitializing","port","hasReducedPerformance","log","shouldFilterClientLog","event","isAppRegistryStartupMessage","data","transformCacheReset","logWarning","dependencyGraphLoading","join","_logBundlingError","error","moduleResolutionError","cause","message","maybeAppendCodeFrame","_expoImportStack","targetModuleName","originModulePath","relativePath","DOCS_PAGE_URL","includes","learnMore","moduleName","test","NODE_STDLIB_MODULES","rawMessage","codeFrame","errorMessage","lines","split","index","findIndex","line","slice","body","formatted","ios","android","web","customTransformOptions","environment"],"mappings":"AAAA;;;;QAuIgBA,mCAAmC,GAAnCA,mCAAmC;QAwCnCC,sBAAsB,GAAtBA,sBAAsB;QAkBtBC,cAAc,GAAdA,cAAc;AAjMZ,IAAA,MAAO,kCAAP,OAAO,EAAA;AAER,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEsB,IAAA,iBAAoB,WAApB,oBAAoB,CAAA;AAE7B,IAAA,UAAa,WAAb,aAAa,CAAA;AACvB,IAAA,KAAqB,WAArB,qBAAqB,CAAA;;;;;;AAE/C,MAAMC,2BAA2B,GAAG,EAAE,AAAC;AACvC,MAAMC,eAAe,GAAG,QAAQ,AAAC;AACjC,MAAMC,gBAAgB,GAAG,QAAQ,AAAC;AAK3B,MAAMC,qBAAqB,SAASC,iBAAgB,iBAAA;IACzDC,YACSC,WAAmB,EAC1BC,QAAkB,CAClB;QACA,KAAK,CAACA,QAAQ,CAAC,CAAC;aAHTD,WAAmB,GAA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Reporter.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { Terminal } from 'metro-core';\nimport path from 'path';\n\nimport { logWarning, TerminalReporter } from './TerminalReporter';\nimport {\n BuildPhase,\n BundleDetails,\n BundleProgress,\n SnippetError,\n TerminalReportableEvent,\n} from './TerminalReporter.types';\nimport { NODE_STDLIB_MODULES } from './externals';\nimport { learnMore } from '../../../utils/link';\n\nconst MAX_PROGRESS_BAR_CHAR_WIDTH = 16;\nconst DARK_BLOCK_CHAR = '\\u2593';\nconst LIGHT_BLOCK_CHAR = '\\u2591';\n/**\n * Extends the default Metro logger and adds some additional features.\n * Also removes the giant Metro logo from the output.\n */\nexport class MetroTerminalReporter extends TerminalReporter {\n constructor(\n public projectRoot: string,\n terminal: Terminal\n ) {\n super(terminal);\n }\n\n // Used for testing\n _getElapsedTime(startTime: number): number {\n return Date.now() - startTime;\n }\n /**\n * Extends the bundle progress to include the current platform that we're bundling.\n *\n * @returns `iOS path/to/bundle.js ▓▓▓▓▓░░░░░░░░░░░ 36.6% (4790/7922)`\n */\n _getBundleStatusMessage(progress: BundleProgress, phase: BuildPhase): string {\n const env = getEnvironmentForBuildDetails(progress.bundleDetails);\n const platform = env || getPlatformTagForBuildDetails(progress.bundleDetails);\n const inProgress = phase === 'in_progress';\n\n const localPath = progress.bundleDetails.entryFile.startsWith(path.sep)\n ? path.relative(this.projectRoot, progress.bundleDetails.entryFile)\n : progress.bundleDetails.entryFile;\n\n if (!inProgress) {\n const status = phase === 'done' ? `Bundling complete ` : `Bundling failed `;\n const color = phase === 'done' ? chalk.green : chalk.red;\n\n const startTime = this._bundleTimers.get(progress.bundleDetails.buildID!);\n const time = startTime != null ? chalk.dim(this._getElapsedTime(startTime) + 'ms') : '';\n // iOS Bundling complete 150ms\n return color(platform + status) + time + chalk.reset.dim(' (' + localPath + ')');\n }\n\n const filledBar = Math.floor(progress.ratio * MAX_PROGRESS_BAR_CHAR_WIDTH);\n\n const _progress = inProgress\n ? chalk.green.bgGreen(DARK_BLOCK_CHAR.repeat(filledBar)) +\n chalk.bgWhite.white(LIGHT_BLOCK_CHAR.repeat(MAX_PROGRESS_BAR_CHAR_WIDTH - filledBar)) +\n chalk.bold(` ${(100 * progress.ratio).toFixed(1).padStart(4)}% `) +\n chalk.dim(\n `(${progress.transformedFileCount\n .toString()\n .padStart(progress.totalFileCount.toString().length)}/${progress.totalFileCount})`\n )\n : '';\n\n return (\n platform +\n chalk.reset.dim(`${path.dirname(localPath)}/`) +\n chalk.bold(path.basename(localPath)) +\n ' ' +\n _progress\n );\n }\n\n _logInitializing(port: number, hasReducedPerformance: boolean): void {\n // Don't print a giant logo...\n this.terminal.log('Starting Metro Bundler');\n }\n\n shouldFilterClientLog(event: {\n type: 'client_log';\n level: 'trace' | 'info' | 'warn' | 'log' | 'group' | 'groupCollapsed' | 'groupEnd' | 'debug';\n data: unknown[];\n }): boolean {\n return isAppRegistryStartupMessage(event.data);\n }\n\n shouldFilterBundleEvent(event: TerminalReportableEvent): boolean {\n return 'bundleDetails' in event && event.bundleDetails?.bundleType === 'map';\n }\n\n /** Print the cache clear message. */\n transformCacheReset(): void {\n logWarning(\n this.terminal,\n chalk`Bundler cache is empty, rebuilding {dim (this may take a minute)}`\n );\n }\n\n /** One of the first logs that will be printed */\n dependencyGraphLoading(hasReducedPerformance: boolean): void {\n // this.terminal.log('Dependency graph is loading...');\n if (hasReducedPerformance) {\n // Extends https://github.com/facebook/metro/blob/347b1d7ed87995d7951aaa9fd597c04b06013dac/packages/metro/src/lib/TerminalReporter.js#L283-L290\n this.terminal.log(\n chalk.red(\n [\n 'Metro is operating with reduced performance.',\n 'Please fix the problem above and restart Metro.',\n ].join('\\n')\n )\n );\n }\n }\n\n _logBundlingError(error: SnippetError): void {\n const moduleResolutionError = formatUsingNodeStandardLibraryError(this.projectRoot, error);\n const cause = error.cause as undefined | { _expoImportStack?: string };\n if (moduleResolutionError) {\n let message = maybeAppendCodeFrame(moduleResolutionError, error.message);\n if (cause?._expoImportStack) {\n message += `\\n\\n${cause?._expoImportStack}`;\n }\n return this.terminal.log(message);\n }\n if (cause?._expoImportStack) {\n error.message += `\\n\\n${cause._expoImportStack}`;\n }\n return super._logBundlingError(error);\n }\n}\n\n/**\n * Formats an error where the user is attempting to import a module from the Node.js standard library.\n * Exposed for testing.\n *\n * @param error\n * @returns error message or null if not a module resolution error\n */\nexport function formatUsingNodeStandardLibraryError(\n projectRoot: string,\n error: SnippetError\n): string | null {\n if (!error.message) {\n return null;\n }\n const { targetModuleName, originModulePath } = error;\n if (!targetModuleName || !originModulePath) {\n return null;\n }\n const relativePath = path.relative(projectRoot, originModulePath);\n\n const DOCS_PAGE_URL =\n 'https://docs.expo.dev/workflow/using-libraries/#using-third-party-libraries';\n\n if (isNodeStdLibraryModule(targetModuleName)) {\n if (originModulePath.includes('node_modules')) {\n return [\n `The package at \"${chalk.bold(\n relativePath\n )}\" attempted to import the Node standard library module \"${chalk.bold(\n targetModuleName\n )}\".`,\n `It failed because the native React runtime does not include the Node standard library.`,\n learnMore(DOCS_PAGE_URL),\n ].join('\\n');\n } else {\n return [\n `You attempted to import the Node standard library module \"${chalk.bold(\n targetModuleName\n )}\" from \"${chalk.bold(relativePath)}\".`,\n `It failed because the native React runtime does not include the Node standard library.`,\n learnMore(DOCS_PAGE_URL),\n ].join('\\n');\n }\n }\n return `Unable to resolve \"${targetModuleName}\" from \"${relativePath}\"`;\n}\n\nexport function isNodeStdLibraryModule(moduleName: string): boolean {\n return /^node:/.test(moduleName) || NODE_STDLIB_MODULES.includes(moduleName);\n}\n\n/** If the code frame can be found then append it to the existing message. */\nfunction maybeAppendCodeFrame(message: string, rawMessage: string): string {\n const codeFrame = stripMetroInfo(rawMessage);\n if (codeFrame) {\n message += '\\n' + codeFrame;\n }\n return message;\n}\n\n/**\n * Remove the Metro cache clearing steps if they exist.\n * In future versions we won't need this.\n * Returns the remaining code frame logs.\n */\nexport function stripMetroInfo(errorMessage: string): string | null {\n // Newer versions of Metro don't include the list.\n if (!errorMessage.includes('4. Remove the cache')) {\n return null;\n }\n const lines = errorMessage.split('\\n');\n const index = lines.findIndex((line) => line.includes('4. Remove the cache'));\n if (index === -1) {\n return null;\n }\n return lines.slice(index + 1).join('\\n');\n}\n\n/** @returns if the message matches the initial startup log */\nfunction isAppRegistryStartupMessage(body: any[]): boolean {\n return (\n body.length === 1 &&\n (/^Running application \"main\" with appParams:/.test(body[0]) ||\n /^Running \"main\" with \\{/.test(body[0]))\n );\n}\n\n/** @returns platform specific tag for a `BundleDetails` object */\nfunction getPlatformTagForBuildDetails(bundleDetails?: BundleDetails | null): string {\n const platform = bundleDetails?.platform ?? null;\n if (platform) {\n const formatted = { ios: 'iOS', android: 'Android', web: 'Web' }[platform] || platform;\n return `${chalk.bold(formatted)} `;\n }\n\n return '';\n}\n/** @returns platform specific tag for a `BundleDetails` object */\nfunction getEnvironmentForBuildDetails(bundleDetails?: BundleDetails | null): string {\n // Expo CLI will pass `customTransformOptions.environment = 'node'` when bundling for the server.\n const env = bundleDetails?.customTransformOptions?.environment ?? null;\n if (env === 'node') {\n return `${chalk.bold('Server')} `;\n }\n\n return '';\n}\n"],"names":["formatUsingNodeStandardLibraryError","isNodeStdLibraryModule","stripMetroInfo","MAX_PROGRESS_BAR_CHAR_WIDTH","DARK_BLOCK_CHAR","LIGHT_BLOCK_CHAR","MetroTerminalReporter","TerminalReporter","constructor","projectRoot","terminal","_getElapsedTime","startTime","Date","now","_getBundleStatusMessage","progress","phase","env","getEnvironmentForBuildDetails","bundleDetails","platform","getPlatformTagForBuildDetails","inProgress","localPath","entryFile","startsWith","path","sep","relative","status","color","chalk","green","red","_bundleTimers","get","buildID","time","dim","reset","filledBar","Math","floor","ratio","_progress","bgGreen","repeat","bgWhite","white","bold","toFixed","padStart","transformedFileCount","toString","totalFileCount","length","dirname","basename","_logInitializing","port","hasReducedPerformance","log","shouldFilterClientLog","event","isAppRegistryStartupMessage","data","shouldFilterBundleEvent","bundleType","transformCacheReset","logWarning","dependencyGraphLoading","join","_logBundlingError","error","moduleResolutionError","cause","message","maybeAppendCodeFrame","_expoImportStack","targetModuleName","originModulePath","relativePath","DOCS_PAGE_URL","includes","learnMore","moduleName","test","NODE_STDLIB_MODULES","rawMessage","codeFrame","errorMessage","lines","split","index","findIndex","line","slice","body","formatted","ios","android","web","customTransformOptions","environment"],"mappings":"AAAA;;;;QAiJgBA,mCAAmC,GAAnCA,mCAAmC;QAwCnCC,sBAAsB,GAAtBA,sBAAsB;QAkBtBC,cAAc,GAAdA,cAAc;AA3MZ,IAAA,MAAO,kCAAP,OAAO,EAAA;AAER,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEsB,IAAA,iBAAoB,WAApB,oBAAoB,CAAA;AAQ7B,IAAA,UAAa,WAAb,aAAa,CAAA;AACvB,IAAA,KAAqB,WAArB,qBAAqB,CAAA;;;;;;AAE/C,MAAMC,2BAA2B,GAAG,EAAE,AAAC;AACvC,MAAMC,eAAe,GAAG,QAAQ,AAAC;AACjC,MAAMC,gBAAgB,GAAG,QAAQ,AAAC;AAK3B,MAAMC,qBAAqB,SAASC,iBAAgB,iBAAA;IACzDC,YACSC,WAAmB,EAC1BC,QAAkB,CAClB;QACA,KAAK,CAACA,QAAQ,CAAC,CAAC;aAHTD,WAAmB,GAAnBA,WAAmB;KAI3B;IAED,mBAAmB;IACnBE,eAAe,CAACC,SAAiB,EAAU;QACzC,OAAOC,IAAI,CAACC,GAAG,EAAE,GAAGF,SAAS,CAAC;KAC/B;IACD;;;;KAIG,CACHG,uBAAuB,CAACC,QAAwB,EAAEC,KAAiB,EAAU;QAC3E,MAAMC,GAAG,GAAGC,6BAA6B,CAACH,QAAQ,CAACI,aAAa,CAAC,AAAC;QAClE,MAAMC,QAAQ,GAAGH,GAAG,IAAII,6BAA6B,CAACN,QAAQ,CAACI,aAAa,CAAC,AAAC;QAC9E,MAAMG,UAAU,GAAGN,KAAK,KAAK,aAAa,AAAC;QAE3C,MAAMO,SAAS,GAAGR,QAAQ,CAACI,aAAa,CAACK,SA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CAAC,CAAC,CAC1C;CACH;AAED,kEAAkE,CAClE,SAAS5E,6BAA6B,CAACF,aAAoC,EAAU;QAClEA,GAAuB;IAAxC,MAAMC,QAAQ,GAAGD,CAAAA,GAAuB,GAAvBA,aAAa,QAAU,GAAvBA,KAAAA,CAAuB,GAAvBA,aAAa,CAAEC,QAAQ,YAAvBD,GAAuB,GAAI,IAAI,AAAC;IACjD,IAAIC,QAAQ,EAAE;QACZ,MAAM8E,SAAS,GAAG;YAAEC,GAAG,EAAE,KAAK;YAAEC,OAAO,EAAE,SAAS;YAAEC,GAAG,EAAE,KAAK;SAAE,CAACjF,QAAQ,CAAC,IAAIA,QAAQ,AAAC;QACvF,OAAO,CAAC,EAAEW,MAAK,QAAA,CAACkB,IAAI,CAACiD,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;KACpC;IAED,OAAO,EAAE,CAAC;CACX;AACD,kEAAkE,CAClE,SAAShF,6BAA6B,CAACC,aAAoC,EAAU;QAEvEA,GAAqC;QAArCA,IAAkD;IAD9D,iGAAiG;IACjG,MAAMF,GAAG,GAAGE,CAAAA,IAAkD,GAAlDA,aAAa,QAAwB,GAArCA,KAAAA,CAAqC,GAArCA,CAAAA,GAAqC,GAArCA,aAAa,CAAEmF,sBAAsB,SAAA,GAArCnF,KAAAA,CAAqC,GAArCA,GAAqC,CAAEoF,WAAW,AAAb,YAArCpF,IAAkD,GAAI,IAAI,AAAC;IACvE,IAAIF,GAAG,KAAK,MAAM,EAAE;QAClB,OAAO,CAAC,EAAEc,MAAK,QAAA,CAACkB,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;KACnC;IAED,OAAO,EAAE,CAAC;CACX"}
@@ -13,6 +13,7 @@ function _interopRequireDefault(obj) {
13
13
  default: obj
14
14
  };
15
15
  }
16
+ const debug = require("debug")("expo:metro:logger");
16
17
  function logWarning(terminal, format, ...args) {
17
18
  const str = _util.default.format(format, ...args);
18
19
  terminal.log("%s: %s", _chalk.default.yellow("warning"), str);
@@ -32,6 +33,7 @@ class TerminalReporter extends XTerminalReporter {
32
33
  * so we need to cache the details in order to print the platform info with other event types.
33
34
  */ _bundleDetails = new Map();
34
35
  /** Keep track of how long a bundle takes to complete */ _bundleTimers = new Map();
36
+ /** Keep track of bundle processes that should not be logged. */ _hiddenBundleEvents = new Set();
35
37
  _log(event) {
36
38
  switch(event.type){
37
39
  case "transform_cache_reset":
@@ -49,6 +51,9 @@ class TerminalReporter extends XTerminalReporter {
49
51
  /** Gives subclasses an easy interface for filtering out logs. Return `true` to skip. */ shouldFilterClientLog(event) {
50
52
  return false;
51
53
  }
54
+ /** Gives subclasses an easy interface for filtering out bundle events, specifically for source maps. Return `true` to skip. */ shouldFilterBundleEvent(event) {
55
+ return false;
56
+ }
52
57
  /** Cache has been reset. */ transformCacheReset() {}
53
58
  /** One of the first logs that will be printed. */ dependencyGraphLoading(hasReducedPerformance) {}
54
59
  /**
@@ -61,11 +66,23 @@ class TerminalReporter extends XTerminalReporter {
61
66
  * This function is exclusively concerned with updating the internal state.
62
67
  * No logging or status updates should be done at this point.
63
68
  */ _updateState(event) {
69
+ var ref;
64
70
  // Append the buildID to the bundleDetails.
65
71
  if (event.bundleDetails) {
66
72
  event.bundleDetails.buildID = event.buildID;
67
73
  }
68
- super._updateState(event);
74
+ var ref1;
75
+ const buildID = (ref1 = (ref = event.bundleDetails) == null ? void 0 : ref.buildID) != null ? ref1 : event.buildID;
76
+ if (buildID && !this._hiddenBundleEvents.has(buildID)) {
77
+ if (this.shouldFilterBundleEvent(event)) {
78
+ debug("skipping bundle events for", buildID, event);
79
+ this._hiddenBundleEvents.add(buildID);
80
+ } else {
81
+ super._updateState(event);
82
+ }
83
+ } else {
84
+ super._updateState(event);
85
+ }
69
86
  switch(event.type){
70
87
  case "bundle_build_done":
71
88
  case "bundle_build_failed":
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/TerminalReporter.ts"],"sourcesContent":["// This file represents an abstraction on the metro TerminalReporter.\n// We use this abstraction to safely extend the TerminalReporter for our own custom logging.\nimport chalk from 'chalk';\nimport UpstreamTerminalReporter from 'metro/src/lib/TerminalReporter';\nimport { Terminal } from 'metro-core';\nimport util from 'util';\n\nimport {\n BundleDetails,\n TerminalReportableEvent,\n TerminalReporterInterface,\n} from './TerminalReporter.types';\nimport { stripAnsi } from '../../../utils/ansi';\n\n/**\n * A standard way to log a warning to the terminal. This should not be called\n * from some arbitrary Metro logic, only from the reporters. Instead of\n * calling this, add a new type of ReportableEvent instead, and implement a\n * proper handler in the reporter(s).\n */\nexport function logWarning(terminal: Terminal, format: string, ...args: any[]): void {\n const str = util.format(format, ...args);\n terminal.log('%s: %s', chalk.yellow('warning'), str);\n}\n\n/**\n * Similar to `logWarning`, but for messages that require the user to act.\n */\nexport function logError(terminal: Terminal, format: string, ...args: any[]): void {\n terminal.log(\n '%s: %s',\n chalk.red('error'),\n // Syntax errors may have colors applied for displaying code frames\n // in various places outside of where Metro is currently running.\n // If the current terminal does not support color, we'll strip the colors\n // here.\n util.format(chalk.supportsColor ? format : stripAnsi(format), ...args)\n );\n}\n\nconst XTerminalReporter = UpstreamTerminalReporter as unknown as TerminalReporterInterface;\n\n/** Extended TerminalReporter class but with proper types and extra functionality to avoid using the `_log` method directly in subclasses. */\nexport class TerminalReporter extends XTerminalReporter implements TerminalReporterInterface {\n /**\n * A cache of { [buildID]: BundleDetails } which can be used to\n * add more contextual logs. BundleDetails is currently only sent with `bundle_build_started`\n * so we need to cache the details in order to print the platform info with other event types.\n */\n _bundleDetails: Map<string, BundleDetails> = new Map();\n\n /** Keep track of how long a bundle takes to complete */\n _bundleTimers: Map<string, number> = new Map();\n\n _log(event: TerminalReportableEvent): void {\n switch (event.type) {\n case 'transform_cache_reset':\n return this.transformCacheReset();\n case 'dep_graph_loading':\n return this.dependencyGraphLoading(event.hasReducedPerformance);\n case 'client_log':\n if (this.shouldFilterClientLog(event)) {\n return;\n }\n break;\n }\n return super._log(event);\n }\n\n /** Gives subclasses an easy interface for filtering out logs. Return `true` to skip. */\n shouldFilterClientLog(event: {\n type: 'client_log';\n level: 'trace' | 'info' | 'warn' | 'log' | 'group' | 'groupCollapsed' | 'groupEnd' | 'debug';\n data: unknown[];\n }): boolean {\n return false;\n }\n\n /** Cache has been reset. */\n transformCacheReset(): void {}\n\n /** One of the first logs that will be printed. */\n dependencyGraphLoading(hasReducedPerformance: boolean): void {}\n\n /**\n * Custom log event representing the end of the bundling.\n *\n * @param event event object.\n * @param duration duration of the build in milliseconds.\n */\n bundleBuildEnded(event: TerminalReportableEvent, duration: number): void {}\n\n /**\n * This function is exclusively concerned with updating the internal state.\n * No logging or status updates should be done at this point.\n */\n _updateState(\n event: TerminalReportableEvent & { bundleDetails?: BundleDetails; buildID?: string }\n ) {\n // Append the buildID to the bundleDetails.\n if (event.bundleDetails) {\n event.bundleDetails.buildID = event.buildID;\n }\n\n super._updateState(event);\n switch (event.type) {\n case 'bundle_build_done':\n case 'bundle_build_failed': {\n const startTime = this._bundleTimers.get(event.buildID);\n // Observed a bug in Metro where the `bundle_build_done` is invoked twice during a static bundle\n // i.e. `expo export`.\n if (startTime == null) {\n break;\n }\n\n this.bundleBuildEnded(event, startTime ? Date.now() - startTime : 0);\n this._bundleTimers.delete(event.buildID);\n break;\n }\n case 'bundle_build_started':\n this._bundleDetails.set(event.buildID, event.bundleDetails);\n this._bundleTimers.set(event.buildID, Date.now());\n break;\n }\n }\n}\n"],"names":["logWarning","logError","terminal","format","args","str","util","log","chalk","yellow","red","supportsColor","stripAnsi","XTerminalReporter","UpstreamTerminalReporter","TerminalReporter","_bundleDetails","Map","_bundleTimers","_log","event","type","transformCacheReset","dependencyGraphLoading","hasReducedPerformance","shouldFilterClientLog","bundleBuildEnded","duration","_updateState","bundleDetails","buildID","startTime","get","Date","now","delete","set"],"mappings":"AAEA;;;;QAkBgBA,UAAU,GAAVA,UAAU;QAQVC,QAAQ,GAARA,QAAQ;AA1BN,IAAA,MAAO,kCAAP,OAAO,EAAA;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AEV,KAAK,CAACS,aAAa,CAAC,CAAC;gBAC5D,IAAI,CAACX,aAAa,CAACkB,GAAG,CAAChB,KAAK,CAACU,OAAO,EAAEG,IAAI,CAACC,GAAG,EAAE,CAAC,CAAC;gBAClD,MAAM;SACT;KACF;CACF;QAlFYnB,gBAAgB,GAAhBA,gBAAgB"}
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/TerminalReporter.ts"],"sourcesContent":["// This file represents an abstraction on the metro TerminalReporter.\n// We use this abstraction to safely extend the TerminalReporter for our own custom logging.\nimport chalk from 'chalk';\nimport UpstreamTerminalReporter from 'metro/src/lib/TerminalReporter';\nimport { Terminal } from 'metro-core';\nimport util from 'util';\n\nimport {\n BundleDetails,\n TerminalReportableEvent,\n TerminalReporterInterface,\n} from './TerminalReporter.types';\nimport { stripAnsi } from '../../../utils/ansi';\n\nconst debug = require('debug')('expo:metro:logger') as typeof console.log;\n\n/**\n * A standard way to log a warning to the terminal. This should not be called\n * from some arbitrary Metro logic, only from the reporters. Instead of\n * calling this, add a new type of ReportableEvent instead, and implement a\n * proper handler in the reporter(s).\n */\nexport function logWarning(terminal: Terminal, format: string, ...args: any[]): void {\n const str = util.format(format, ...args);\n terminal.log('%s: %s', chalk.yellow('warning'), str);\n}\n\n/**\n * Similar to `logWarning`, but for messages that require the user to act.\n */\nexport function logError(terminal: Terminal, format: string, ...args: any[]): void {\n terminal.log(\n '%s: %s',\n chalk.red('error'),\n // Syntax errors may have colors applied for displaying code frames\n // in various places outside of where Metro is currently running.\n // If the current terminal does not support color, we'll strip the colors\n // here.\n util.format(chalk.supportsColor ? format : stripAnsi(format), ...args)\n );\n}\n\nconst XTerminalReporter = UpstreamTerminalReporter as unknown as TerminalReporterInterface;\n\n/** Extended TerminalReporter class but with proper types and extra functionality to avoid using the `_log` method directly in subclasses. */\nexport class TerminalReporter extends XTerminalReporter implements TerminalReporterInterface {\n /**\n * A cache of { [buildID]: BundleDetails } which can be used to\n * add more contextual logs. BundleDetails is currently only sent with `bundle_build_started`\n * so we need to cache the details in order to print the platform info with other event types.\n */\n _bundleDetails: Map<string, BundleDetails> = new Map();\n\n /** Keep track of how long a bundle takes to complete */\n _bundleTimers: Map<string, number> = new Map();\n\n /** Keep track of bundle processes that should not be logged. */\n _hiddenBundleEvents: Set<string> = new Set();\n\n _log(event: TerminalReportableEvent): void {\n switch (event.type) {\n case 'transform_cache_reset':\n return this.transformCacheReset();\n case 'dep_graph_loading':\n return this.dependencyGraphLoading(event.hasReducedPerformance);\n case 'client_log':\n if (this.shouldFilterClientLog(event)) {\n return;\n }\n break;\n }\n return super._log(event);\n }\n\n /** Gives subclasses an easy interface for filtering out logs. Return `true` to skip. */\n shouldFilterClientLog(event: {\n type: 'client_log';\n level: 'trace' | 'info' | 'warn' | 'log' | 'group' | 'groupCollapsed' | 'groupEnd' | 'debug';\n data: unknown[];\n }): boolean {\n return false;\n }\n\n /** Gives subclasses an easy interface for filtering out bundle events, specifically for source maps. Return `true` to skip. */\n shouldFilterBundleEvent(event: TerminalReportableEvent): boolean {\n return false;\n }\n\n /** Cache has been reset. */\n transformCacheReset(): void {}\n\n /** One of the first logs that will be printed. */\n dependencyGraphLoading(hasReducedPerformance: boolean): void {}\n\n /**\n * Custom log event representing the end of the bundling.\n *\n * @param event event object.\n * @param duration duration of the build in milliseconds.\n */\n bundleBuildEnded(event: TerminalReportableEvent, duration: number): void {}\n\n /**\n * This function is exclusively concerned with updating the internal state.\n * No logging or status updates should be done at this point.\n */\n _updateState(\n event: TerminalReportableEvent & { bundleDetails?: BundleDetails; buildID?: string }\n ) {\n // Append the buildID to the bundleDetails.\n if (event.bundleDetails) {\n event.bundleDetails.buildID = event.buildID;\n }\n\n const buildID = event.bundleDetails?.buildID ?? event.buildID;\n\n if (buildID && !this._hiddenBundleEvents.has(buildID)) {\n if (this.shouldFilterBundleEvent(event)) {\n debug('skipping bundle events for', buildID, event);\n this._hiddenBundleEvents.add(buildID);\n } else {\n super._updateState(event);\n }\n } else {\n super._updateState(event);\n }\n\n switch (event.type) {\n case 'bundle_build_done':\n case 'bundle_build_failed': {\n const startTime = this._bundleTimers.get(event.buildID);\n // Observed a bug in Metro where the `bundle_build_done` is invoked twice during a static bundle\n // i.e. `expo export`.\n if (startTime == null) {\n break;\n }\n\n this.bundleBuildEnded(event, startTime ? Date.now() - startTime : 0);\n this._bundleTimers.delete(event.buildID);\n break;\n }\n case 'bundle_build_started':\n this._bundleDetails.set(event.buildID, event.bundleDetails);\n this._bundleTimers.set(event.buildID, Date.now());\n break;\n }\n }\n}\n"],"names":["logWarning","logError","debug","require","terminal","format","args","str","util","log","chalk","yellow","red","supportsColor","stripAnsi","XTerminalReporter","UpstreamTerminalReporter","TerminalReporter","_bundleDetails","Map","_bundleTimers","_hiddenBundleEvents","Set","_log","event","type","transformCacheReset","dependencyGraphLoading","hasReducedPerformance","shouldFilterClientLog","shouldFilterBundleEvent","bundleBuildEnded","duration","_updateState","bundleDetails","buildID","has","add","startTime","get","Date","now","delete","set"],"mappings":"AAEA;;;;QAoBgBA,UAAU,GAAVA,UAAU;QAQVC,QAAQ,GAARA,QAAQ;AA5BN,IAAA,MAAO,kCAAP,OAAO,EAAA;AACY,IAAA,iBAAgC,kCAAhC,gCAAgC,EAAA;AAEpD,IAAA,KAAM,kCAAN,MAAM,EAAA;AAOG,IAAA,KAAqB,WAArB,qBAAqB,CAAA;;;;;;AAE/C,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC,AAAsB,AAAC;AAQnE,SAASH,UAAU,CAACI,QAAkB,EAAEC,MAAc,EAAE,GAAGC,IAAI,AAAO,EAAQ;IACnF,MAAMC,GAAG,GAAGC,KAAI,QAAA,CAACH,MAAM,CAACA,MAAM,KAAKC,IAAI,CAAC,AAAC;IACzCF,QAAQ,CAACK,GAAG,CAAC,QAAQ,EAAEC,MAAK,QAAA,CAACC,MAAM,CAAC,SAAS,CAAC,EAAEJ,GAAG,CAAC,CAAC;CACtD;AAKM,SAASN,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AM;qBACP;oBAED,IAAI,CAACP,gBAAgB,CAACP,KAAK,EAAEc,SAAS,GAAGE,IAAI,CAACC,GAAG,EAAE,GAAGH,SAAS,GAAG,CAAC,CAAC,CAAC;oBACrE,IAAI,CAAClB,aAAa,CAACsB,MAAM,CAAClB,KAAK,CAACW,OAAO,CAAC,CAAC;oBACzC,MAAM;iBACP;YACD,KAAK,sBAAsB;gBACzB,IAAI,CAACjB,cAAc,CAACyB,GAAG,CAACnB,KAAK,CAACW,OAAO,EAAEX,KAAK,CAACU,aAAa,CAAC,CAAC;gBAC5D,IAAI,CAACd,aAAa,CAACuB,GAAG,CAACnB,KAAK,CAACW,OAAO,EAAEK,IAAI,CAACC,GAAG,EAAE,CAAC,CAAC;gBAClD,MAAM;SACT;KACF;CACF;QAtGYxB,gBAAgB,GAAhBA,gBAAgB"}
@@ -6,7 +6,7 @@ exports.bundleApiRoute = bundleApiRoute;
6
6
  exports.rebundleApiRoute = rebundleApiRoute;
7
7
  var _metroErrorInterface = require("./metroErrorInterface");
8
8
  var _getStaticRenderFunctions = require("../getStaticRenderFunctions");
9
- const debug = require("debug")("expo:server-routes");
9
+ const debug = require("debug")("expo:api-routes");
10
10
  const pendingRouteOperations = new Map();
11
11
  async function bundleApiRoute(projectRoot, filepath, options) {
12
12
  if (pendingRouteOperations.has(filepath)) {
@@ -15,12 +15,14 @@ async function bundleApiRoute(projectRoot, filepath, options) {
15
15
  const devServerUrl = `http://localhost:${options.port}`;
16
16
  async function bundleAsync() {
17
17
  try {
18
- debug("Check API route:", options.appDir, filepath);
18
+ debug("Bundle API route:", options.routerRoot, filepath);
19
19
  const middleware = await (0, _getStaticRenderFunctions).requireFileContentsWithMetro(projectRoot, devServerUrl, filepath, {
20
20
  minify: options.mode === "production",
21
21
  dev: options.mode !== "production",
22
22
  // Ensure Node.js
23
- environment: "node"
23
+ environment: "node",
24
+ baseUrl: options.baseUrl,
25
+ routerRoot: options.routerRoot
24
26
  });
25
27
  return middleware;
26
28
  } catch (error) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/bundleApiRoutes.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 */\n\nimport { logMetroErrorAsync } from './metroErrorInterface';\nimport { requireFileContentsWithMetro } from '../getStaticRenderFunctions';\n\nconst debug = require('debug')('expo:server-routes') as typeof console.log;\n\nconst pendingRouteOperations = new Map<string, Promise<string | null>>();\n\nexport type ApiRouteOptions = {\n mode?: string;\n appDir: string;\n port?: number;\n shouldThrow?: boolean;\n};\n\n// Bundle the API Route with Metro and return the string contents to be evaluated in the server.\nexport async function bundleApiRoute(\n projectRoot: string,\n filepath: string,\n options: ApiRouteOptions\n): Promise<string | null | undefined> {\n if (pendingRouteOperations.has(filepath)) {\n return pendingRouteOperations.get(filepath);\n }\n\n const devServerUrl = `http://localhost:${options.port}`;\n\n async function bundleAsync() {\n try {\n debug('Check API route:', options.appDir, filepath);\n\n const middleware = await requireFileContentsWithMetro(projectRoot, devServerUrl, filepath, {\n minify: options.mode === 'production',\n dev: options.mode !== 'production',\n // Ensure Node.js\n environment: 'node',\n });\n\n return middleware;\n } catch (error: any) {\n if (error instanceof Error) {\n await logMetroErrorAsync({ error, projectRoot });\n }\n if (options.shouldThrow) {\n throw error;\n }\n // TODO: improve error handling, maybe have this be a mock function which returns the static error html\n return null;\n } finally {\n // pendingRouteOperations.delete(filepath);\n }\n }\n const route = bundleAsync();\n\n pendingRouteOperations.set(filepath, route);\n return route;\n}\n\nexport async function rebundleApiRoute(\n projectRoot: string,\n filepath: string,\n options: ApiRouteOptions\n) {\n pendingRouteOperations.delete(filepath);\n return bundleApiRoute(projectRoot, filepath, options);\n}\n"],"names":["bundleApiRoute","rebundleApiRoute","debug","require","pendingRouteOperations","Map","projectRoot","filepath","options","has","get","devServerUrl","port","bundleAsync","appDir","middleware","requireFileContentsWithMetro","minify","mode","dev","environment","error","Error","logMetroError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,OAAO,CAACgB,WAAW,EAAE;gBACvB,MAAMH,KAAK,CAAC;aACb;YACD,uGAAuG;YACvG,OAAO,IAAI,CAAC;SACb,QAAS;QACR,2CAA2C;SAC5C;KACF;IACD,MAAMI,KAAK,GAAGZ,WAAW,EAAE,AAAC;IAE5BT,sBAAsB,CAACsB,GAAG,CAACnB,QAAQ,EAAEkB,KAAK,CAAC,CAAC;IAC5C,OAAOA,KAAK,CAAC;CACd;AAEM,eAAexB,gBAAgB,CACpCK,WAAmB,EACnBC,QAAgB,EAChBC,OAAwB,EACxB;IACAJ,sBAAsB,CAACuB,MAAM,CAACpB,QAAQ,CAAC,CAAC;IACxC,OAAOP,cAAc,CAACM,WAAW,EAAEC,QAAQ,EAAEC,OAAO,CAAC,CAAC;CACvD"}
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/bundleApiRoutes.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 */\n\nimport { logMetroErrorAsync } from './metroErrorInterface';\nimport { requireFileContentsWithMetro } from '../getStaticRenderFunctions';\n\nconst debug = require('debug')('expo:api-routes') as typeof console.log;\n\nconst pendingRouteOperations = new Map<string, Promise<string | null>>();\n\nexport type ApiRouteOptions = {\n mode?: string;\n routerRoot: string;\n port?: number;\n shouldThrow?: boolean;\n baseUrl: string;\n};\n\n// Bundle the API Route with Metro and return the string contents to be evaluated in the server.\nexport async function bundleApiRoute(\n projectRoot: string,\n filepath: string,\n options: ApiRouteOptions\n): Promise<string | null | undefined> {\n if (pendingRouteOperations.has(filepath)) {\n return pendingRouteOperations.get(filepath);\n }\n\n const devServerUrl = `http://localhost:${options.port}`;\n\n async function bundleAsync() {\n try {\n debug('Bundle API route:', options.routerRoot, filepath);\n\n const middleware = await requireFileContentsWithMetro(projectRoot, devServerUrl, filepath, {\n minify: options.mode === 'production',\n dev: options.mode !== 'production',\n // Ensure Node.js\n environment: 'node',\n baseUrl: options.baseUrl,\n routerRoot: options.routerRoot,\n });\n\n return middleware;\n } catch (error: any) {\n if (error instanceof Error) {\n await logMetroErrorAsync({ error, projectRoot });\n }\n if (options.shouldThrow) {\n throw error;\n }\n // TODO: improve error handling, maybe have this be a mock function which returns the static error html\n return null;\n } finally {\n // pendingRouteOperations.delete(filepath);\n }\n }\n const route = bundleAsync();\n\n pendingRouteOperations.set(filepath, route);\n return route;\n}\n\nexport async function rebundleApiRoute(\n projectRoot: string,\n filepath: string,\n options: ApiRouteOptions\n) {\n pendingRouteOperations.delete(filepath);\n return bundleApiRoute(projectRoot, filepath, options);\n}\n"],"names":["bundleApiRoute","rebundleApiRoute","debug","require","pendingRouteOperations","Map","projectRoot","filepath","options","has","get","devServerUrl","port","bundleAsync","routerRoot","middleware","requireFileContentsWithMetro","minify","mode","dev","environment","baseUrl","error","Error","logMetroErrorAsync","shouldThrow","route","set","delete"],"mappings":"AAOA;;;;QAgBsBA,cAAc,GAAdA,cAAc;QA4CdC,gBAAgB,GAAhBA,gBAAgB;AA5DH,IAAA,oBAAuB,WAAvB,uBAAuB,CAAA;AACb,IAAA,yBAA6B,WAA7B,6BAA6B,CAAA;AAE1E,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,iBAAiB,CAAC,AAAsB,AAAC;AAExE,MAAMC,sBAAsB,GAAG,IAAIC,GAAG,EAAkC,AAAC;AAWlE,eAAeL,cAAc,CAClCM,WAAmB,EACnBC,QAAgB,EAChBC,OAAwB,EACY;IACpC,IAAIJ,sBAAsB,CAACK,GAAG,CAACF,QAAQ,CAAC,EAAE;QACxC,OAAOH,sBAAsB,CAACM,GAAG,CAACH,QAAQ,CAAC,CAAC;KAC7C;IAED,MAAMI,YAAY,GAAG,CAAC,iBAAiB,EAAEH,OAAO,CAACI,IAAI,CAAC,CAAC,AAAC;IAExD,eAAeC,WAAW,GAAG;QAC3B,IAAI;YACFX,KAAK,CAAC,mBAAmB,EAAEM,OAAO,CAACM,UAAU,EAAEP,QAAQ,CAAC,CAAC;YAEzD,MAAMQ,UAAU,GAAG,MAAMC,CAAAA,GAAAA,yBAA4B,AAOnD,CAAA,6BAPmD,CAACV,WAAW,EAAEK,YAAY,EAAEJ,QAAQ,EAAE;gBACzFU,MAAM,EAAET,OAAO,CAACU,IAAI,KAAK,YAAY;gBACrCC,GAAG,EAAEX,OAAO,CAACU,IAAI,KAAK,YAAY;gBAClC,iBAAiB;gBACjBE,WAAW,EAAE,MAAM;gBACnBC,OAAO,EAAEb,OAAO,CAACa,OAAO;gBACxBP,UAAU,EAAEN,OAAO,CAACM,UAAU;aAC/B,CAAC,AAAC;YAEH,OAAOC,UAAU,CAAC;SACnB,CAAC,OAAOO,KAAK,EAAO;YACnB,IAAIA,KAAK,YAAYC,KAAK,EAAE;gBAC1B,MAAMC,CAAAA,GAAAA,oBAAkB,AAAwB,CAAA,mBAAxB,CAAC;oBAAEF,KAAK;oBAAEhB,WAAW;iBAAE,CAAC,CAAC;aAClD;YACD,IAAIE,OAAO,CAACiB,WAAW,EAAE;gBACvB,MAAMH,KAAK,CAAC;aACb;YACD,uGAAuG;YACvG,OAAO,IAAI,CAAC;SACb,QAAS;QACR,2CAA2C;SAC5C;KACF;IACD,MAAMI,KAAK,GAAGb,WAAW,EAAE,AAAC;IAE5BT,sBAAsB,CAACuB,GAAG,CAACpB,QAAQ,EAAEmB,KAAK,CAAC,CAAC;IAC5C,OAAOA,KAAK,CAAC;CACd;AAEM,eAAezB,gBAAgB,CACpCK,WAAmB,EACnBC,QAAgB,EAChBC,OAAwB,EACxB;IACAJ,sBAAsB,CAACwB,MAAM,CAACrB,QAAQ,CAAC,CAAC;IACxC,OAAOP,cAAc,CAACM,WAAW,EAAEC,QAAQ,EAAEC,OAAO,CAAC,CAAC;CACvD"}
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.createFastResolver = createFastResolver;
6
+ var _fs = _interopRequireDefault(require("fs"));
6
7
  var _path = _interopRequireDefault(require("path"));
7
- var _resolve = _interopRequireDefault(require("resolve"));
8
+ var _createJResolver = _interopRequireDefault(require("./createJResolver"));
8
9
  var _externals = require("./externals");
9
10
  var _formatFileCandidates = require("./formatFileCandidates");
10
- var _errors = require("../../../utils/errors");
11
11
  function _interopRequireDefault(obj) {
12
12
  return obj && obj.__esModule ? obj : {
13
13
  default: obj
@@ -17,7 +17,18 @@ class FailedToResolvePathError extends Error {
17
17
  }
18
18
  class ShimModuleError extends Error {
19
19
  }
20
- function createFastResolver({ preserveSymlinks }) {
20
+ const realpathFS = process.platform !== "win32" && _fs.default.realpathSync && typeof _fs.default.realpathSync.native === "function" ? _fs.default.realpathSync.native : _fs.default.realpathSync;
21
+ function realpathSync(x) {
22
+ try {
23
+ return realpathFS(x);
24
+ } catch (realpathErr) {
25
+ if (realpathErr.code !== "ENOENT") {
26
+ throw realpathErr;
27
+ }
28
+ }
29
+ return x;
30
+ }
31
+ function createFastResolver({ preserveSymlinks , blockList }) {
21
32
  const cachedExtensions = new Map();
22
33
  function getAdjustedExtensions({ metroSourceExtensions , platform , isNative }) {
23
34
  const key = JSON.stringify({
@@ -49,12 +60,6 @@ function createFastResolver({ preserveSymlinks }) {
49
60
  }
50
61
  function fastResolve(context, moduleName, platform) {
51
62
  var ref2;
52
- // TODO: Support extraNodeModules for tsconfig basePath support
53
- // TODO: Support package exports import { resolve as resolveExports } from 'resolve.exports'
54
- // TODO: Support `resolver.blockList`
55
- if (context.unstable_enablePackageExports) {
56
- throw new _errors.CommandError("package exports are not supported with EXPO_USE_FAST_RESOLVER=1");
57
- }
58
63
  const environment = (ref2 = context.customResolverOptions) == null ? void 0 : ref2.environment;
59
64
  const isServer = environment === "node";
60
65
  const extensions = getAdjustedExtensions({
@@ -64,18 +69,29 @@ function createFastResolver({ preserveSymlinks }) {
64
69
  });
65
70
  let fp;
66
71
  try {
67
- fp = _resolve.default.sync(moduleName, {
72
+ var _platform;
73
+ const conditions = context.unstable_enablePackageExports ? [
74
+ ...new Set([
75
+ "default",
76
+ ...context.unstable_conditionNames,
77
+ ...platform != null ? (_platform = context.unstable_conditionsByPlatform[platform]) != null ? _platform : [] : [],
78
+ ]),
79
+ ] : [];
80
+ fp = (0, _createJResolver).default(moduleName, {
81
+ blockList,
82
+ enablePackageExports: context.unstable_enablePackageExports,
68
83
  basedir: _path.default.dirname(context.originModulePath),
84
+ paths: context.nodeModulesPaths.length ? context.nodeModulesPaths : undefined,
69
85
  extensions,
70
- // Used to ensure files trace to packages instead of node_modules in expo/expo. This is how Metro works and
71
- // the app doesn't finish without it.
72
- preserveSymlinks,
73
- readPackageSync (readFileSync, pkgFile) {
74
- var ref;
75
- return (ref = context.getPackage(pkgFile)) != null ? ref : JSON.parse(// @ts-expect-error
76
- readFileSync(pkgfile));
86
+ conditions,
87
+ realpathSync (file) {
88
+ // @ts-expect-error: Missing on type.
89
+ const metroRealPath = context.unstable_getRealPath == null ? void 0 : context.unstable_getRealPath(file);
90
+ if (metroRealPath == null && preserveSymlinks) {
91
+ return realpathSync(file);
92
+ }
93
+ return metroRealPath != null ? metroRealPath : file;
77
94
  },
78
- moduleDirectory: context.nodeModulesPaths,
79
95
  packageFilter (pkg) {
80
96
  // set the pkg.main to the first available field in context.mainFields
81
97
  for (const field of context.mainFields){
@@ -89,7 +105,17 @@ function createFastResolver({ preserveSymlinks }) {
89
105
  }
90
106
  return pkg;
91
107
  },
92
- pathFilter: isServer ? undefined : (pkg, _resolvedPath, relativePathIn)=>{
108
+ // Used to ensure files trace to packages instead of node_modules in expo/expo. This is how Metro works and
109
+ // the app doesn't finish without it.
110
+ preserveSymlinks,
111
+ readPackageSync (readFileSync, pkgFile) {
112
+ var ref;
113
+ return (ref = context.getPackage(pkgFile)) != null ? ref : JSON.parse(// @ts-expect-error
114
+ readFileSync(pkgfile));
115
+ },
116
+ includeCoreModules: isServer,
117
+ pathFilter: // Disable `browser` field for server environments.
118
+ isServer ? undefined : (pkg, _resolvedPath, relativePathIn)=>{
93
119
  let relativePath = relativePathIn;
94
120
  if (relativePath[0] !== ".") {
95
121
  relativePath = `./${relativePath}`;
@@ -106,17 +132,8 @@ function createFastResolver({ preserveSymlinks }) {
106
132
  throw new ShimModuleError();
107
133
  }
108
134
  return mappedPath;
109
- },
110
- // Not needed but added for parity...
111
- // @ts-ignore
112
- realpathSync: context.unstable_getRealPath
135
+ }
113
136
  });
114
- if (!isServer && (0, _externals).isNodeExternal(fp)) {
115
- // In this case, mock the file to use an empty module.
116
- return {
117
- type: "empty"
118
- };
119
- }
120
137
  } catch (error) {
121
138
  if (error instanceof ShimModuleError) {
122
139
  return {
@@ -124,12 +141,17 @@ function createFastResolver({ preserveSymlinks }) {
124
141
  };
125
142
  }
126
143
  if ("code" in error && error.code === "MODULE_NOT_FOUND") {
127
- // TODO: Add improved error handling.
144
+ if ((0, _externals).isNodeExternal(moduleName)) {
145
+ // In this case, mock the file to use an empty module.
146
+ return {
147
+ type: "empty"
148
+ };
149
+ }
128
150
  throw new FailedToResolvePathError("The module could not be resolved because no file or module matched the pattern:\n" + ` ${(0, _formatFileCandidates).formatFileCandidates({
129
151
  type: "sourceFile",
130
152
  filePathPrefix: moduleName,
131
153
  candidateExts: extensions
132
- }, true)}\n\n`);
154
+ }, true)}\n\nFrom:\n ${context.originModulePath}\n`);
133
155
  }
134
156
  throw error;
135
157
  }
@@ -139,30 +161,42 @@ function createFastResolver({ preserveSymlinks }) {
139
161
  type: "sourceFile",
140
162
  filePath: fp
141
163
  };
142
- } else {
143
- // NOTE: platform extensions may not be supported on assets.
144
- if (platform === "web") {
145
- // Skip multi-resolution on web/server bundles. Only consideration here is that
146
- // we may still need it in case the only image is a multi-resolution image.
164
+ }
165
+ if ((0, _externals).isNodeExternal(fp)) {
166
+ if (isServer) {
147
167
  return {
148
- type: "assetFiles",
149
- filePaths: [
150
- fp
151
- ]
168
+ type: "sourceFile",
169
+ filePath: fp
152
170
  };
153
171
  }
154
- const dirPath = _path.default.dirname(fp);
155
- const extension = _path.default.extname(fp);
156
- const basename = _path.default.basename(fp, extension);
157
- var ref1;
172
+ // NOTE: This shouldn't happen, the module should throw.
173
+ // Mock non-server built-in modules to empty.
174
+ return {
175
+ type: "empty"
176
+ };
177
+ }
178
+ // NOTE: platform extensions may not be supported on assets.
179
+ if (platform === "web") {
180
+ // Skip multi-resolution on web/server bundles. Only consideration here is that
181
+ // we may still need it in case the only image is a multi-resolution image.
158
182
  return {
159
183
  type: "assetFiles",
160
- // Support multi-resolution asset extensions...
161
- filePaths: (ref1 = context.resolveAsset(dirPath, basename, extension)) != null ? ref1 : [
184
+ filePaths: [
162
185
  fp
163
186
  ]
164
187
  };
165
188
  }
189
+ const dirPath = _path.default.dirname(fp);
190
+ const extension = _path.default.extname(fp);
191
+ const basename = _path.default.basename(fp, extension);
192
+ var ref1;
193
+ return {
194
+ type: "assetFiles",
195
+ // Support multi-resolution asset extensions...
196
+ filePaths: (ref1 = context.resolveAsset(dirPath, basename, extension)) != null ? ref1 : [
197
+ fp
198
+ ]
199
+ };
166
200
  }
167
201
  return fastResolve;
168
202
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/createExpoMetroResolver.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 { Resolution, ResolutionContext } from 'metro-resolver';\nimport path from 'path';\nimport nodeResolve from 'resolve';\n\nimport { isNodeExternal } from './externals';\nimport { formatFileCandidates } from './formatFileCandidates';\nimport { CommandError } from '../../../utils/errors';\n\nclass FailedToResolvePathError extends Error {}\n\nclass ShimModuleError extends Error {}\n\nexport function createFastResolver({ preserveSymlinks }: { preserveSymlinks: boolean }) {\n const cachedExtensions: Map<string, readonly string[]> = new Map();\n\n function getAdjustedExtensions({\n metroSourceExtensions,\n platform,\n isNative,\n }: {\n metroSourceExtensions: readonly string[];\n platform: string | null;\n isNative: boolean;\n }): readonly string[] {\n const key = JSON.stringify({ metroSourceExtensions, platform, isNative });\n if (cachedExtensions.has(key)) {\n return cachedExtensions.get(key)!;\n }\n\n let output = metroSourceExtensions;\n if (platform) {\n const nextOutput: string[] = [];\n\n output.forEach((ext) => {\n nextOutput.push(`${platform}.${ext}`);\n if (isNative) {\n nextOutput.push(`native.${ext}`);\n }\n nextOutput.push(ext);\n });\n\n output = nextOutput;\n }\n\n output = Array.from(new Set<string>(output));\n\n // resolve expects these to start with a dot.\n output = output.map((ext) => `.${ext}`);\n\n cachedExtensions.set(key, output);\n\n return output;\n }\n\n function fastResolve(\n context: Pick<\n ResolutionContext,\n | 'unstable_enablePackageExports'\n | 'customResolverOptions'\n | 'sourceExts'\n | 'preferNativePlatform'\n | 'originModulePath'\n | 'getPackage'\n | 'nodeModulesPaths'\n | 'mainFields'\n | 'resolveAsset'\n >,\n moduleName: string,\n platform: string | null\n ): Resolution {\n // TODO: Support extraNodeModules for tsconfig basePath support\n // TODO: Support package exports import { resolve as resolveExports } from 'resolve.exports'\n // TODO: Support `resolver.blockList`\n if (context.unstable_enablePackageExports) {\n throw new CommandError('package exports are not supported with EXPO_USE_FAST_RESOLVER=1');\n }\n\n const environment = context.customResolverOptions?.environment;\n const isServer = environment === 'node';\n\n const extensions = getAdjustedExtensions({\n metroSourceExtensions: context.sourceExts,\n platform,\n isNative: context.preferNativePlatform,\n });\n\n let fp: string;\n\n try {\n fp = nodeResolve.sync(moduleName, {\n basedir: path.dirname(context.originModulePath),\n extensions,\n // Used to ensure files trace to packages instead of node_modules in expo/expo. This is how Metro works and\n // the app doesn't finish without it.\n preserveSymlinks,\n readPackageSync(readFileSync, pkgFile) {\n return (\n context.getPackage(pkgFile) ??\n JSON.parse(\n // @ts-expect-error\n readFileSync(pkgfile)\n )\n );\n },\n moduleDirectory: context.nodeModulesPaths,\n packageFilter(pkg) {\n // set the pkg.main to the first available field in context.mainFields\n for (const field of context.mainFields) {\n if (\n pkg[field] &&\n // object-inspect uses browser: {} in package.json\n typeof pkg[field] === 'string'\n ) {\n return {\n ...pkg,\n main: pkg[field],\n };\n }\n }\n return pkg;\n },\n\n pathFilter: isServer\n ? undefined\n : (pkg: any, _resolvedPath: string, relativePathIn: string): string => {\n let relativePath = relativePathIn;\n if (relativePath[0] !== '.') {\n relativePath = `./${relativePath}`;\n }\n\n const replacements = pkg.browser;\n if (replacements === undefined) {\n return '';\n }\n\n // TODO: Probably use a better extension matching system here.\n // This was added for `uuid/v4` -> `./lib/rng` -> `./lib/rng-browser.js`\n const mappedPath = replacements[relativePath] ?? replacements[relativePath + '.js'];\n if (mappedPath === false) {\n throw new ShimModuleError();\n }\n return mappedPath;\n },\n\n // Not needed but added for parity...\n\n // @ts-ignore\n realpathSync: context.unstable_getRealPath,\n });\n\n if (!isServer && isNodeExternal(fp)) {\n // In this case, mock the file to use an empty module.\n return {\n type: 'empty',\n };\n }\n } catch (error: any) {\n if (error instanceof ShimModuleError) {\n return {\n type: 'empty',\n };\n }\n\n if ('code' in error && error.code === 'MODULE_NOT_FOUND') {\n // TODO: Add improved error handling.\n throw new FailedToResolvePathError(\n 'The module could not be resolved because no file or module matched the pattern:\\n' +\n ` ${formatFileCandidates(\n {\n type: 'sourceFile',\n filePathPrefix: moduleName,\n candidateExts: extensions,\n },\n true\n )}\\n\\n`\n );\n }\n throw error;\n }\n\n if (context.sourceExts.some((ext) => fp.endsWith(ext))) {\n return {\n type: 'sourceFile',\n filePath: fp,\n };\n } else {\n // NOTE: platform extensions may not be supported on assets.\n\n if (platform === 'web') {\n // Skip multi-resolution on web/server bundles. Only consideration here is that\n // we may still need it in case the only image is a multi-resolution image.\n return {\n type: 'assetFiles',\n filePaths: [fp],\n };\n }\n\n const dirPath = path.dirname(fp);\n const extension = path.extname(fp);\n const basename = path.basename(fp, extension);\n return {\n type: 'assetFiles',\n // Support multi-resolution asset extensions...\n filePaths: context.resolveAsset(dirPath, basename, extension) ?? [fp],\n };\n }\n }\n\n return fastResolve;\n}\n"],"names":["createFastResolver","FailedToResolvePathError","Error","ShimModuleError","preserveSymlinks","cachedExtensions","Map","getAdjustedExtensions","metroSourceExtensions","platform","isNative","key","JSON","stringify","has","get","output","nextOutput","forEach","ext","push","Array","from","Set","map","set","fastResolve","context","moduleName","unstable_enablePackageExports","CommandError","environment","customResolverOptions","isServer","extensions","sourceExts","preferNativePlatform","fp","nodeResolve","sync","basedir","path","dirname","originModulePath","readPackageSync","readFileSync","pkgFile","getPackage","parse","pkgfile","moduleDirectory","nodeModulesPaths","packageFilter","pkg","field","mainFields","main","pathFilter","undefined","_resolvedPath","relativePathIn","relativePath","replacements","browser","mappedPath","realpathSync","unstable_getRealPath","isNodeExternal","type","error","code","formatFileCandidates","filePathPrefix","candidateExts","some","endsWith","filePath","filePaths","dirPath","extension","extname","basename","resolveAsset"],"mappings":"AAMA;;;;QAYgBA,kBAAkB,GAAlBA,kBAAkB;AAXjB,IAAA,KAAM,kCAAN,MAAM,EAAA;AACC,IAAA,QAAS,kCAAT,SAAS,EAAA;AAEF,IAAA,UAAa,WAAb,aAAa,CAAA;AACP,IAAA,qBAAwB,WAAxB,wBAAwB,CAAA;AAChC,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;;;;;;AAEpD,MAAMC,wBAAwB,SAASC,KAAK;CAAG;AAE/C,MAAMC,eAAe,SAASD,KAAK;CAAG;AAE/B,SAASF,kBAAkB,CAAC,EAAEI,gBAAgB,CAAA,EAAiC,EAAE;IACtF,MAAMC,gBAAgB,GAAmC,IAAIC,GAAG,EAAE,AAAC;IAEnE,SAASC,qBAAqB,CAAC,EAC7BC,qBAAqB,CAAA,EACrBC,QAAQ,CAAA,EACRC,QAAQ,CAAA,EAKT,EAAqB;QACpB,MAAMC,GAAG,GAAGC,IAAI,CAACC,SAAS,CAAC;YAAEL,qBAAqB;YAAEC,QAAQ;YAAEC,QAAQ;SAAE,CAAC,AAAC;QAC1E,IAAIL,gBAAgB,CAACS,GAAG,CAACH,GAAG,CAAC,EAAE;YAC7B,OAAON,gBAAgB,CAACU,GAAG,CAACJ,GAAG,CAAC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,IAAI,CAAC,CACV,CAAC;aACH;YACD,MAAMmC,KAAK,CAAC;SACb;QAED,IAAI1C,OAAO,CAACQ,UAAU,CAACuC,IAAI,CAAC,CAACvD,GAAG,GAAKkB,EAAE,CAACsC,QAAQ,CAACxD,GAAG,CAAC;QAAA,CAAC,EAAE;YACtD,OAAO;gBACLiD,IAAI,EAAE,YAAY;gBAClBQ,QAAQ,EAAEvC,EAAE;aACb,CAAC;SACH,MAAM;YACL,4DAA4D;YAE5D,IAAI5B,QAAQ,KAAK,KAAK,EAAE;gBACtB,+EAA+E;gBAC/E,2EAA2E;gBAC3E,OAAO;oBACL2D,IAAI,EAAE,YAAY;oBAClBS,SAAS,EAAE;wBAACxC,EAAE;qBAAC;iBAChB,CAAC;aACH;YAED,MAAMyC,OAAO,GAAGrC,KAAI,QAAA,CAACC,OAAO,CAACL,EAAE,CAAC,AAAC;YACjC,MAAM0C,SAAS,GAAGtC,KAAI,QAAA,CAACuC,OAAO,CAAC3C,EAAE,CAAC,AAAC;YACnC,MAAM4C,QAAQ,GAAGxC,KAAI,QAAA,CAACwC,QAAQ,CAAC5C,EAAE,EAAE0C,SAAS,CAAC,AAAC;gBAIjCpD,IAAkD;YAH/D,OAAO;gBACLyC,IAAI,EAAE,YAAY;gBAClB,+CAA+C;gBAC/CS,SAAS,EAAElD,CAAAA,IAAkD,GAAlDA,OAAO,CAACuD,YAAY,CAACJ,OAAO,EAAEG,QAAQ,EAAEF,SAAS,CAAC,YAAlDpD,IAAkD,GAAI;oBAACU,EAAE;iBAAC;aACtE,CAAC;SACH;KACF;IAED,OAAOX,WAAW,CAAC;CACpB"}
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/createExpoMetroResolver.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 fs from 'fs';\nimport { Resolution, ResolutionContext } from 'metro-resolver';\nimport path from 'path';\n\nimport jestResolver from './createJResolver';\nimport { isNodeExternal } from './externals';\nimport { formatFileCandidates } from './formatFileCandidates';\n\nclass FailedToResolvePathError extends Error {}\n\nclass ShimModuleError extends Error {}\n\nconst realpathFS =\n process.platform !== 'win32' && fs.realpathSync && typeof fs.realpathSync.native === 'function'\n ? fs.realpathSync.native\n : fs.realpathSync;\n\nfunction realpathSync(x: string) {\n try {\n return realpathFS(x);\n } catch (realpathErr: any) {\n if (realpathErr.code !== 'ENOENT') {\n throw realpathErr;\n }\n }\n return x;\n}\n\nexport function createFastResolver({\n preserveSymlinks,\n blockList,\n}: {\n preserveSymlinks: boolean;\n blockList: RegExp[];\n}) {\n const cachedExtensions: Map<string, readonly string[]> = new Map();\n\n function getAdjustedExtensions({\n metroSourceExtensions,\n platform,\n isNative,\n }: {\n metroSourceExtensions: readonly string[];\n platform: string | null;\n isNative: boolean;\n }): readonly string[] {\n const key = JSON.stringify({ metroSourceExtensions, platform, isNative });\n if (cachedExtensions.has(key)) {\n return cachedExtensions.get(key)!;\n }\n\n let output = metroSourceExtensions;\n if (platform) {\n const nextOutput: string[] = [];\n\n output.forEach((ext) => {\n nextOutput.push(`${platform}.${ext}`);\n if (isNative) {\n nextOutput.push(`native.${ext}`);\n }\n nextOutput.push(ext);\n });\n\n output = nextOutput;\n }\n\n output = Array.from(new Set<string>(output));\n\n // resolve expects these to start with a dot.\n output = output.map((ext) => `.${ext}`);\n\n cachedExtensions.set(key, output);\n\n return output;\n }\n\n function fastResolve(\n context: Pick<\n ResolutionContext,\n | 'unstable_enablePackageExports'\n | 'customResolverOptions'\n | 'sourceExts'\n | 'preferNativePlatform'\n | 'originModulePath'\n | 'getPackage'\n | 'nodeModulesPaths'\n | 'mainFields'\n | 'resolveAsset'\n | 'unstable_conditionNames'\n | 'unstable_conditionsByPlatform'\n >,\n moduleName: string,\n platform: string | null\n ): Resolution {\n const environment = context.customResolverOptions?.environment;\n const isServer = environment === 'node';\n\n const extensions = getAdjustedExtensions({\n metroSourceExtensions: context.sourceExts,\n platform,\n isNative: context.preferNativePlatform,\n }) as string[];\n\n let fp: string;\n\n try {\n const conditions = context.unstable_enablePackageExports\n ? [\n ...new Set([\n 'default',\n ...context.unstable_conditionNames,\n ...(platform != null ? context.unstable_conditionsByPlatform[platform] ?? [] : []),\n ]),\n ]\n : [];\n\n fp = jestResolver(moduleName, {\n blockList,\n enablePackageExports: context.unstable_enablePackageExports,\n basedir: path.dirname(context.originModulePath),\n paths: context.nodeModulesPaths.length ? (context.nodeModulesPaths as string[]) : undefined,\n extensions,\n conditions,\n realpathSync(file: string): string {\n // @ts-expect-error: Missing on type.\n const metroRealPath = context.unstable_getRealPath?.(file);\n if (metroRealPath == null && preserveSymlinks) {\n return realpathSync(file);\n }\n return metroRealPath ?? file;\n },\n packageFilter(pkg) {\n // set the pkg.main to the first available field in context.mainFields\n for (const field of context.mainFields) {\n if (\n pkg[field] &&\n // object-inspect uses browser: {} in package.json\n typeof pkg[field] === 'string'\n ) {\n return {\n ...pkg,\n main: pkg[field],\n };\n }\n }\n return pkg;\n },\n // Used to ensure files trace to packages instead of node_modules in expo/expo. This is how Metro works and\n // the app doesn't finish without it.\n preserveSymlinks,\n readPackageSync(readFileSync, pkgFile) {\n return (\n context.getPackage(pkgFile) ??\n JSON.parse(\n // @ts-expect-error\n readFileSync(pkgfile)\n )\n );\n },\n includeCoreModules: isServer,\n\n pathFilter:\n // Disable `browser` field for server environments.\n isServer\n ? undefined\n : // Enable `browser` field support\n (pkg: any, _resolvedPath: string, relativePathIn: string): string => {\n let relativePath = relativePathIn;\n if (relativePath[0] !== '.') {\n relativePath = `./${relativePath}`;\n }\n\n const replacements = pkg.browser;\n if (replacements === undefined) {\n return '';\n }\n\n // TODO: Probably use a better extension matching system here.\n // This was added for `uuid/v4` -> `./lib/rng` -> `./lib/rng-browser.js`\n const mappedPath = replacements[relativePath] ?? replacements[relativePath + '.js'];\n if (mappedPath === false) {\n throw new ShimModuleError();\n }\n return mappedPath;\n },\n });\n } catch (error: any) {\n if (error instanceof ShimModuleError) {\n return {\n type: 'empty',\n };\n }\n\n if ('code' in error && error.code === 'MODULE_NOT_FOUND') {\n if (isNodeExternal(moduleName)) {\n // In this case, mock the file to use an empty module.\n return {\n type: 'empty',\n };\n }\n\n throw new FailedToResolvePathError(\n 'The module could not be resolved because no file or module matched the pattern:\\n' +\n ` ${formatFileCandidates(\n {\n type: 'sourceFile',\n filePathPrefix: moduleName,\n candidateExts: extensions,\n },\n true\n )}\\n\\nFrom:\\n ${context.originModulePath}\\n`\n );\n }\n throw error;\n }\n\n if (context.sourceExts.some((ext) => fp.endsWith(ext))) {\n return {\n type: 'sourceFile',\n filePath: fp,\n };\n }\n\n if (isNodeExternal(fp)) {\n if (isServer) {\n return {\n type: 'sourceFile',\n filePath: fp,\n };\n }\n // NOTE: This shouldn't happen, the module should throw.\n // Mock non-server built-in modules to empty.\n return {\n type: 'empty',\n };\n }\n\n // NOTE: platform extensions may not be supported on assets.\n\n if (platform === 'web') {\n // Skip multi-resolution on web/server bundles. Only consideration here is that\n // we may still need it in case the only image is a multi-resolution image.\n return {\n type: 'assetFiles',\n filePaths: [fp],\n };\n }\n\n const dirPath = path.dirname(fp);\n const extension = path.extname(fp);\n const basename = path.basename(fp, extension);\n return {\n type: 'assetFiles',\n // Support multi-resolution asset extensions...\n filePaths: context.resolveAsset(dirPath, basename, extension) ?? [fp],\n };\n }\n\n return fastResolve;\n}\n"],"names":["createFastResolver","FailedToResolvePathError","Error","ShimModuleError","realpathFS","process","platform","fs","realpathSync","native","x","realpathErr","code","preserveSymlinks","blockList","cachedExtensions","Map","getAdjustedExtensions","metroSourceExtensions","isNative","key","JSON","stringify","has","get","output","nextOutput","forEach","ext","push","Array","from","Set","map","set","fastResolve","context","moduleName","environment","customResolverOptions","isServer","extensions","sourceExts","preferNativePlatform","fp","conditions","unstable_enablePackageExports","unstable_conditionNames","unstable_conditionsByPlatform","jestResolver","enablePackageExports","basedir","path","dirname","originModulePath","paths","nodeModulesPaths","length","undefined","file","metroRealPath","unstable_getRealPath","packageFilter","pkg","field","mainFields","main","readPackageSync","readFileSync","pkgFile","getPackage","parse","pkgfile","includeCoreModules","pathFilter","_resolvedPath","relativePathIn","relativePath","replacements","browser","mappedPath","error","type","isNodeExternal","formatFileCandidates","filePathPrefix","candidateExts","some","endsWith","filePath","filePaths","dirPath","extension","extname","basename","resolveAsset"],"mappings":"AAMA;;;;QA4BgBA,kBAAkB,GAAlBA,kBAAkB;AA5BnB,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAEF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEE,IAAA,gBAAmB,kCAAnB,mBAAmB,EAAA;AACb,IAAA,UAAa,WAAb,aAAa,CAAA;AACP,IAAA,qBAAwB,WAAxB,wBAAwB,CAAA;;;;;;AAE7D,MAAMC,wBAAwB,SAASC,KAAK;CAAG;AAE/C,MAAMC,eAAe,SAASD,KAAK;CAAG;AAEtC,MAAME,UAAU,GACdC,OAAO,CAACC,QAAQ,KAAK,OAAO,IAAIC,GAAE,QAAA,CAACC,YAAY,IAAI,OAAOD,GAAE,QAAA,CAACC,YAAY,CAACC,MAAM,KAAK,UAAU,GAC3FF,GAAE,QAAA,CAACC,YAAY,CAACC,MAAM,GACtBF,GAAE,QAAA,CAACC,YAAY,AAAC;AAEtB,SAASA,YAAY,CAACE,CAAS,EAAE;IAC/B,IAAI;QACF,OAAON,UAAU,CAACM,CAAC,CAAC,CAAC;KACtB,CAAC,OAAOC,WAAW,EAAO;QACzB,IAAIA,WAAW,CAACC,IAAI,KAAK,QAAQ,EAAE;YACjC,MAAMD,WAAW,CAAC;SACnB;KACF;IACD,OAAOD,CAAC,CAAC;CACV;AAEM,SAASV,kBAAkB,CAAC,EACjCa,gBAAgB,CAAA,EAChBC,SAAS,CAAA,EAIV,EAAE;IACD,MAAMC,gBAAgB,GAAmC,IAAIC,GAAG,EAAE,AAAC;IAEnE,SAASC,qBAAqB,CAAC,EAC7BC,qBAAqB,CAAA,EACrBZ,QAAQ,CAAA,EACRa,QA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