@expo/cli 1.0.0-canary-20250404-3c3b5fd → 1.0.0-canary-20250701-6a945c5
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/README.md +33 -24
- package/build/bin/cli +1 -1
- package/build/metro-require/require.js +6 -4
- package/build/src/api/user/actions.js +25 -11
- package/build/src/api/user/actions.js.map +1 -1
- package/build/src/customize/templates.js +15 -1
- package/build/src/customize/templates.js.map +1 -1
- package/build/src/export/exportApp.js +26 -14
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportAsync.js +6 -0
- package/build/src/export/exportAsync.js.map +1 -1
- package/build/src/export/exportHermes.js +2 -2
- package/build/src/export/exportHermes.js.map +1 -1
- package/build/src/export/persistMetroAssets.js.map +1 -1
- package/build/src/install/checkPackages.js +22 -4
- package/build/src/install/checkPackages.js.map +1 -1
- package/build/src/install/index.js +3 -1
- package/build/src/install/index.js.map +1 -1
- package/build/src/install/resolveOptions.js +7 -2
- package/build/src/install/resolveOptions.js.map +1 -1
- package/build/src/install/utils/checkPackagesCompatibility.js +1 -1
- package/build/src/install/utils/checkPackagesCompatibility.js.map +1 -1
- package/build/src/lint/ESlintPrerequisite.js +32 -48
- package/build/src/lint/ESlintPrerequisite.js.map +1 -1
- package/build/src/lint/index.js +45 -47
- package/build/src/lint/index.js.map +1 -1
- package/build/src/lint/lintAsync.js +150 -4
- package/build/src/lint/lintAsync.js.map +1 -1
- package/build/src/lint/resolveOptions.js +115 -0
- package/build/src/lint/resolveOptions.js.map +1 -0
- package/build/src/prebuild/renameTemplateAppName.js +4 -1
- package/build/src/prebuild/renameTemplateAppName.js.map +1 -1
- package/build/src/prebuild/resolveTemplate.js +4 -4
- package/build/src/prebuild/resolveTemplate.js.map +1 -1
- package/build/src/prebuild/updatePackageJson.js +19 -9
- package/build/src/prebuild/updatePackageJson.js.map +1 -1
- package/build/src/run/android/resolveOptions.js +13 -1
- package/build/src/run/android/resolveOptions.js.map +1 -1
- package/build/src/run/android/runAndroidAsync.js +39 -17
- package/build/src/run/android/runAndroidAsync.js.map +1 -1
- package/build/src/run/ios/XcodeBuild.js +3 -3
- package/build/src/run/ios/XcodeBuild.js.map +1 -1
- package/build/src/run/ios/options/resolveOptions.js +13 -1
- package/build/src/run/ios/options/resolveOptions.js.map +1 -1
- package/build/src/run/ios/runIosAsync.js +38 -7
- package/build/src/run/ios/runIosAsync.js.map +1 -1
- package/build/src/start/doctor/SecurityBinPrerequisite.js +1 -1
- package/build/src/start/doctor/SecurityBinPrerequisite.js.map +1 -1
- package/build/src/start/doctor/apple/XcodePrerequisite.js +1 -1
- package/build/src/start/doctor/apple/XcodePrerequisite.js.map +1 -1
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +1 -1
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
- package/build/src/start/doctor/dependencies/resolvePackages.js +1 -1
- package/build/src/start/doctor/dependencies/resolvePackages.js.map +1 -1
- package/build/src/start/doctor/ngrok/ExternalModule.js +1 -1
- package/build/src/start/doctor/ngrok/ExternalModule.js.map +1 -1
- package/build/src/start/index.js +1 -1
- package/build/src/start/index.js.map +1 -1
- package/build/src/start/platforms/PlatformManager.js +1 -1
- package/build/src/start/platforms/PlatformManager.js.map +1 -1
- package/build/src/start/platforms/android/AndroidPlatformManager.js +1 -1
- package/build/src/start/platforms/android/AndroidPlatformManager.js.map +1 -1
- package/build/src/start/platforms/android/getDevices.js +1 -1
- package/build/src/start/platforms/android/getDevices.js.map +1 -1
- package/build/src/start/platforms/ios/AppleDeviceManager.js +1 -1
- package/build/src/start/platforms/ios/AppleDeviceManager.js.map +1 -1
- package/build/src/start/platforms/ios/xcrun.js +1 -1
- package/build/src/start/platforms/ios/xcrun.js.map +1 -1
- package/build/src/start/project/dotExpo.js +5 -0
- package/build/src/start/project/dotExpo.js.map +1 -1
- package/build/src/start/resolveOptions.js +3 -0
- package/build/src/start/resolveOptions.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +38 -26
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/MetroTerminalReporter.js +29 -2
- package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
- package/build/src/start/server/metro/createExpoFallbackResolver.js +6 -4
- package/build/src/start/server/metro/createExpoFallbackResolver.js.map +1 -1
- package/build/src/start/server/metro/createJResolver.js +2 -2
- package/build/src/start/server/metro/createJResolver.js.map +1 -1
- package/build/src/start/server/metro/createServerComponentsMiddleware.js +16 -5
- package/build/src/start/server/metro/createServerComponentsMiddleware.js.map +1 -1
- package/build/src/start/server/metro/debugging/createDebugMiddleware.js +19 -19
- package/build/src/start/server/metro/debugging/createDebugMiddleware.js.map +1 -1
- package/build/src/start/server/metro/externals.js +1 -1
- package/build/src/start/server/metro/externals.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +13 -8
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/log-box/LogBoxSymbolication.js +21 -2
- package/build/src/start/server/metro/log-box/LogBoxSymbolication.js.map +1 -1
- package/build/src/start/server/metro/log-box/formatProjectFilePath.js +15 -12
- package/build/src/start/server/metro/log-box/formatProjectFilePath.js.map +1 -1
- package/build/src/start/server/metro/metroErrorInterface.js +19 -8
- package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
- package/build/src/start/server/metro/runServer-fork.js +1 -1
- package/build/src/start/server/metro/runServer-fork.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +7 -12
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/middleware/CorsMiddleware.js +1 -1
- package/build/src/start/server/middleware/CorsMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +4 -8
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/inspector/JsInspector.js +2 -25
- package/build/src/start/server/middleware/inspector/JsInspector.js.map +1 -1
- package/build/src/start/server/middleware/metroOptions.js +2 -26
- package/build/src/start/server/middleware/metroOptions.js.map +1 -1
- package/build/src/utils/build-cache-providers/helpers.js +61 -0
- package/build/src/utils/build-cache-providers/helpers.js.map +1 -0
- package/build/src/utils/build-cache-providers/index.js +283 -0
- package/build/src/utils/build-cache-providers/index.js.map +1 -0
- package/build/src/utils/codesigning.js +14 -2
- package/build/src/utils/codesigning.js.map +1 -1
- package/build/src/utils/exit.js +0 -1
- package/build/src/utils/exit.js.map +1 -1
- package/build/src/utils/ip.js +7 -104
- package/build/src/utils/ip.js.map +1 -1
- package/build/src/utils/modifyConfigAsync.js +1 -1
- package/build/src/utils/modifyConfigAsync.js.map +1 -1
- package/build/src/utils/resolveArgs.js +8 -0
- package/build/src/utils/resolveArgs.js.map +1 -1
- package/build/src/utils/scheme.js +1 -1
- package/build/src/utils/scheme.js.map +1 -1
- package/build/src/utils/telemetry/clients/FetchClient.js +2 -2
- package/build/src/utils/telemetry/clients/FetchClient.js.map +1 -1
- package/build/src/utils/telemetry/utils/context.js +1 -1
- package/build/src/utils/tsconfig/evaluateTsConfig.js +7 -2
- package/build/src/utils/tsconfig/evaluateTsConfig.js.map +1 -1
- package/build/src/utils/variadic.js +63 -6
- package/build/src/utils/variadic.js.map +1 -1
- package/package.json +20 -20
- package/static/canary/react-is/cjs/react-is.development.js +118 -185
- package/static/canary/react-is/cjs/react-is.production.js +2 -2
- package/static/canary/react-native/Libraries/Renderer/implementations/ReactFabric-dev.js +16582 -26565
- package/static/canary/react-native/Libraries/Renderer/implementations/ReactFabric-prod.js +3495 -3357
- package/static/canary/react-native/Libraries/Renderer/implementations/ReactFabric-profiling.js +3929 -3801
- package/static/canary/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +16869 -27032
- package/static/canary/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +3535 -3428
- package/static/canary/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +4198 -4095
- package/static/canary/scheduler/cjs/scheduler-unstable_mock.development.js +387 -684
- package/static/canary/scheduler/cjs/scheduler-unstable_mock.production.js +0 -9
- package/static/canary/scheduler/cjs/scheduler-unstable_post_task.development.js +137 -195
- package/static/canary/scheduler/cjs/scheduler-unstable_post_task.production.js +0 -5
- package/static/canary/scheduler/cjs/scheduler.development.js +339 -600
- package/static/canary/scheduler/cjs/scheduler.native.development.js +324 -512
- package/static/canary/scheduler/cjs/scheduler.native.production.js +6 -5
- package/static/canary/scheduler/cjs/scheduler.production.js +16 -17
- package/static/canary-full/react/cjs/react-compiler-runtime.development.js +13 -68
- package/static/canary-full/react/cjs/react-jsx-dev-runtime.development.js +317 -1251
- package/static/canary-full/react/cjs/react-jsx-dev-runtime.react-server.development.js +353 -1286
- package/static/canary-full/react/cjs/react-jsx-runtime.development.js +326 -1279
- package/static/canary-full/react/cjs/react-jsx-runtime.react-server.development.js +353 -1286
- package/static/canary-full/react/cjs/react.development.js +1204 -2771
- package/static/canary-full/react/cjs/react.production.js +25 -20
- package/static/canary-full/react/cjs/react.react-server.development.js +783 -2162
- package/static/canary-full/react/cjs/react.react-server.production.js +13 -63
- package/static/canary-full/react/package.json +1 -1
- package/static/canary-full/react-dom/cjs/react-dom-client.development.js +24847 -37099
- package/static/canary-full/react-dom/cjs/react-dom-client.production.js +8261 -7475
- package/static/canary-full/react-dom/cjs/react-dom-profiling.development.js +25252 -37571
- package/static/canary-full/react-dom/cjs/react-dom-profiling.profiling.js +9442 -8662
- package/static/canary-full/react-dom/cjs/react-dom-server-legacy.browser.development.js +8944 -11568
- package/static/canary-full/react-dom/cjs/react-dom-server-legacy.browser.production.js +1378 -944
- package/static/canary-full/react-dom/cjs/react-dom-server-legacy.node.development.js +8944 -11568
- package/static/canary-full/react-dom/cjs/react-dom-server-legacy.node.production.js +1386 -954
- package/static/canary-full/react-dom/cjs/react-dom-server.browser.development.js +9344 -11600
- package/static/canary-full/react-dom/cjs/react-dom-server.browser.production.js +1545 -954
- package/static/canary-full/react-dom/cjs/react-dom-server.bun.development.js +8286 -11064
- package/static/canary-full/react-dom/cjs/react-dom-server.bun.production.js +1437 -976
- package/static/canary-full/react-dom/cjs/react-dom-server.edge.development.js +9356 -11609
- package/static/canary-full/react-dom/cjs/react-dom-server.edge.production.js +1542 -970
- package/static/canary-full/react-dom/cjs/react-dom-server.node.development.js +9227 -11571
- package/static/canary-full/react-dom/cjs/react-dom-server.node.production.js +1787 -1183
- package/static/canary-full/react-dom/cjs/react-dom-test-utils.development.js +13 -59
- package/static/canary-full/react-dom/cjs/react-dom.development.js +402 -604
- package/static/canary-full/react-dom/cjs/react-dom.production.js +4 -3
- package/static/canary-full/react-dom/cjs/react-dom.react-server.development.js +322 -382
- package/static/canary-full/react-dom/cjs/react-dom.react-server.production.js +6 -7
- package/static/canary-full/react-dom/package.json +5 -5
- package/static/canary-full/react-dom/static.browser.js +1 -0
- package/static/canary-full/react-dom/static.edge.js +1 -0
- package/static/canary-full/react-dom/static.node.js +1 -0
- package/static/template/eslint.config.js +10 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/middleware/ManifestMiddleware.ts"],"sourcesContent":["import {\n ExpoConfig,\n ExpoGoConfig,\n getConfig,\n PackageJSONConfig,\n ProjectConfig,\n} from '@expo/config';\nimport { resolveEntryPoint, getMetroServerRoot } from '@expo/config/paths';\nimport path from 'path';\nimport { resolve } from 'url';\n\nimport { ExpoMiddleware } from './ExpoMiddleware';\nimport {\n shouldEnableAsyncImports,\n createBundleUrlPath,\n getBaseUrlFromExpoConfig,\n getAsyncRoutesFromExpoConfig,\n createBundleUrlPathFromExpoConfig,\n convertPathToModuleSpecifier,\n} from './metroOptions';\nimport { resolveGoogleServicesFile, resolveManifestAssets } from './resolveAssets';\nimport { parsePlatformHeader, RuntimePlatform } from './resolvePlatform';\nimport { ServerHeaders, ServerNext, ServerRequest, ServerResponse } from './server.types';\nimport { isEnableHermesManaged } from '../../../export/exportHermes';\nimport * as Log from '../../../log';\nimport { CommandError } from '../../../utils/errors';\nimport { stripExtension } from '../../../utils/url';\nimport * as ProjectDevices from '../../project/devices';\nimport { UrlCreator } from '../UrlCreator';\nimport { getRouterDirectoryModuleIdWithManifest } from '../metro/router';\nimport { getPlatformBundlers, PlatformBundlers } from '../platformBundlers';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../webTemplate';\n\nconst debug = require('debug')('expo:start:server:middleware:manifest') as typeof console.log;\n\nconst supportedPlatforms = ['ios', 'android', 'web', 'none'];\n\nexport function getEntryWithServerRoot(\n projectRoot: string,\n props: { platform: string; pkg?: PackageJSONConfig }\n) {\n if (!supportedPlatforms.includes(props.platform)) {\n throw new CommandError(\n `Failed to resolve the project's entry file: The platform \"${props.platform}\" is not supported.`\n );\n }\n return convertPathToModuleSpecifier(\n path.relative(getMetroServerRoot(projectRoot), resolveEntryPoint(projectRoot, props))\n );\n}\n\n/** Get the main entry module ID (file) relative to the project root. */\nexport function resolveMainModuleName(\n projectRoot: string,\n props: { platform: string; pkg?: PackageJSONConfig }\n): string {\n const entryPoint = getEntryWithServerRoot(projectRoot, props);\n\n debug(`Resolved entry point: ${entryPoint} (project root: ${projectRoot})`);\n\n return convertPathToModuleSpecifier(stripExtension(entryPoint, 'js'));\n}\n\n/** Info about the computer hosting the dev server. */\nexport interface HostInfo {\n host: string;\n server: 'expo';\n serverVersion: string;\n serverDriver: string | null;\n serverOS: NodeJS.Platform;\n serverOSVersion: string;\n}\n\n/** Parsed values from the supported request headers. */\nexport interface ManifestRequestInfo {\n /** Platform to serve. */\n platform: RuntimePlatform;\n /** Requested host name. */\n hostname?: string | null;\n /** The protocol used to request the manifest */\n protocol?: 'http' | 'https';\n}\n\n/** Project related info. */\nexport type ResponseProjectSettings = {\n expoGoConfig: ExpoGoConfig;\n hostUri: string;\n bundleUrl: string;\n exp: ExpoConfig;\n};\n\nexport const DEVELOPER_TOOL = 'expo-cli';\n\nexport type ManifestMiddlewareOptions = {\n /** Should start the dev servers in development mode (minify). */\n mode?: 'development' | 'production';\n /** Should instruct the bundler to create minified bundles. */\n minify?: boolean;\n constructUrl: UrlCreator['constructUrl'];\n isNativeWebpack?: boolean;\n privateKeyPath?: string;\n};\n\n/** Base middleware creator for serving the Expo manifest (like the index.html but for native runtimes). */\nexport abstract class ManifestMiddleware<\n TManifestRequestInfo extends ManifestRequestInfo,\n> extends ExpoMiddleware {\n private initialProjectConfig: ProjectConfig;\n private platformBundlers: PlatformBundlers;\n\n constructor(\n protected projectRoot: string,\n protected options: ManifestMiddlewareOptions\n ) {\n super(\n projectRoot,\n /**\n * Only support `/`, `/manifest`, `/index.exp` for the manifest middleware.\n */\n ['/', '/manifest', '/index.exp']\n );\n this.initialProjectConfig = getConfig(projectRoot);\n this.platformBundlers = getPlatformBundlers(projectRoot, this.initialProjectConfig.exp);\n }\n\n /** Exposed for testing. */\n public async _resolveProjectSettingsAsync({\n platform,\n hostname,\n protocol,\n }: Pick<\n TManifestRequestInfo,\n 'hostname' | 'platform' | 'protocol'\n >): Promise<ResponseProjectSettings> {\n // Read the config\n const projectConfig = getConfig(this.projectRoot);\n\n // Read from headers\n const mainModuleName = this.resolveMainModuleName({\n pkg: projectConfig.pkg,\n platform,\n });\n\n const isHermesEnabled = isEnableHermesManaged(projectConfig.exp, platform);\n\n // Create the manifest and set fields within it\n const expoGoConfig = this.getExpoGoConfig({\n mainModuleName,\n hostname,\n });\n\n const hostUri = this.options.constructUrl({ scheme: '', hostname });\n\n const bundleUrl = this._getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n engine: isHermesEnabled ? 'hermes' : undefined,\n baseUrl: getBaseUrlFromExpoConfig(projectConfig.exp),\n asyncRoutes: getAsyncRoutesFromExpoConfig(\n projectConfig.exp,\n this.options.mode ?? 'development',\n platform\n ),\n routerRoot: getRouterDirectoryModuleIdWithManifest(this.projectRoot, projectConfig.exp),\n protocol,\n reactCompiler: !!projectConfig.exp.experiments?.reactCompiler,\n });\n\n // Resolve all assets and set them on the manifest as URLs\n await this.mutateManifestWithAssetsAsync(projectConfig.exp, bundleUrl);\n\n return {\n expoGoConfig,\n hostUri,\n bundleUrl,\n exp: projectConfig.exp,\n };\n }\n\n /** Get the main entry module ID (file) relative to the project root. */\n private resolveMainModuleName(props: { pkg: PackageJSONConfig; platform: string }): string {\n let entryPoint = getEntryWithServerRoot(this.projectRoot, props);\n\n debug(`Resolved entry point: ${entryPoint} (project root: ${this.projectRoot})`);\n\n // NOTE(Bacon): Webpack is currently hardcoded to index.bundle on native\n // in the future (TODO) we should move this logic into a Webpack plugin and use\n // a generated file name like we do on web.\n // const server = getDefaultDevServer();\n // // TODO: Move this into BundlerDevServer and read this info from self.\n // const isNativeWebpack = server instanceof WebpackBundlerDevServer && server.isTargetingNative();\n if (this.options.isNativeWebpack) {\n entryPoint = 'index.js';\n }\n\n return stripExtension(entryPoint, 'js');\n }\n\n /** Parse request headers into options. */\n public abstract getParsedHeaders(req: ServerRequest): TManifestRequestInfo;\n\n /** Store device IDs that were sent in the request headers. */\n private async saveDevicesAsync(req: ServerRequest) {\n const deviceIds = req.headers?.['expo-dev-client-id'];\n if (deviceIds) {\n await ProjectDevices.saveDevicesAsync(this.projectRoot, deviceIds).catch((e) =>\n Log.exception(e)\n );\n }\n }\n\n /** Create the bundle URL (points to the single JS entry file). Exposed for testing. */\n public _getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n engine,\n baseUrl,\n isExporting,\n asyncRoutes,\n routerRoot,\n protocol,\n reactCompiler,\n }: {\n platform: string;\n hostname?: string | null;\n mainModuleName: string;\n engine?: 'hermes';\n baseUrl?: string;\n asyncRoutes: boolean;\n isExporting?: boolean;\n routerRoot: string;\n protocol?: 'http' | 'https';\n reactCompiler: boolean;\n }): string {\n const path = createBundleUrlPath({\n mode: this.options.mode ?? 'development',\n minify: this.options.minify,\n platform,\n mainModuleName,\n lazy: shouldEnableAsyncImports(this.projectRoot),\n engine,\n bytecode: engine === 'hermes',\n baseUrl,\n isExporting: !!isExporting,\n asyncRoutes,\n routerRoot,\n reactCompiler,\n });\n\n return (\n this.options.constructUrl({\n scheme: protocol ?? 'http',\n // hostType: this.options.location.hostType,\n hostname,\n }) + path\n );\n }\n\n /** Get the manifest response to return to the runtime. This file contains info regarding where the assets can be loaded from. Exposed for testing. */\n public abstract _getManifestResponseAsync(options: TManifestRequestInfo): Promise<{\n body: string;\n version: string;\n headers: ServerHeaders;\n }>;\n\n private getExpoGoConfig({\n mainModuleName,\n hostname,\n }: {\n mainModuleName: string;\n hostname?: string | null;\n }): ExpoGoConfig {\n return {\n // localhost:8081\n debuggerHost: this.options.constructUrl({ scheme: '', hostname }),\n // Required for Expo Go to function.\n developer: {\n tool: DEVELOPER_TOOL,\n projectRoot: this.projectRoot,\n },\n packagerOpts: {\n // Required for dev client.\n dev: this.options.mode !== 'production',\n },\n // Indicates the name of the main bundle.\n mainModuleName,\n // Add this string to make Flipper register React Native / Metro as \"running\".\n // Can be tested by running:\n // `METRO_SERVER_PORT=8081 open -a flipper.app`\n // Where 8081 is the port where the Expo project is being hosted.\n __flipperHack: 'React Native packager is running',\n };\n }\n\n /** Resolve all assets and set them on the manifest as URLs */\n private async mutateManifestWithAssetsAsync(manifest: ExpoConfig, bundleUrl: string) {\n await resolveManifestAssets(this.projectRoot, {\n manifest,\n resolver: async (path) => {\n if (this.options.isNativeWebpack) {\n // When using our custom dev server, just do assets normally\n // without the `assets/` subpath redirect.\n return resolve(bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0], path);\n }\n return bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0] + 'assets/' + path;\n },\n });\n // The server normally inserts this but if we're offline we'll do it here\n await resolveGoogleServicesFile(this.projectRoot, manifest);\n }\n\n public getWebBundleUrl() {\n const platform = 'web';\n // Read from headers\n const mainModuleName = this.resolveMainModuleName({\n pkg: this.initialProjectConfig.pkg,\n platform,\n });\n\n return createBundleUrlPathFromExpoConfig(this.projectRoot, this.initialProjectConfig.exp, {\n platform,\n mainModuleName,\n minify: this.options.minify,\n lazy: shouldEnableAsyncImports(this.projectRoot),\n mode: this.options.mode ?? 'development',\n // Hermes doesn't support more modern JS features than most, if not all, modern browser.\n engine: 'hermes',\n isExporting: false,\n bytecode: false,\n });\n }\n\n /**\n * Web platforms should create an index.html response using the same script resolution as native.\n *\n * Instead of adding a `bundleUrl` to a `manifest.json` (native) we'll add a `<script src=\"\">`\n * to an `index.html`, this enables the web platform to load JavaScript from the server.\n */\n private async handleWebRequestAsync(req: ServerRequest, res: ServerResponse) {\n res.setHeader('Content-Type', 'text/html');\n\n res.end(await this.getSingleHtmlTemplateAsync());\n }\n\n getSingleHtmlTemplateAsync() {\n // Read from headers\n const bundleUrl = this.getWebBundleUrl();\n\n return createTemplateHtmlFromExpoConfigAsync(this.projectRoot, {\n exp: this.initialProjectConfig.exp,\n scripts: [bundleUrl],\n });\n }\n\n /** Exposed for testing. */\n async checkBrowserRequestAsync(req: ServerRequest, res: ServerResponse, next: ServerNext) {\n if (\n this.platformBundlers.web === 'metro' &&\n this.initialProjectConfig.exp.platforms?.includes('web')\n ) {\n // NOTE(EvanBacon): This effectively disables the safety check we do on custom runtimes to ensure\n // the `expo-platform` header is included. When `web.bundler=web`, if the user has non-standard Expo\n // code loading then they'll get a web bundle without a clear assertion of platform support.\n const platform = parsePlatformHeader(req);\n // On web, serve the public folder\n if (!platform || platform === 'web') {\n if (['static', 'server'].includes(this.initialProjectConfig.exp.web?.output ?? '')) {\n // Skip the spa-styled index.html when static generation is enabled.\n next();\n return true;\n } else {\n await this.handleWebRequestAsync(req, res);\n return true;\n }\n }\n }\n return false;\n }\n\n async handleRequestAsync(\n req: ServerRequest,\n res: ServerResponse,\n next: ServerNext\n ): Promise<void> {\n // First check for standard JavaScript runtimes (aka legacy browsers like Chrome).\n if (await this.checkBrowserRequestAsync(req, res, next)) {\n return;\n }\n\n // Save device IDs for dev client.\n await this.saveDevicesAsync(req);\n\n // Read from headers\n const options = this.getParsedHeaders(req);\n const { body, headers } = await this._getManifestResponseAsync(options);\n for (const [headerName, headerValue] of headers) {\n res.setHeader(headerName, headerValue);\n }\n res.end(body);\n }\n}\n"],"names":["DEVELOPER_TOOL","ManifestMiddleware","getEntryWithServerRoot","resolveMainModuleName","debug","require","supportedPlatforms","projectRoot","props","includes","platform","CommandError","convertPathToModuleSpecifier","path","relative","getMetroServerRoot","resolveEntryPoint","entryPoint","stripExtension","ExpoMiddleware","constructor","options","initialProjectConfig","getConfig","platformBundlers","getPlatformBundlers","exp","_resolveProjectSettingsAsync","hostname","protocol","projectConfig","mainModuleName","pkg","isHermesEnabled","isEnableHermesManaged","expoGoConfig","getExpoGoConfig","hostUri","constructUrl","scheme","bundleUrl","_getBundleUrl","engine","undefined","baseUrl","getBaseUrlFromExpoConfig","asyncRoutes","getAsyncRoutesFromExpoConfig","mode","routerRoot","getRouterDirectoryModuleIdWithManifest","reactCompiler","experiments","mutateManifestWithAssetsAsync","isNativeWebpack","saveDevicesAsync","req","deviceIds","headers","ProjectDevices","catch","e","Log","exception","isExporting","createBundleUrlPath","minify","lazy","shouldEnableAsyncImports","bytecode","debuggerHost","developer","tool","packagerOpts","dev","__flipperHack","manifest","resolveManifestAssets","resolver","resolve","match","resolveGoogleServicesFile","getWebBundleUrl","createBundleUrlPathFromExpoConfig","handleWebRequestAsync","res","setHeader","end","getSingleHtmlTemplateAsync","createTemplateHtmlFromExpoConfigAsync","scripts","checkBrowserRequestAsync","next","web","platforms","parsePlatformHeader","output","handleRequestAsync","getParsedHeaders","body","_getManifestResponseAsync","headerName","headerValue"],"mappings":";;;;;;;;;;;IA2FaA,cAAc;eAAdA;;IAaSC,kBAAkB;eAAlBA;;IAnENC,sBAAsB;eAAtBA;;IAeAC,qBAAqB;eAArBA;;;;yBA9CT;;;;;;;yBAC+C;;;;;;;gEACrC;;;;;;;yBACO;;;;;;gCAEO;8BAQxB;+BAC0D;iCACZ;8BAEf;6DACjB;wBACQ;sBACE;iEACC;wBAEuB;kCACD;6BACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AMnC,UAAU,IAAI,CAAC6E,gBAAgB,CAAC1C;QACtC,MAAM,EAAE2C,IAAI,EAAEzC,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC0C,yBAAyB,CAAC/E;QAC/D,KAAK,MAAM,CAACgF,YAAYC,YAAY,IAAI5C,QAAS;YAC/C2B,IAAIC,SAAS,CAACe,YAAYC;QAC5B;QACAjB,IAAIE,GAAG,CAACY;IACV;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/middleware/ManifestMiddleware.ts"],"sourcesContent":["import {\n ExpoConfig,\n ExpoGoConfig,\n getConfig,\n PackageJSONConfig,\n ProjectConfig,\n} from '@expo/config';\nimport { resolveEntryPoint, getMetroServerRoot } from '@expo/config/paths';\nimport path from 'path';\nimport { resolve } from 'url';\n\nimport { ExpoMiddleware } from './ExpoMiddleware';\nimport {\n createBundleUrlPath,\n getBaseUrlFromExpoConfig,\n getAsyncRoutesFromExpoConfig,\n createBundleUrlPathFromExpoConfig,\n convertPathToModuleSpecifier,\n} from './metroOptions';\nimport { resolveGoogleServicesFile, resolveManifestAssets } from './resolveAssets';\nimport { parsePlatformHeader, RuntimePlatform } from './resolvePlatform';\nimport { ServerHeaders, ServerNext, ServerRequest, ServerResponse } from './server.types';\nimport { isEnableHermesManaged } from '../../../export/exportHermes';\nimport * as Log from '../../../log';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { stripExtension } from '../../../utils/url';\nimport * as ProjectDevices from '../../project/devices';\nimport { UrlCreator } from '../UrlCreator';\nimport { getRouterDirectoryModuleIdWithManifest } from '../metro/router';\nimport { getPlatformBundlers, PlatformBundlers } from '../platformBundlers';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../webTemplate';\n\nconst debug = require('debug')('expo:start:server:middleware:manifest') as typeof console.log;\n\nconst supportedPlatforms = ['ios', 'android', 'web', 'none'];\n\nexport function getEntryWithServerRoot(\n projectRoot: string,\n props: { platform: string; pkg?: PackageJSONConfig }\n) {\n if (!supportedPlatforms.includes(props.platform)) {\n throw new CommandError(\n `Failed to resolve the project's entry file: The platform \"${props.platform}\" is not supported.`\n );\n }\n return convertPathToModuleSpecifier(\n path.relative(getMetroServerRoot(projectRoot), resolveEntryPoint(projectRoot, props))\n );\n}\n\n/** Get the main entry module ID (file) relative to the project root. */\nexport function resolveMainModuleName(\n projectRoot: string,\n props: { platform: string; pkg?: PackageJSONConfig }\n): string {\n const entryPoint = getEntryWithServerRoot(projectRoot, props);\n\n debug(`Resolved entry point: ${entryPoint} (project root: ${projectRoot})`);\n\n return convertPathToModuleSpecifier(stripExtension(entryPoint, 'js'));\n}\n\n/** Info about the computer hosting the dev server. */\nexport interface HostInfo {\n host: string;\n server: 'expo';\n serverVersion: string;\n serverDriver: string | null;\n serverOS: NodeJS.Platform;\n serverOSVersion: string;\n}\n\n/** Parsed values from the supported request headers. */\nexport interface ManifestRequestInfo {\n /** Platform to serve. */\n platform: RuntimePlatform;\n /** Requested host name. */\n hostname?: string | null;\n /** The protocol used to request the manifest */\n protocol?: 'http' | 'https';\n}\n\n/** Project related info. */\nexport type ResponseProjectSettings = {\n expoGoConfig: ExpoGoConfig;\n hostUri: string;\n bundleUrl: string;\n exp: ExpoConfig;\n};\n\nexport const DEVELOPER_TOOL = 'expo-cli';\n\nexport type ManifestMiddlewareOptions = {\n /** Should start the dev servers in development mode (minify). */\n mode?: 'development' | 'production';\n /** Should instruct the bundler to create minified bundles. */\n minify?: boolean;\n constructUrl: UrlCreator['constructUrl'];\n isNativeWebpack?: boolean;\n privateKeyPath?: string;\n};\n\n/** Base middleware creator for serving the Expo manifest (like the index.html but for native runtimes). */\nexport abstract class ManifestMiddleware<\n TManifestRequestInfo extends ManifestRequestInfo,\n> extends ExpoMiddleware {\n private initialProjectConfig: ProjectConfig;\n private platformBundlers: PlatformBundlers;\n\n constructor(\n protected projectRoot: string,\n protected options: ManifestMiddlewareOptions\n ) {\n super(\n projectRoot,\n /**\n * Only support `/`, `/manifest`, `/index.exp` for the manifest middleware.\n */\n ['/', '/manifest', '/index.exp']\n );\n this.initialProjectConfig = getConfig(projectRoot);\n this.platformBundlers = getPlatformBundlers(projectRoot, this.initialProjectConfig.exp);\n }\n\n /** Exposed for testing. */\n public async _resolveProjectSettingsAsync({\n platform,\n hostname,\n protocol,\n }: Pick<\n TManifestRequestInfo,\n 'hostname' | 'platform' | 'protocol'\n >): Promise<ResponseProjectSettings> {\n // Read the config\n const projectConfig = getConfig(this.projectRoot);\n\n // Read from headers\n const mainModuleName = this.resolveMainModuleName({\n pkg: projectConfig.pkg,\n platform,\n });\n\n const isHermesEnabled = isEnableHermesManaged(projectConfig.exp, platform);\n\n // Create the manifest and set fields within it\n const expoGoConfig = this.getExpoGoConfig({\n mainModuleName,\n hostname,\n });\n\n const hostUri = this.options.constructUrl({ scheme: '', hostname });\n\n const bundleUrl = this._getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n engine: isHermesEnabled ? 'hermes' : undefined,\n baseUrl: getBaseUrlFromExpoConfig(projectConfig.exp),\n asyncRoutes: getAsyncRoutesFromExpoConfig(\n projectConfig.exp,\n this.options.mode ?? 'development',\n platform\n ),\n routerRoot: getRouterDirectoryModuleIdWithManifest(this.projectRoot, projectConfig.exp),\n protocol,\n reactCompiler: !!projectConfig.exp.experiments?.reactCompiler,\n });\n\n // Resolve all assets and set them on the manifest as URLs\n await this.mutateManifestWithAssetsAsync(projectConfig.exp, bundleUrl);\n\n return {\n expoGoConfig,\n hostUri,\n bundleUrl,\n exp: projectConfig.exp,\n };\n }\n\n /** Get the main entry module ID (file) relative to the project root. */\n private resolveMainModuleName(props: { pkg: PackageJSONConfig; platform: string }): string {\n let entryPoint = getEntryWithServerRoot(this.projectRoot, props);\n\n debug(`Resolved entry point: ${entryPoint} (project root: ${this.projectRoot})`);\n\n // NOTE(Bacon): Webpack is currently hardcoded to index.bundle on native\n // in the future (TODO) we should move this logic into a Webpack plugin and use\n // a generated file name like we do on web.\n // const server = getDefaultDevServer();\n // // TODO: Move this into BundlerDevServer and read this info from self.\n // const isNativeWebpack = server instanceof WebpackBundlerDevServer && server.isTargetingNative();\n if (this.options.isNativeWebpack) {\n entryPoint = 'index.js';\n }\n\n return stripExtension(entryPoint, 'js');\n }\n\n /** Parse request headers into options. */\n public abstract getParsedHeaders(req: ServerRequest): TManifestRequestInfo;\n\n /** Store device IDs that were sent in the request headers. */\n private async saveDevicesAsync(req: ServerRequest) {\n const deviceIds = req.headers?.['expo-dev-client-id'];\n if (deviceIds) {\n await ProjectDevices.saveDevicesAsync(this.projectRoot, deviceIds).catch((e) =>\n Log.exception(e)\n );\n }\n }\n\n /** Create the bundle URL (points to the single JS entry file). Exposed for testing. */\n public _getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n engine,\n baseUrl,\n isExporting,\n asyncRoutes,\n routerRoot,\n protocol,\n reactCompiler,\n }: {\n platform: string;\n hostname?: string | null;\n mainModuleName: string;\n engine?: 'hermes';\n baseUrl?: string;\n asyncRoutes: boolean;\n isExporting?: boolean;\n routerRoot: string;\n protocol?: 'http' | 'https';\n reactCompiler: boolean;\n }): string {\n const path = createBundleUrlPath({\n mode: this.options.mode ?? 'development',\n minify: this.options.minify,\n platform,\n mainModuleName,\n lazy: !env.EXPO_NO_METRO_LAZY,\n engine,\n bytecode: engine === 'hermes',\n baseUrl,\n isExporting: !!isExporting,\n asyncRoutes,\n routerRoot,\n reactCompiler,\n });\n\n return (\n this.options.constructUrl({\n scheme: protocol ?? 'http',\n // hostType: this.options.location.hostType,\n hostname,\n }) + path\n );\n }\n\n /** Get the manifest response to return to the runtime. This file contains info regarding where the assets can be loaded from. Exposed for testing. */\n public abstract _getManifestResponseAsync(options: TManifestRequestInfo): Promise<{\n body: string;\n version: string;\n headers: ServerHeaders;\n }>;\n\n private getExpoGoConfig({\n mainModuleName,\n hostname,\n }: {\n mainModuleName: string;\n hostname?: string | null;\n }): ExpoGoConfig {\n return {\n // localhost:8081\n debuggerHost: this.options.constructUrl({ scheme: '', hostname }),\n // Required for Expo Go to function.\n developer: {\n tool: DEVELOPER_TOOL,\n projectRoot: this.projectRoot,\n },\n packagerOpts: {\n // Required for dev client.\n dev: this.options.mode !== 'production',\n },\n // Indicates the name of the main bundle.\n mainModuleName,\n };\n }\n\n /** Resolve all assets and set them on the manifest as URLs */\n private async mutateManifestWithAssetsAsync(manifest: ExpoConfig, bundleUrl: string) {\n await resolveManifestAssets(this.projectRoot, {\n manifest,\n resolver: async (path) => {\n if (this.options.isNativeWebpack) {\n // When using our custom dev server, just do assets normally\n // without the `assets/` subpath redirect.\n return resolve(bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0], path);\n }\n return bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0] + 'assets/' + path;\n },\n });\n // The server normally inserts this but if we're offline we'll do it here\n await resolveGoogleServicesFile(this.projectRoot, manifest);\n }\n\n public getWebBundleUrl() {\n const platform = 'web';\n // Read from headers\n const mainModuleName = this.resolveMainModuleName({\n pkg: this.initialProjectConfig.pkg,\n platform,\n });\n\n return createBundleUrlPathFromExpoConfig(this.projectRoot, this.initialProjectConfig.exp, {\n platform,\n mainModuleName,\n minify: this.options.minify,\n lazy: !env.EXPO_NO_METRO_LAZY,\n mode: this.options.mode ?? 'development',\n // Hermes doesn't support more modern JS features than most, if not all, modern browser.\n engine: 'hermes',\n isExporting: false,\n bytecode: false,\n });\n }\n\n /**\n * Web platforms should create an index.html response using the same script resolution as native.\n *\n * Instead of adding a `bundleUrl` to a `manifest.json` (native) we'll add a `<script src=\"\">`\n * to an `index.html`, this enables the web platform to load JavaScript from the server.\n */\n private async handleWebRequestAsync(req: ServerRequest, res: ServerResponse) {\n res.setHeader('Content-Type', 'text/html');\n\n res.end(await this.getSingleHtmlTemplateAsync());\n }\n\n getSingleHtmlTemplateAsync() {\n // Read from headers\n const bundleUrl = this.getWebBundleUrl();\n\n return createTemplateHtmlFromExpoConfigAsync(this.projectRoot, {\n exp: this.initialProjectConfig.exp,\n scripts: [bundleUrl],\n });\n }\n\n /** Exposed for testing. */\n async checkBrowserRequestAsync(req: ServerRequest, res: ServerResponse, next: ServerNext) {\n if (\n this.platformBundlers.web === 'metro' &&\n this.initialProjectConfig.exp.platforms?.includes('web')\n ) {\n // NOTE(EvanBacon): This effectively disables the safety check we do on custom runtimes to ensure\n // the `expo-platform` header is included. When `web.bundler=web`, if the user has non-standard Expo\n // code loading then they'll get a web bundle without a clear assertion of platform support.\n const platform = parsePlatformHeader(req);\n // On web, serve the public folder\n if (!platform || platform === 'web') {\n if (['static', 'server'].includes(this.initialProjectConfig.exp.web?.output ?? '')) {\n // Skip the spa-styled index.html when static generation is enabled.\n next();\n return true;\n } else {\n await this.handleWebRequestAsync(req, res);\n return true;\n }\n }\n }\n return false;\n }\n\n async handleRequestAsync(\n req: ServerRequest,\n res: ServerResponse,\n next: ServerNext\n ): Promise<void> {\n // First check for standard JavaScript runtimes (aka legacy browsers like Chrome).\n if (await this.checkBrowserRequestAsync(req, res, next)) {\n return;\n }\n\n // Save device IDs for dev client.\n await this.saveDevicesAsync(req);\n\n // Read from headers\n const options = this.getParsedHeaders(req);\n const { body, headers } = await this._getManifestResponseAsync(options);\n for (const [headerName, headerValue] of headers) {\n res.setHeader(headerName, headerValue);\n }\n res.end(body);\n }\n}\n"],"names":["DEVELOPER_TOOL","ManifestMiddleware","getEntryWithServerRoot","resolveMainModuleName","debug","require","supportedPlatforms","projectRoot","props","includes","platform","CommandError","convertPathToModuleSpecifier","path","relative","getMetroServerRoot","resolveEntryPoint","entryPoint","stripExtension","ExpoMiddleware","constructor","options","initialProjectConfig","getConfig","platformBundlers","getPlatformBundlers","exp","_resolveProjectSettingsAsync","hostname","protocol","projectConfig","mainModuleName","pkg","isHermesEnabled","isEnableHermesManaged","expoGoConfig","getExpoGoConfig","hostUri","constructUrl","scheme","bundleUrl","_getBundleUrl","engine","undefined","baseUrl","getBaseUrlFromExpoConfig","asyncRoutes","getAsyncRoutesFromExpoConfig","mode","routerRoot","getRouterDirectoryModuleIdWithManifest","reactCompiler","experiments","mutateManifestWithAssetsAsync","isNativeWebpack","saveDevicesAsync","req","deviceIds","headers","ProjectDevices","catch","e","Log","exception","isExporting","createBundleUrlPath","minify","lazy","env","EXPO_NO_METRO_LAZY","bytecode","debuggerHost","developer","tool","packagerOpts","dev","manifest","resolveManifestAssets","resolver","resolve","match","resolveGoogleServicesFile","getWebBundleUrl","createBundleUrlPathFromExpoConfig","handleWebRequestAsync","res","setHeader","end","getSingleHtmlTemplateAsync","createTemplateHtmlFromExpoConfigAsync","scripts","checkBrowserRequestAsync","next","web","platforms","parsePlatformHeader","output","handleRequestAsync","getParsedHeaders","body","_getManifestResponseAsync","headerName","headerValue"],"mappings":";;;;;;;;;;;IA2FaA,cAAc;eAAdA;;IAaSC,kBAAkB;eAAlBA;;IAnENC,sBAAsB;eAAtBA;;IAeAC,qBAAqB;eAArBA;;;;yBA9CT;;;;;;;yBAC+C;;;;;;;gEACrC;;;;;;;yBACO;;;;;;gCAEO;8BAOxB;+BAC0D;iCACZ;8BAEf;6DACjB;qBACD;wBACS;sBACE;iEACC;wBAEuB;kCACD;6BACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtD,MAAMC,QAAQC,QAAQ,SAAS;AAE/B,MAAMC,qBAAqB;IAAC;IAAO;IAAW;IAAO;CAAO;AAErD,SAASJ,uBACdK,WAAmB,EACnBC,KAAoD;IAEpD,IAAI,CAACF,mBAAmBG,QAAQ,CAACD,MAAME,QAAQ,GAAG;QAChD,MAAM,IAAIC,oBAAY,CACpB,CAAC,0DAA0D,EAAEH,MAAME,QAAQ,CAAC,mBAAmB,CAAC;IAEpG;IACA,OAAOE,IAAAA,0CAA4B,EACjCC,eAAI,CAACC,QAAQ,CAACC,IAAAA,2BAAkB,EAACR,cAAcS,IAAAA,0BAAiB,EAACT,aAAaC;AAElF;AAGO,SAASL,sBACdI,WAAmB,EACnBC,KAAoD;IAEpD,MAAMS,aAAaf,uBAAuBK,aAAaC;IA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F,IAAAA,oCAAmB,EAACvC;YACrC,kCAAkC;YAClC,IAAI,CAAC9C,YAAYA,aAAa,OAAO;oBACD;gBAAlC,IAAI;oBAAC;oBAAU;iBAAS,CAACD,QAAQ,CAAC,EAAA,qCAAA,IAAI,CAACa,oBAAoB,CAACI,GAAG,CAACmE,GAAG,qBAAjC,mCAAmCG,MAAM,KAAI,KAAK;oBAClF,oEAAoE;oBACpEJ;oBACA,OAAO;gBACT,OAAO;oBACL,MAAM,IAAI,CAACR,qBAAqB,CAAC5B,KAAK6B;oBACtC,OAAO;gBACT;YACF;QACF;QACA,OAAO;IACT;IAEA,MAAMY,mBACJzC,GAAkB,EAClB6B,GAAmB,EACnBO,IAAgB,EACD;QACf,kFAAkF;QAClF,IAAI,MAAM,IAAI,CAACD,wBAAwB,CAACnC,KAAK6B,KAAKO,OAAO;YACvD;QACF;QAEA,kCAAkC;QAClC,MAAM,IAAI,CAACrC,gBAAgB,CAACC;QAE5B,oBAAoB;QACpB,MAAMnC,UAAU,IAAI,CAAC6E,gBAAgB,CAAC1C;QACtC,MAAM,EAAE2C,IAAI,EAAEzC,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC0C,yBAAyB,CAAC/E;QAC/D,KAAK,MAAM,CAACgF,YAAYC,YAAY,IAAI5C,QAAS;YAC/C2B,IAAIC,SAAS,CAACe,YAAYC;QAC5B;QACAjB,IAAIE,GAAG,CAACY;IACV;AACF"}
|
|
@@ -45,8 +45,6 @@ async function openJsInspector(metroBaseUrl, app) {
|
|
|
45
45
|
return false;
|
|
46
46
|
}
|
|
47
47
|
const url = new URL('/open-debugger', metroBaseUrl);
|
|
48
|
-
url.searchParams.set('appId', app.description);
|
|
49
|
-
url.searchParams.set('device', app.reactNative.logicalDeviceId);
|
|
50
48
|
url.searchParams.set('target', app.id);
|
|
51
49
|
// Request to open the React Native DevTools, but limit it to 1s
|
|
52
50
|
// This is a workaround as this endpoint might not respond on some devices
|
|
@@ -69,13 +67,13 @@ async function openJsInspector(metroBaseUrl, app) {
|
|
|
69
67
|
}
|
|
70
68
|
async function queryInspectorAppAsync(metroServerOrigin, appId) {
|
|
71
69
|
const apps = await queryAllInspectorAppsAsync(metroServerOrigin);
|
|
72
|
-
return apps.find((app)=>app.
|
|
70
|
+
return apps.find((app)=>app.appId === appId) ?? null;
|
|
73
71
|
}
|
|
74
72
|
async function queryAllInspectorAppsAsync(metroServerOrigin) {
|
|
75
73
|
const resp = await fetch(`${metroServerOrigin}/json/list`);
|
|
76
74
|
// The newest runtime will be at the end of the list,
|
|
77
75
|
// reversing the result would save time from try-error.
|
|
78
|
-
const apps =
|
|
76
|
+
const apps = (await resp.json()).reverse();
|
|
79
77
|
const results = [];
|
|
80
78
|
for (const app of apps){
|
|
81
79
|
// Only use targets with better reloading support
|
|
@@ -115,27 +113,6 @@ async function promptInspectorAppAsync(apps) {
|
|
|
115
113
|
const value = await (0, _prompts.selectAsync)((0, _chalk().default)`Debug target {dim (Hermes only)}`, choices);
|
|
116
114
|
return (_choices_find = choices.find((item)=>item.value === value)) == null ? void 0 : _choices_find.app;
|
|
117
115
|
}
|
|
118
|
-
// The description of `React Native Experimental (Improved Chrome Reloads)` target is `don't use` from metro.
|
|
119
|
-
// This function tries to transform the unmeaningful description to appId
|
|
120
|
-
function transformApps(apps) {
|
|
121
|
-
const deviceIdToAppId = {};
|
|
122
|
-
for (const app of apps){
|
|
123
|
-
if (app.description !== "don't use") {
|
|
124
|
-
var _app_reactNative;
|
|
125
|
-
const deviceId = ((_app_reactNative = app.reactNative) == null ? void 0 : _app_reactNative.logicalDeviceId) ?? app.id.split('-')[0];
|
|
126
|
-
const appId = app.description;
|
|
127
|
-
deviceIdToAppId[deviceId] = appId;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return apps.map((app)=>{
|
|
131
|
-
if (app.description === "don't use") {
|
|
132
|
-
var _app_reactNative;
|
|
133
|
-
const deviceId = ((_app_reactNative = app.reactNative) == null ? void 0 : _app_reactNative.logicalDeviceId) ?? app.id.split('-')[0];
|
|
134
|
-
app.description = deviceIdToAppId[deviceId] ?? app.description;
|
|
135
|
-
}
|
|
136
|
-
return app;
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
116
|
const HIDE_FROM_INSPECTOR_ENV = 'globalThis.__expo_hide_from_inspector__';
|
|
140
117
|
async function appShouldBeIgnoredAsync(app) {
|
|
141
118
|
const hideFromInspector = await (0, _CdpClient.evaluateJsFromCdpAsync)(app.webSocketDebuggerUrl, HIDE_FROM_INSPECTOR_ENV);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/start/server/middleware/inspector/JsInspector.ts"],"sourcesContent":["import type { CustomMessageHandlerConnection } from '@react-native/dev-middleware';\nimport chalk from 'chalk';\n\nimport { evaluateJsFromCdpAsync } from './CdpClient';\nimport { selectAsync } from '../../../../utils/prompts';\nimport { pageIsSupported } from '../../metro/debugging/pageIsSupported';\n\nconst debug = require('debug')(\n 'expo:start:server:middleware:inspector:jsInspector'\n) as typeof console.log;\n\nexport interface MetroInspectorProxyApp {\n /** Unique device ID combined with the page ID */\n id: string;\n /** Information about the underlying CDP implementation, e.g. \"React Native Bridgeless [C++ connection]\" */\n title: string;\n /** The application ID that is currently running on the device, e.g. \"dev.expo.bareexpo\" */\n description: string;\n /** The CDP debugger type, which should always be \"node\" */\n type: 'node';\n /** The internal `devtools://..` URL for the debugger to connect to */\n devtoolsFrontendUrl: string;\n /** The websocket URL for the debugger to connect to */\n webSocketDebuggerUrl: string;\n /**\n * Human-readable device name\n * @since react-native@0.73\n */\n deviceName: string;\n /**\n * React Native specific information, like the unique device ID and native capabilities\n * @since react-native@0.74\n */\n reactNative?: {\n /** The unique device ID */\n logicalDeviceId: string;\n /** All supported native capabilities */\n capabilities: CustomMessageHandlerConnection['page']['capabilities'];\n };\n}\n\n/**\n * Launch the React Native DevTools by executing the `POST /open-debugger` request.\n * This endpoint is handled through `@react-native/dev-middleware`.\n */\nexport async function openJsInspector(metroBaseUrl: string, app: MetroInspectorProxyApp) {\n if (!app.reactNative?.logicalDeviceId) {\n debug('Failed to open React Native DevTools, target is missing device ID');\n return false;\n }\n\n const url = new URL('/open-debugger', metroBaseUrl);\n url.searchParams.set('appId', app.description);\n url.searchParams.set('device', app.reactNative.logicalDeviceId);\n url.searchParams.set('target', app.id);\n\n // Request to open the React Native DevTools, but limit it to 1s\n // This is a workaround as this endpoint might not respond on some devices\n const response = await fetch(url, {\n method: 'POST',\n signal: AbortSignal.timeout(1000),\n }).catch((error) => {\n // Only swallow timeout errors\n if (error.name === 'TimeoutError') {\n return null;\n }\n\n throw error;\n });\n\n if (!response) {\n debug(`No response received from the React Native DevTools.`);\n } else if (response.ok === false) {\n debug('Failed to open React Native DevTools, received response:', response.status);\n }\n\n return response?.ok ?? true;\n}\n\nexport async function queryInspectorAppAsync(\n metroServerOrigin: string,\n appId: string\n): Promise<MetroInspectorProxyApp | null> {\n const apps = await queryAllInspectorAppsAsync(metroServerOrigin);\n return apps.find((app) => app.description === appId) ?? null;\n}\n\nexport async function queryAllInspectorAppsAsync(\n metroServerOrigin: string\n): Promise<MetroInspectorProxyApp[]> {\n const resp = await fetch(`${metroServerOrigin}/json/list`);\n // The newest runtime will be at the end of the list,\n // reversing the result would save time from try-error.\n const apps: MetroInspectorProxyApp[] = transformApps(await resp.json()).reverse();\n const results: MetroInspectorProxyApp[] = [];\n for (const app of apps) {\n // Only use targets with better reloading support\n if (!pageIsSupported(app)) {\n continue;\n }\n\n try {\n // Hide targets that are marked as hidden from the inspector, e.g. instances from expo-dev-menu and expo-dev-launcher.\n if (await appShouldBeIgnoredAsync(app)) {\n continue;\n }\n } catch (e: unknown) {\n // If we can't evaluate the JS, we just ignore the error and skips the target.\n debug(`Can't evaluate the JS on the app:`, JSON.stringify(e, null, 2));\n continue;\n }\n\n results.push(app);\n }\n return results;\n}\n\nexport async function promptInspectorAppAsync(apps: MetroInspectorProxyApp[]) {\n if (apps.length === 1) {\n return apps[0];\n }\n\n // Check if multiple devices are connected with the same device names\n // In this case, append the actual app id (device ID + page number) to the prompt\n const hasDuplicateNames = apps.some(\n (app, index) => index !== apps.findIndex((other) => app.deviceName === other.deviceName)\n );\n\n const choices = apps.map((app) => {\n const name = app.deviceName ?? 'Unknown device';\n return {\n title: hasDuplicateNames ? chalk`${name}{dim - ${app.id}}` : name,\n value: app.id,\n app,\n };\n });\n\n const value = await selectAsync(chalk`Debug target {dim (Hermes only)}`, choices);\n\n return choices.find((item) => item.value === value)?.app;\n}\n\n// The description of `React Native Experimental (Improved Chrome Reloads)` target is `don't use` from metro.\n// This function tries to transform the unmeaningful description to appId\nfunction transformApps(apps: MetroInspectorProxyApp[]): MetroInspectorProxyApp[] {\n const deviceIdToAppId: Record<string, string> = {};\n\n for (const app of apps) {\n if (app.description !== \"don't use\") {\n const deviceId = app.reactNative?.logicalDeviceId ?? app.id.split('-')[0];\n const appId = app.description;\n deviceIdToAppId[deviceId] = appId;\n }\n }\n\n return apps.map((app) => {\n if (app.description === \"don't use\") {\n const deviceId = app.reactNative?.logicalDeviceId ?? app.id.split('-')[0];\n app.description = deviceIdToAppId[deviceId] ?? app.description;\n }\n return app;\n });\n}\n\nconst HIDE_FROM_INSPECTOR_ENV = 'globalThis.__expo_hide_from_inspector__';\n\nasync function appShouldBeIgnoredAsync(app: MetroInspectorProxyApp): Promise<boolean> {\n const hideFromInspector = await evaluateJsFromCdpAsync(\n app.webSocketDebuggerUrl,\n HIDE_FROM_INSPECTOR_ENV\n );\n debug(\n `[appShouldBeIgnoredAsync] webSocketDebuggerUrl[${app.webSocketDebuggerUrl}] hideFromInspector[${hideFromInspector}]`\n );\n return hideFromInspector !== undefined;\n}\n"],"names":["openJsInspector","promptInspectorAppAsync","queryAllInspectorAppsAsync","queryInspectorAppAsync","debug","require","metroBaseUrl","app","reactNative","logicalDeviceId","url","URL","searchParams","set","description","id","response","fetch","method","signal","AbortSignal","timeout","catch","error","name","ok","status","metroServerOrigin","appId","apps","find","resp","transformApps","json","reverse","results","pageIsSupported","appShouldBeIgnoredAsync","e","JSON","stringify","push","choices","length","hasDuplicateNames","some","index","findIndex","other","deviceName","map","title","chalk","value","selectAsync","item","deviceIdToAppId","deviceId","split","HIDE_FROM_INSPECTOR_ENV","hideFromInspector","evaluateJsFromCdpAsync","webSocketDebuggerUrl","undefined"],"mappings":";;;;;;;;;;;IA6CsBA,eAAe;eAAfA;;IAwEAC,uBAAuB;eAAvBA;;IA9BAC,0BAA0B;eAA1BA;;IARAC,sBAAsB;eAAtBA;;;;gEA9EJ;;;;;;2BAEqB;yBACX;iCACI;;;;;;AAEhC,MAAMC,QAAQC,QAAQ,SACpB;AAqCK,eAAeL,gBAAgBM,YAAoB,EAAEC,GAA2B;QAChFA;IAAL,IAAI,GAACA,mBAAAA,IAAIC,WAAW,qBAAfD,iBAAiBE,eAAe,GAAE;QACrCL,MAAM;QACN,OAAO;IACT;IAEA,MAAMM,MAAM,IAAIC,IAAI,kBAAkBL;IACtCI,IAAIE,YAAY,CAACC,GAAG,CAAC,SAASN,IAAIO,WAAW;IAC7CJ,IAAIE,YAAY,CAACC,GAAG,CAAC,UAAUN,IAAIC,WAAW,CAACC,eAAe;IAC9DC,IAAIE,YAAY,CAACC,GAAG,CAAC,UAAUN,IAAIQ,EAAE;IAErC,gEAAgE;IAChE,0EAA0E;IAC1E,MAAMC,WAAW,MAAMC,MAAMP,KAAK;QAChCQ,QAAQ;QACRC,QAAQC,YAAYC,OAAO,CAAC;IAC9B,GAAGC,KAAK,CAAC,CAACC;QACR,8BAA8B;QAC9B,IAAIA,MAAMC,IAAI,KAAK,gBAAgB;YACjC,OAAO;QACT;QAEA,MAAMD;IACR;IAEA,IAAI,CAACP,UAAU;QACbZ,MAAM,CAAC,oDAAoD,CAAC;IAC9D,OAAO,IAAIY,SAASS,EAAE,KAAK,OAAO;QAChCrB,MAAM,4DAA4DY,SAASU,MAAM;IACnF;IAEA,OAAOV,CAAAA,4BAAAA,SAAUS,EAAE,KAAI;AACzB;AAEO,eAAetB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B"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/start/server/middleware/inspector/JsInspector.ts"],"sourcesContent":["import type { CustomMessageHandlerConnection } from '@react-native/dev-middleware';\nimport chalk from 'chalk';\n\nimport { evaluateJsFromCdpAsync } from './CdpClient';\nimport { selectAsync } from '../../../../utils/prompts';\nimport { pageIsSupported } from '../../metro/debugging/pageIsSupported';\n\nconst debug = require('debug')(\n 'expo:start:server:middleware:inspector:jsInspector'\n) as typeof console.log;\n\nexport interface MetroInspectorProxyApp {\n /** Unique device ID combined with the page ID */\n id: string;\n /** Information about the underlying CDP implementation, e.g. \"React Native Bridgeless [C++ connection]\" */\n title: string;\n /** The application ID that is currently running on the device, e.g. \"dev.expo.bareexpo\" */\n appId: string;\n /** The description of the runtime, e.g. \"React Native Bridgeless [C++ connection]\" */\n description: string;\n /** The CDP debugger type, which should always be \"node\" */\n type: 'node';\n /** The internal `devtools://..` URL for the debugger to connect to */\n devtoolsFrontendUrl: string;\n /** The websocket URL for the debugger to connect to */\n webSocketDebuggerUrl: string;\n /**\n * Human-readable device name\n * @since react-native@0.73\n */\n deviceName: string;\n /**\n * React Native specific information, like the unique device ID and native capabilities\n * @since react-native@0.74\n */\n reactNative?: {\n /** The unique device ID */\n logicalDeviceId: string;\n /** All supported native capabilities */\n capabilities: CustomMessageHandlerConnection['page']['capabilities'];\n };\n}\n\n/**\n * Launch the React Native DevTools by executing the `POST /open-debugger` request.\n * This endpoint is handled through `@react-native/dev-middleware`.\n */\nexport async function openJsInspector(metroBaseUrl: string, app: MetroInspectorProxyApp) {\n if (!app.reactNative?.logicalDeviceId) {\n debug('Failed to open React Native DevTools, target is missing device ID');\n return false;\n }\n\n const url = new URL('/open-debugger', metroBaseUrl);\n url.searchParams.set('target', app.id);\n\n // Request to open the React Native DevTools, but limit it to 1s\n // This is a workaround as this endpoint might not respond on some devices\n const response = await fetch(url, {\n method: 'POST',\n signal: AbortSignal.timeout(1000),\n }).catch((error) => {\n // Only swallow timeout errors\n if (error.name === 'TimeoutError') {\n return null;\n }\n\n throw error;\n });\n\n if (!response) {\n debug(`No response received from the React Native DevTools.`);\n } else if (response.ok === false) {\n debug('Failed to open React Native DevTools, received response:', response.status);\n }\n\n return response?.ok ?? true;\n}\n\nexport async function queryInspectorAppAsync(\n metroServerOrigin: string,\n appId: string\n): Promise<MetroInspectorProxyApp | null> {\n const apps = await queryAllInspectorAppsAsync(metroServerOrigin);\n return apps.find((app) => app.appId === appId) ?? null;\n}\n\nexport async function queryAllInspectorAppsAsync(\n metroServerOrigin: string\n): Promise<MetroInspectorProxyApp[]> {\n const resp = await fetch(`${metroServerOrigin}/json/list`);\n // The newest runtime will be at the end of the list,\n // reversing the result would save time from try-error.\n const apps: MetroInspectorProxyApp[] = (await resp.json()).reverse();\n const results: MetroInspectorProxyApp[] = [];\n for (const app of apps) {\n // Only use targets with better reloading support\n if (!pageIsSupported(app)) {\n continue;\n }\n\n try {\n // Hide targets that are marked as hidden from the inspector, e.g. instances from expo-dev-menu and expo-dev-launcher.\n if (await appShouldBeIgnoredAsync(app)) {\n continue;\n }\n } catch (e: unknown) {\n // If we can't evaluate the JS, we just ignore the error and skips the target.\n debug(`Can't evaluate the JS on the app:`, JSON.stringify(e, null, 2));\n continue;\n }\n\n results.push(app);\n }\n return results;\n}\n\nexport async function promptInspectorAppAsync(apps: MetroInspectorProxyApp[]) {\n if (apps.length === 1) {\n return apps[0];\n }\n\n // Check if multiple devices are connected with the same device names\n // In this case, append the actual app id (device ID + page number) to the prompt\n const hasDuplicateNames = apps.some(\n (app, index) => index !== apps.findIndex((other) => app.deviceName === other.deviceName)\n );\n\n const choices = apps.map((app) => {\n const name = app.deviceName ?? 'Unknown device';\n return {\n title: hasDuplicateNames ? chalk`${name}{dim - ${app.id}}` : name,\n value: app.id,\n app,\n };\n });\n\n const value = await selectAsync(chalk`Debug target {dim (Hermes only)}`, choices);\n\n return choices.find((item) => item.value === value)?.app;\n}\n\nconst HIDE_FROM_INSPECTOR_ENV = 'globalThis.__expo_hide_from_inspector__';\n\nasync function appShouldBeIgnoredAsync(app: MetroInspectorProxyApp): Promise<boolean> {\n const hideFromInspector = await evaluateJsFromCdpAsync(\n app.webSocketDebuggerUrl,\n HIDE_FROM_INSPECTOR_ENV\n );\n debug(\n `[appShouldBeIgnoredAsync] webSocketDebuggerUrl[${app.webSocketDebuggerUrl}] hideFromInspector[${hideFromInspector}]`\n );\n return hideFromInspector !== undefined;\n}\n"],"names":["openJsInspector","promptInspectorAppAsync","queryAllInspectorAppsAsync","queryInspectorAppAsync","debug","require","metroBaseUrl","app","reactNative","logicalDeviceId","url","URL","searchParams","set","id","response","fetch","method","signal","AbortSignal","timeout","catch","error","name","ok","status","metroServerOrigin","appId","apps","find","resp","json","reverse","results","pageIsSupported","appShouldBeIgnoredAsync","e","JSON","stringify","push","choices","length","hasDuplicateNames","some","index","findIndex","other","deviceName","map","title","chalk","value","selectAsync","item","HIDE_FROM_INSPECTOR_ENV","hideFromInspector","evaluateJsFromCdpAsync","webSocketDebuggerUrl","undefined"],"mappings":";;;;;;;;;;;IA+CsBA,eAAe;eAAfA;;IAsEAC,uBAAuB;eAAvBA;;IA9BAC,0BAA0B;eAA1BA;;IARAC,sBAAsB;eAAtBA;;;;gEA9EJ;;;;;;2BAEqB;yBACX;iCACI;;;;;;AAEhC,MAAMC,QAAQC,QAAQ,SACpB;AAuCK,eAAeL,gBAAgBM,YAAoB,EAAEC,GAA2B;QAChFA;IAAL,IAAI,GAACA,mBAAAA,IAAIC,WAAW,qBAAfD,iBAAiBE,eAAe,GAAE;QACrCL,MAAM;QACN,OAAO;IACT;IAEA,MAAMM,MAAM,IAAIC,IAAI,kBAAkBL;IACtCI,IAAIE,YAAY,CAACC,GAAG,CAAC,UAAUN,IAAIO,EAAE;IAErC,gEAAgE;IAChE,0EAA0E;IAC1E,MAAMC,WAAW,MAAMC,MAAMN,KAAK;QAChCO,QAAQ;QACRC,QAAQC,YAAYC,OAAO,CAAC;IAC9B,GAAGC,KAAK,CA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pC,KAAKqC,QAAUA,UAAUhB,KAAKiB,SAAS,CAAC,CAACC,QAAUvC,IAAIwC,UAAU,KAAKD,MAAMC,UAAU;IAGzF,MAAMP,UAAUZ,KAAKoB,GAAG,CAAC,CAACzC;QACxB,MAAMgB,OAAOhB,IAAIwC,UAAU,IAAI;QAC/B,OAAO;YACLE,OAAOP,oBAAoBQ,IAAAA,gBAAK,CAAA,CAAC,EAAE3B,KAAK,QAAQ,EAAEhB,IAAIO,EAAE,CAAC,CAAC,CAAC,GAAGS;YAC9D4B,OAAO5C,IAAIO,EAAE;YACbP;QACF;IACF;IAEA,MAAM4C,QAAQ,MAAMC,IAAAA,oBAAW,EAACF,IAAAA,gBAAK,CAAA,CAAC,gCAAgC,CAAC,EAAEV;IAEzE,QAAOA,gBAAAA,QAAQX,IAAI,CAAC,CAACwB,OAASA,KAAKF,KAAK,KAAKA,2BAAtCX,cAA8CjC,GAAG;AAC1D;AAEA,MAAM+C,0BAA0B;AAEhC,eAAenB,wBAAwB5B,GAA2B;IAChE,MAAMgD,oBAAoB,MAAMC,IAAAA,iCAAsB,EACpDjD,IAAIkD,oBAAoB,EACxBH;IAEFlD,MACE,CAAC,+CAA+C,EAAEG,IAAIkD,oBAAoB,CAAC,oBAAoB,EAAEF,kBAAkB,CAAC,CAAC;IAEvH,OAAOA,sBAAsBG;AAC/B"}
|
|
@@ -41,41 +41,16 @@ _export(exports, {
|
|
|
41
41
|
},
|
|
42
42
|
isServerEnvironment: function() {
|
|
43
43
|
return isServerEnvironment;
|
|
44
|
-
},
|
|
45
|
-
shouldEnableAsyncImports: function() {
|
|
46
|
-
return shouldEnableAsyncImports;
|
|
47
44
|
}
|
|
48
45
|
});
|
|
49
|
-
function _resolvefrom() {
|
|
50
|
-
const data = /*#__PURE__*/ _interop_require_default(require("resolve-from"));
|
|
51
|
-
_resolvefrom = function() {
|
|
52
|
-
return data;
|
|
53
|
-
};
|
|
54
|
-
return data;
|
|
55
|
-
}
|
|
56
46
|
const _env = require("../../../utils/env");
|
|
57
47
|
const _errors = require("../../../utils/errors");
|
|
58
48
|
const _filePath = require("../../../utils/filePath");
|
|
59
49
|
const _router = require("../metro/router");
|
|
60
|
-
function _interop_require_default(obj) {
|
|
61
|
-
return obj && obj.__esModule ? obj : {
|
|
62
|
-
default: obj
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
50
|
const debug = require('debug')('expo:metro:options');
|
|
66
51
|
function isServerEnvironment(environment) {
|
|
67
52
|
return environment === 'node' || environment === 'react-server';
|
|
68
53
|
}
|
|
69
|
-
function shouldEnableAsyncImports(projectRoot) {
|
|
70
|
-
if (_env.env.EXPO_NO_METRO_LAZY) {
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
// `@expo/metro-runtime` includes support for the fetch + eval runtime code required
|
|
74
|
-
// to support async imports. If it's not installed, we can't support async imports.
|
|
75
|
-
// If it is installed, the user MUST import it somewhere in their project.
|
|
76
|
-
// Expo Router automatically pulls this in, so we can check for it.
|
|
77
|
-
return _resolvefrom().default.silent(projectRoot, '@expo/metro-runtime/package.json') != null;
|
|
78
|
-
}
|
|
79
54
|
function withDefaults({ mode = 'development', minify = mode === 'production', preserveEnvVars = mode !== 'development' && _env.env.EXPO_NO_CLIENT_ENV_VARS, lazy, environment, ...props }) {
|
|
80
55
|
if (props.bytecode) {
|
|
81
56
|
if (props.platform === 'web') {
|
|
@@ -192,7 +167,8 @@ function getMetroDirectBundleOptions(options) {
|
|
|
192
167
|
splitChunks,
|
|
193
168
|
usedExports: usedExports || undefined,
|
|
194
169
|
output: serializerOutput,
|
|
195
|
-
includeSourceMaps: serializerIncludeMaps
|
|
170
|
+
includeSourceMaps: serializerIncludeMaps,
|
|
171
|
+
exporting: isExporting || undefined
|
|
196
172
|
}
|
|
197
173
|
};
|
|
198
174
|
return bundleOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/middleware/metroOptions.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport type { BundleOptions as MetroBundleOptions } from 'metro/src/shared/types';\nimport resolveFrom from 'resolve-from';\n\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { toPosixPath } from '../../../utils/filePath';\nimport { getRouterDirectoryModuleIdWithManifest } from '../metro/router';\n\nconst debug = require('debug')('expo:metro:options') as typeof console.log;\n\nexport type MetroEnvironment = 'node' | 'react-server' | 'client';\n\nexport type ExpoMetroOptions = {\n platform: string;\n mainModuleName: string;\n mode: string;\n minify?: boolean;\n environment?: MetroEnvironment;\n serializerOutput?: 'static';\n serializerIncludeMaps?: boolean;\n lazy?: boolean;\n engine?: 'hermes';\n preserveEnvVars?: boolean;\n bytecode: boolean;\n /** Enable async routes (route-based bundle splitting) in Expo Router. */\n asyncRoutes?: boolean;\n /** Module ID relative to the projectRoot for the Expo Router app directory. */\n routerRoot: string;\n /** Enable React compiler support in Babel. */\n reactCompiler: boolean;\n baseUrl?: string;\n isExporting: boolean;\n /** Is bundling a DOM Component (\"use dom\"). Requires the entry dom component file path. */\n domRoot?: string;\n /** Exporting MD5 filename based on file contents, for EAS Update. */\n useMd5Filename?: boolean;\n inlineSourceMap?: boolean;\n clientBoundaries?: string[];\n splitChunks?: boolean;\n usedExports?: boolean;\n /** Enable optimized bundling (required for tree shaking). */\n optimize?: boolean;\n\n modulesOnly?: boolean;\n runModule?: boolean;\n};\n\nexport type SerializerOptions = {\n includeSourceMaps?: boolean;\n output?: 'static';\n splitChunks?: boolean;\n usedExports?: boolean;\n};\n\nexport type ExpoMetroBundleOptions = MetroBundleOptions & {\n serializerOptions?: SerializerOptions;\n};\n\nexport function isServerEnvironment(environment?: any): boolean {\n return environment === 'node' || environment === 'react-server';\n}\n\nexport function shouldEnableAsyncImports(projectRoot: string): boolean {\n if (env.EXPO_NO_METRO_LAZY) {\n return false;\n }\n\n // `@expo/metro-runtime` includes support for the fetch + eval runtime code required\n // to support async imports. If it's not installed, we can't support async imports.\n // If it is installed, the user MUST import it somewhere in their project.\n // Expo Router automatically pulls this in, so we can check for it.\n return resolveFrom.silent(projectRoot, '@expo/metro-runtime/package.json') != null;\n}\n\nfunction withDefaults({\n mode = 'development',\n minify = mode === 'production',\n preserveEnvVars = mode !== 'development' && env.EXPO_NO_CLIENT_ENV_VARS,\n lazy,\n environment,\n ...props\n}: ExpoMetroOptions): ExpoMetroOptions {\n if (props.bytecode) {\n if (props.platform === 'web') {\n throw new CommandError('Cannot use bytecode with the web platform');\n }\n if (props.engine !== 'hermes') {\n throw new CommandError('Bytecode is only supported with the Hermes engine');\n }\n }\n\n const optimize =\n props.optimize ??\n (environment !== 'node' && mode === 'production' && env.EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH);\n\n return {\n mode,\n minify,\n preserveEnvVars,\n optimize,\n usedExports: optimize && env.EXPO_UNSTABLE_TREE_SHAKING,\n lazy: !props.isExporting && lazy,\n environment: environment === 'client' ? undefined : environment,\n ...props,\n };\n}\n\nexport function getBaseUrlFromExpoConfig(exp: ExpoConfig) {\n return exp.experiments?.baseUrl?.trim().replace(/\\/+$/, '') ?? '';\n}\n\nexport function getAsyncRoutesFromExpoConfig(exp: ExpoConfig, mode: string, platform: string) {\n let asyncRoutesSetting;\n\n if (exp.extra?.router?.asyncRoutes) {\n const asyncRoutes = exp.extra?.router?.asyncRoutes;\n if (['boolean', 'string'].includes(typeof asyncRoutes)) {\n asyncRoutesSetting = asyncRoutes;\n } else if (typeof asyncRoutes === 'object') {\n asyncRoutesSetting = asyncRoutes[platform] ?? asyncRoutes.default;\n }\n }\n\n return [mode, true].includes(asyncRoutesSetting);\n}\n\nexport function getMetroDirectBundleOptionsForExpoConfig(\n projectRoot: string,\n exp: ExpoConfig,\n options: Omit<ExpoMetroOptions, 'baseUrl' | 'reactCompiler' | 'routerRoot' | 'asyncRoutes'>\n): Partial<ExpoMetroBundleOptions> {\n return getMetroDirectBundleOptions({\n ...options,\n reactCompiler: !!exp.experiments?.reactCompiler,\n baseUrl: getBaseUrlFromExpoConfig(exp),\n routerRoot: getRouterDirectoryModuleIdWithManifest(projectRoot, exp),\n asyncRoutes: getAsyncRoutesFromExpoConfig(exp, options.mode, options.platform),\n });\n}\n\nexport function getMetroDirectBundleOptions(\n options: ExpoMetroOptions\n): Partial<ExpoMetroBundleOptions> {\n const {\n mainModuleName,\n platform,\n mode,\n minify,\n environment,\n serializerOutput,\n serializerIncludeMaps,\n bytecode,\n lazy,\n engine,\n preserveEnvVars,\n asyncRoutes,\n baseUrl,\n routerRoot,\n isExporting,\n inlineSourceMap,\n splitChunks,\n usedExports,\n reactCompiler,\n optimize,\n domRoot,\n clientBoundaries,\n runModule,\n modulesOnly,\n useMd5Filename,\n } = withDefaults(options);\n\n const dev = mode !== 'production';\n const isHermes = engine === 'hermes';\n\n if (isExporting) {\n debug('Disabling lazy bundling for export build');\n options.lazy = false;\n }\n\n let fakeSourceUrl: string | undefined;\n let fakeSourceMapUrl: string | undefined;\n\n // TODO: Upstream support to Metro for passing custom serializer options.\n if (serializerIncludeMaps != null || serializerOutput != null) {\n fakeSourceUrl = new URL(\n createBundleUrlPath(options).replace(/^\\//, ''),\n 'http://localhost:8081'\n ).toString();\n if (serializerIncludeMaps) {\n fakeSourceMapUrl = fakeSourceUrl.replace('.bundle?', '.map?');\n }\n }\n\n const customTransformOptions: ExpoMetroBundleOptions['customTransformOptions'] = {\n __proto__: null,\n optimize: optimize || undefined,\n engine,\n clientBoundaries,\n preserveEnvVars: preserveEnvVars || undefined,\n // Use string to match the query param behavior.\n asyncRoutes: asyncRoutes ? String(asyncRoutes) : undefined,\n environment,\n baseUrl: baseUrl || undefined,\n routerRoot,\n bytecode: bytecode ? '1' : undefined,\n reactCompiler: reactCompiler ? String(reactCompiler) : undefined,\n dom: domRoot,\n useMd5Filename: useMd5Filename || undefined,\n };\n\n // Iterate and delete undefined values\n for (const key in customTransformOptions) {\n if (customTransformOptions[key] === undefined) {\n delete customTransformOptions[key];\n }\n }\n\n const bundleOptions: Partial<ExpoMetroBundleOptions> = {\n platform,\n entryFile: mainModuleName,\n dev,\n minify: minify ?? !dev,\n inlineSourceMap: inlineSourceMap ?? false,\n lazy: (!isExporting && lazy) || undefined,\n unstable_transformProfile: isHermes ? 'hermes-stable' : 'default',\n customTransformOptions,\n runModule,\n modulesOnly,\n customResolverOptions: {\n __proto__: null,\n environment,\n exporting: isExporting || undefined,\n },\n sourceMapUrl: fakeSourceMapUrl,\n sourceUrl: fakeSourceUrl,\n serializerOptions: {\n splitChunks,\n usedExports: usedExports || undefined,\n output: serializerOutput,\n includeSourceMaps: serializerIncludeMaps,\n },\n };\n\n return bundleOptions;\n}\n\nexport function createBundleUrlPathFromExpoConfig(\n projectRoot: string,\n exp: ExpoConfig,\n options: Omit<ExpoMetroOptions, 'reactCompiler' | 'baseUrl' | 'routerRoot'>\n): string {\n return createBundleUrlPath({\n ...options,\n reactCompiler: !!exp.experiments?.reactCompiler,\n baseUrl: getBaseUrlFromExpoConfig(exp),\n routerRoot: getRouterDirectoryModuleIdWithManifest(projectRoot, exp),\n });\n}\n\nexport function createBundleUrlPath(options: ExpoMetroOptions): string {\n const queryParams = createBundleUrlSearchParams(options);\n return `/${encodeURI(options.mainModuleName.replace(/^\\/+/, ''))}.bundle?${queryParams.toString()}`;\n}\n\n/**\n * Create a bundle URL, containing all required query parameters, using a valid \"os path\".\n * On POSIX systems, this would look something like `/Users/../project/file.js?dev=false&..`.\n * On UNIX systems, this would look something like `C:\\Users\\..\\project\\file.js?dev=false&..`.\n * This path can safely be used with `path.*` modifiers and resolved.\n */\nexport function createBundleOsPath(options: ExpoMetroOptions): string {\n const queryParams = createBundleUrlSearchParams(options);\n const mainModuleName = toPosixPath(options.mainModuleName);\n return `${mainModuleName}.bundle?${queryParams.toString()}`;\n}\n\nexport function createBundleUrlSearchParams(options: ExpoMetroOptions): URLSearchParams {\n const {\n platform,\n mode,\n minify,\n environment,\n serializerOutput,\n serializerIncludeMaps,\n lazy,\n bytecode,\n engine,\n preserveEnvVars,\n asyncRoutes,\n baseUrl,\n routerRoot,\n reactCompiler,\n inlineSourceMap,\n isExporting,\n clientBoundaries,\n splitChunks,\n usedExports,\n optimize,\n domRoot,\n modulesOnly,\n runModule,\n } = withDefaults(options);\n\n const dev = String(mode !== 'production');\n const queryParams = new URLSearchParams({\n platform: encodeURIComponent(platform),\n dev,\n // TODO: Is this still needed?\n hot: String(false),\n });\n\n // Lazy bundling must be disabled for bundle splitting to work.\n if (!isExporting && lazy) {\n queryParams.append('lazy', String(lazy));\n }\n\n if (inlineSourceMap) {\n queryParams.append('inlineSourceMap', String(inlineSourceMap));\n }\n\n if (minify) {\n queryParams.append('minify', String(minify));\n }\n\n // We split bytecode from the engine since you could technically use Hermes without bytecode.\n // Hermes indicates the type of language features you want to transform out of the JS, whereas bytecode\n // indicates whether you want to use the Hermes bytecode format.\n if (engine) {\n queryParams.append('transform.engine', engine);\n }\n if (bytecode) {\n queryParams.append('transform.bytecode', '1');\n }\n if (asyncRoutes) {\n queryParams.append('transform.asyncRoutes', String(asyncRoutes));\n }\n if (preserveEnvVars) {\n queryParams.append('transform.preserveEnvVars', String(preserveEnvVars));\n }\n if (baseUrl) {\n queryParams.append('transform.baseUrl', baseUrl);\n }\n if (clientBoundaries?.length) {\n queryParams.append('transform.clientBoundaries', JSON.stringify(clientBoundaries));\n }\n if (routerRoot != null) {\n queryParams.append('transform.routerRoot', routerRoot);\n }\n if (reactCompiler) {\n queryParams.append('transform.reactCompiler', String(reactCompiler));\n }\n if (domRoot) {\n queryParams.append('transform.dom', domRoot);\n }\n\n if (environment) {\n queryParams.append('resolver.environment', environment);\n queryParams.append('transform.environment', environment);\n }\n\n if (isExporting) {\n queryParams.append('resolver.exporting', String(isExporting));\n }\n\n if (splitChunks) {\n queryParams.append('serializer.splitChunks', String(splitChunks));\n }\n if (usedExports) {\n queryParams.append('serializer.usedExports', String(usedExports));\n }\n if (optimize) {\n queryParams.append('transform.optimize', String(optimize));\n }\n if (serializerOutput) {\n queryParams.append('serializer.output', serializerOutput);\n }\n if (serializerIncludeMaps) {\n queryParams.append('serializer.map', String(serializerIncludeMaps));\n }\n if (engine === 'hermes') {\n queryParams.append('unstable_transformProfile', 'hermes-stable');\n }\n\n if (modulesOnly != null) {\n queryParams.set('modulesOnly', String(modulesOnly));\n }\n if (runModule != null) {\n queryParams.set('runModule', String(runModule));\n }\n\n return queryParams;\n}\n\n/**\n * Convert all path separators to `/`, including on Windows.\n * Metro asumes that all module specifiers are posix paths.\n * References to directories can still be Windows-style paths in Metro.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#importing_features_into_your_script\n * @see https://github.com/facebook/metro/pull/1286\n */\nexport function convertPathToModuleSpecifier(pathLike: string) {\n return toPosixPath(pathLike);\n}\n\nexport function getMetroOptionsFromUrl(urlFragment: string) {\n const url = new URL(urlFragment, 'http://localhost:0');\n const getStringParam = (key: string) => {\n const param = url.searchParams.get(key);\n if (Array.isArray(param)) {\n throw new Error(`Expected single value for ${key}`);\n }\n return param;\n };\n\n let pathname = url.pathname;\n if (pathname.endsWith('.bundle')) {\n pathname = pathname.slice(0, -'.bundle'.length);\n }\n\n const options: ExpoMetroOptions = {\n mode: isTruthy(getStringParam('dev') ?? 'true') ? 'development' : 'production',\n minify: isTruthy(getStringParam('minify') ?? 'false'),\n lazy: isTruthy(getStringParam('lazy') ?? 'false'),\n routerRoot: getStringParam('transform.routerRoot') ?? 'app',\n isExporting: isTruthy(getStringParam('resolver.exporting') ?? 'false'),\n environment: assertEnvironment(getStringParam('transform.environment') ?? 'node'),\n platform: url.searchParams.get('platform') ?? 'web',\n bytecode: isTruthy(getStringParam('transform.bytecode') ?? 'false'),\n mainModuleName: convertPathToModuleSpecifier(pathname),\n reactCompiler: isTruthy(getStringParam('transform.reactCompiler') ?? 'false'),\n asyncRoutes: isTruthy(getStringParam('transform.asyncRoutes') ?? 'false'),\n baseUrl: getStringParam('transform.baseUrl') ?? undefined,\n // clientBoundaries: JSON.parse(getStringParam('transform.clientBoundaries') ?? '[]'),\n engine: assertEngine(getStringParam('transform.engine')),\n runModule: isTruthy(getStringParam('runModule') ?? 'true'),\n modulesOnly: isTruthy(getStringParam('modulesOnly') ?? 'false'),\n };\n\n return options;\n}\n\nfunction isTruthy(value: string | null): boolean {\n return value === 'true' || value === '1';\n}\n\nfunction assertEnvironment(environment: string | undefined): MetroEnvironment | undefined {\n if (!environment) {\n return undefined;\n }\n if (!['node', 'react-server', 'client'].includes(environment)) {\n throw new Error(`Expected transform.environment to be one of: node, react-server, client`);\n }\n return environment as MetroEnvironment;\n}\nfunction assertEngine(engine: string | undefined | null): 'hermes' | undefined {\n if (!engine) {\n return undefined;\n }\n if (!['hermes'].includes(engine)) {\n throw new Error(`Expected transform.engine to be one of: hermes`);\n }\n return engine as 'hermes';\n}\n"],"names":["convertPathToModuleSpecifier","createBundleOsPath","createBundleUrlPath","createBundleUrlPathFromExpoConfig","createBundleUrlSearchParams","getAsyncRoutesFromExpoConfig","getBaseUrlFromExpoConfig","getMetroDirectBundleOptions","getMetroDirectBundleOptionsForExpoConfig","getMetroOptionsFromUrl","isServerEnvironment","shouldEnableAsyncImports","debug","require","environment","projectRoot","env","EXPO_NO_METRO_LAZY","resolveFrom","silent","withDefaults","mode","minify","preserveEnvVars","EXPO_NO_CLIENT_ENV_VARS","lazy","props","bytecode","platform","CommandError","engine","optimize","EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH","usedExports","EXPO_UNSTABLE_TREE_SHAKING","isExporting","undefined","exp","experiments","baseUrl","trim","replace","asyncRoutesSetting","extra","router","asyncRoutes","includes","default","options","reactCompiler","routerRoot","getRouterDirectoryModuleIdWithManifest","mainModuleName","serializerOutput","serializerIncludeMaps","inlineSourceMap","splitChunks","domRoot","clientBoundaries","runModule","modulesOnly","useMd5Filename","dev","isHermes","fakeSourceUrl","fakeSourceMapUrl","URL","toString","customTransformOptions","__proto__","String","dom","key","bundleOptions","entryFile","unstable_transformProfile","customResolverOptions","exporting","sourceMapUrl","sourceUrl","serializerOptions","output","includeSourceMaps","queryParams","encodeURI","toPosixPath","URLSearchParams","encodeURIComponent","hot","append","length","JSON","stringify","set","pathLike","urlFragment","url","getStringParam","param","searchParams","get","Array","isArray","Error","pathname","endsWith","slice","isTruthy","assertEnvironment","assertEngine","value"],"mappings":";;;;;;;;;;;IAkZgBA,4BAA4B;eAA5BA;;IAnIAC,kBAAkB;eAAlBA;;IAXAC,mBAAmB;eAAnBA;;IAbAC,iCAAiC;eAAjCA;;IA8BAC,2BAA2B;eAA3BA;;IArKAC,4BAA4B;eAA5BA;;IAJAC,wBAAwB;eAAxBA;;IAiCAC,2BAA2B;eAA3BA;;IAdAC,wCAAwC;eAAxCA;;IAuRAC,sBAAsB;eAAtBA;;IA3VAC,mBAAmB;eAAnBA;;IAIAC,wBAAwB;eAAxBA;;;;gEA7DQ;;;;;;qBAEJ;wBACS;0BACD;wBAC2B;;;;;;AAEvD,MAAMC,QAAQC,QAAQ,SAAS;AAkDxB,SAASH,oBAAoBI,WAAiB;IACnD,OAAOA,gBAAgB,UAAUA,gBAAgB;AACnD;AAEO,SAASH,yBAAyBI,WAAmB;IAC1D,IAAIC,QAAG,CAACC,kBAAkB,EAAE;QAC1B,OAAO;IACT;IAEA,oFAAoF;IACpF,mFAAmF;IACnF,0EAA0E;IAC1E,mEAAmE;IACnE,OAAOC,sBAAW,CAACC,MAAM,CAACJ,aAAa,uCAAuC;AAChF;AAEA,SAASK,aAAa,EACpBC,OAAO,aAAa,EACpBC,SAASD,SAAS,YAAY,EAC9BE,kBAAkBF,SAAS,iBAAiBL,QAAG,CAACQ,uBAAuB,EACvEC,IAAI,EACJX,WAAW,EACX,GAAGY,OACc;IACjB,IAAIA,MAAMC,QAAQ,EAAE;QAClB,IAAID,MAAME,QAAQ,KAAK,OAAO;YAC5B,MAAM,IAAIC,oBAAY,CAAC;QACzB;QACA,IAAIH,MAAMI,MAAM,KAAK,UAAU;YAC7B,MAAM,IAAID,oBAAY,CAAC;QACzB;IACF;IAEA,MAAME,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AAIyE,MAAM,CAAC,8CAA8C,CAAC;IAClE;IACA,OAAOzE;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/middleware/metroOptions.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport type { BundleOptions as MetroBundleOptions } from 'metro/src/shared/types';\nimport resolveFrom from 'resolve-from';\n\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { toPosixPath } from '../../../utils/filePath';\nimport { getRouterDirectoryModuleIdWithManifest } from '../metro/router';\n\nconst debug = require('debug')('expo:metro:options') as typeof console.log;\n\nexport type MetroEnvironment = 'node' | 'react-server' | 'client';\n\nexport type ExpoMetroOptions = {\n platform: string;\n mainModuleName: string;\n mode: string;\n minify?: boolean;\n environment?: MetroEnvironment;\n serializerOutput?: 'static';\n serializerIncludeMaps?: boolean;\n lazy?: boolean;\n engine?: 'hermes';\n preserveEnvVars?: boolean;\n bytecode: boolean;\n /** Enable async routes (route-based bundle splitting) in Expo Router. */\n asyncRoutes?: boolean;\n /** Module ID relative to the projectRoot for the Expo Router app directory. */\n routerRoot: string;\n /** Enable React compiler support in Babel. */\n reactCompiler: boolean;\n baseUrl?: string;\n isExporting: boolean;\n /** Is bundling a DOM Component (\"use dom\"). Requires the entry dom component file path. */\n domRoot?: string;\n /** Exporting MD5 filename based on file contents, for EAS Update. */\n useMd5Filename?: boolean;\n inlineSourceMap?: boolean;\n clientBoundaries?: string[];\n splitChunks?: boolean;\n usedExports?: boolean;\n /** Enable optimized bundling (required for tree shaking). */\n optimize?: boolean;\n\n modulesOnly?: boolean;\n runModule?: boolean;\n};\n\n// See: @expo/metro-config/src/serializer/fork/baseJSBundle.ts `ExpoSerializerOptions`\nexport type SerializerOptions = {\n includeSourceMaps?: boolean;\n output?: 'static';\n splitChunks?: boolean;\n usedExports?: boolean;\n exporting?: boolean;\n};\n\nexport type ExpoMetroBundleOptions = MetroBundleOptions & {\n serializerOptions?: SerializerOptions;\n};\n\nexport function isServerEnvironment(environment?: any): boolean {\n return environment === 'node' || environment === 'react-server';\n}\n\nfunction withDefaults({\n mode = 'development',\n minify = mode === 'production',\n preserveEnvVars = mode !== 'development' && env.EXPO_NO_CLIENT_ENV_VARS,\n lazy,\n environment,\n ...props\n}: ExpoMetroOptions): ExpoMetroOptions {\n if (props.bytecode) {\n if (props.platform === 'web') {\n throw new CommandError('Cannot use bytecode with the web platform');\n }\n if (props.engine !== 'hermes') {\n throw new CommandError('Bytecode is only supported with the Hermes engine');\n }\n }\n\n const optimize =\n props.optimize ??\n (environment !== 'node' && mode === 'production' && env.EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH);\n\n return {\n mode,\n minify,\n preserveEnvVars,\n optimize,\n usedExports: optimize && env.EXPO_UNSTABLE_TREE_SHAKING,\n lazy: !props.isExporting && lazy,\n environment: environment === 'client' ? undefined : environment,\n ...props,\n };\n}\n\nexport function getBaseUrlFromExpoConfig(exp: ExpoConfig) {\n return exp.experiments?.baseUrl?.trim().replace(/\\/+$/, '') ?? '';\n}\n\nexport function getAsyncRoutesFromExpoConfig(exp: ExpoConfig, mode: string, platform: string) {\n let asyncRoutesSetting;\n\n if (exp.extra?.router?.asyncRoutes) {\n const asyncRoutes = exp.extra?.router?.asyncRoutes;\n if (['boolean', 'string'].includes(typeof asyncRoutes)) {\n asyncRoutesSetting = asyncRoutes;\n } else if (typeof asyncRoutes === 'object') {\n asyncRoutesSetting = asyncRoutes[platform] ?? asyncRoutes.default;\n }\n }\n\n return [mode, true].includes(asyncRoutesSetting);\n}\n\nexport function getMetroDirectBundleOptionsForExpoConfig(\n projectRoot: string,\n exp: ExpoConfig,\n options: Omit<ExpoMetroOptions, 'baseUrl' | 'reactCompiler' | 'routerRoot' | 'asyncRoutes'>\n): Partial<ExpoMetroBundleOptions> {\n return getMetroDirectBundleOptions({\n ...options,\n reactCompiler: !!exp.experiments?.reactCompiler,\n baseUrl: getBaseUrlFromExpoConfig(exp),\n routerRoot: getRouterDirectoryModuleIdWithManifest(projectRoot, exp),\n asyncRoutes: getAsyncRoutesFromExpoConfig(exp, options.mode, options.platform),\n });\n}\n\nexport function getMetroDirectBundleOptions(\n options: ExpoMetroOptions\n): Partial<ExpoMetroBundleOptions> {\n const {\n mainModuleName,\n platform,\n mode,\n minify,\n environment,\n serializerOutput,\n serializerIncludeMaps,\n bytecode,\n lazy,\n engine,\n preserveEnvVars,\n asyncRoutes,\n baseUrl,\n routerRoot,\n isExporting,\n inlineSourceMap,\n splitChunks,\n usedExports,\n reactCompiler,\n optimize,\n domRoot,\n clientBoundaries,\n runModule,\n modulesOnly,\n useMd5Filename,\n } = withDefaults(options);\n\n const dev = mode !== 'production';\n const isHermes = engine === 'hermes';\n\n if (isExporting) {\n debug('Disabling lazy bundling for export build');\n options.lazy = false;\n }\n\n let fakeSourceUrl: string | undefined;\n let fakeSourceMapUrl: string | undefined;\n\n // TODO: Upstream support to Metro for passing custom serializer options.\n if (serializerIncludeMaps != null || serializerOutput != null) {\n fakeSourceUrl = new URL(\n createBundleUrlPath(options).replace(/^\\//, ''),\n 'http://localhost:8081'\n ).toString();\n if (serializerIncludeMaps) {\n fakeSourceMapUrl = fakeSourceUrl.replace('.bundle?', '.map?');\n }\n }\n\n const customTransformOptions: ExpoMetroBundleOptions['customTransformOptions'] = {\n __proto__: null,\n optimize: optimize || undefined,\n engine,\n clientBoundaries,\n preserveEnvVars: preserveEnvVars || undefined,\n // Use string to match the query param behavior.\n asyncRoutes: asyncRoutes ? String(asyncRoutes) : undefined,\n environment,\n baseUrl: baseUrl || undefined,\n routerRoot,\n bytecode: bytecode ? '1' : undefined,\n reactCompiler: reactCompiler ? String(reactCompiler) : undefined,\n dom: domRoot,\n useMd5Filename: useMd5Filename || undefined,\n };\n\n // Iterate and delete undefined values\n for (const key in customTransformOptions) {\n if (customTransformOptions[key] === undefined) {\n delete customTransformOptions[key];\n }\n }\n\n const bundleOptions: Partial<ExpoMetroBundleOptions> = {\n platform,\n entryFile: mainModuleName,\n dev,\n minify: minify ?? !dev,\n inlineSourceMap: inlineSourceMap ?? false,\n lazy: (!isExporting && lazy) || undefined,\n unstable_transformProfile: isHermes ? 'hermes-stable' : 'default',\n customTransformOptions,\n runModule,\n modulesOnly,\n customResolverOptions: {\n __proto__: null,\n environment,\n exporting: isExporting || undefined,\n },\n sourceMapUrl: fakeSourceMapUrl,\n sourceUrl: fakeSourceUrl,\n serializerOptions: {\n splitChunks,\n usedExports: usedExports || undefined,\n output: serializerOutput,\n includeSourceMaps: serializerIncludeMaps,\n exporting: isExporting || undefined,\n },\n };\n\n return bundleOptions;\n}\n\nexport function createBundleUrlPathFromExpoConfig(\n projectRoot: string,\n exp: ExpoConfig,\n options: Omit<ExpoMetroOptions, 'reactCompiler' | 'baseUrl' | 'routerRoot'>\n): string {\n return createBundleUrlPath({\n ...options,\n reactCompiler: !!exp.experiments?.reactCompiler,\n baseUrl: getBaseUrlFromExpoConfig(exp),\n routerRoot: getRouterDirectoryModuleIdWithManifest(projectRoot, exp),\n });\n}\n\nexport function createBundleUrlPath(options: ExpoMetroOptions): string {\n const queryParams = createBundleUrlSearchParams(options);\n return `/${encodeURI(options.mainModuleName.replace(/^\\/+/, ''))}.bundle?${queryParams.toString()}`;\n}\n\n/**\n * Create a bundle URL, containing all required query parameters, using a valid \"os path\".\n * On POSIX systems, this would look something like `/Users/../project/file.js?dev=false&..`.\n * On UNIX systems, this would look something like `C:\\Users\\..\\project\\file.js?dev=false&..`.\n * This path can safely be used with `path.*` modifiers and resolved.\n */\nexport function createBundleOsPath(options: ExpoMetroOptions): string {\n const queryParams = createBundleUrlSearchParams(options);\n const mainModuleName = toPosixPath(options.mainModuleName);\n return `${mainModuleName}.bundle?${queryParams.toString()}`;\n}\n\nexport function createBundleUrlSearchParams(options: ExpoMetroOptions): URLSearchParams {\n const {\n platform,\n mode,\n minify,\n environment,\n serializerOutput,\n serializerIncludeMaps,\n lazy,\n bytecode,\n engine,\n preserveEnvVars,\n asyncRoutes,\n baseUrl,\n routerRoot,\n reactCompiler,\n inlineSourceMap,\n isExporting,\n clientBoundaries,\n splitChunks,\n usedExports,\n optimize,\n domRoot,\n modulesOnly,\n runModule,\n } = withDefaults(options);\n\n const dev = String(mode !== 'production');\n const queryParams = new URLSearchParams({\n platform: encodeURIComponent(platform),\n dev,\n // TODO: Is this still needed?\n hot: String(false),\n });\n\n // Lazy bundling must be disabled for bundle splitting to work.\n if (!isExporting && lazy) {\n queryParams.append('lazy', String(lazy));\n }\n\n if (inlineSourceMap) {\n queryParams.append('inlineSourceMap', String(inlineSourceMap));\n }\n\n if (minify) {\n queryParams.append('minify', String(minify));\n }\n\n // We split bytecode from the engine since you could technically use Hermes without bytecode.\n // Hermes indicates the type of language features you want to transform out of the JS, whereas bytecode\n // indicates whether you want to use the Hermes bytecode format.\n if (engine) {\n queryParams.append('transform.engine', engine);\n }\n if (bytecode) {\n queryParams.append('transform.bytecode', '1');\n }\n if (asyncRoutes) {\n queryParams.append('transform.asyncRoutes', String(asyncRoutes));\n }\n if (preserveEnvVars) {\n queryParams.append('transform.preserveEnvVars', String(preserveEnvVars));\n }\n if (baseUrl) {\n queryParams.append('transform.baseUrl', baseUrl);\n }\n if (clientBoundaries?.length) {\n queryParams.append('transform.clientBoundaries', JSON.stringify(clientBoundaries));\n }\n if (routerRoot != null) {\n queryParams.append('transform.routerRoot', routerRoot);\n }\n if (reactCompiler) {\n queryParams.append('transform.reactCompiler', String(reactCompiler));\n }\n if (domRoot) {\n queryParams.append('transform.dom', domRoot);\n }\n\n if (environment) {\n queryParams.append('resolver.environment', environment);\n queryParams.append('transform.environment', environment);\n }\n\n if (isExporting) {\n queryParams.append('resolver.exporting', String(isExporting));\n }\n\n if (splitChunks) {\n queryParams.append('serializer.splitChunks', String(splitChunks));\n }\n if (usedExports) {\n queryParams.append('serializer.usedExports', String(usedExports));\n }\n if (optimize) {\n queryParams.append('transform.optimize', String(optimize));\n }\n if (serializerOutput) {\n queryParams.append('serializer.output', serializerOutput);\n }\n if (serializerIncludeMaps) {\n queryParams.append('serializer.map', String(serializerIncludeMaps));\n }\n if (engine === 'hermes') {\n queryParams.append('unstable_transformProfile', 'hermes-stable');\n }\n\n if (modulesOnly != null) {\n queryParams.set('modulesOnly', String(modulesOnly));\n }\n if (runModule != null) {\n queryParams.set('runModule', String(runModule));\n }\n\n return queryParams;\n}\n\n/**\n * Convert all path separators to `/`, including on Windows.\n * Metro asumes that all module specifiers are posix paths.\n * References to directories can still be Windows-style paths in Metro.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#importing_features_into_your_script\n * @see https://github.com/facebook/metro/pull/1286\n */\nexport function convertPathToModuleSpecifier(pathLike: string) {\n return toPosixPath(pathLike);\n}\n\nexport function getMetroOptionsFromUrl(urlFragment: string) {\n const url = new URL(urlFragment, 'http://localhost:0');\n const getStringParam = (key: string) => {\n const param = url.searchParams.get(key);\n if (Array.isArray(param)) {\n throw new Error(`Expected single value for ${key}`);\n }\n return param;\n };\n\n let pathname = url.pathname;\n if (pathname.endsWith('.bundle')) {\n pathname = pathname.slice(0, -'.bundle'.length);\n }\n\n const options: ExpoMetroOptions = {\n mode: isTruthy(getStringParam('dev') ?? 'true') ? 'development' : 'production',\n minify: isTruthy(getStringParam('minify') ?? 'false'),\n lazy: isTruthy(getStringParam('lazy') ?? 'false'),\n routerRoot: getStringParam('transform.routerRoot') ?? 'app',\n isExporting: isTruthy(getStringParam('resolver.exporting') ?? 'false'),\n environment: assertEnvironment(getStringParam('transform.environment') ?? 'node'),\n platform: url.searchParams.get('platform') ?? 'web',\n bytecode: isTruthy(getStringParam('transform.bytecode') ?? 'false'),\n mainModuleName: convertPathToModuleSpecifier(pathname),\n reactCompiler: isTruthy(getStringParam('transform.reactCompiler') ?? 'false'),\n asyncRoutes: isTruthy(getStringParam('transform.asyncRoutes') ?? 'false'),\n baseUrl: getStringParam('transform.baseUrl') ?? undefined,\n // clientBoundaries: JSON.parse(getStringParam('transform.clientBoundaries') ?? '[]'),\n engine: assertEngine(getStringParam('transform.engine')),\n runModule: isTruthy(getStringParam('runModule') ?? 'true'),\n modulesOnly: isTruthy(getStringParam('modulesOnly') ?? 'false'),\n };\n\n return options;\n}\n\nfunction isTruthy(value: string | null): boolean {\n return value === 'true' || value === '1';\n}\n\nfunction assertEnvironment(environment: string | undefined): MetroEnvironment | undefined {\n if (!environment) {\n return undefined;\n }\n if (!['node', 'react-server', 'client'].includes(environment)) {\n throw new Error(`Expected transform.environment to be one of: node, react-server, client`);\n }\n return environment as MetroEnvironment;\n}\nfunction assertEngine(engine: string | undefined | null): 'hermes' | undefined {\n if (!engine) {\n return undefined;\n }\n if (!['hermes'].includes(engine)) {\n throw new Error(`Expected transform.engine to be one of: hermes`);\n }\n return engine as 'hermes';\n}\n"],"names":["convertPathToModuleSpecifier","createBundleOsPath","createBundleUrlPath","createBundleUrlPathFromExpoConfig","createBundleUrlSearchParams","getAsyncRoutesFromExpoConfig","getBaseUrlFromExpoConfig","getMetroDirectBundleOptions","getMetroDirectBundleOptionsForExpoConfig","getMetroOptionsFromUrl","isServerEnvironment","debug","require","environment","withDefaults","mode","minify","preserveEnvVars","env","EXPO_NO_CLIENT_ENV_VARS","lazy","props","bytecode","platform","CommandError","engine","optimize","EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH","usedExports","EXPO_UNSTABLE_TREE_SHAKING","isExporting","undefined","exp","experiments","baseUrl","trim","replace","asyncRoutesSetting","extra","router","asyncRoutes","includes","default","projectRoot","options","reactCompiler","routerRoot","getRouterDirectoryModuleIdWithManifest","mainModuleName","serializerOutput","serializerIncludeMaps","inlineSourceMap","splitChunks","domRoot","clientBoundaries","runModule","modulesOnly","useMd5Filename","dev","isHermes","fakeSourceUrl","fakeSourceMapUrl","URL","toString","customTransformOptions","__proto__","String","dom","key","bundleOptions","entryFile","unstable_transformProfile","customResolverOptions","exporting","sourceMapUrl","sourceUrl","serializerOptions","output","includeSourceMaps","queryParams","encodeURI","toPosixPath","URLSearchParams","encodeURIComponent","hot","append","length","JSON","stringify","set","pathLike","urlFragment","url","getStringParam","param","searchParams","get","Array","isArray","Error","pathname","endsWith","slice","isTruthy","assertEnvironment","assertEngine","value"],"mappings":";;;;;;;;;;;IAyYgBA,4BAA4B;eAA5BA;;IAnIAC,kBAAkB;eAAlBA;;IAXAC,mBAAmB;eAAnBA;;IAbAC,iCAAiC;eAAjCA;;IA8BAC,2BAA2B;eAA3BA;;IAtKAC,4BAA4B;eAA5BA;;IAJAC,wBAAwB;eAAxBA;;IAiCAC,2BAA2B;eAA3BA;;IAdAC,wCAAwC;eAAxCA;;IAwRAC,sBAAsB;eAAtBA;;IAhVAC,mBAAmB;eAAnBA;;;qBAzDI;wBACS;0BACD;wBAC2B;AAEvD,MAAMC,QAAQC,QAAQ,SAAS;AAoDxB,SAASF,oBAAoBG,WAAiB;IACnD,OAAOA,gBAAgB,UAAUA,gBAAgB;AACnD;AAEA,SAASC,aAAa,EACpBC,OAAO,aAAa,EACpBC,SAASD,SAAS,YAAY,EAC9BE,kBAAkBF,SAAS,iBAAiBG,QAAG,CAACC,uBAAuB,EACvEC,IAAI,EACJP,WAAW,EACX,GAAGQ,OACc;IACjB,IAAIA,MAAMC,QAAQ,EAAE;QAClB,IAAID,MAAME,QAAQ,KAAK,OAAO;YAC5B,MAAM,IAAIC,oBAAY,CAAC;QACzB;QACA,IAAIH,MAAMI,MAAM,KAAK,UAAU;YAC7B,MAAM,IAAID,oBAAY,CAAC;QACzB;IACF;IAEA,MAAME,WACJL,MAAMK,QAAQ,IACbb,CAAAA,gBAAgB,UAAUE,SAAS,gBAAgBG,QAAG,CAACS,kCAAkC,AAAD;IAE3F,OAAO;QACLZ;QACAC;QACAC;QACAS;QACAE,aAAaF,YAAYR,QAAG,CAACW,0BAA0B;QACvDT,MAAM,CAACC,MAAMS,WAAW,IAAIV;QAC5BP,aAAaA,gBAAgB,WAAWkB,YAAYlB;QACpD,GAAGQ,KAAK;IACV;AACF;AAEO,SAASf,yBAAyB0B,GAAe;QAC/CA,0BAA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CzE,MAAMmF,SAASV,eAAe,WAAW;QACzC/C,YAAY+C,eAAe,2BAA2B;QACtD/D,aAAayE,SAASV,eAAe,yBAAyB;QAC9DhF,aAAa2F,kBAAkBX,eAAe,4BAA4B;QAC1EtE,UAAUqE,IAAIG,YAAY,CAACC,GAAG,CAAC,eAAe;QAC9C1E,UAAUiF,SAASV,eAAe,yBAAyB;QAC3D7C,gBAAgBhD,6BAA6BoG;QAC7CvD,eAAe0D,SAASV,eAAe,8BAA8B;QACrErD,aAAa+D,SAASV,eAAe,4BAA4B;QACjE3D,SAAS2D,eAAe,wBAAwB9D;QAChD,sFAAsF;QACtFN,QAAQgF,aAAaZ,eAAe;QACpCtC,WAAWgD,SAASV,eAAe,gBAAgB;QACnDrC,aAAa+C,SAASV,eAAe,kBAAkB;IACzD;IAEA,OAAOjD;AACT;AAEA,SAAS2D,SAASG,KAAoB;IACpC,OAAOA,UAAU,UAAUA,UAAU;AACvC;AAEA,SAASF,kBAAkB3F,WAA+B;IACxD,IAAI,CAACA,aAAa;QAChB,OAAOkB;IACT;IACA,IAAI,CAAC;QAAC;QAAQ;QAAgB;KAAS,CAACU,QAAQ,CAAC5B,cAAc;QAC7D,MAAM,IAAIsF,MAAM,CAAC,uEAAuE,CAAC;IAC3F;IACA,OAAOtF;AACT;AACA,SAAS4F,aAAahF,MAAiC;IACrD,IAAI,CAACA,QAAQ;QACX,OAAOM;IACT;IACA,IAAI,CAAC;QAAC;KAAS,CAACU,QAAQ,CAAChB,SAAS;QAChC,MAAM,IAAI0E,MAAM,CAAC,8CAA8C,CAAC;IAClE;IACA,OAAO1E;AACT"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
fileExists: function() {
|
|
13
|
+
return fileExists;
|
|
14
|
+
},
|
|
15
|
+
moduleNameIsDirectFileReference: function() {
|
|
16
|
+
return moduleNameIsDirectFileReference;
|
|
17
|
+
},
|
|
18
|
+
moduleNameIsPackageReference: function() {
|
|
19
|
+
return moduleNameIsPackageReference;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
function _fs() {
|
|
23
|
+
const data = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
24
|
+
_fs = function() {
|
|
25
|
+
return data;
|
|
26
|
+
};
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
function _interop_require_default(obj) {
|
|
30
|
+
return obj && obj.__esModule ? obj : {
|
|
31
|
+
default: obj
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function moduleNameIsDirectFileReference(name) {
|
|
35
|
+
var _name_split;
|
|
36
|
+
// Check if path is a file. Matches lines starting with: . / ~/
|
|
37
|
+
if (name.match(/^(\.|~\/|\/)/g)) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
const slashCount = (_name_split = name.split('/')) == null ? void 0 : _name_split.length;
|
|
41
|
+
// Orgs (like @expo/config ) should have more than one slash to be a direct file.
|
|
42
|
+
if (name.startsWith('@')) {
|
|
43
|
+
return slashCount > 2;
|
|
44
|
+
}
|
|
45
|
+
// Regular packages should be considered direct reference if they have more than one slash.
|
|
46
|
+
return slashCount > 1;
|
|
47
|
+
}
|
|
48
|
+
function moduleNameIsPackageReference(name) {
|
|
49
|
+
var _name_split;
|
|
50
|
+
const slashCount = (_name_split = name.split('/')) == null ? void 0 : _name_split.length;
|
|
51
|
+
return name.startsWith('@') ? slashCount === 2 : slashCount === 1;
|
|
52
|
+
}
|
|
53
|
+
function fileExists(file) {
|
|
54
|
+
try {
|
|
55
|
+
return _fs().default.statSync(file).isFile();
|
|
56
|
+
} catch {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/utils/build-cache-providers/helpers.ts"],"sourcesContent":["import fs from 'fs';\n\nexport function moduleNameIsDirectFileReference(name: string): boolean {\n // Check if path is a file. Matches lines starting with: . / ~/\n if (name.match(/^(\\.|~\\/|\\/)/g)) {\n return true;\n }\n\n const slashCount = name.split('/')?.length;\n // Orgs (like @expo/config ) should have more than one slash to be a direct file.\n if (name.startsWith('@')) {\n return slashCount > 2;\n }\n\n // Regular packages should be considered direct reference if they have more than one slash.\n return slashCount > 1;\n}\n\nexport function moduleNameIsPackageReference(name: string): boolean {\n const slashCount = name.split('/')?.length;\n return name.startsWith('@') ? slashCount === 2 : slashCount === 1;\n}\n\nexport function fileExists(file: string): boolean {\n try {\n return fs.statSync(file).isFile();\n } catch {\n return false;\n }\n}\n"],"names":["fileExists","moduleNameIsDirectFileReference","moduleNameIsPackageReference","name","match","slashCount","split","length","startsWith","file","fs","statSync","isFile"],"mappings":";;;;;;;;;;;IAuBgBA,UAAU;eAAVA;;IArBAC,+BAA+B;eAA/BA;;IAgBAC,4BAA4B;eAA5BA;;;;gEAlBD;;;;;;;;;;;AAER,SAASD,gCAAgCE,IAAY;QAMvCA;IALnB,+DAA+D;IAC/D,IAAIA,KAAKC,KAAK,CAAC,kBAAkB;QAC/B,OAAO;IACT;IAEA,MAAMC,cAAaF,cAAAA,KAAKG,KAAK,CAAC,yBAAXH,YAAiBI,MAAM;IAC1C,iFAAiF;IACjF,IAAIJ,KAAKK,UAAU,CAAC,MAAM;QACxB,OAAOH,aAAa;IACtB;IAEA,2FAA2F;IAC3F,OAAOA,aAAa;AACtB;AAEO,SAASH,6BAA6BC,IAAY;QACpCA;IAAnB,MAAME,cAAaF,cAAAA,KAAKG,KAAK,CAAC,yBAAXH,YAAiBI,MAAM;IAC1C,OAAOJ,KAAKK,UAAU,CAAC,OAAOH,eAAe,IAAIA,eAAe;AAClE;AAEO,SAASL,WAAWS,IAAY;IACrC,IAAI;QACF,OAAOC,aAAE,CAACC,QAAQ,CAACF,MAAMG,MAAM;IACjC,EAAE,OAAM;QACN,OAAO;IACT;AACF"}
|