@expo/cli 54.1.0-canary-20251023-4c86f95 → 54.1.0-canary-20260119-17896bf
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/add-module.js +4 -1
- package/build/bin/cli +3 -1
- package/build/bin/cli.map +1 -1
- package/build/src/export/embed/exportEmbedAsync.js +1 -2
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/install/applyPlugins.js +2 -1
- package/build/src/install/applyPlugins.js.map +1 -1
- package/build/src/install/fixPackages.js +1 -1
- package/build/src/install/fixPackages.js.map +1 -1
- package/build/src/install/installAsync.js +1 -1
- package/build/src/install/installAsync.js.map +1 -1
- package/build/src/install/utils/parsePackageSpecifier.js +24 -0
- package/build/src/install/utils/parsePackageSpecifier.js.map +1 -0
- package/build/src/run/ios/runIosAsync.js +8 -0
- package/build/src/run/ios/runIosAsync.js.map +1 -1
- package/build/src/start/interface/commandsTable.js.map +1 -1
- package/build/src/start/interface/interactiveActions.js +14 -9
- package/build/src/start/interface/interactiveActions.js.map +1 -1
- package/build/src/start/interface/startInterface.js +3 -0
- package/build/src/start/interface/startInterface.js.map +1 -1
- package/build/src/start/platforms/android/adb.js +1 -1
- package/build/src/start/platforms/android/adb.js.map +1 -1
- package/build/src/start/server/DevToolsPluginManager.js +8 -4
- package/build/src/start/server/DevToolsPluginManager.js.map +1 -1
- package/build/src/start/server/MCP.js +28 -5
- package/build/src/start/server/MCP.js.map +1 -1
- package/build/src/start/server/UrlCreator.js +1 -1
- package/build/src/start/server/UrlCreator.js.map +1 -1
- package/build/src/start/server/metro/DevToolsPluginWebsocketEndpoint.js +10 -2
- package/build/src/start/server/metro/DevToolsPluginWebsocketEndpoint.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +29 -155
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/MetroTerminalReporter.js +151 -33
- package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
- package/build/src/start/server/metro/createExpoAutolinkingResolver.js +1 -3
- package/build/src/start/server/metro/createExpoAutolinkingResolver.js.map +1 -1
- package/build/src/start/server/metro/createExpoFallbackResolver.js +1 -3
- package/build/src/start/server/metro/createExpoFallbackResolver.js.map +1 -1
- package/build/src/start/server/metro/createServerComponentsMiddleware.js +1 -2
- package/build/src/start/server/metro/createServerComponentsMiddleware.js.map +1 -1
- package/build/src/start/server/metro/createServerRouteMiddleware.js +2 -2
- package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
- package/build/src/start/server/metro/debugging/createDebugMiddleware.js +23 -9
- package/build/src/start/server/metro/debugging/createDebugMiddleware.js.map +1 -1
- package/build/src/start/server/metro/dev-server/compression.js +45 -0
- package/build/src/start/server/metro/dev-server/compression.js.map +1 -0
- package/build/src/start/server/metro/dev-server/createMetroMiddleware.js +2 -2
- package/build/src/start/server/metro/dev-server/createMetroMiddleware.js.map +1 -1
- package/build/src/start/server/metro/externals.js +11 -0
- package/build/src/start/server/metro/externals.js.map +1 -1
- package/build/src/start/server/metro/fetchRouterManifest.js +1 -1
- package/build/src/start/server/metro/fetchRouterManifest.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +98 -27
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/log-box/LogBoxLog.js +7 -11
- package/build/src/start/server/metro/log-box/LogBoxLog.js.map +1 -1
- package/build/src/start/server/metro/log-box/LogBoxSymbolication.js.map +1 -1
- package/build/src/start/server/metro/metroErrorInterface.js +43 -14
- package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +74 -57
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/middleware/CorsMiddleware.js +43 -12
- package/build/src/start/server/middleware/CorsMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/CreateFileMiddleware.js +63 -24
- package/build/src/start/server/middleware/CreateFileMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js +3 -1
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +14 -9
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/startAsync.js +12 -9
- package/build/src/start/startAsync.js.map +1 -1
- package/build/src/utils/env.js +36 -2
- package/build/src/utils/env.js.map +1 -1
- package/build/src/utils/interactive.js +1 -1
- package/build/src/utils/interactive.js.map +1 -1
- package/build/src/utils/jsonl.js +243 -0
- package/build/src/utils/jsonl.js.map +1 -0
- package/build/src/utils/net.js +43 -0
- package/build/src/utils/net.js.map +1 -0
- package/build/src/utils/progress.js +5 -0
- package/build/src/utils/progress.js.map +1 -1
- package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
- package/build/src/utils/telemetry/utils/context.js +1 -1
- package/build/src/utils/url.js +4 -8
- package/build/src/utils/url.js.map +1 -1
- package/package.json +25 -28
- package/static/canary/react-is/cjs/react-is.development.js +133 -0
- package/static/canary/react-is/cjs/react-is.production.js +130 -0
- package/static/canary/react-native/Libraries/Renderer/implementations/ReactFabric-dev.js +16820 -0
- package/static/canary/react-native/Libraries/Renderer/implementations/ReactFabric-prod.js +10552 -0
- package/static/canary/react-native/Libraries/Renderer/implementations/ReactFabric-profiling.js +11255 -0
- package/static/canary/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +17064 -0
- package/static/canary/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +10742 -0
- package/static/canary/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +11450 -0
- package/static/canary/scheduler/cjs/scheduler-unstable_mock.development.js +414 -0
- package/static/canary/scheduler/cjs/scheduler-unstable_mock.production.js +406 -0
- package/static/canary/scheduler/cjs/scheduler-unstable_post_task.development.js +150 -0
- package/static/canary/scheduler/cjs/scheduler-unstable_post_task.production.js +140 -0
- package/static/canary/scheduler/cjs/scheduler.development.js +364 -0
- package/static/canary/scheduler/cjs/scheduler.native.development.js +350 -0
- package/static/canary/scheduler/cjs/scheduler.native.production.js +330 -0
- package/static/canary/scheduler/cjs/scheduler.production.js +340 -0
- package/static/canary-full/node_modules/react/LICENSE +21 -0
- package/static/canary-full/node_modules/react/README.md +37 -0
- package/static/canary-full/node_modules/react/cjs/react-compiler-runtime.development.js +24 -0
- package/static/canary-full/node_modules/react/cjs/react-compiler-runtime.production.js +16 -0
- package/static/canary-full/node_modules/react/cjs/react-compiler-runtime.profiling.js +16 -0
- package/static/canary-full/node_modules/react/cjs/react-jsx-dev-runtime.development.js +349 -0
- package/static/canary-full/node_modules/react/cjs/react-jsx-dev-runtime.production.js +14 -0
- package/static/canary-full/node_modules/react/cjs/react-jsx-dev-runtime.profiling.js +14 -0
- package/static/canary-full/node_modules/react/cjs/react-jsx-dev-runtime.react-server.development.js +385 -0
- package/static/canary-full/node_modules/react/cjs/react-jsx-dev-runtime.react-server.production.js +40 -0
- package/static/canary-full/node_modules/react/cjs/react-jsx-runtime.development.js +358 -0
- package/static/canary-full/node_modules/react/cjs/react-jsx-runtime.production.js +34 -0
- package/static/canary-full/node_modules/react/cjs/react-jsx-runtime.profiling.js +34 -0
- package/static/canary-full/node_modules/react/cjs/react-jsx-runtime.react-server.development.js +385 -0
- package/static/canary-full/node_modules/react/cjs/react-jsx-runtime.react-server.production.js +40 -0
- package/static/canary-full/node_modules/react/cjs/react.development.js +1250 -0
- package/static/canary-full/node_modules/react/cjs/react.production.js +544 -0
- package/static/canary-full/node_modules/react/cjs/react.react-server.development.js +815 -0
- package/static/canary-full/node_modules/react/cjs/react.react-server.production.js +429 -0
- package/static/canary-full/node_modules/react/compiler-runtime.js +14 -0
- package/static/canary-full/node_modules/react/index.js +7 -0
- package/static/canary-full/node_modules/react/jsx-dev-runtime.js +7 -0
- package/static/canary-full/node_modules/react/jsx-dev-runtime.react-server.js +7 -0
- package/static/canary-full/node_modules/react/jsx-runtime.js +7 -0
- package/static/canary-full/node_modules/react/jsx-runtime.react-server.js +7 -0
- package/static/canary-full/node_modules/react/package.json +51 -0
- package/static/canary-full/node_modules/react/react.react-server.js +7 -0
- package/static/canary-full/node_modules/react-dom/LICENSE +21 -0
- package/static/canary-full/node_modules/react-dom/README.md +60 -0
- package/static/canary-full/node_modules/react-dom/cjs/react-dom-client.development.js +25089 -0
- package/static/canary-full/node_modules/react-dom/cjs/react-dom-client.production.js +15426 -0
- package/static/canary-full/node_modules/react-dom/cjs/react-dom-profiling.development.js +25476 -0
- package/static/canary-full/node_modules/react-dom/cjs/react-dom-profiling.profiling.js +16296 -0
- package/static/canary-full/node_modules/react-dom/cjs/react-dom-server-legacy.browser.development.js +9035 -0
- package/static/canary-full/node_modules/react-dom/cjs/react-dom-server-legacy.browser.production.js +5892 -0
- package/static/canary-full/node_modules/react-dom/cjs/react-dom-server-legacy.node.development.js +9035 -0
- package/static/canary-full/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.js +5972 -0
- package/static/canary-full/node_modules/react-dom/cjs/react-dom-server.browser.development.js +9424 -0
- package/static/canary-full/node_modules/react-dom/cjs/react-dom-server.browser.production.js +6384 -0
- package/static/canary-full/node_modules/react-dom/cjs/react-dom-server.bun.development.js +8739 -0
- package/static/canary-full/node_modules/react-dom/cjs/react-dom-server.bun.production.js +5967 -0
- package/static/canary-full/node_modules/react-dom/cjs/react-dom-server.edge.development.js +9443 -0
- package/static/canary-full/node_modules/react-dom/cjs/react-dom-server.edge.production.js +6477 -0
- package/static/canary-full/node_modules/react-dom/cjs/react-dom-server.node.development.js +9317 -0
- package/static/canary-full/node_modules/react-dom/cjs/react-dom-server.node.production.js +6372 -0
- package/static/canary-full/node_modules/react-dom/cjs/react-dom-test-utils.development.js +24 -0
- package/static/canary-full/node_modules/react-dom/cjs/react-dom-test-utils.production.js +21 -0
- package/static/canary-full/node_modules/react-dom/cjs/react-dom.development.js +424 -0
- package/static/canary-full/node_modules/react-dom/cjs/react-dom.production.js +210 -0
- package/static/canary-full/node_modules/react-dom/cjs/react-dom.react-server.development.js +340 -0
- package/static/canary-full/node_modules/react-dom/cjs/react-dom.react-server.production.js +152 -0
- package/static/canary-full/node_modules/react-dom/client.js +38 -0
- package/static/canary-full/node_modules/react-dom/client.react-server.js +5 -0
- package/static/canary-full/node_modules/react-dom/index.js +38 -0
- package/static/canary-full/node_modules/react-dom/package.json +117 -0
- package/static/canary-full/node_modules/react-dom/profiling.js +38 -0
- package/static/canary-full/node_modules/react-dom/profiling.react-server.js +5 -0
- package/static/canary-full/node_modules/react-dom/react-dom.react-server.js +7 -0
- package/static/canary-full/node_modules/react-dom/server.browser.js +18 -0
- package/static/canary-full/node_modules/react-dom/server.bun.js +19 -0
- package/static/canary-full/node_modules/react-dom/server.edge.js +19 -0
- package/static/canary-full/node_modules/react-dom/server.js +3 -0
- package/static/canary-full/node_modules/react-dom/server.node.js +18 -0
- package/static/canary-full/node_modules/react-dom/server.react-server.js +5 -0
- package/static/canary-full/node_modules/react-dom/static.browser.js +12 -0
- package/static/canary-full/node_modules/react-dom/static.edge.js +12 -0
- package/static/canary-full/node_modules/react-dom/static.js +3 -0
- package/static/canary-full/node_modules/react-dom/static.node.js +12 -0
- package/static/canary-full/node_modules/react-dom/static.react-server.js +5 -0
- package/static/canary-full/node_modules/react-dom/test-utils.js +7 -0
- package/build/src/start/interface/cliExtensionMenuItemHandler.js +0 -173
- package/build/src/start/interface/cliExtensionMenuItemHandler.js.map +0 -1
- package/build/src/start/interface/createDevToolsMenuItems.js +0 -159
- package/build/src/start/interface/createDevToolsMenuItems.js.map +0 -1
- package/build/src/start/server/DevToolsPlugin.js +0 -60
- package/build/src/start/server/DevToolsPlugin.js.map +0 -1
- package/build/src/start/server/DevToolsPlugin.schema.js +0 -79
- package/build/src/start/server/DevToolsPlugin.schema.js.map +0 -1
- package/build/src/start/server/DevToolsPluginCliExtensionExecutor.js +0 -119
- package/build/src/start/server/DevToolsPluginCliExtensionExecutor.js.map +0 -1
- package/build/src/start/server/DevToolsPluginCliExtensionResults.js +0 -61
- package/build/src/start/server/DevToolsPluginCliExtensionResults.js.map +0 -1
- package/build/src/start/server/middleware/DataLoaderModuleMiddleware.js +0 -75
- package/build/src/start/server/middleware/DataLoaderModuleMiddleware.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/metroErrorInterface.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { getMetroServerRoot } from '@expo/config/paths';\nimport { parseWebBuildErrors } from '@expo/log-box/utils';\nimport chalk from 'chalk';\nimport { stripVTControlCharacters } from 'node:util';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport { parse, StackFrame } from 'stacktrace-parser';\nimport terminalLink from 'terminal-link';\n\nimport { LogBoxLog, LogBoxLogData } from './log-box/LogBoxLog';\nimport type { CodeFrame, StackFrame as MetroStackFrame } from './log-box/LogBoxSymbolication';\nimport { getStackFormattedLocation } from './log-box/formatProjectFilePath';\nimport { Log } from '../../../log';\nimport { stripAnsi } from '../../../utils/ansi';\nimport { env } from '../../../utils/env';\nimport { CommandError, SilentError } from '../../../utils/errors';\nimport { createMetroEndpointAsync } from '../getStaticRenderFunctions';\n\nconst isDebug = require('debug').enabled('expo:start:server:metro');\n\nfunction fill(width: number): string {\n return Array(width).join(' ');\n}\n\nfunction formatPaths(config: { filePath: string | null; line?: number; col?: number }) {\n const filePath = chalk.reset(config.filePath);\n return (\n chalk.dim('(') +\n filePath +\n chalk.dim(`:${[config.line, config.col].filter(Boolean).join(':')})`)\n );\n}\n\nexport async function logMetroErrorWithStack(\n projectRoot: string,\n {\n stack,\n codeFrame,\n error,\n }: {\n stack: MetroStackFrame[];\n codeFrame?: CodeFrame;\n error: Error;\n }\n) {\n if (error instanceof SilentError) {\n return;\n }\n\n // process.stdout.write('\\u001b[0m'); // Reset attributes\n // process.stdout.write('\\u001bc'); // Reset the terminal\n\n Log.log();\n Log.log(chalk.red('Metro error: ') + error.message);\n Log.log();\n\n if (error instanceof CommandError) {\n return;\n }\n\n Log.log(\n getStackAsFormattedLog(projectRoot, { stack, codeFrame, error, showCollapsedFrames: true })\n .stack\n );\n}\n\nexport function getStackAsFormattedLog(\n projectRoot: string,\n {\n stack,\n codeFrame,\n error,\n showCollapsedFrames = env.EXPO_DEBUG,\n }: {\n stack: MetroStackFrame[];\n codeFrame?: CodeFrame;\n error?: Error;\n showCollapsedFrames?: boolean;\n }\n): {\n isFallback: boolean;\n stack: string;\n} {\n const logs: string[] = [];\n const containsCodeFrame = likelyContainsCodeFrame(error?.message);\n\n if (containsCodeFrame) {\n // Some transformation errors will have a code frame embedded in the error message\n // from Babel and we should not duplicate it as message is already printed before this call.\n } else if (codeFrame) {\n const maxWarningLineLength = Math.max(800, process.stdout.columns);\n\n const lineText = codeFrame.content;\n const lines = codeFrame.content.split('\\n');\n\n // ---- index.tsx ------------------------------------------------------\n // 32 | This is example code which will be under the title.\n const title = path.basename(codeFrame.fileName);\n logs.push(chalk.bold`Code: ${title}`);\n\n const isPreviewTooLong = lines.some((line) => line.length > maxWarningLineLength);\n const column = codeFrame.location?.column;\n // When the preview is too long, we skip reading the file and attempting to apply\n // code coloring, this is because it can get very slow.\n if (isPreviewTooLong) {\n let previewLine = '';\n let cursorLine = '';\n\n const formattedPath = formatPaths({\n filePath: codeFrame.fileName,\n line: codeFrame.location?.row,\n col: codeFrame.location?.column,\n });\n // Create a curtailed preview line like:\n // `...transition:'fade'},k._updatePropsStack=function(){clearImmediate(k._updateImmediate),k._updateImmediate...`\n // If there is no text preview or column number, we can't do anything.\n if (lineText && column != null) {\n const rangeWindow = Math.round(\n Math.max(codeFrame.fileName?.length ?? 0, Math.max(80, process.stdout.columns)) / 2\n );\n let minBounds = Math.max(0, column - rangeWindow);\n const maxBounds = Math.min(minBounds + rangeWindow * 2, lineText.length);\n previewLine = lineText.slice(minBounds, maxBounds);\n\n // If we splice content off the start, then we should append `...`.\n // This is unlikely to happen since we limit the activation size.\n if (minBounds > 0) {\n // Adjust the min bounds so the cursor is aligned after we add the \"...\"\n minBounds -= 3;\n previewLine = chalk.dim('...') + previewLine;\n }\n if (maxBounds < lineText.length) {\n previewLine += chalk.dim('...');\n }\n\n // If the column property could be found, then use that to fix the cursor location which is often broken in regex.\n cursorLine = (column == null ? '' : fill(column) + chalk.reset('^')).slice(minBounds);\n\n logs.push(formattedPath, '', previewLine, cursorLine, chalk.dim('(error truncated)'));\n }\n } else {\n logs.push(codeFrame.content);\n }\n }\n\n let isFallback = false;\n if (stack?.length) {\n const stackProps = stack.map((frame) => {\n return {\n title: frame.methodName,\n subtitle: getStackFormattedLocation(projectRoot, frame),\n collapse: frame.collapse || isInternalBytecode(frame),\n };\n });\n\n const stackLines: string[] = [];\n const backupStackLines: string[] = [];\n\n stackProps.forEach((frame) => {\n const shouldShow = !frame.collapse || showCollapsedFrames;\n\n const position = terminalLink.isSupported\n ? terminalLink(frame.subtitle, frame.subtitle)\n : frame.subtitle;\n let lineItem = chalk.gray(` ${frame.title} (${position})`);\n\n if (frame.collapse) {\n lineItem = chalk.dim(lineItem);\n }\n // Never show the internal module system.\n const isMetroRuntime =\n /\\/metro-runtime\\/src\\/polyfills\\/require\\.js/.test(frame.subtitle) ||\n /\\/metro-require\\/require\\.js/.test(frame.subtitle);\n if (!isMetroRuntime) {\n if (shouldShow) {\n stackLines.push(lineItem);\n }\n backupStackLines.push(lineItem);\n }\n });\n\n logs.push(chalk.bold`Call Stack`);\n\n if (!backupStackLines.length) {\n logs.push(chalk.gray(' No stack trace available.'));\n } else {\n isFallback = stackLines.length === 0;\n // If there are not stack lines then it means the error likely happened in the node modules, in this case we should fallback to showing all the\n // the stacks to give the user whatever help we can.\n const displayStack = stackLines.length ? stackLines : backupStackLines;\n logs.push(displayStack.join('\\n'));\n }\n } else if (error && error.stack) {\n logs.push(chalk.gray(` ${error.stack}`));\n }\n\n return {\n isFallback,\n stack: logs.join('\\n'),\n };\n}\n\nexport const IS_METRO_BUNDLE_ERROR_SYMBOL = Symbol('_isMetroBundleError');\nconst HAS_LOGGED_SYMBOL = Symbol('_hasLoggedInCLI');\n\nexport async function logMetroError(\n projectRoot: string,\n {\n error,\n }: {\n error: Error & {\n [HAS_LOGGED_SYMBOL]?: boolean;\n };\n }\n) {\n if (error instanceof SilentError || error[HAS_LOGGED_SYMBOL]) {\n return;\n }\n error[HAS_LOGGED_SYMBOL] = true;\n\n const stack = parseErrorStack(projectRoot, error.stack);\n\n const log = new LogBoxLog({\n level: 'static',\n message: {\n content: error.message,\n substitutions: [],\n },\n isComponentError: false,\n stack,\n category: 'static',\n componentStack: [],\n });\n\n await new Promise((res) => log.symbolicate('stack', res));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nfunction logFromError({ error, projectRoot }: { error: Error; projectRoot: string }): LogBoxLog {\n const data = parseWebBuildErrors({\n error,\n projectRoot,\n parseErrorStack,\n });\n return new LogBoxLog(data as LogBoxLogData);\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nexport async function logMetroErrorAsync({\n error,\n projectRoot,\n}: {\n error: Error;\n projectRoot: string;\n}) {\n const log = logFromError({ projectRoot, error });\n\n await new Promise<void>((res) => log.symbolicate('stack', () => res()));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nexport async function getErrorOverlayHtmlAsync({\n error,\n projectRoot,\n routerRoot,\n}: {\n error: Error;\n projectRoot: string;\n routerRoot: string;\n}) {\n const log = logFromError({ projectRoot, error });\n\n await new Promise<void>((res) => log.symbolicate('stack', () => res()));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n\n if ('message' in log && 'content' in log.message && typeof log.message.content === 'string') {\n log.message.content = stripAnsi(log.message.content)!;\n }\n\n const logBoxContext = {\n selectedLogIndex: 0,\n isDisabled: false,\n logs: [log],\n };\n const html = `<html><head><style>#root,body,html{height:100%;background-color:black}body{overflow:hidden}#root{display:flex}</style></head><body><div id=\"root\"></div><script id=\"_expo-static-error\" type=\"application/json\">${JSON.stringify(\n logBoxContext\n )}</script></body></html>`;\n\n // TODO: We could reuse the pre-built DOM Log Box from @expo/log-box\n const errorOverlayEntry = await createMetroEndpointAsync(\n projectRoot,\n // Keep the URL relative\n '',\n resolveFrom(projectRoot, 'expo-router/_error'),\n {\n mode: 'development',\n platform: 'web',\n minify: false,\n optimize: false,\n usedExports: false,\n baseUrl: '',\n routerRoot,\n isExporting: false,\n reactCompiler: false,\n }\n );\n\n const htmlWithJs = html.replace('</body>', `<script src=${errorOverlayEntry}></script></body>`);\n return htmlWithJs;\n}\n\nfunction parseErrorStack(\n projectRoot: string,\n stack?: string\n): (StackFrame & { collapse?: boolean })[] {\n if (stack == null) {\n return [];\n }\n if (Array.isArray(stack)) {\n return stack;\n }\n\n const serverRoot = getMetroServerRoot(projectRoot);\n\n return parse(stack)\n .map((frame) => {\n // frame.file will mostly look like `http://localhost:8081/index.bundle?platform=web&dev=true&hot=false`\n\n if (frame.file) {\n // SSR will sometimes have absolute paths followed by `.bundle?...`, we need to try and make them relative paths and append a dev server URL.\n if (frame.file.startsWith('/') && frame.file.includes('bundle?') && !canParse(frame.file)) {\n // Malformed stack file from SSR. Attempt to repair.\n frame.file = 'https://localhost:8081/' + path.relative(serverRoot, frame.file);\n }\n }\n\n return {\n ...frame,\n column: frame.column != null ? frame.column - 1 : null,\n };\n })\n .filter((frame) => frame.file && !frame.file.includes('node_modules'));\n}\n\nfunction canParse(url: string): boolean {\n try {\n // eslint-disable-next-line no-new\n new URL(url);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function dropStackIfContainsCodeFrame(err: unknown) {\n if (!(err instanceof Error)) return;\n\n if (likelyContainsCodeFrame(err.message)) {\n // If the error message contains a code frame, we should drop the stack to avoid cluttering the output.\n delete err.stack;\n }\n}\n\n/**\n * Tests given string on presence of ` [num] |` at the start of any line.\n * Returns `false` for undefined or empty strings.\n */\nexport function likelyContainsCodeFrame(message: string | undefined): boolean {\n if (!message) return false;\n\n const clean = stripVTControlCharacters(message);\n if (!clean) return false;\n\n return /^\\s*\\d+\\s+\\|/m.test(clean);\n}\n\n/**\n * Walks thru the error cause chain and attaches the import stack to the root error message.\n * Removes the error stack for import and syntax errors.\n */\nexport const attachImportStackToRootMessage = (err: unknown) => {\n if (!(err instanceof Error)) return;\n\n // Space out build failures.\n const nearestImportStackValue = nearestImportStack(err);\n if (nearestImportStackValue) {\n err.message += '\\n\\n' + nearestImportStackValue;\n\n if (!isDebug) {\n // When not debugging remove the stack to avoid cluttering the output and confusing users,\n // the import stack is the guide to fixing the error.\n delete err.stack;\n }\n }\n};\n\n/**\n * Walks thru the error cause chain and returns the nearest import stack.\n * If the import stack is not found, it returns `undefined`.\n */\nexport const nearestImportStack = (err: unknown, root: unknown = err): string | undefined => {\n if (!(err instanceof Error) || !(root instanceof Error)) return undefined;\n\n if ('_expoImportStack' in err && typeof err._expoImportStack === 'string') {\n // Space out build failures.\n return err._expoImportStack;\n } else {\n return nearestImportStack(err.cause, root);\n }\n};\n\nfunction isInternalBytecode(frame: StackFrame): boolean {\n return frame.file?.includes('InternalBytecode.js') ?? false;\n}\n"],"names":["IS_METRO_BUNDLE_ERROR_SYMBOL","attachImportStackToRootMessage","dropStackIfContainsCodeFrame","getErrorOverlayHtmlAsync","getStackAsFormattedLog","likelyContainsCodeFrame","logMetroError","logMetroErrorAsync","logMetroErrorWithStack","nearestImportStack","isDebug","require","enabled","fill","width","Array","join","formatPaths","config","filePath","chalk","reset","dim","line","col","filter","Boolean","projectRoot","stack","codeFrame","error","SilentError","Log","log","red","message","CommandError","showCollapsedFrames","env","EXPO_DEBUG","logs","containsCodeFrame","maxWarningLineLength","Math","max","process","stdout","columns","lineText","content","lines","split","title","path","basename","fileName","push","bold","isPreviewTooLong","some","length","column","location","previewLine","cursorLine","formattedPath","row","rangeWindow","round","minBounds","maxBounds","min","slice","isFallback","stackProps","map","frame","methodName","subtitle","getStackFormattedLocation","collapse","isInternalBytecode","stackLines","backupStackLines","forEach","shouldShow","position","terminalLink","isSupported","lineItem","gray","isMetroRuntime","test","displayStack","Symbol","HAS_LOGGED_SYMBOL","parseErrorStack","LogBoxLog","level","substitutions","isComponentError","category","componentStack","Promise","res","symbolicate","symbolicated","logFromError","data","parseWebBuildErrors","routerRoot","stripAnsi","logBoxContext","selectedLogIndex","isDisabled","html","JSON","stringify","errorOverlayEntry","createMetroEndpointAsync","resolveFrom","mode","platform","minify","optimize","usedExports","baseUrl","isExporting","reactCompiler","htmlWithJs","replace","isArray","serverRoot","getMetroServerRoot","parse","file","startsWith","includes","canParse","relative","url","URL","err","Error","clean","stripVTControlCharacters","nearestImportStackValue","root","undefined","_expoImportStack","cause"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;IA2MYA,4BAA4B;eAA5BA;;IAmMAC,8BAA8B;eAA9BA;;IA1BGC,4BAA4B;eAA5BA;;IAlGMC,wBAAwB;eAAxBA;;IA/MNC,sBAAsB;eAAtBA;;IA8TAC,uBAAuB;eAAvBA;;IAnLMC,aAAa;eAAbA;;IAiDAC,kBAAkB;eAAlBA;;IA7NAC,sBAAsB;eAAtBA;;IAgYTC,kBAAkB;eAAlBA;;;;yBAjasB;;;;;;;yBACC;;;;;;;gEAClB;;;;;;;yBACuB;;;;;;;gEACxB;;;;;;;gEACO;;;;;;;yBACU;;;;;;;gEACT;;;;;;2BAEgB;uCAEC;qBACtB;sBACM;qBACN;wBACsB;0CACD;;;;;;AAEzC,MAAMC,UAAUC,QAAQ,SAASC,OAAO,CAAC;AAEzC,SAASC,KAAKC,KAAa;IACzB,OAAOC,MAAMD,OAAOE,IAAI,CA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AEH;IACvC;AACF;AAEA,SAASlE,mBAAmBL,KAAiB;QACpCA;IAAP,OAAOA,EAAAA,cAAAA,MAAM2D,IAAI,qBAAV3D,YAAY6D,QAAQ,CAAC,2BAA0B;AACxD"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/metroErrorInterface.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { getMetroServerRoot } from '@expo/config/paths';\nimport chalk from 'chalk';\nimport { stripVTControlCharacters } from 'node:util';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport { parse, StackFrame } from 'stacktrace-parser';\nimport terminalLink from 'terminal-link';\n\nimport { LogBoxLog } from './log-box/LogBoxLog';\nimport type { CodeFrame, StackFrame as MetroStackFrame } from './log-box/LogBoxSymbolication';\nimport { getStackFormattedLocation } from './log-box/formatProjectFilePath';\nimport { Log } from '../../../log';\nimport { stripAnsi } from '../../../utils/ansi';\nimport { env } from '../../../utils/env';\nimport { CommandError, SilentError } from '../../../utils/errors';\nimport { createMetroEndpointAsync } from '../getStaticRenderFunctions';\n\nconst isDebug = require('debug').enabled('expo:start:server:metro');\n\nfunction fill(width: number): string {\n return Array(width).join(' ');\n}\n\nfunction formatPaths(config: { filePath: string | null; line?: number; col?: number }) {\n const filePath = chalk.reset(config.filePath);\n return (\n chalk.dim('(') +\n filePath +\n chalk.dim(`:${[config.line, config.col].filter(Boolean).join(':')})`)\n );\n}\n\nexport async function logMetroErrorWithStack(\n projectRoot: string,\n {\n stack,\n codeFrame,\n error,\n }: {\n stack: MetroStackFrame[];\n codeFrame?: CodeFrame;\n error: Error;\n }\n) {\n if (error instanceof SilentError) {\n return;\n }\n\n // process.stdout.write('\\u001b[0m'); // Reset attributes\n // process.stdout.write('\\u001bc'); // Reset the terminal\n\n Log.log();\n Log.log(chalk.red('Metro error: ') + error.message);\n Log.log();\n\n if (error instanceof CommandError) {\n return;\n }\n\n Log.log(\n getStackAsFormattedLog(projectRoot, { stack, codeFrame, error, showCollapsedFrames: true })\n .stack\n );\n}\n\nexport function getStackAsFormattedLog(\n projectRoot: string,\n {\n stack,\n codeFrame,\n error,\n showCollapsedFrames = env.EXPO_DEBUG,\n }: {\n stack: MetroStackFrame[];\n codeFrame?: CodeFrame;\n error?: Error;\n showCollapsedFrames?: boolean;\n }\n): {\n isFallback: boolean;\n stack: string;\n} {\n const logs: string[] = [];\n const containsCodeFrame = likelyContainsCodeFrame(error?.message);\n\n if (containsCodeFrame) {\n // Some transformation errors will have a code frame embedded in the error message\n // from Babel and we should not duplicate it as message is already printed before this call.\n } else if (codeFrame) {\n const maxWarningLineLength = Math.max(800, process.stdout.columns);\n\n const lineText = codeFrame.content;\n const lines = codeFrame.content.split('\\n');\n\n // ---- index.tsx ------------------------------------------------------\n // 32 | This is example code which will be under the title.\n const title = path.basename(codeFrame.fileName);\n logs.push(chalk.bold`Code: ${title}`);\n\n const isPreviewTooLong = lines.some((line) => line.length > maxWarningLineLength);\n const column = codeFrame.location?.column;\n // When the preview is too long, we skip reading the file and attempting to apply\n // code coloring, this is because it can get very slow.\n if (isPreviewTooLong) {\n let previewLine = '';\n let cursorLine = '';\n\n const formattedPath = formatPaths({\n filePath: codeFrame.fileName,\n line: codeFrame.location?.row,\n col: codeFrame.location?.column,\n });\n // Create a curtailed preview line like:\n // `...transition:'fade'},k._updatePropsStack=function(){clearImmediate(k._updateImmediate),k._updateImmediate...`\n // If there is no text preview or column number, we can't do anything.\n if (lineText && column != null) {\n const rangeWindow = Math.round(\n Math.max(codeFrame.fileName?.length ?? 0, Math.max(80, process.stdout.columns)) / 2\n );\n let minBounds = Math.max(0, column - rangeWindow);\n const maxBounds = Math.min(minBounds + rangeWindow * 2, lineText.length);\n previewLine = lineText.slice(minBounds, maxBounds);\n\n // If we splice content off the start, then we should append `...`.\n // This is unlikely to happen since we limit the activation size.\n if (minBounds > 0) {\n // Adjust the min bounds so the cursor is aligned after we add the \"...\"\n minBounds -= 3;\n previewLine = chalk.dim('...') + previewLine;\n }\n if (maxBounds < lineText.length) {\n previewLine += chalk.dim('...');\n }\n\n // If the column property could be found, then use that to fix the cursor location which is often broken in regex.\n cursorLine = (column == null ? '' : fill(column) + chalk.reset('^')).slice(minBounds);\n\n logs.push(formattedPath, '', previewLine, cursorLine, chalk.dim('(error truncated)'));\n }\n } else {\n logs.push(codeFrame.content);\n }\n }\n\n let isFallback = false;\n if (stack?.length) {\n const stackProps = stack.map((frame) => {\n return {\n title: frame.methodName,\n subtitle: getStackFormattedLocation(projectRoot, frame),\n collapse: frame.collapse || isInternalBytecode(frame),\n };\n });\n\n const stackLines: string[] = [];\n const backupStackLines: string[] = [];\n\n stackProps.forEach((frame) => {\n const shouldShow = !frame.collapse || showCollapsedFrames;\n\n const position = terminalLink.isSupported\n ? terminalLink(frame.subtitle, frame.subtitle)\n : frame.subtitle;\n let lineItem = chalk.gray(` ${frame.title} (${position})`);\n\n if (frame.collapse) {\n lineItem = chalk.dim(lineItem);\n }\n // Never show the internal module system.\n const isMetroRuntime =\n /\\/metro-runtime\\/src\\/polyfills\\/require\\.js/.test(frame.subtitle) ||\n /\\/metro-require\\/require\\.js/.test(frame.subtitle);\n if (!isMetroRuntime) {\n if (shouldShow) {\n stackLines.push(lineItem);\n }\n backupStackLines.push(lineItem);\n }\n });\n\n logs.push(chalk.bold`Call Stack`);\n\n if (!backupStackLines.length) {\n logs.push(chalk.gray(' No stack trace available.'));\n } else {\n isFallback = stackLines.length === 0;\n // If there are not stack lines then it means the error likely happened in the node modules, in this case we should fallback to showing all the\n // the stacks to give the user whatever help we can.\n const displayStack = stackLines.length ? stackLines : backupStackLines;\n logs.push(displayStack.join('\\n'));\n }\n } else if (error && error.stack) {\n logs.push(chalk.gray(` ${error.stack}`));\n }\n\n return {\n isFallback,\n stack: logs.join('\\n'),\n };\n}\n\nexport const IS_METRO_BUNDLE_ERROR_SYMBOL = Symbol('_isMetroBundleError');\nconst HAS_LOGGED_SYMBOL = Symbol('_hasLoggedInCLI');\n\nexport async function logMetroError(\n projectRoot: string,\n {\n error,\n }: {\n error: Error & {\n [HAS_LOGGED_SYMBOL]?: boolean;\n };\n }\n) {\n if (error instanceof SilentError || error[HAS_LOGGED_SYMBOL]) {\n return;\n }\n error[HAS_LOGGED_SYMBOL] = true;\n\n const stack = parseErrorStack(projectRoot, error.stack);\n\n const log = new LogBoxLog({\n level: 'static',\n message: {\n content: error.message,\n substitutions: [],\n },\n isComponentError: false,\n stack,\n category: 'static',\n componentStack: [],\n });\n\n await new Promise((res) => log.symbolicate('stack', res));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n}\n\nfunction isTransformError(\n error: any\n): error is { type: 'TransformError'; filename: string; lineNumber: number; column: number } {\n return error.type === 'TransformError';\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nfunction logFromError({ error, projectRoot }: { error: Error; projectRoot: string }) {\n // Remap direct Metro Node.js errors to a format that will appear more client-friendly in the logbox UI.\n let stack: MetroStackFrame[] | undefined;\n if (isTransformError(error) && error.filename) {\n // Syntax errors in static rendering.\n stack = [\n {\n file: path.join(projectRoot, error.filename),\n methodName: '<unknown>',\n arguments: [],\n // TODO: Import stack\n lineNumber: error.lineNumber,\n column: error.column,\n },\n ];\n } else if ('originModulePath' in error && typeof error.originModulePath === 'string') {\n // TODO: Use import stack here when the error is resolution based.\n stack = [\n {\n file: error.originModulePath,\n methodName: '<unknown>',\n arguments: [],\n // TODO: Import stack\n lineNumber: 0,\n column: 0,\n },\n ];\n } else {\n stack = parseErrorStack(projectRoot, error.stack);\n }\n\n return new LogBoxLog({\n level: 'static',\n message: {\n content: error.message,\n substitutions: [],\n },\n isComponentError: false,\n stack,\n category: 'static',\n componentStack: [],\n });\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nexport async function logMetroErrorAsync({\n error,\n projectRoot,\n}: {\n error: Error;\n projectRoot: string;\n}) {\n const log = logFromError({ projectRoot, error });\n\n await new Promise<void>((res) => log.symbolicate('stack', () => res()));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nexport async function getErrorOverlayHtmlAsync({\n error,\n projectRoot,\n routerRoot,\n}: {\n error: Error;\n projectRoot: string;\n routerRoot: string;\n}) {\n const log = logFromError({ projectRoot, error });\n\n await new Promise<void>((res) => log.symbolicate('stack', () => res()));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n\n if ('message' in log && 'content' in log.message && typeof log.message.content === 'string') {\n log.message.content = stripAnsi(log.message.content)!;\n }\n\n const logBoxContext = {\n selectedLogIndex: 0,\n isDisabled: false,\n logs: [log],\n };\n const html = `<html><head><style>#root,body,html{height:100%}body{overflow:hidden}#root{display:flex}</style></head><body><div id=\"root\"></div><script id=\"_expo-static-error\" type=\"application/json\">${JSON.stringify(\n logBoxContext\n )}</script></body></html>`;\n\n const errorOverlayEntry = await createMetroEndpointAsync(\n projectRoot,\n // Keep the URL relative\n '',\n resolveFrom(projectRoot, 'expo-router/_error'),\n {\n mode: 'development',\n platform: 'web',\n minify: false,\n optimize: false,\n usedExports: false,\n baseUrl: '',\n routerRoot,\n isExporting: false,\n reactCompiler: false,\n }\n );\n\n const htmlWithJs = html.replace('</body>', `<script src=${errorOverlayEntry}></script></body>`);\n return htmlWithJs;\n}\n\nfunction parseErrorStack(\n projectRoot: string,\n stack?: string\n): (StackFrame & { collapse?: boolean })[] {\n if (stack == null) {\n return [];\n }\n if (Array.isArray(stack)) {\n return stack;\n }\n\n const serverRoot = getMetroServerRoot(projectRoot);\n\n return parse(stack)\n .map((frame) => {\n // frame.file will mostly look like `http://localhost:8081/index.bundle?platform=web&dev=true&hot=false`\n\n if (frame.file) {\n // SSR will sometimes have absolute paths followed by `.bundle?...`, we need to try and make them relative paths and append a dev server URL.\n if (frame.file.startsWith('/') && frame.file.includes('bundle?') && !canParse(frame.file)) {\n // Malformed stack file from SSR. Attempt to repair.\n frame.file = 'https://localhost:8081/' + path.relative(serverRoot, frame.file);\n }\n }\n\n return {\n ...frame,\n column: frame.column != null ? frame.column - 1 : null,\n };\n })\n .filter((frame) => frame.file && !frame.file.includes('node_modules'));\n}\n\nfunction canParse(url: string): boolean {\n try {\n // eslint-disable-next-line no-new\n new URL(url);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function dropStackIfContainsCodeFrame(err: unknown) {\n if (!(err instanceof Error)) return;\n\n if (likelyContainsCodeFrame(err.message)) {\n // If the error message contains a code frame, we should drop the stack to avoid cluttering the output.\n delete err.stack;\n }\n}\n\n/**\n * Tests given string on presence of ` [num] |` at the start of any line.\n * Returns `false` for undefined or empty strings.\n */\nexport function likelyContainsCodeFrame(message: string | undefined): boolean {\n if (!message) return false;\n\n const clean = stripVTControlCharacters(message);\n if (!clean) return false;\n\n return /^\\s*\\d+\\s+\\|/m.test(clean);\n}\n\n/**\n * Walks thru the error cause chain and attaches the import stack to the root error message.\n * Removes the error stack for import and syntax errors.\n */\nexport const attachImportStackToRootMessage = (err: unknown) => {\n if (!(err instanceof Error)) return;\n\n // Space out build failures.\n const nearestImportStackValue = nearestImportStack(err);\n if (nearestImportStackValue) {\n err.message += '\\n\\n' + nearestImportStackValue;\n\n if (!isDebug) {\n // When not debugging remove the stack to avoid cluttering the output and confusing users,\n // the import stack is the guide to fixing the error.\n delete err.stack;\n }\n }\n};\n\n/**\n * Walks thru the error cause chain and returns the nearest import stack.\n * If the import stack is not found, it returns `undefined`.\n */\nexport const nearestImportStack = (err: unknown, root: unknown = err): string | undefined => {\n if (!(err instanceof Error) || !(root instanceof Error)) return undefined;\n\n if ('_expoImportStack' in err && typeof err._expoImportStack === 'string') {\n // Space out build failures.\n return err._expoImportStack;\n } else {\n return nearestImportStack(err.cause, root);\n }\n};\n\nfunction isInternalBytecode(frame: StackFrame): boolean {\n return frame.file?.includes('InternalBytecode.js') ?? false;\n}\n"],"names":["IS_METRO_BUNDLE_ERROR_SYMBOL","attachImportStackToRootMessage","dropStackIfContainsCodeFrame","getErrorOverlayHtmlAsync","getStackAsFormattedLog","likelyContainsCodeFrame","logMetroError","logMetroErrorAsync","logMetroErrorWithStack","nearestImportStack","isDebug","require","enabled","fill","width","Array","join","formatPaths","config","filePath","chalk","reset","dim","line","col","filter","Boolean","projectRoot","stack","codeFrame","error","SilentError","Log","log","red","message","CommandError","showCollapsedFrames","env","EXPO_DEBUG","logs","containsCodeFrame","maxWarningLineLength","Math","max","process","stdout","columns","lineText","content","lines","split","title","path","basename","fileName","push","bold","isPreviewTooLong","some","length","column","location","previewLine","cursorLine","formattedPath","row","rangeWindow","round","minBounds","maxBounds","min","slice","isFallback","stackProps","map","frame","methodName","subtitle","getStackFormattedLocation","collapse","isInternalBytecode","stackLines","backupStackLines","forEach","shouldShow","position","terminalLink","isSupported","lineItem","gray","isMetroRuntime","test","displayStack","Symbol","HAS_LOGGED_SYMBOL","parseErrorStack","LogBoxLog","level","substitutions","isComponentError","category","componentStack","Promise","res","symbolicate","symbolicated","isTransformError","type","logFromError","filename","file","arguments","lineNumber","originModulePath","routerRoot","stripAnsi","logBoxContext","selectedLogIndex","isDisabled","html","JSON","stringify","errorOverlayEntry","createMetroEndpointAsync","resolveFrom","mode","platform","minify","optimize","usedExports","baseUrl","isExporting","reactCompiler","htmlWithJs","replace","isArray","serverRoot","getMetroServerRoot","parse","startsWith","includes","canParse","relative","url","URL","err","Error","clean","stripVTControlCharacters","nearestImportStackValue","root","undefined","_expoImportStack","cause"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;IA0MYA,4BAA4B;eAA5BA;;IA2OAC,8BAA8B;eAA9BA;;IA1BGC,4BAA4B;eAA5BA;;IAjGMC,wBAAwB;eAAxBA;;IAxPNC,sBAAsB;eAAtBA;;IAsWAC,uBAAuB;eAAv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AACxD"}
|
|
@@ -96,7 +96,10 @@ function withWebPolyfills(config, { getMetroBundler }) {
|
|
|
96
96
|
const virtualModuleId = `\0polyfill:external-require`;
|
|
97
97
|
(0, _metroVirtualModules.getMetroBundlerWithVirtualModules)(getMetroBundler()).setVirtualModule(virtualModuleId, (()=>{
|
|
98
98
|
if (ctx.platform === 'web') {
|
|
99
|
-
|
|
99
|
+
// NOTE(@hassankhan): We need to wrap require in an arrow function rather than assigning
|
|
100
|
+
// it directly because `workerd` loses its `this` context when `require` is dereferenced
|
|
101
|
+
// and called later.
|
|
102
|
+
return `global.$$require_external = typeof require !== "undefined" ? (m) => require(m) : () => null;`;
|
|
100
103
|
} else {
|
|
101
104
|
// Wrap in try/catch to support Android.
|
|
102
105
|
return 'try { global.$$require_external = typeof expo === "undefined" ? require : (moduleId) => { throw new Error(`Node.js standard library module ${moduleId} is not available in this JavaScript environment`);} } catch { global.$$require_external = (moduleId) => { throw new Error(`Node.js standard library module ${moduleId} is not available in this JavaScript environment`);} }';
|
|
@@ -160,11 +163,14 @@ function getNodejsExtensions(srcExts) {
|
|
|
160
163
|
nodejsSourceExtensions.splice(jsIndex + 1, 0, ...mjsExts);
|
|
161
164
|
return nodejsSourceExtensions;
|
|
162
165
|
}
|
|
163
|
-
function withExtendedResolver(config, { tsconfig, autolinkingModuleResolverInput, isTsconfigPathsEnabled, isFastResolverEnabled, isExporting, isReactServerComponentsEnabled, getMetroBundler }) {
|
|
166
|
+
function withExtendedResolver(config, { tsconfig, autolinkingModuleResolverInput, isTsconfigPathsEnabled, isFastResolverEnabled, isExporting, isReactCanaryEnabled, isReactServerComponentsEnabled, getMetroBundler }) {
|
|
164
167
|
var _config_resolver, _config_resolver1, _config_resolver2, _config_resolver3, _config_serializer_createModuleIdFactory, _config_serializer;
|
|
165
168
|
if (isReactServerComponentsEnabled) {
|
|
166
169
|
_log.Log.warn(`React Server Components (beta) is enabled.`);
|
|
167
170
|
}
|
|
171
|
+
if (isReactCanaryEnabled) {
|
|
172
|
+
_log.Log.warn(`Experimental React 19 canary is enabled.`);
|
|
173
|
+
}
|
|
168
174
|
if (isFastResolverEnabled) {
|
|
169
175
|
_log.Log.log(_chalk().default.dim`Fast resolver is enabled.`);
|
|
170
176
|
}
|
|
@@ -182,6 +188,10 @@ function withExtendedResolver(config, { tsconfig, autolinkingModuleResolverInput
|
|
|
182
188
|
'react-native/Libraries/Image/resolveAssetSource': 'expo-asset/build/resolveAssetSource'
|
|
183
189
|
}
|
|
184
190
|
};
|
|
191
|
+
// The vendored canary modules live inside /static/canary-full/node_modules
|
|
192
|
+
// Adding the `index.js` allows us to add this path as `originModulePath` to
|
|
193
|
+
// resolve the nested `node_modules` folder properly.
|
|
194
|
+
const canaryModulesPath = _path().default.join(require.resolve('@expo/cli/package.json'), '../static/canary-full/index.js');
|
|
185
195
|
let _universalAliases;
|
|
186
196
|
function getUniversalAliases() {
|
|
187
197
|
if (_universalAliases) {
|
|
@@ -287,6 +297,19 @@ function withExtendedResolver(config, { tsconfig, autolinkingModuleResolverInput
|
|
|
287
297
|
}
|
|
288
298
|
// TODO: This is a hack to get resolveWeak working.
|
|
289
299
|
const idFactory = ((_config_serializer = config.serializer) == null ? void 0 : (_config_serializer_createModuleIdFactory = _config_serializer.createModuleIdFactory) == null ? void 0 : _config_serializer_createModuleIdFactory.call(_config_serializer)) ?? ((id, context)=>id);
|
|
300
|
+
// We're manually resolving the `asyncRequireModulePath` since it's a module request
|
|
301
|
+
// However, in isolated installations it might not resolve from all paths, so we're resolving
|
|
302
|
+
// it from the project root manually
|
|
303
|
+
let _asyncRequireModuleResolvedPath;
|
|
304
|
+
const getAsyncRequireModule = ()=>{
|
|
305
|
+
if (_asyncRequireModuleResolvedPath === undefined) {
|
|
306
|
+
_asyncRequireModuleResolvedPath = _resolvefrom().default.silent(config.projectRoot, config.transformer.asyncRequireModulePath) ?? null;
|
|
307
|
+
}
|
|
308
|
+
return _asyncRequireModuleResolvedPath ? {
|
|
309
|
+
type: 'sourceFile',
|
|
310
|
+
filePath: _asyncRequireModuleResolvedPath
|
|
311
|
+
} : null;
|
|
312
|
+
};
|
|
290
313
|
const getAssetRegistryModule = ()=>{
|
|
291
314
|
const virtualModuleId = `\0polyfill:assets-registry`;
|
|
292
315
|
(0, _metroVirtualModules.getMetroBundlerWithVirtualModules)(getMetroBundler()).setVirtualModule(virtualModuleId, ASSET_REGISTRY_SRC);
|
|
@@ -487,8 +510,12 @@ function withExtendedResolver(config, { tsconfig, autolinkingModuleResolverInput
|
|
|
487
510
|
}
|
|
488
511
|
return null;
|
|
489
512
|
},
|
|
490
|
-
// Polyfill for asset registry
|
|
491
|
-
function
|
|
513
|
+
// Polyfill for asset registry (assetRegistryPath) and async require module (asyncRequireModulePath)
|
|
514
|
+
function requestStableConfigModules(context, moduleName, platform) {
|
|
515
|
+
if (moduleName === config.transformer.asyncRequireModulePath) {
|
|
516
|
+
return getAsyncRequireModule();
|
|
517
|
+
}
|
|
518
|
+
// TODO(@kitten): Compare against `config.transformer.assetRegistryPath`
|
|
492
519
|
if (/^@react-native\/assets-registry\/registry(\.js)?$/.test(moduleName)) {
|
|
493
520
|
return getAssetRegistryModule();
|
|
494
521
|
}
|
|
@@ -509,20 +536,19 @@ function withExtendedResolver(config, { tsconfig, autolinkingModuleResolverInput
|
|
|
509
536
|
return result;
|
|
510
537
|
}
|
|
511
538
|
const normalizedPath = normalizeSlashes(result.filePath);
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
debug('Using `_unstable-web-modal` implementation.');
|
|
524
|
-
return webModalModule;
|
|
539
|
+
if (normalizedPath.endsWith('expo-router/build/layouts/_web-modal.js')) {
|
|
540
|
+
if (_env.env.EXPO_UNSTABLE_WEB_MODAL) {
|
|
541
|
+
try {
|
|
542
|
+
const webModal = doResolve('expo-router/build/layouts/ExperimentalModalStack.js');
|
|
543
|
+
if (webModal.type === 'sourceFile') {
|
|
544
|
+
debug('Using `_unstable-web-modal` implementation.');
|
|
545
|
+
return webModal;
|
|
546
|
+
}
|
|
547
|
+
} catch (error) {
|
|
548
|
+
// Fallback to react-navigation web modal implementation.
|
|
549
|
+
}
|
|
525
550
|
}
|
|
551
|
+
debug("Using React Navigation's web modal implementation.");
|
|
526
552
|
}
|
|
527
553
|
if (platform === 'web') {
|
|
528
554
|
if (result.filePath.includes('node_modules')) {
|
|
@@ -557,19 +583,26 @@ function withExtendedResolver(config, { tsconfig, autolinkingModuleResolverInput
|
|
|
557
583
|
const isServer = ((_context_customResolverOptions = context.customResolverOptions) == null ? void 0 : _context_customResolverOptions.environment) === 'node' || ((_context_customResolverOptions1 = context.customResolverOptions) == null ? void 0 : _context_customResolverOptions1.environment) === 'react-server';
|
|
558
584
|
// Shim out React Native native runtime globals in server mode for native.
|
|
559
585
|
if (isServer) {
|
|
560
|
-
|
|
561
|
-
if (emptyModule) {
|
|
586
|
+
if (normalizedPath.endsWith('react-native/Libraries/Core/InitializeCore.js')) {
|
|
562
587
|
debug('Shimming out InitializeCore for React Native in native SSR bundle');
|
|
563
|
-
return
|
|
588
|
+
return {
|
|
589
|
+
type: 'empty'
|
|
590
|
+
};
|
|
564
591
|
}
|
|
565
592
|
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
if (
|
|
569
|
-
const
|
|
570
|
-
|
|
571
|
-
const
|
|
572
|
-
if (
|
|
593
|
+
// When server components are enabled, redirect React Native's renderer to the canary build
|
|
594
|
+
// this will enable the use hook and other requisite features from React 19.
|
|
595
|
+
if (isReactCanaryEnabled && result.filePath.includes('node_modules')) {
|
|
596
|
+
const normalName = normalizeSlashes(result.filePath)// Drop everything up until the `node_modules` folder.
|
|
597
|
+
.replace(/.*node_modules\//, '');
|
|
598
|
+
const canaryFile = (0, _externals.shouldCreateVirtualCanary)(normalName);
|
|
599
|
+
if (canaryFile) {
|
|
600
|
+
debug(`Redirecting React Native module "${result.filePath}" to canary build`);
|
|
601
|
+
return {
|
|
602
|
+
...result,
|
|
603
|
+
filePath: canaryFile
|
|
604
|
+
};
|
|
605
|
+
}
|
|
573
606
|
}
|
|
574
607
|
}
|
|
575
608
|
return result;
|
|
@@ -592,6 +625,14 @@ function withExtendedResolver(config, { tsconfig, autolinkingModuleResolverInput
|
|
|
592
625
|
...immutableContext,
|
|
593
626
|
preferNativePlatform: platform !== 'web'
|
|
594
627
|
};
|
|
628
|
+
// TODO: Remove this when we have React 19 in the expo/expo monorepo.
|
|
629
|
+
if (isReactCanaryEnabled && // Change the node modules path for react and react-dom to use the vendor in Expo CLI.
|
|
630
|
+
/^(react|react\/.*|react-dom|react-dom\/.*)$/.test(moduleName)) {
|
|
631
|
+
// Modifying the origin module path changes the starting Node module resolution path to this folder
|
|
632
|
+
context.originModulePath = canaryModulesPath;
|
|
633
|
+
// Hierarchical lookup has to be enabled for this to work
|
|
634
|
+
context.disableHierarchicalLookup = false;
|
|
635
|
+
}
|
|
595
636
|
if ((0, _metroOptions.isServerEnvironment)((_context_customResolverOptions = context.customResolverOptions) == null ? void 0 : _context_customResolverOptions.environment)) {
|
|
596
637
|
var _context_customResolverOptions1, _context_customResolverOptions2;
|
|
597
638
|
// Adjust nodejs source extensions to sort mjs after js, including platform variants.
|
|
@@ -659,44 +700,15 @@ function withExtendedResolver(config, { tsconfig, autolinkingModuleResolverInput
|
|
|
659
700
|
});
|
|
660
701
|
return (0, _withMetroErrorReportingResolver.withMetroErrorReportingResolver)((0, _withMetroSupervisingTransformWorker.withMetroSupervisingTransformWorker)(metroConfigWithCustomContext));
|
|
661
702
|
}
|
|
662
|
-
function doReplaceHelper(from, to, { throws = false, normalizedPath, doResolve }) {
|
|
663
|
-
if (!normalizedPath.endsWith(from)) {
|
|
664
|
-
return undefined;
|
|
665
|
-
}
|
|
666
|
-
if (to === undefined) {
|
|
667
|
-
return {
|
|
668
|
-
type: 'empty'
|
|
669
|
-
};
|
|
670
|
-
}
|
|
671
|
-
try {
|
|
672
|
-
const hmrModule = doResolve(to);
|
|
673
|
-
if (hmrModule.type === 'sourceFile') {
|
|
674
|
-
debug(`Using \`${to}\` implementation.`);
|
|
675
|
-
return hmrModule;
|
|
676
|
-
}
|
|
677
|
-
} catch (resolutionError) {
|
|
678
|
-
if (throws) {
|
|
679
|
-
throw new Error(`Failed to replace ${from} with ${to}. Resolution of ${to} failed.`, {
|
|
680
|
-
cause: resolutionError
|
|
681
|
-
});
|
|
682
|
-
}
|
|
683
|
-
debug(`Failed to resolve ${to} when swapping from ${from}: ${resolutionError}`);
|
|
684
|
-
}
|
|
685
|
-
return undefined;
|
|
686
|
-
}
|
|
687
703
|
function shouldAliasModule(input, alias) {
|
|
688
704
|
var _input_result, _input_result1;
|
|
689
705
|
return input.platform === alias.platform && ((_input_result = input.result) == null ? void 0 : _input_result.type) === 'sourceFile' && typeof ((_input_result1 = input.result) == null ? void 0 : _input_result1.filePath) === 'string' && normalizeSlashes(input.result.filePath).endsWith(alias.output);
|
|
690
706
|
}
|
|
691
|
-
async function withMetroMultiPlatformAsync(projectRoot, { config, exp, platformBundlers, isTsconfigPathsEnabled, isAutolinkingResolverEnabled, isFastResolverEnabled, isExporting, isReactServerComponentsEnabled, getMetroBundler }) {
|
|
707
|
+
async function withMetroMultiPlatformAsync(projectRoot, { config, exp, platformBundlers, isTsconfigPathsEnabled, isAutolinkingResolverEnabled, isFastResolverEnabled, isExporting, isReactCanaryEnabled, isReactServerComponentsEnabled, getMetroBundler }) {
|
|
692
708
|
// Change the default metro-runtime to a custom one that supports bundle splitting.
|
|
693
709
|
// NOTE(@kitten): This is now always active and EXPO_USE_METRO_REQUIRE / isNamedRequiresEnabled is disregarded
|
|
694
710
|
const metroDefaults = require('@expo/metro/metro-config/defaults/defaults');
|
|
695
711
|
metroDefaults.moduleSystem = require.resolve('@expo/cli/build/metro-require/require');
|
|
696
|
-
if (!config.projectRoot) {
|
|
697
|
-
// @ts-expect-error: read-only types
|
|
698
|
-
config.projectRoot = projectRoot;
|
|
699
|
-
}
|
|
700
712
|
// Required for @expo/metro-runtime to format paths in the web LogBox.
|
|
701
713
|
process.env.EXPO_PUBLIC_PROJECT_ROOT = process.env.EXPO_PUBLIC_PROJECT_ROOT ?? projectRoot;
|
|
702
714
|
// This is used for running Expo CLI in development against projects outside the monorepo.
|
|
@@ -711,6 +723,10 @@ async function withMetroMultiPlatformAsync(projectRoot, { config, exp, platformB
|
|
|
711
723
|
// @ts-expect-error: watchFolders is readonly
|
|
712
724
|
config.watchFolders.push(_path().default.join(require.resolve('@expo/metro-config/package.json'), '../..'), // For virtual modules
|
|
713
725
|
_path().default.join(require.resolve('expo/package.json'), '..'));
|
|
726
|
+
if (isReactCanaryEnabled) {
|
|
727
|
+
// @ts-expect-error: watchFolders is readonly
|
|
728
|
+
config.watchFolders.push(_path().default.join(require.resolve('@expo/cli/package.json'), '..'));
|
|
729
|
+
}
|
|
714
730
|
}
|
|
715
731
|
let tsconfig = null;
|
|
716
732
|
if (isTsconfigPathsEnabled) {
|
|
@@ -743,6 +759,7 @@ async function withMetroMultiPlatformAsync(projectRoot, { config, exp, platformB
|
|
|
743
759
|
isExporting,
|
|
744
760
|
isTsconfigPathsEnabled,
|
|
745
761
|
isFastResolverEnabled,
|
|
762
|
+
isReactCanaryEnabled,
|
|
746
763
|
isReactServerComponentsEnabled,
|
|
747
764
|
getMetroBundler
|
|
748
765
|
});
|