@expo/cli 1.0.0-canary-20250305-0af9ad2 → 1.0.0-canary-20250320-7a205d3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/build/bin/cli +1 -1
  2. package/build/src/api/rest/client.js +4 -0
  3. package/build/src/api/rest/client.js.map +1 -1
  4. package/build/src/export/exportApp.js +10 -6
  5. package/build/src/export/exportApp.js.map +1 -1
  6. package/build/src/export/exportAssets.js +2 -2
  7. package/build/src/export/exportAssets.js.map +1 -1
  8. package/build/src/export/exportDomComponents.js +41 -41
  9. package/build/src/export/exportDomComponents.js.map +1 -1
  10. package/build/src/export/persistMetroAssets.js +7 -0
  11. package/build/src/export/persistMetroAssets.js.map +1 -1
  12. package/build/src/run/resolveBundlerProps.js +2 -2
  13. package/build/src/run/resolveBundlerProps.js.map +1 -1
  14. package/build/src/start/server/metro/createExpoMetroResolver.js +1 -0
  15. package/build/src/start/server/metro/createExpoMetroResolver.js.map +1 -1
  16. package/build/src/start/server/metro/createJResolver.js +0 -4
  17. package/build/src/start/server/metro/createJResolver.js.map +1 -1
  18. package/build/src/start/server/metro/debugging/messageHandlers/NetworkResponse.js +0 -3
  19. package/build/src/start/server/metro/debugging/messageHandlers/NetworkResponse.js.map +1 -1
  20. package/build/src/start/server/metro/getCssModulesFromBundler.js +4 -4
  21. package/build/src/start/server/metro/getCssModulesFromBundler.js.map +1 -1
  22. package/build/src/start/server/metro/instantiateMetro.js +1 -4
  23. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  24. package/build/src/start/server/metro/withMetroMultiPlatform.js +14 -10
  25. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  26. package/build/src/start/server/middleware/FaviconMiddleware.js +4 -0
  27. package/build/src/start/server/middleware/FaviconMiddleware.js.map +1 -1
  28. package/build/src/start/server/middleware/metroOptions.js +3 -2
  29. package/build/src/start/server/middleware/metroOptions.js.map +1 -1
  30. package/build/src/utils/npm.js +2 -2
  31. package/build/src/utils/npm.js.map +1 -1
  32. package/build/src/utils/tar.js +2 -2
  33. package/build/src/utils/tar.js.map +1 -1
  34. package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
  35. package/build/src/utils/telemetry/utils/context.js +1 -1
  36. package/package.json +17 -20
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/persistMetroAssets.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Based on the community asset persisting for Metro but with base path and web support:\n * https://github.com/facebook/react-native/blob/d6e0bc714ad4d215ede4949d3c4f44af6dea5dd3/packages/community-cli-plugin/src/commands/bundle/saveAssets.js#L1\n */\nimport fs from 'fs';\nimport type { AssetData } from 'metro';\nimport path from 'path';\n\nimport { getAssetLocalPath } from './metroAssetLocalPath';\nimport { ExportAssetMap } from './saveAssets';\nimport { Log } from '../log';\n\nfunction cleanAssetCatalog(catalogDir: string): void {\n const files = fs.readdirSync(catalogDir).filter((file) => file.endsWith('.imageset'));\n for (const file of files) {\n fs.rmSync(path.join(catalogDir, file));\n }\n}\n\nexport async function persistMetroAssetsAsync(\n projectRoot: string,\n assets: readonly AssetData[],\n {\n platform,\n outputDirectory,\n baseUrl,\n iosAssetCatalogDirectory,\n files,\n }: {\n platform: string;\n outputDirectory: string;\n baseUrl?: string;\n iosAssetCatalogDirectory?: string;\n files?: ExportAssetMap;\n }\n) {\n if (outputDirectory == null) {\n Log.warn('Assets destination folder is not set, skipping...');\n return;\n }\n\n let assetsToCopy: AssetData[] = [];\n\n // TODO: Use `files` as below to defer writing files\n if (platform === 'ios' && iosAssetCatalogDirectory != null) {\n // Use iOS Asset Catalog for images. This will allow Apple app thinning to\n // remove unused scales from the optimized bundle.\n const catalogDir = path.join(iosAssetCatalogDirectory, 'RNAssets.xcassets');\n if (!fs.existsSync(catalogDir)) {\n Log.error(\n `Could not find asset catalog 'RNAssets.xcassets' in ${iosAssetCatalogDirectory}. Make sure to create it if it does not exist.`\n );\n return;\n }\n\n Log.log('Adding images to asset catalog', catalogDir);\n cleanAssetCatalog(catalogDir);\n for (const asset of assets) {\n if (isCatalogAsset(asset)) {\n const imageSet = getImageSet(\n catalogDir,\n asset,\n filterPlatformAssetScales(platform, asset.scales)\n );\n writeImageSet(imageSet);\n } else {\n assetsToCopy.push(asset);\n }\n }\n Log.log('Done adding images to asset catalog');\n } else {\n assetsToCopy = [...assets];\n }\n\n const batches: Record<string, string> = {};\n\n for (const asset of assetsToCopy) {\n const validScales = new Set(filterPlatformAssetScales(platform, asset.scales));\n for (let idx = 0; idx < asset.scales.length; idx++) {\n const scale = asset.scales[idx];\n if (validScales.has(scale)) {\n const src = asset.files[idx];\n const dest = getAssetLocalPath(asset, { platform, scale, baseUrl });\n if (files) {\n const data = await fs.promises.readFile(src);\n files.set(dest, {\n contents: data,\n assetId: getAssetIdForLogGrouping(projectRoot, asset),\n targetDomain: platform === 'web' ? 'client' : undefined,\n });\n } else {\n batches[src] = path.join(outputDirectory, dest);\n }\n }\n }\n }\n\n if (!files) {\n await copyInBatchesAsync(batches);\n }\n}\n\nexport function getAssetIdForLogGrouping(\n projectRoot: string,\n asset: Partial<Pick<AssetData, 'fileSystemLocation' | 'name' | 'type'>>\n): string | undefined {\n return 'fileSystemLocation' in asset && asset.fileSystemLocation != null && asset.name != null\n ? path.relative(projectRoot, path.join(asset.fileSystemLocation, asset.name)) +\n (asset.type ? '.' + asset.type : '')\n : undefined;\n}\n\nfunction writeImageSet(imageSet: ImageSet): void {\n fs.mkdirSync(imageSet.baseUrl, { recursive: true });\n\n for (const file of imageSet.files) {\n const dest = path.join(imageSet.baseUrl, file.name);\n fs.copyFileSync(file.src, dest);\n }\n\n fs.writeFileSync(\n path.join(imageSet.baseUrl, 'Contents.json'),\n JSON.stringify({\n images: imageSet.files.map((file) => ({\n filename: file.name,\n idiom: 'universal',\n scale: `${file.scale}x`,\n })),\n info: {\n author: 'expo',\n version: 1,\n },\n })\n );\n}\n\nfunction isCatalogAsset(asset: Pick<AssetData, 'type'>): boolean {\n return asset.type === 'png' || asset.type === 'jpg' || asset.type === 'jpeg';\n}\n\ntype ImageSet = {\n baseUrl: string;\n files: { name: string; src: string; scale: number }[];\n};\n\nfunction getImageSet(\n catalogDir: string,\n asset: Pick<AssetData, 'httpServerLocation' | 'name' | 'type' | 'files'>,\n scales: number[]\n): ImageSet {\n const fileName = getResourceIdentifier(asset);\n return {\n baseUrl: path.join(catalogDir, `${fileName}.imageset`),\n files: scales.map((scale, idx) => {\n const suffix = scale === 1 ? '' : `@${scale}x`;\n return {\n name: `${fileName + suffix}.${asset.type}`,\n scale,\n src: asset.files[idx],\n };\n }),\n };\n}\n\nexport function copyInBatchesAsync(filesToCopy: Record<string, string>) {\n const queue = Object.keys(filesToCopy);\n if (queue.length === 0) {\n return;\n }\n\n Log.log(`Copying ${queue.length} asset files`);\n return new Promise<void>((resolve, reject) => {\n const copyNext = (error?: NodeJS.ErrnoException) => {\n if (error) {\n return reject(error);\n }\n if (queue.length) {\n // queue.length === 0 is checked in previous branch, so this is string\n const src = queue.shift() as string;\n const dest = filesToCopy[src];\n copy(src, dest, copyNext);\n } else {\n resolve();\n }\n };\n copyNext();\n });\n}\n\nfunction copy(src: string, dest: string, callback: (error: NodeJS.ErrnoException) => void): void {\n fs.mkdir(path.dirname(dest), { recursive: true }, (err?) => {\n if (err) {\n callback(err);\n return;\n }\n fs.createReadStream(src).pipe(fs.createWriteStream(dest)).on('finish', callback);\n });\n}\n\nconst ALLOWED_SCALES: { [key: string]: number[] } = {\n ios: [1, 2, 3],\n};\n\nexport function filterPlatformAssetScales(platform: string, scales: number[]): number[] {\n const whitelist: number[] = ALLOWED_SCALES[platform];\n if (!whitelist) {\n return scales;\n }\n const result = scales.filter((scale) => whitelist.includes(scale));\n if (!result.length && scales.length) {\n // No matching scale found, but there are some available. Ideally we don't\n // want to be in this situation and should throw, but for now as a fallback\n // let's just use the closest larger image\n const maxScale = whitelist[whitelist.length - 1];\n for (const scale of scales) {\n if (scale > maxScale) {\n result.push(scale);\n break;\n }\n }\n\n // There is no larger scales available, use the largest we have\n if (!result.length) {\n result.push(scales[scales.length - 1]);\n }\n }\n return result;\n}\n\nfunction getResourceIdentifier(asset: Pick<AssetData, 'httpServerLocation' | 'name'>): string {\n const folderPath = getBaseUrl(asset);\n return `${folderPath}/${asset.name}`\n .toLowerCase()\n .replace(/\\//g, '_') // Encode folder structure in file name\n .replace(/([^a-z0-9_])/g, '') // Remove illegal chars\n .replace(/^assets_/, ''); // Remove \"assets_\" prefix\n}\n\nfunction getBaseUrl(asset: Pick<AssetData, 'httpServerLocation'>): string {\n let baseUrl = asset.httpServerLocation;\n if (baseUrl[0] === '/') {\n baseUrl = baseUrl.substring(1);\n }\n return baseUrl;\n}\n"],"names":["persistMetroAssetsAsync","getAssetIdForLogGrouping","copyInBatchesAsync","filterPlatformAssetScales","cleanAssetCatalog","catalogDir","files","fs","readdirSync","filter","file","endsWith","rmSync","path","join","projectRoot","assets","platform","outputDirectory","baseUrl","iosAssetCatalogDirectory","Log","warn","assetsToCopy","existsSync","error","log","asset","isCatalogAsset","imageSet","getImageSet","scales","writeImageSet","push","batches","validScales","Set","idx","length","scale","has","src","dest","getAssetLocalPath","data","promises","readFile","set","contents","assetId","targetDomain","undefined","fileSystemLocation","name","relative","type","mkdirSync","recursive","copyFileSync","writeFileSync","JSON","stringify","images","map","filename","idiom","info","author","version","fileName","getResourceIdentifier","suffix","filesToCopy","queue","Object","keys","Promise","resolve","reject","copyNext","shift","copy","callback","mkdir","dirname","err","createReadStream","pipe","createWriteStream","on","ALLOWED_SCALES","ios","whitelist","result","includes","maxScale","folderPath","getBaseUrl","toLowerCase","replace","httpServerLocation","substring"],"mappings":"AAAA;;;;;;;;;CASC,GACD;;;;;;;;;;;IAesBA,uBAAuB,MAAvBA,uBAAuB;IAmF7BC,wBAAwB,MAAxBA,w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AAMyD,QAAQ,GAAGH,SAAS,CAACA,SAAS,CAACtD,MAAM,GAAG,CAAC,CAAC,AAAC;QACjD,KAAK,MAAMC,KAAK,IAAIR,MAAM,CAAE;YAC1B,IAAIQ,KAAK,GAAGwD,QAAQ,EAAE;gBACpBF,MAAM,CAAC5D,IAAI,CAACM,KAAK,CAAC,CAAC;gBACnB,MAAM;YACR,CAAC;QACH,CAAC;QAED,+DAA+D;QAC/D,IAAI,CAACsD,MAAM,CAACvD,MAAM,EAAE;YAClBuD,MAAM,CAAC5D,IAAI,CAACF,MAAM,CAACA,MAAM,CAACO,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IACD,OAAOuD,MAAM,CAAC;AAChB,CAAC;AAED,SAASvB,qBAAqB,CAAC3C,KAAqD,EAAU;IAC5F,MAAMqE,UAAU,GAAGC,UAAU,CAACtE,KAAK,CAAC,AAAC;IACrC,OAAO,CAAC,EAAEqE,UAAU,CAAC,CAAC,EAAErE,KAAK,CAAC0B,IAAI,CAAC,CAAC,CACjC6C,WAAW,EAAE,CACbC,OAAO,QAAQ,GAAG,CAAC,CAAC,uCAAuC;KAC3DA,OAAO,kBAAkB,EAAE,CAAC,CAAC,uBAAuB;KACpDA,OAAO,aAAa,EAAE,CAAC,CAAC,CAAC,0BAA0B;AACxD,CAAC;AAED,SAASF,UAAU,CAACtE,KAA4C,EAAU;IACxE,IAAIR,OAAO,GAAGQ,KAAK,CAACyE,kBAAkB,AAAC;IACvC,IAAIjF,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;QACtBA,OAAO,GAAGA,OAAO,CAACkF,SAAS,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC;IACD,OAAOlF,OAAO,CAAC;AACjB,CAAC"}
1
+ {"version":3,"sources":["../../../src/export/persistMetroAssets.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Based on the community asset persisting for Metro but with base path and web support:\n * https://github.com/facebook/react-native/blob/d6e0bc714ad4d215ede4949d3c4f44af6dea5dd3/packages/community-cli-plugin/src/commands/bundle/saveAssets.js#L1\n */\nimport fs from 'fs';\nimport type { AssetData } from 'metro';\nimport path from 'path';\n\nimport { getAssetLocalPath } from './metroAssetLocalPath';\nimport { ExportAssetMap } from './saveAssets';\nimport { Log } from '../log';\n\nfunction cleanAssetCatalog(catalogDir: string): void {\n const files = fs.readdirSync(catalogDir).filter((file) => file.endsWith('.imageset'));\n for (const file of files) {\n fs.rmSync(path.join(catalogDir, file));\n }\n}\n\nexport async function persistMetroAssetsAsync(\n projectRoot: string,\n assets: readonly AssetData[],\n {\n platform,\n outputDirectory,\n baseUrl,\n iosAssetCatalogDirectory,\n files,\n }: {\n platform: string;\n outputDirectory: string;\n baseUrl?: string;\n iosAssetCatalogDirectory?: string;\n files?: ExportAssetMap;\n }\n) {\n if (outputDirectory == null) {\n Log.warn('Assets destination folder is not set, skipping...');\n return;\n }\n\n // For iOS, we need to ensure that the outputDirectory exists.\n // The bundle code and images build phase script always tries to access this folder\n if (platform === 'ios' && !fs.existsSync(outputDirectory)) {\n fs.mkdirSync(outputDirectory, { recursive: true });\n }\n\n let assetsToCopy: AssetData[] = [];\n\n // TODO: Use `files` as below to defer writing files\n if (platform === 'ios' && iosAssetCatalogDirectory != null) {\n // Use iOS Asset Catalog for images. This will allow Apple app thinning to\n // remove unused scales from the optimized bundle.\n const catalogDir = path.join(iosAssetCatalogDirectory, 'RNAssets.xcassets');\n if (!fs.existsSync(catalogDir)) {\n Log.error(\n `Could not find asset catalog 'RNAssets.xcassets' in ${iosAssetCatalogDirectory}. Make sure to create it if it does not exist.`\n );\n return;\n }\n\n Log.log('Adding images to asset catalog', catalogDir);\n cleanAssetCatalog(catalogDir);\n for (const asset of assets) {\n if (isCatalogAsset(asset)) {\n const imageSet = getImageSet(\n catalogDir,\n asset,\n filterPlatformAssetScales(platform, asset.scales)\n );\n writeImageSet(imageSet);\n } else {\n assetsToCopy.push(asset);\n }\n }\n Log.log('Done adding images to asset catalog');\n } else {\n assetsToCopy = [...assets];\n }\n\n const batches: Record<string, string> = {};\n\n for (const asset of assetsToCopy) {\n const validScales = new Set(filterPlatformAssetScales(platform, asset.scales));\n for (let idx = 0; idx < asset.scales.length; idx++) {\n const scale = asset.scales[idx];\n if (validScales.has(scale)) {\n const src = asset.files[idx];\n const dest = getAssetLocalPath(asset, { platform, scale, baseUrl });\n if (files) {\n const data = await fs.promises.readFile(src);\n files.set(dest, {\n contents: data,\n assetId: getAssetIdForLogGrouping(projectRoot, asset),\n targetDomain: platform === 'web' ? 'client' : undefined,\n });\n } else {\n batches[src] = path.join(outputDirectory, dest);\n }\n }\n }\n }\n\n if (!files) {\n await copyInBatchesAsync(batches);\n }\n}\n\nexport function getAssetIdForLogGrouping(\n projectRoot: string,\n asset: Partial<Pick<AssetData, 'fileSystemLocation' | 'name' | 'type'>>\n): string | undefined {\n return 'fileSystemLocation' in asset && asset.fileSystemLocation != null && asset.name != null\n ? path.relative(projectRoot, path.join(asset.fileSystemLocation, asset.name)) +\n (asset.type ? '.' + asset.type : '')\n : undefined;\n}\n\nfunction writeImageSet(imageSet: ImageSet): void {\n fs.mkdirSync(imageSet.baseUrl, { recursive: true });\n\n for (const file of imageSet.files) {\n const dest = path.join(imageSet.baseUrl, file.name);\n fs.copyFileSync(file.src, dest);\n }\n\n fs.writeFileSync(\n path.join(imageSet.baseUrl, 'Contents.json'),\n JSON.stringify({\n images: imageSet.files.map((file) => ({\n filename: file.name,\n idiom: 'universal',\n scale: `${file.scale}x`,\n })),\n info: {\n author: 'expo',\n version: 1,\n },\n })\n );\n}\n\nfunction isCatalogAsset(asset: Pick<AssetData, 'type'>): boolean {\n return asset.type === 'png' || asset.type === 'jpg' || asset.type === 'jpeg';\n}\n\ntype ImageSet = {\n baseUrl: string;\n files: { name: string; src: string; scale: number }[];\n};\n\nfunction getImageSet(\n catalogDir: string,\n asset: Pick<AssetData, 'httpServerLocation' | 'name' | 'type' | 'files'>,\n scales: number[]\n): ImageSet {\n const fileName = getResourceIdentifier(asset);\n return {\n baseUrl: path.join(catalogDir, `${fileName}.imageset`),\n files: scales.map((scale, idx) => {\n const suffix = scale === 1 ? '' : `@${scale}x`;\n return {\n name: `${fileName + suffix}.${asset.type}`,\n scale,\n src: asset.files[idx],\n };\n }),\n };\n}\n\nexport function copyInBatchesAsync(filesToCopy: Record<string, string>) {\n const queue = Object.keys(filesToCopy);\n if (queue.length === 0) {\n return;\n }\n\n Log.log(`Copying ${queue.length} asset files`);\n return new Promise<void>((resolve, reject) => {\n const copyNext = (error?: NodeJS.ErrnoException) => {\n if (error) {\n return reject(error);\n }\n if (queue.length) {\n // queue.length === 0 is checked in previous branch, so this is string\n const src = queue.shift() as string;\n const dest = filesToCopy[src];\n copy(src, dest, copyNext);\n } else {\n resolve();\n }\n };\n copyNext();\n });\n}\n\nfunction copy(src: string, dest: string, callback: (error: NodeJS.ErrnoException) => void): void {\n fs.mkdir(path.dirname(dest), { recursive: true }, (err?) => {\n if (err) {\n callback(err);\n return;\n }\n fs.createReadStream(src).pipe(fs.createWriteStream(dest)).on('finish', callback);\n });\n}\n\nconst ALLOWED_SCALES: { [key: string]: number[] } = {\n ios: [1, 2, 3],\n};\n\nexport function filterPlatformAssetScales(platform: string, scales: number[]): number[] {\n const whitelist: number[] = ALLOWED_SCALES[platform];\n if (!whitelist) {\n return scales;\n }\n const result = scales.filter((scale) => whitelist.includes(scale));\n if (!result.length && scales.length) {\n // No matching scale found, but there are some available. Ideally we don't\n // want to be in this situation and should throw, but for now as a fallback\n // let's just use the closest larger image\n const maxScale = whitelist[whitelist.length - 1];\n for (const scale of scales) {\n if (scale > maxScale) {\n result.push(scale);\n break;\n }\n }\n\n // There is no larger scales available, use the largest we have\n if (!result.length) {\n result.push(scales[scales.length - 1]);\n }\n }\n return result;\n}\n\nfunction getResourceIdentifier(asset: Pick<AssetData, 'httpServerLocation' | 'name'>): string {\n const folderPath = getBaseUrl(asset);\n return `${folderPath}/${asset.name}`\n .toLowerCase()\n .replace(/\\//g, '_') // Encode folder structure in file name\n .replace(/([^a-z0-9_])/g, '') // Remove illegal chars\n .replace(/^assets_/, ''); // Remove \"assets_\" prefix\n}\n\nfunction getBaseUrl(asset: Pick<AssetData, 'httpServerLocation'>): string {\n let baseUrl = asset.httpServerLocation;\n if (baseUrl[0] === '/') {\n baseUrl = baseUrl.substring(1);\n }\n return baseUrl;\n}\n"],"names":["persistMetroAssetsAsync","getAssetIdForLogGrouping","copyInBatchesAsync","filterPlatformAssetScales","cleanAssetCatalog","catalogDir","files","fs","readdirSync","filter","file","endsWith","rmSync","path","join","projectRoot","assets","platform","outputDirectory","baseUrl","iosAssetCatalogDirectory","Log","warn","existsSync","mkdirSync","recursive","assetsToCopy","error","log","asset","isCatalogAsset","imageSet","getImageSet","scales","writeImageSet","push","batches","validScales","Set","idx","length","scale","has","src","dest","getAssetLocalPath","data","promises","readFile","set","contents","assetId","targetDomain","undefined","fileSystemLocation","name","relative","type","copyFileSync","writeFileSync","JSON","stringify","images","map","filename","idiom","info","author","version","fileName","getResourceIdentifier","suffix","filesToCopy","queue","Object","keys","Promise","resolve","reject","copyNext","shift","copy","callback","mkdir","dirname","err","createReadStream","pipe","createWriteStream","on","ALLOWED_SCALES","ios","whitelist","result","includes","maxScale","folderPath","getBaseUrl","toLowerCase","replace","httpServerLocation","substring"],"mappings":"AAAA;;;;;;;;;CASC,GACD;;;;;;;;;;;IAesBA,uBAAuB,MAAvBA,uBAAuB;IAyF7BC,wBAAwB,MAAxBA,wBAAwB;IA8DxBC,kBAAkB,MAAlBA,kBAAkB;IAuClBC,yBAAyB,MAAzBA,yBAAyB;;;8DA7M1B,IAAI;;;;;;;8DAEF,MAAM;;;;;;qCAEW,uBAAuB;qBAErC,QAAQ;;;;;;AAE5B,SAASC,iBAAiB,CAACC,UAAkB,EAAQ;IACnD,MAAM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EAA2E;QAC3E,0CAA0C;QAC1C,MAAMuD,QAAQ,GAAGH,SAAS,CAACA,SAAS,CAACpD,MAAM,GAAG,CAAC,CAAC,AAAC;QACjD,KAAK,MAAMC,KAAK,IAAIR,MAAM,CAAE;YAC1B,IAAIQ,KAAK,GAAGsD,QAAQ,EAAE;gBACpBF,MAAM,CAAC1D,IAAI,CAACM,KAAK,CAAC,CAAC;gBACnB,MAAM;YACR,CAAC;QACH,CAAC;QAED,+DAA+D;QAC/D,IAAI,CAACoD,MAAM,CAACrD,MAAM,EAAE;YAClBqD,MAAM,CAAC1D,IAAI,CAACF,MAAM,CAACA,MAAM,CAACO,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IACD,OAAOqD,MAAM,CAAC;AAChB,CAAC;AAED,SAASvB,qBAAqB,CAACzC,KAAqD,EAAU;IAC5F,MAAMmE,UAAU,GAAGC,UAAU,CAACpE,KAAK,CAAC,AAAC;IACrC,OAAO,CAAC,EAAEmE,UAAU,CAAC,CAAC,EAAEnE,KAAK,CAAC0B,IAAI,CAAC,CAAC,CACjC2C,WAAW,EAAE,CACbC,OAAO,QAAQ,GAAG,CAAC,CAAC,uCAAuC;KAC3DA,OAAO,kBAAkB,EAAE,CAAC,CAAC,uBAAuB;KACpDA,OAAO,aAAa,EAAE,CAAC,CAAC,CAAC,0BAA0B;AACxD,CAAC;AAED,SAASF,UAAU,CAACpE,KAA4C,EAAU;IACxE,IAAIV,OAAO,GAAGU,KAAK,CAACuE,kBAAkB,AAAC;IACvC,IAAIjF,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;QACtBA,OAAO,GAAGA,OAAO,CAACkF,SAAS,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC;IACD,OAAOlF,OAAO,CAAC;AACjB,CAAC"}
@@ -23,8 +23,8 @@ async function resolveBundlerPropsAsync(projectRoot, options) {
23
23
  // Skip bundling if the port is null -- meaning skip the bundler if the port is already running the app.
24
24
  options.bundler = !!port;
25
25
  if (!port) {
26
- // any random number
27
- port = 8081;
26
+ // Use explicit user-provided port, or the default port
27
+ port = options.port ?? 8081;
28
28
  }
29
29
  _log.Log.debug(`Resolved port: ${port}, start dev server: ${options.bundler}`);
30
30
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/run/resolveBundlerProps.ts"],"sourcesContent":["import { Log } from '../log';\nimport { CommandError } from '../utils/errors';\nimport { resolvePortAsync } from '../utils/port';\n\nexport interface BundlerProps {\n /** Port to start the dev server on. */\n port: number;\n /** Skip opening the bundler from the native script. */\n shouldStartBundler: boolean;\n}\n\nexport async function resolveBundlerPropsAsync(\n projectRoot: string,\n options: {\n port?: number;\n bundler?: boolean;\n }\n): Promise<BundlerProps> {\n options.bundler = options.bundler ?? true;\n\n if (\n // If the user disables the bundler then they should not pass in the port property.\n !options.bundler &&\n options.port\n ) {\n throw new CommandError('BAD_ARGS', '--port and --no-bundler are mutually exclusive arguments');\n }\n\n // Resolve the port if the bundler is used.\n let port = options.bundler\n ? await resolvePortAsync(projectRoot, { reuseExistingPort: true, defaultPort: options.port })\n : null;\n\n // Skip bundling if the port is null -- meaning skip the bundler if the port is already running the app.\n options.bundler = !!port;\n if (!port) {\n // any random number\n port = 8081;\n }\n Log.debug(`Resolved port: ${port}, start dev server: ${options.bundler}`);\n\n return {\n shouldStartBundler: !!options.bundler,\n port,\n };\n}\n"],"names":["resolveBundlerPropsAsync","projectRoot","options","bundler","port","CommandError","resolvePortAsync","reuseExistingPort","defaultPort","Log","debug","shouldStartBundler"],"mappings":"AAAA;;;;+BAWsBA,0BAAwB;;aAAxBA,wBAAwB;;qBAX1B,QAAQ;wBACC,iBAAiB;sBACb,eAAe;AASzC,eAAeA,wBAAwB,CAC5CC,WAAmB,EACnBC,OAGC,EACsB;IACvBA,OAAO,CAACC,OAAO,GAAGD,OAAO,CAACC,OAAO,IAAI,IAAI,CAAC;IAE1C,IACE,mFAAmF;IACnF,CAACD,OAAO,CAACC,OAAO,IAChBD,OAAO,CAACE,IAAI,EACZ;QACA,MAAM,IAAIC,OAAY,aAAA,CAAC,UAAU,EAAE,0DAA0D,CAAC,CAAC;IACjG,CAAC;IAED,2CAA2C;IAC3C,IAAID,IAAI,GAAGF,OAAO,CAACC,OAAO,GACtB,MAAMG,IAAAA,KAAgB,iBAAA,EAACL,WAAW,EAAE;QAAEM,iBAAiB,EAAE,IAAI;QAAEC,WAAW,EAAEN,OAAO,CAACE,IAAI;KAAE,CAAC,GAC3F,IAAI,AAAC;IAET,wGAAwG;IACxGF,OAAO,CAACC,OAAO,GAAG,CAAC,CAACC,IAAI,CAAC;IACzB,IAAI,CAACA,IAAI,EAAE;QACT,oBAAoB;QACpBA,IAAI,GAAG,IAAI,CAAC;IACd,CAAC;IACDK,IAAG,IAAA,CAACC,KAAK,CAAC,CAAC,eAAe,EAAEN,IAAI,CAAC,oBAAoB,EAAEF,OAAO,CAACC,OAAO,CAAC,CAAC,CAAC,CAAC;IAE1E,OAAO;QACLQ,kBAAkB,EAAE,CAAC,CAACT,OAAO,CAACC,OAAO;QACrCC,IAAI;KACL,CAAC;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../../src/run/resolveBundlerProps.ts"],"sourcesContent":["import { Log } from '../log';\nimport { CommandError } from '../utils/errors';\nimport { resolvePortAsync } from '../utils/port';\n\nexport interface BundlerProps {\n /** Port to start the dev server on. */\n port: number;\n /** Skip opening the bundler from the native script. */\n shouldStartBundler: boolean;\n}\n\nexport async function resolveBundlerPropsAsync(\n projectRoot: string,\n options: {\n port?: number;\n bundler?: boolean;\n }\n): Promise<BundlerProps> {\n options.bundler = options.bundler ?? true;\n\n if (\n // If the user disables the bundler then they should not pass in the port property.\n !options.bundler &&\n options.port\n ) {\n throw new CommandError('BAD_ARGS', '--port and --no-bundler are mutually exclusive arguments');\n }\n\n // Resolve the port if the bundler is used.\n let port = options.bundler\n ? await resolvePortAsync(projectRoot, { reuseExistingPort: true, defaultPort: options.port })\n : null;\n\n // Skip bundling if the port is null -- meaning skip the bundler if the port is already running the app.\n options.bundler = !!port;\n if (!port) {\n // Use explicit user-provided port, or the default port\n port = options.port ?? 8081;\n }\n Log.debug(`Resolved port: ${port}, start dev server: ${options.bundler}`);\n\n return {\n shouldStartBundler: !!options.bundler,\n port,\n };\n}\n"],"names":["resolveBundlerPropsAsync","projectRoot","options","bundler","port","CommandError","resolvePortAsync","reuseExistingPort","defaultPort","Log","debug","shouldStartBundler"],"mappings":"AAAA;;;;+BAWsBA,0BAAwB;;aAAxBA,wBAAwB;;qBAX1B,QAAQ;wBACC,iBAAiB;sBACb,eAAe;AASzC,eAAeA,wBAAwB,CAC5CC,WAAmB,EACnBC,OAGC,EACsB;IACvBA,OAAO,CAACC,OAAO,GAAGD,OAAO,CAACC,OAAO,IAAI,IAAI,CAAC;IAE1C,IACE,mFAAmF;IACnF,CAACD,OAAO,CAACC,OAAO,IAChBD,OAAO,CAACE,IAAI,EACZ;QACA,MAAM,IAAIC,OAAY,aAAA,CAAC,UAAU,EAAE,0DAA0D,CAAC,CAAC;IACjG,CAAC;IAED,2CAA2C;IAC3C,IAAID,IAAI,GAAGF,OAAO,CAACC,OAAO,GACtB,MAAMG,IAAAA,KAAgB,iBAAA,EAACL,WAAW,EAAE;QAAEM,iBAAiB,EAAE,IAAI;QAAEC,WAAW,EAAEN,OAAO,CAACE,IAAI;KAAE,CAAC,GAC3F,IAAI,AAAC;IAET,wGAAwG;IACxGF,OAAO,CAACC,OAAO,GAAG,CAAC,CAACC,IAAI,CAAC;IACzB,IAAI,CAACA,IAAI,EAAE;QACT,uDAAuD;QACvDA,IAAI,GAAGF,OAAO,CAACE,IAAI,IAAI,IAAI,CAAC;IAC9B,CAAC;IACDK,IAAG,IAAA,CAACC,KAAK,CAAC,CAAC,eAAe,EAAEN,IAAI,CAAC,oBAAoB,EAAEF,OAAO,CAACC,OAAO,CAAC,CAAC,CAAC,CAAC;IAE1E,OAAO;QACLQ,kBAAkB,EAAE,CAAC,CAACT,OAAO,CAACC,OAAO;QACrCC,IAAI;KACL,CAAC;AACJ,CAAC"}
@@ -105,6 +105,7 @@ function createFastResolver({ preserveSymlinks , blockList }) {
105
105
  const conditions = context.unstable_enablePackageExports ? [
106
106
  ...new Set([
107
107
  "default",
108
+ context.isESMImport === true ? "import" : "require",
108
109
  ...context.unstable_conditionNames,
109
110
  ...platform != null ? context.unstable_conditionsByPlatform[platform] ?? [] : [],
110
111
  ]),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/createExpoMetroResolver.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport fs from 'fs';\nimport { Resolution, ResolutionContext } from 'metro-resolver';\nimport path from 'path';\n\nimport jestResolver from './createJResolver';\nimport { isNodeExternal } from './externals';\nimport { formatFileCandidates } from './formatFileCandidates';\nimport { isServerEnvironment } from '../middleware/metroOptions';\n\nexport class FailedToResolvePathError extends Error {\n // Added to ensure the error is matched by our tooling.\n // TODO: Test that this matches `isFailedToResolvePathError`\n candidates = {};\n}\n\nclass ShimModuleError extends Error {}\n\nconst debug = require('debug')('expo:metro:resolve') as typeof console.log;\n\nconst realpathFS =\n process.platform !== 'win32' && fs.realpathSync && typeof fs.realpathSync.native === 'function'\n ? fs.realpathSync.native\n : fs.realpathSync;\n\nfunction realpathSync(x: string) {\n try {\n return realpathFS(x);\n } catch (realpathErr: any) {\n if (realpathErr.code !== 'ENOENT') {\n throw realpathErr;\n }\n }\n return x;\n}\n\nexport function createFastResolver({\n preserveSymlinks,\n blockList,\n}: {\n preserveSymlinks: boolean;\n blockList: RegExp[];\n}) {\n debug('Creating with settings:', { preserveSymlinks, blockList });\n const cachedExtensions: Map<string, readonly string[]> = new Map();\n\n function getAdjustedExtensions({\n metroSourceExtensions,\n platform,\n isNative,\n }: {\n metroSourceExtensions: readonly string[];\n platform: string | null;\n isNative: boolean;\n }): readonly string[] {\n const key = JSON.stringify({ metroSourceExtensions, platform, isNative });\n if (cachedExtensions.has(key)) {\n return cachedExtensions.get(key)!;\n }\n\n let output = metroSourceExtensions;\n if (platform) {\n const nextOutput: string[] = [];\n\n output.forEach((ext) => {\n nextOutput.push(`${platform}.${ext}`);\n if (isNative) {\n nextOutput.push(`native.${ext}`);\n }\n nextOutput.push(ext);\n });\n\n output = nextOutput;\n }\n\n output = Array.from(new Set<string>(output));\n\n // resolve expects these to start with a dot.\n output = output.map((ext) => `.${ext}`);\n\n cachedExtensions.set(key, output);\n\n return output;\n }\n\n function fastResolve(\n context: Pick<\n ResolutionContext,\n | 'unstable_enablePackageExports'\n | 'customResolverOptions'\n | 'sourceExts'\n | 'preferNativePlatform'\n | 'originModulePath'\n | 'getPackage'\n | 'nodeModulesPaths'\n | 'mainFields'\n | 'resolveAsset'\n | 'unstable_conditionNames'\n | 'unstable_conditionsByPlatform'\n | 'fileSystemLookup'\n >,\n moduleName: string,\n platform: string | null\n ): Resolution {\n const environment = context.customResolverOptions?.environment;\n const isServer = isServerEnvironment(environment);\n\n const extensions = getAdjustedExtensions({\n metroSourceExtensions: context.sourceExts,\n platform,\n isNative: context.preferNativePlatform,\n }) as string[];\n\n let fp: string;\n\n const conditions = context.unstable_enablePackageExports\n ? [\n ...new Set([\n 'default',\n ...context.unstable_conditionNames,\n ...(platform != null ? (context.unstable_conditionsByPlatform[platform] ?? []) : []),\n ]),\n ]\n : [];\n\n // NOTE(cedric): metro@0.81.0 ships with `fileSystemLookup`, while `metro@0.80.12` ships as unstable\n const fileSystemLookup = (\n 'unstable_fileSystemLookup' in context\n ? context.unstable_fileSystemLookup\n : context.fileSystemLookup\n ) as ResolutionContext['fileSystemLookup'] | undefined;\n\n if (!fileSystemLookup) {\n throw new Error('Metro API fileSystemLookup is required for fast resolver');\n }\n\n try {\n fp = jestResolver(moduleName, {\n blockList,\n enablePackageExports: context.unstable_enablePackageExports,\n basedir: path.dirname(context.originModulePath),\n moduleDirectory: context.nodeModulesPaths.length\n ? (context.nodeModulesPaths as string[])\n : undefined,\n extensions,\n conditions,\n realpathSync(file: string): string {\n let metroRealPath: string | null = null;\n\n const res = fileSystemLookup(file);\n if (res?.exists) {\n metroRealPath = res.realPath;\n }\n\n if (metroRealPath == null && preserveSymlinks) {\n return realpathSync(file);\n }\n return metroRealPath ?? file;\n },\n isDirectory(file: string): boolean {\n const res = fileSystemLookup(file);\n return res.exists && res.type === 'd';\n },\n isFile(file: string): boolean {\n const res = fileSystemLookup(file);\n return res.exists && res.type === 'f';\n },\n pathExists(file: string): boolean {\n return fileSystemLookup(file).exists;\n },\n packageFilter(pkg) {\n // set the pkg.main to the first available field in context.mainFields\n for (const field of context.mainFields) {\n if (\n pkg[field] &&\n // object-inspect uses browser: {} in package.json\n typeof pkg[field] === 'string'\n ) {\n return {\n ...pkg,\n main: pkg[field],\n };\n }\n }\n return pkg;\n },\n // Used to ensure files trace to packages instead of node_modules in expo/expo. This is how Metro works and\n // the app doesn't finish without it.\n preserveSymlinks,\n readPackageSync(readFileSync, pkgFile) {\n return context.getPackage(pkgFile) ?? JSON.parse(fs.readFileSync(pkgFile, 'utf8'));\n },\n includeCoreModules: isServer,\n\n pathFilter:\n // Disable `browser` field for server environments.\n isServer\n ? undefined\n : // Enable `browser` field support\n (pkg: any, _resolvedPath: string, relativePathIn: string): string => {\n let relativePath = relativePathIn;\n if (relativePath[0] !== '.') {\n relativePath = `./${relativePath}`;\n }\n\n const replacements = pkg.browser;\n if (replacements === undefined) {\n return '';\n }\n\n // TODO: Probably use a better extension matching system here.\n // This was added for `uuid/v4` -> `./lib/rng` -> `./lib/rng-browser.js`\n const mappedPath = replacements[relativePath] ?? replacements[relativePath + '.js'];\n if (mappedPath === false) {\n throw new ShimModuleError();\n }\n return mappedPath;\n },\n });\n } catch (error: any) {\n if (error instanceof ShimModuleError) {\n return {\n type: 'empty',\n };\n }\n\n if ('code' in error && error.code === 'MODULE_NOT_FOUND') {\n if (isNodeExternal(moduleName)) {\n // In this case, mock the file to use an empty module.\n return {\n type: 'empty',\n };\n }\n\n debug({ moduleName, platform, conditions, isServer, preserveSymlinks }, context);\n\n throw new FailedToResolvePathError(\n 'The module could not be resolved because no file or module matched the pattern:\\n' +\n ` ${formatFileCandidates(\n {\n type: 'sourceFile',\n filePathPrefix: moduleName,\n candidateExts: extensions,\n },\n true\n )}\\n\\nFrom:\\n ${context.originModulePath}\\n`\n );\n }\n throw error;\n }\n\n if (context.sourceExts.some((ext) => fp.endsWith(ext))) {\n return {\n type: 'sourceFile',\n filePath: fp,\n };\n }\n\n if (isNodeExternal(fp)) {\n if (isServer) {\n return {\n type: 'sourceFile',\n filePath: fp,\n };\n }\n // NOTE: This shouldn't happen, the module should throw.\n // Mock non-server built-in modules to empty.\n return {\n type: 'empty',\n };\n }\n\n // NOTE: platform extensions may not be supported on assets.\n\n if (platform === 'web') {\n // Skip multi-resolution on web/server bundles. Only consideration here is that\n // we may still need it in case the only image is a multi-resolution image.\n return {\n type: 'assetFiles',\n filePaths: [fp],\n };\n }\n\n const dirPath = path.dirname(fp);\n const extension = path.extname(fp);\n const basename = path.basename(fp, extension);\n return {\n type: 'assetFiles',\n // Support multi-resolution asset extensions...\n filePaths: context.resolveAsset(dirPath, basename, extension) ?? [fp],\n };\n }\n\n return fastResolve;\n}\n"],"names":["FailedToResolvePathError","createFastResolver","Error","candidates","ShimModuleError","debug","require","realpathFS","process","platform","fs","realpathSync","native","x","realpathErr","code","preserveSymlinks","blockList","cachedExtensions","Map","getAdjustedExtensions","metroSourceExtensions","isNative","key","JSON","stringify","has","get","output","nextOutput","forEach","ext","push","Array","from","Set","map","set","fastResolve","context","moduleName","environment","customResolverOptions","isServer","isServerEnvironment","extensions","sourceExts","preferNativePlatform","fp","conditions","unstable_enablePackageExports","unstable_conditionNames","unstable_conditionsByPlatform","fileSystemLookup","unstable_fileSystemLookup","jestResolver","enablePackageExports","basedir","path","dirname","originModulePath","moduleDirectory","nodeModulesPaths","length","undefined","file","metroRealPath","res","exists","realPath","isDirectory","type","isFile","pathExists","packageFilter","pkg","field","mainFields","main","readPackageSync","readFileSync","pkgFile","getPackage","parse","includeCoreModules","pathFilter","_resolvedPath","relativePathIn","relativePath","replacements","browser","mappedPath","error","isNodeExternal","formatFileCandidates","filePathPrefix","candidateExts","some","endsWith","filePath","filePaths","dirPath","extension","extname","basename","resolveAsset"],"mappings":"AAAA;;;;;CAKC,GACD;;;;;;;;;;;IASaA,wBAAwB,MAAxBA,wBAAwB;IA0BrBC,kBAAkB,MAAlBA,kBAAkB;;;8DAnCnB,IAAI;;;;;;;8DAEF,MAAM;;;;;;sEAEE,mBAAmB;2BACb,aAAa;sCACP,wBAAwB;8BACzB,4BAA4B;;;;;;AAEzD,MAAMD,wBAAwB,SAASE,KAAK;IACjD,uDAAuD;IACvD,4DAA4D;IAC5DC,UAAU,GAAG,EAAE,CAAC;CACjB;AAED,MAAMC,eAAe,SAASF,KAAK;CAAG;AAEtC,MAAMG,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAAC,AAAsB,AAAC;AAE3E,MAAMC,UAAU,GACdC,OAAO,CAACC,QAAQ,KAAK,OAAO,IAAIC,GAAE,EAAA,QAAA,CAACC,YAAY,IAAI,OAAOD,GAAE,EAAA,QAAA,CAACC,YAAY,CAACC,MAAM,KAAK,UAAU,GAC3FF,GAAE,EAAA,QAAA,CAACC,YAAY,CAACC,MAAM,GACtBF,GAAE,EAAA,QAAA,CAACC,YAAY,AAAC;AAEtB,SAASA,YAAY,CAACE,CAAS,EAAE;IAC/B,IAAI;QACF,OAAON,UAAU,CAACM,CAAC,CAAC,CAAC;IACvB,EAAE,OAAOC,WAAW,EAAO;QACzB,IAAIA,WAAW,CAACC,IAAI,KAAK,QAAQ,EAAE;YACjC,MAAMD,WAAW,CAAC;QACpB,CAAC;IACH,CAAC;IACD,OAAOD,CAAC,CAAC;AACX,CAAC;AAEM,SAASZ,kBAAkB,CAAC,EACjCe,gBAAgB,CAAA,EAChBC,SAAS,CAAA,EA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A6C;YAC7C,OAAO;gBACLuB,IAAI,EAAE,OAAO;aACd,CAAC;QACJ,CAAC;QAED,4DAA4D;QAE5D,IAAI9D,QAAQ,KAAK,KAAK,EAAE;YACtB,+EAA+E;YAC/E,2EAA2E;YAC3E,OAAO;gBACL8D,IAAI,EAAE,YAAY;gBAClB6B,SAAS,EAAE;oBAACpD,EAAE;iBAAC;aAChB,CAAC;QACJ,CAAC;QAED,MAAMqD,OAAO,GAAG3C,KAAI,EAAA,QAAA,CAACC,OAAO,CAACX,EAAE,CAAC,AAAC;QACjC,MAAMsD,SAAS,GAAG5C,KAAI,EAAA,QAAA,CAAC6C,OAAO,CAACvD,EAAE,CAAC,AAAC;QACnC,MAAMwD,QAAQ,GAAG9C,KAAI,EAAA,QAAA,CAAC8C,QAAQ,CAACxD,EAAE,EAAEsD,SAAS,CAAC,AAAC;QAC9C,OAAO;YACL/B,IAAI,EAAE,YAAY;YAClB,+CAA+C;YAC/C6B,SAAS,EAAE7D,OAAO,CAACkE,YAAY,CAACJ,OAAO,EAAEG,QAAQ,EAAEF,SAAS,CAAC,IAAI;gBAACtD,EAAE;aAAC;SACtE,CAAC;IACJ,CAAC;IAED,OAAOV,WAAW,CAAC;AACrB,CAAC"}
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/createExpoMetroResolver.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport fs from 'fs';\nimport { Resolution, ResolutionContext } from 'metro-resolver';\nimport path from 'path';\n\nimport jestResolver from './createJResolver';\nimport { isNodeExternal } from './externals';\nimport { formatFileCandidates } from './formatFileCandidates';\nimport { isServerEnvironment } from '../middleware/metroOptions';\n\nexport class FailedToResolvePathError extends Error {\n // Added to ensure the error is matched by our tooling.\n // TODO: Test that this matches `isFailedToResolvePathError`\n candidates = {};\n}\n\nclass ShimModuleError extends Error {}\n\nconst debug = require('debug')('expo:metro:resolve') as typeof console.log;\n\nconst realpathFS =\n process.platform !== 'win32' && fs.realpathSync && typeof fs.realpathSync.native === 'function'\n ? fs.realpathSync.native\n : fs.realpathSync;\n\nfunction realpathSync(x: string) {\n try {\n return realpathFS(x);\n } catch (realpathErr: any) {\n if (realpathErr.code !== 'ENOENT') {\n throw realpathErr;\n }\n }\n return x;\n}\n\nexport function createFastResolver({\n preserveSymlinks,\n blockList,\n}: {\n preserveSymlinks: boolean;\n blockList: RegExp[];\n}) {\n debug('Creating with settings:', { preserveSymlinks, blockList });\n const cachedExtensions: Map<string, readonly string[]> = new Map();\n\n function getAdjustedExtensions({\n metroSourceExtensions,\n platform,\n isNative,\n }: {\n metroSourceExtensions: readonly string[];\n platform: string | null;\n isNative: boolean;\n }): readonly string[] {\n const key = JSON.stringify({ metroSourceExtensions, platform, isNative });\n if (cachedExtensions.has(key)) {\n return cachedExtensions.get(key)!;\n }\n\n let output = metroSourceExtensions;\n if (platform) {\n const nextOutput: string[] = [];\n\n output.forEach((ext) => {\n nextOutput.push(`${platform}.${ext}`);\n if (isNative) {\n nextOutput.push(`native.${ext}`);\n }\n nextOutput.push(ext);\n });\n\n output = nextOutput;\n }\n\n output = Array.from(new Set<string>(output));\n\n // resolve expects these to start with a dot.\n output = output.map((ext) => `.${ext}`);\n\n cachedExtensions.set(key, output);\n\n return output;\n }\n\n function fastResolve(\n context: Pick<\n ResolutionContext,\n | 'unstable_enablePackageExports'\n | 'customResolverOptions'\n | 'sourceExts'\n | 'preferNativePlatform'\n | 'originModulePath'\n | 'getPackage'\n | 'nodeModulesPaths'\n | 'mainFields'\n | 'resolveAsset'\n | 'unstable_conditionNames'\n | 'unstable_conditionsByPlatform'\n | 'fileSystemLookup'\n | 'isESMImport'\n >,\n moduleName: string,\n platform: string | null\n ): Resolution {\n const environment = context.customResolverOptions?.environment;\n const isServer = isServerEnvironment(environment);\n\n const extensions = getAdjustedExtensions({\n metroSourceExtensions: context.sourceExts,\n platform,\n isNative: context.preferNativePlatform,\n }) as string[];\n\n let fp: string;\n\n const conditions = context.unstable_enablePackageExports\n ? [\n ...new Set([\n 'default',\n context.isESMImport === true ? 'import' : 'require',\n ...context.unstable_conditionNames,\n ...(platform != null ? (context.unstable_conditionsByPlatform[platform] ?? []) : []),\n ]),\n ]\n : [];\n\n // NOTE(cedric): metro@0.81.0 ships with `fileSystemLookup`, while `metro@0.80.12` ships as unstable\n const fileSystemLookup = (\n 'unstable_fileSystemLookup' in context\n ? context.unstable_fileSystemLookup\n : context.fileSystemLookup\n ) as ResolutionContext['fileSystemLookup'] | undefined;\n\n if (!fileSystemLookup) {\n throw new Error('Metro API fileSystemLookup is required for fast resolver');\n }\n\n try {\n fp = jestResolver(moduleName, {\n blockList,\n enablePackageExports: context.unstable_enablePackageExports,\n basedir: path.dirname(context.originModulePath),\n moduleDirectory: context.nodeModulesPaths.length\n ? (context.nodeModulesPaths as string[])\n : undefined,\n extensions,\n conditions,\n realpathSync(file: string): string {\n let metroRealPath: string | null = null;\n\n const res = fileSystemLookup(file);\n if (res?.exists) {\n metroRealPath = res.realPath;\n }\n\n if (metroRealPath == null && preserveSymlinks) {\n return realpathSync(file);\n }\n return metroRealPath ?? file;\n },\n isDirectory(file: string): boolean {\n const res = fileSystemLookup(file);\n return res.exists && res.type === 'd';\n },\n isFile(file: string): boolean {\n const res = fileSystemLookup(file);\n return res.exists && res.type === 'f';\n },\n pathExists(file: string): boolean {\n return fileSystemLookup(file).exists;\n },\n packageFilter(pkg) {\n // set the pkg.main to the first available field in context.mainFields\n for (const field of context.mainFields) {\n if (\n pkg[field] &&\n // object-inspect uses browser: {} in package.json\n typeof pkg[field] === 'string'\n ) {\n return {\n ...pkg,\n main: pkg[field],\n };\n }\n }\n return pkg;\n },\n // Used to ensure files trace to packages instead of node_modules in expo/expo. This is how Metro works and\n // the app doesn't finish without it.\n preserveSymlinks,\n readPackageSync(readFileSync, pkgFile) {\n return context.getPackage(pkgFile) ?? JSON.parse(fs.readFileSync(pkgFile, 'utf8'));\n },\n includeCoreModules: isServer,\n\n pathFilter:\n // Disable `browser` field for server environments.\n isServer\n ? undefined\n : // Enable `browser` field support\n (pkg: any, _resolvedPath: string, relativePathIn: string): string => {\n let relativePath = relativePathIn;\n if (relativePath[0] !== '.') {\n relativePath = `./${relativePath}`;\n }\n\n const replacements = pkg.browser;\n if (replacements === undefined) {\n return '';\n }\n\n // TODO: Probably use a better extension matching system here.\n // This was added for `uuid/v4` -> `./lib/rng` -> `./lib/rng-browser.js`\n const mappedPath = replacements[relativePath] ?? replacements[relativePath + '.js'];\n if (mappedPath === false) {\n throw new ShimModuleError();\n }\n return mappedPath;\n },\n });\n } catch (error: any) {\n if (error instanceof ShimModuleError) {\n return {\n type: 'empty',\n };\n }\n\n if ('code' in error && error.code === 'MODULE_NOT_FOUND') {\n if (isNodeExternal(moduleName)) {\n // In this case, mock the file to use an empty module.\n return {\n type: 'empty',\n };\n }\n\n debug({ moduleName, platform, conditions, isServer, preserveSymlinks }, context);\n\n throw new FailedToResolvePathError(\n 'The module could not be resolved because no file or module matched the pattern:\\n' +\n ` ${formatFileCandidates(\n {\n type: 'sourceFile',\n filePathPrefix: moduleName,\n candidateExts: extensions,\n },\n true\n )}\\n\\nFrom:\\n ${context.originModulePath}\\n`\n );\n }\n throw error;\n }\n\n if (context.sourceExts.some((ext) => fp.endsWith(ext))) {\n return {\n type: 'sourceFile',\n filePath: fp,\n };\n }\n\n if (isNodeExternal(fp)) {\n if (isServer) {\n return {\n type: 'sourceFile',\n filePath: fp,\n };\n }\n // NOTE: This shouldn't happen, the module should throw.\n // Mock non-server built-in modules to empty.\n return {\n type: 'empty',\n };\n }\n\n // NOTE: platform extensions may not be supported on assets.\n\n if (platform === 'web') {\n // Skip multi-resolution on web/server bundles. Only consideration here is that\n // we may still need it in case the only image is a multi-resolution image.\n return {\n type: 'assetFiles',\n filePaths: [fp],\n };\n }\n\n const dirPath = path.dirname(fp);\n const extension = path.extname(fp);\n const basename = path.basename(fp, extension);\n return {\n type: 'assetFiles',\n // Support multi-resolution asset extensions...\n filePaths: context.resolveAsset(dirPath, basename, extension) ?? [fp],\n };\n }\n\n return fastResolve;\n}\n"],"names":["FailedToResolvePathError","createFastResolver","Error","candidates","ShimModuleError","debug","require","realpathFS","process","platform","fs","realpathSync","native","x","realpathErr","code","preserveSymlinks","blockList","cachedExtensions","Map","getAdjustedExtensions","metroSourceExtensions","isNative","key","JSON","stringify","has","get","output","nextOutput","forEach","ext","push","Array","from","Set","map","set","fastResolve","context","moduleName","environment","customResolverOptions","isServer","isServerEnvironment","extensions","sourceExts","preferNativePlatform","fp","conditions","unstable_enablePackageExports","isESMImport","unstable_conditionNames","unstable_conditionsByPlatform","fileSystemLookup","unstable_fileSystemLookup","jestResolver","enablePackageExports","basedir","path","dirname","originModulePath","moduleDirectory","nodeModulesPaths","length","undefined","file","metroRealPath","res","exists","realPath","isDirectory","type","isFile","pathExists","packageFilter","pkg","field","mainFields","main","readPackageSync","readFileSync","pkgFile","getPackage","parse","includeCoreModules","pathFilter","_resolvedPath","relativePathIn","relativePath","replacements","browser","mappedPath","error","isNodeExternal","formatFileCandidates","filePathPrefix","candidateExts","some","endsWith","filePath","filePaths","dirPath","extension","extname","basename","resolveAsset"],"mappings":"AAAA;;;;;CAKC,GACD;;;;;;;;;;;IASaA,wBAAwB,MAAxBA,wBAAwB;IA0BrBC,kBAAkB,MAAlBA,kBAAkB;;;8DAnCnB,IAAI;;;;;;;8DAEF,MAAM;;;;;;sEAEE,mBAAmB;2BACb,aAAa;sCACP,wBAAwB;8BACzB,4BAA4B;;;;;;AAEzD,MAAMD,wBAAwB,SAASE,KAAK;IACjD,uDAAuD;IACvD,4DAA4D;IAC5DC,UAAU,GAAG,EAAE,CAAC;CACjB;AAED,MAAMC,eAAe,SAASF,KAAK;CAAG;AAEtC,MAAMG,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAAC,AAAsB,AAAC;AAE3E,MAAMC,UAAU,GACdC,OAAO,CAACC,QAAQ,KAAK,OA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OAAO,EAAEG,QAAQ,EAAEF,SAAS,CAAC,IAAI;gBAACvD,EAAE;aAAC;SACtE,CAAC;IACJ,CAAC;IAED,OAAOV,WAAW,CAAC;AACrB,CAAC"}
@@ -117,10 +117,6 @@ const _default = defaultResolver;
117
117
  if (moduleName.startsWith("@")) {
118
118
  moduleName = `${moduleName}/${segments.shift()}`;
119
119
  }
120
- // Disable package exports for babel/runtime for https://github.com/facebook/metro/issues/984/
121
- if (moduleName === "@babel/runtime") {
122
- return path;
123
- }
124
120
  // self-reference
125
121
  const closestPackageJson = findClosestPackageJson(options.basedir, options);
126
122
  if (closestPackageJson) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/createJResolver.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Fork of the jest resolver but with additional settings for Metro and pnp removed.\n * https://github.com/jestjs/jest/blob/d1a2ed7fea4bdc19836274cd810c8360e3ab62f3/packages/jest-resolve/src/defaultResolver.ts#L1\n */\nimport type { JSONObject as PackageJSON } from '@expo/json-file';\nimport assert from 'assert';\nimport { dirname, isAbsolute, resolve as pathResolve } from 'path';\nimport { sync as resolveSync, SyncOpts as UpstreamResolveOptions } from 'resolve';\nimport * as resolve from 'resolve.exports';\n\n/**\n * Allows transforming parsed `package.json` contents.\n *\n * @param pkg - Parsed `package.json` contents.\n * @param file - Path to `package.json` file.\n * @param dir - Directory that contains the `package.json`.\n *\n * @returns Transformed `package.json` contents.\n */\ntype PackageFilter = (pkg: PackageJSON, file: string, dir: string) => PackageJSON;\n\n/**\n * Allows transforming a path within a package.\n *\n * @param pkg - Parsed `package.json` contents.\n * @param path - Path being resolved.\n * @param relativePath - Path relative from the `package.json` location.\n *\n * @returns Relative path that will be joined from the `package.json` location.\n */\ntype PathFilter = (pkg: PackageJSON, path: string, relativePath: string) => string;\n\ntype ResolverOptions = {\n /** Directory to begin resolving from. */\n basedir: string;\n /** List of export conditions. */\n conditions?: string[];\n /** Instance of default resolver. */\n defaultResolver: typeof defaultResolver;\n /** List of file extensions to search in order. */\n extensions?: string[];\n /**\n * List of directory names to be looked up for modules recursively.\n *\n * @defaultValue\n * The default is `['node_modules']`.\n */\n moduleDirectory?: string[];\n /**\n * List of `require.paths` to use if nothing is found in `node_modules`.\n *\n * @defaultValue\n * The default is `undefined`.\n */\n paths?: string[];\n /** Allows transforming parsed `package.json` contents. */\n packageFilter?: PackageFilter;\n /** Allows transforms a path within a package. */\n pathFilter?: PathFilter;\n /** Current root directory. */\n rootDir?: string;\n\n enablePackageExports?: boolean;\n\n blockList: RegExp[];\n\n getPackageForModule: import('metro-resolver').CustomResolutionContext['getPackageForModule'];\n} & Pick<\n UpstreamResolveOptions,\n | 'readPackageSync'\n | 'realpathSync'\n | 'moduleDirectory'\n | 'extensions'\n | 'preserveSymlinks'\n | 'includeCoreModules'\n>;\n\ntype UpstreamResolveOptionsWithConditions = UpstreamResolveOptions &\n ResolverOptions & {\n pathExists: (file: string) => boolean;\n };\n\nconst defaultResolver = (\n path: string,\n {\n enablePackageExports,\n blockList = [],\n ...options\n }: Omit<ResolverOptions, 'defaultResolver' | 'getPackageForModule'> & {\n isDirectory: (file: string) => boolean;\n isFile: (file: string) => boolean;\n pathExists: (file: string) => boolean;\n }\n): string => {\n // @ts-expect-error\n const resolveOptions: UpstreamResolveOptionsWithConditions = {\n ...options,\n preserveSymlinks: options.preserveSymlinks,\n defaultResolver,\n };\n\n // resolveSync dereferences symlinks to ensure we don't create a separate\n // module instance depending on how it was referenced.\n const result = resolveSync(enablePackageExports ? getPathInModule(path, resolveOptions) : path, {\n ...resolveOptions,\n preserveSymlinks: !options.preserveSymlinks,\n });\n\n return result;\n};\n\nexport default defaultResolver;\n\n/*\n * helper functions\n */\n\nfunction getPathInModule(path: string, options: UpstreamResolveOptionsWithConditions): string {\n if (shouldIgnoreRequestForExports(path)) {\n return path;\n }\n\n const segments = path.split('/');\n\n let moduleName = segments.shift();\n\n if (!moduleName) {\n return path;\n }\n\n if (moduleName.startsWith('@')) {\n moduleName = `${moduleName}/${segments.shift()}`;\n }\n\n // Disable package exports for babel/runtime for https://github.com/facebook/metro/issues/984/\n if (moduleName === '@babel/runtime') {\n return path;\n }\n\n // self-reference\n const closestPackageJson = findClosestPackageJson(options.basedir, options);\n if (closestPackageJson) {\n const pkg = options.readPackageSync!(options.readFileSync!, closestPackageJson);\n assert(pkg, 'package.json should be read by `readPackageSync`');\n\n // Added support for the package.json \"imports\" field (#-prefixed paths)\n if (path.startsWith('#')) {\n const resolved = resolve.imports(pkg, path, createResolveOptions(options.conditions));\n if (resolved) {\n // TODO: Should we attempt to resolve every path in the array?\n return pathResolve(dirname(closestPackageJson), resolved[0]);\n }\n // NOTE: resolve.imports would have thrown by this point.\n return path;\n }\n\n if (pkg.name === moduleName) {\n const resolved = resolve.exports(\n pkg,\n (segments.join('/') || '.') as resolve.Exports.Entry,\n createResolveOptions(options.conditions)\n );\n\n if (resolved) {\n return pathResolve(dirname(closestPackageJson), resolved[0]);\n }\n\n if (pkg.exports) {\n throw new Error(\n \"`exports` exists, but no results - this is a bug in Expo CLI's Metro resolver. Please report an issue\"\n );\n }\n }\n }\n\n let packageJsonPath = '';\n\n try {\n packageJsonPath = resolveSync(`${moduleName}/package.json`, options);\n } catch {\n // ignore if package.json cannot be found\n }\n\n if (!packageJsonPath) {\n return path;\n }\n\n const pkg = options.readPackageSync!(options.readFileSync!, packageJsonPath);\n assert(pkg, 'package.json should be read by `readPackageSync`');\n\n const resolved = resolve.exports(\n pkg,\n (segments.join('/') || '.') as resolve.Exports.Entry,\n createResolveOptions(options.conditions)\n );\n\n if (resolved) {\n return pathResolve(dirname(packageJsonPath), resolved[0]);\n }\n\n if (pkg.exports) {\n throw new Error(\n \"`exports` exists, but no results - this is a bug in Expo CLI's Metro resolver. Please report an issue\"\n );\n }\n\n return path;\n}\n\nfunction createResolveOptions(conditions: string[] | undefined): resolve.Options {\n return conditions\n ? { conditions, unsafe: true }\n : // no conditions were passed - let's assume this is Jest internal and it should be `require`\n { browser: false, require: true };\n}\n\n// if it's a relative import or an absolute path, imports/exports are ignored\nconst shouldIgnoreRequestForExports = (path: string) => path.startsWith('.') || isAbsolute(path);\n\n// adapted from\n// https://github.com/lukeed/escalade/blob/2477005062cdbd8407afc90d3f48f4930354252b/src/sync.js\nfunction findClosestPackageJson(\n start: string,\n options: UpstreamResolveOptionsWithConditions\n): string | undefined {\n let dir = pathResolve('.', start);\n if (!options.isDirectory!(dir)) {\n dir = dirname(dir);\n }\n\n while (true) {\n const pkgJsonFile = pathResolve(dir, './package.json');\n const hasPackageJson = options.pathExists!(pkgJsonFile);\n\n if (hasPackageJson) {\n return pkgJsonFile;\n }\n\n const prevDir = dir;\n dir = dirname(dir);\n\n if (prevDir === dir) {\n return undefined;\n }\n }\n}\n"],"names":["defaultResolver","path","enablePackageExports","blockList","options","resolveOptions","preserveSymlinks","result","resolveSync","getPathInModule","shouldIgnoreRequestForExports","segments","split","moduleName","shift","startsWith","closestPackageJson","findClosestPackageJson","basedir","pkg","readPackageSync","readFileSync","assert","resolved","resolve","imports","createResolveOptions","conditions","pathResolve","dirname","name","exports","join","Error","packageJsonPath","unsafe","browser","require","isAbsolute","start","dir","isDirectory","pkgJsonFile","hasPackageJson","pathExists","prevDir","undefined"],"mappings":"AAAA;;;;;;;;;CASC,GACD;;;;+BA2GA,SAA+B;;aAA/B,QAA+B;;;8DA1GZ,QAAQ;;;;;;;yBACiC,MAAM;;;;;;;yBACM,SAAS;;;;;;;+DACxD,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0E1C,MAAMA,eAAe,GAAG,CACtBC,IAAY,EACZ,EACEC,oBAAoB,CAAA,EACpBC,SAAS,EAAG,EAAE,CAAA,EACd,GAAGC,OAAO,EAKX,GACU;IACX,mBAAmB;IACnB,MAAMC,cAAc,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IoC,GAAG,GAAGZ,IAAAA,KAAW,EAAA,QAAA,EAAC,GAAG,EAAEW,KAAK,CAAC,AAAC;IAClC,IAAI,CAACnC,OAAO,CAACqC,WAAW,CAAED,GAAG,CAAC,EAAE;QAC9BA,GAAG,GAAGX,IAAAA,KAAO,EAAA,QAAA,EAACW,GAAG,CAAC,CAAC;IACrB,CAAC;IAED,MAAO,IAAI,CAAE;QACX,MAAME,WAAW,GAAGd,IAAAA,KAAW,EAAA,QAAA,EAACY,GAAG,EAAE,gBAAgB,CAAC,AAAC;QACvD,MAAMG,cAAc,GAAGvC,OAAO,CAACwC,UAAU,CAAEF,WAAW,CAAC,AAAC;QAExD,IAAIC,cAAc,EAAE;YAClB,OAAOD,WAAW,CAAC;QACrB,CAAC;QAED,MAAMG,OAAO,GAAGL,GAAG,AAAC;QACpBA,GAAG,GAAGX,IAAAA,KAAO,EAAA,QAAA,EAACW,GAAG,CAAC,CAAC;QAEnB,IAAIK,OAAO,KAAKL,GAAG,EAAE;YACnB,OAAOM,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;AACH,CAAC"}
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/createJResolver.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Fork of the jest resolver but with additional settings for Metro and pnp removed.\n * https://github.com/jestjs/jest/blob/d1a2ed7fea4bdc19836274cd810c8360e3ab62f3/packages/jest-resolve/src/defaultResolver.ts#L1\n */\nimport type { JSONObject as PackageJSON } from '@expo/json-file';\nimport assert from 'assert';\nimport { dirname, isAbsolute, resolve as pathResolve } from 'path';\nimport { sync as resolveSync, SyncOpts as UpstreamResolveOptions } from 'resolve';\nimport * as resolve from 'resolve.exports';\n\n/**\n * Allows transforming parsed `package.json` contents.\n *\n * @param pkg - Parsed `package.json` contents.\n * @param file - Path to `package.json` file.\n * @param dir - Directory that contains the `package.json`.\n *\n * @returns Transformed `package.json` contents.\n */\ntype PackageFilter = (pkg: PackageJSON, file: string, dir: string) => PackageJSON;\n\n/**\n * Allows transforming a path within a package.\n *\n * @param pkg - Parsed `package.json` contents.\n * @param path - Path being resolved.\n * @param relativePath - Path relative from the `package.json` location.\n *\n * @returns Relative path that will be joined from the `package.json` location.\n */\ntype PathFilter = (pkg: PackageJSON, path: string, relativePath: string) => string;\n\ntype ResolverOptions = {\n /** Directory to begin resolving from. */\n basedir: string;\n /** List of export conditions. */\n conditions?: string[];\n /** Instance of default resolver. */\n defaultResolver: typeof defaultResolver;\n /** List of file extensions to search in order. */\n extensions?: string[];\n /**\n * List of directory names to be looked up for modules recursively.\n *\n * @defaultValue\n * The default is `['node_modules']`.\n */\n moduleDirectory?: string[];\n /**\n * List of `require.paths` to use if nothing is found in `node_modules`.\n *\n * @defaultValue\n * The default is `undefined`.\n */\n paths?: string[];\n /** Allows transforming parsed `package.json` contents. */\n packageFilter?: PackageFilter;\n /** Allows transforms a path within a package. */\n pathFilter?: PathFilter;\n /** Current root directory. */\n rootDir?: string;\n\n enablePackageExports?: boolean;\n\n blockList: RegExp[];\n\n getPackageForModule: import('metro-resolver').CustomResolutionContext['getPackageForModule'];\n} & Pick<\n UpstreamResolveOptions,\n | 'readPackageSync'\n | 'realpathSync'\n | 'moduleDirectory'\n | 'extensions'\n | 'preserveSymlinks'\n | 'includeCoreModules'\n>;\n\ntype UpstreamResolveOptionsWithConditions = UpstreamResolveOptions &\n ResolverOptions & {\n pathExists: (file: string) => boolean;\n };\n\nconst defaultResolver = (\n path: string,\n {\n enablePackageExports,\n blockList = [],\n ...options\n }: Omit<ResolverOptions, 'defaultResolver' | 'getPackageForModule'> & {\n isDirectory: (file: string) => boolean;\n isFile: (file: string) => boolean;\n pathExists: (file: string) => boolean;\n }\n): string => {\n // @ts-expect-error\n const resolveOptions: UpstreamResolveOptionsWithConditions = {\n ...options,\n preserveSymlinks: options.preserveSymlinks,\n defaultResolver,\n };\n\n // resolveSync dereferences symlinks to ensure we don't create a separate\n // module instance depending on how it was referenced.\n const result = resolveSync(enablePackageExports ? getPathInModule(path, resolveOptions) : path, {\n ...resolveOptions,\n preserveSymlinks: !options.preserveSymlinks,\n });\n\n return result;\n};\n\nexport default defaultResolver;\n\n/*\n * helper functions\n */\n\nfunction getPathInModule(path: string, options: UpstreamResolveOptionsWithConditions): string {\n if (shouldIgnoreRequestForExports(path)) {\n return path;\n }\n\n const segments = path.split('/');\n\n let moduleName = segments.shift();\n\n if (!moduleName) {\n return path;\n }\n\n if (moduleName.startsWith('@')) {\n moduleName = `${moduleName}/${segments.shift()}`;\n }\n\n // self-reference\n const closestPackageJson = findClosestPackageJson(options.basedir, options);\n if (closestPackageJson) {\n const pkg = options.readPackageSync!(options.readFileSync!, closestPackageJson);\n assert(pkg, 'package.json should be read by `readPackageSync`');\n\n // Added support for the package.json \"imports\" field (#-prefixed paths)\n if (path.startsWith('#')) {\n const resolved = resolve.imports(pkg, path, createResolveOptions(options.conditions));\n if (resolved) {\n // TODO: Should we attempt to resolve every path in the array?\n return pathResolve(dirname(closestPackageJson), resolved[0]);\n }\n // NOTE: resolve.imports would have thrown by this point.\n return path;\n }\n\n if (pkg.name === moduleName) {\n const resolved = resolve.exports(\n pkg,\n (segments.join('/') || '.') as resolve.Exports.Entry,\n createResolveOptions(options.conditions)\n );\n\n if (resolved) {\n return pathResolve(dirname(closestPackageJson), resolved[0]);\n }\n\n if (pkg.exports) {\n throw new Error(\n \"`exports` exists, but no results - this is a bug in Expo CLI's Metro resolver. Please report an issue\"\n );\n }\n }\n }\n\n let packageJsonPath = '';\n\n try {\n packageJsonPath = resolveSync(`${moduleName}/package.json`, options);\n } catch {\n // ignore if package.json cannot be found\n }\n\n if (!packageJsonPath) {\n return path;\n }\n\n const pkg = options.readPackageSync!(options.readFileSync!, packageJsonPath);\n assert(pkg, 'package.json should be read by `readPackageSync`');\n\n const resolved = resolve.exports(\n pkg,\n (segments.join('/') || '.') as resolve.Exports.Entry,\n createResolveOptions(options.conditions)\n );\n\n if (resolved) {\n return pathResolve(dirname(packageJsonPath), resolved[0]);\n }\n\n if (pkg.exports) {\n throw new Error(\n \"`exports` exists, but no results - this is a bug in Expo CLI's Metro resolver. Please report an issue\"\n );\n }\n\n return path;\n}\n\nfunction createResolveOptions(conditions: string[] | undefined): resolve.Options {\n return conditions\n ? { conditions, unsafe: true }\n : // no conditions were passed - let's assume this is Jest internal and it should be `require`\n { browser: false, require: true };\n}\n\n// if it's a relative import or an absolute path, imports/exports are ignored\nconst shouldIgnoreRequestForExports = (path: string) => path.startsWith('.') || isAbsolute(path);\n\n// adapted from\n// https://github.com/lukeed/escalade/blob/2477005062cdbd8407afc90d3f48f4930354252b/src/sync.js\nfunction findClosestPackageJson(\n start: string,\n options: UpstreamResolveOptionsWithConditions\n): string | undefined {\n let dir = pathResolve('.', start);\n if (!options.isDirectory!(dir)) {\n dir = dirname(dir);\n }\n\n while (true) {\n const pkgJsonFile = pathResolve(dir, './package.json');\n const hasPackageJson = options.pathExists!(pkgJsonFile);\n\n if (hasPackageJson) {\n return pkgJsonFile;\n }\n\n const prevDir = dir;\n dir = dirname(dir);\n\n if (prevDir === dir) {\n return undefined;\n }\n }\n}\n"],"names":["defaultResolver","path","enablePackageExports","blockList","options","resolveOptions","preserveSymlinks","result","resolveSync","getPathInModule","shouldIgnoreRequestForExports","segments","split","moduleName","shift","startsWith","closestPackageJson","findClosestPackageJson","basedir","pkg","readPackageSync","readFileSync","assert","resolved","resolve","imports","createResolveOptions","conditions","pathResolve","dirname","name","exports","join","Error","packageJsonPath","unsafe","browser","require","isAbsolute","start","dir","isDirectory","pkgJsonFile","hasPackageJson","pathExists","prevDir","undefined"],"mappings":"AAAA;;;;;;;;;CASC,GACD;;;;+BA2GA,SAA+B;;aAA/B,QAA+B;;;8DA1GZ,QAAQ;;;;;;;yBACiC,MAAM;;;;;;;yBACM,SAAS;;;;;;;+DACxD,iBAAiB;;;;;;;;;;;;;;;;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I,CAAC,AAAC;AAEjG,eAAe;AACf,+FAA+F;AAC/F,SAASgB,sBAAsB,CAC7BsB,KAAa,EACbnC,OAA6C,EACzB;IACpB,IAAIoC,GAAG,GAAGZ,IAAAA,KAAW,EAAA,QAAA,EAAC,GAAG,EAAEW,KAAK,CAAC,AAAC;IAClC,IAAI,CAACnC,OAAO,CAACqC,WAAW,CAAED,GAAG,CAAC,EAAE;QAC9BA,GAAG,GAAGX,IAAAA,KAAO,EAAA,QAAA,EAACW,GAAG,CAAC,CAAC;IACrB,CAAC;IAED,MAAO,IAAI,CAAE;QACX,MAAME,WAAW,GAAGd,IAAAA,KAAW,EAAA,QAAA,EAACY,GAAG,EAAE,gBAAgB,CAAC,AAAC;QACvD,MAAMG,cAAc,GAAGvC,OAAO,CAACwC,UAAU,CAAEF,WAAW,CAAC,AAAC;QAExD,IAAIC,cAAc,EAAE;YAClB,OAAOD,WAAW,CAAC;QACrB,CAAC;QAED,MAAMG,OAAO,GAAGL,GAAG,AAAC;QACpBA,GAAG,GAAGX,IAAAA,KAAO,EAAA,QAAA,EAACW,GAAG,CAAC,CAAC;QAEnB,IAAIK,OAAO,KAAKL,GAAG,EAAE;YACnB,OAAOM,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -16,9 +16,6 @@ const _messageHandler = require("../MessageHandler");
16
16
  const NETWORK_RESPONSE_STORAGE = new Map();
17
17
  class NetworkResponseHandler extends _messageHandler.MessageHandler {
18
18
  /** All known responses, mapped by request id */ storage = NETWORK_RESPONSE_STORAGE;
19
- isEnabled() {
20
- return this.page.capabilities.nativeNetworkInspection !== true;
21
- }
22
19
  handleDeviceMessage(message) {
23
20
  if (message.method === "Expo(Network.receivedResponseBody)") {
24
21
  const { requestId , ...requestInfo } = message.params;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../src/start/server/metro/debugging/messageHandlers/NetworkResponse.ts"],"sourcesContent":["import type { Protocol } from 'devtools-protocol';\n\nimport { MessageHandler } from '../MessageHandler';\nimport type {\n CdpMessage,\n DeviceRequest,\n DebuggerRequest,\n DebuggerResponse,\n DeviceResponse,\n} from '../types';\n\n/**\n * The global network response storage, as a workaround for the network inspector.\n * @see createDebugMiddleware#createNetworkWebsocket\n */\nexport const NETWORK_RESPONSE_STORAGE = new Map<\n string,\n DebuggerResponse<NetworkGetResponseBody>['result']\n>();\n\nexport class NetworkResponseHandler extends MessageHandler {\n /** All known responses, mapped by request id */\n storage = NETWORK_RESPONSE_STORAGE;\n\n isEnabled() {\n return this.page.capabilities.nativeNetworkInspection !== true;\n }\n\n handleDeviceMessage(message: DeviceRequest<NetworkReceivedResponseBody>) {\n if (message.method === 'Expo(Network.receivedResponseBody)') {\n const { requestId, ...requestInfo } = message.params;\n this.storage.set(requestId, requestInfo);\n return true;\n }\n\n return false;\n }\n\n handleDebuggerMessage(message: DebuggerRequest<NetworkGetResponseBody>) {\n if (\n message.method === 'Network.getResponseBody' &&\n this.storage.has(message.params.requestId)\n ) {\n return this.sendToDebugger<DeviceResponse<NetworkGetResponseBody>>({\n id: message.id,\n result: this.storage.get(message.params.requestId)!,\n });\n }\n\n return false;\n }\n}\n\n/** Custom message to transfer the response body data to the proxy */\nexport type NetworkReceivedResponseBody = CdpMessage<\n 'Expo(Network.receivedResponseBody)',\n Protocol.Network.GetResponseBodyRequest & Protocol.Network.GetResponseBodyResponse,\n never\n>;\n\n/** @see https://chromedevtools.github.io/devtools-protocol/1-2/Network/#method-getResponseBody */\nexport type NetworkGetResponseBody = CdpMessage<\n 'Network.getResponseBody',\n Protocol.Network.GetResponseBodyRequest,\n Protocol.Network.GetResponseBodyResponse\n>;\n"],"names":["NETWORK_RESPONSE_STORAGE","NetworkResponseHandler","Map","MessageHandler","storage","isEnabled","page","capabilities","nativeNetworkInspection","handleDeviceMessage","message","method","requestId","requestInfo","params","set","handleDebuggerMessage","has","sendToDebugger","id","result","get"],"mappings":"AAAA;;;;;;;;;;;IAeaA,wBAAwB,MAAxBA,wBAAwB;IAKxBC,sBAAsB,MAAtBA,sBAAsB;;gCAlBJ,mBAAmB;AAa3C,MAAMD,wBAAwB,GAAG,IAAIE,GAAG,EAG5C,AAAC;AAEG,MAAMD,sBAAsB,SAASE,eAAc,eAAA;IACxD,8CAA8C,GAC9CC,OAAO,GAAGJ,wBAAwB,CAAC;IAEnCK,SAAS,GAAG;QACV,OAAO,IAAI,CAACC,IAAI,CAACC,YAAY,CAACC,uBAAuB,KAAK,IAAI,CAAC;IACjE;IAEAC,mBAAmB,CAACC,OAAmD,EAAE;QACvE,IAAIA,OAAO,CAACC,MAAM,KAAK,oCAAoC,EAAE;YAC3D,MAAM,EAAEC,SAAS,CAAA,EAAE,GAAGC,WAAW,EAAE,GAAGH,OAAO,CAACI,MAAM,AAAC;YACrD,IAAI,CAACV,OAAO,CAACW,GAAG,CAACH,SAAS,EAAEC,WAAW,CAAC,CAAC;YACzC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,KAAK,CAAC;IACf;IAEAG,qBAAqB,CAACN,OAAgD,EAAE;QACtE,IACEA,OAAO,CAACC,MAAM,KAAK,yBAAyB,IAC5C,IAAI,CAACP,OAAO,CAACa,GAAG,CAACP,OAAO,CAACI,MAAM,CAACF,SAAS,CAAC,EAC1C;YACA,OAAO,IAAI,CAACM,cAAc,CAAyC;gBACjEC,EAAE,EAAET,OAAO,CAACS,EAAE;gBACdC,MAAM,EAAE,IAAI,CAAChB,OAAO,CAACiB,GAAG,CAACX,OAAO,CAACI,MAAM,CAACF,SAAS,CAAC;aACnD,CAAC,CAAC;QACL,CAAC;QAED,OAAO,KAAK,CAAC;IACf;CACD"}
1
+ {"version":3,"sources":["../../../../../../../src/start/server/metro/debugging/messageHandlers/NetworkResponse.ts"],"sourcesContent":["import type { Protocol } from 'devtools-protocol';\n\nimport { MessageHandler } from '../MessageHandler';\nimport type {\n CdpMessage,\n DeviceRequest,\n DebuggerRequest,\n DebuggerResponse,\n DeviceResponse,\n} from '../types';\n\n/**\n * The global network response storage, as a workaround for the network inspector.\n * @see createDebugMiddleware#createNetworkWebsocket\n */\nexport const NETWORK_RESPONSE_STORAGE = new Map<\n string,\n DebuggerResponse<NetworkGetResponseBody>['result']\n>();\n\nexport class NetworkResponseHandler extends MessageHandler {\n /** All known responses, mapped by request id */\n storage = NETWORK_RESPONSE_STORAGE;\n\n handleDeviceMessage(message: DeviceRequest<NetworkReceivedResponseBody>) {\n if (message.method === 'Expo(Network.receivedResponseBody)') {\n const { requestId, ...requestInfo } = message.params;\n this.storage.set(requestId, requestInfo);\n return true;\n }\n\n return false;\n }\n\n handleDebuggerMessage(message: DebuggerRequest<NetworkGetResponseBody>) {\n if (\n message.method === 'Network.getResponseBody' &&\n this.storage.has(message.params.requestId)\n ) {\n return this.sendToDebugger<DeviceResponse<NetworkGetResponseBody>>({\n id: message.id,\n result: this.storage.get(message.params.requestId)!,\n });\n }\n\n return false;\n }\n}\n\n/** Custom message to transfer the response body data to the proxy */\nexport type NetworkReceivedResponseBody = CdpMessage<\n 'Expo(Network.receivedResponseBody)',\n Protocol.Network.GetResponseBodyRequest & Protocol.Network.GetResponseBodyResponse,\n never\n>;\n\n/** @see https://chromedevtools.github.io/devtools-protocol/1-2/Network/#method-getResponseBody */\nexport type NetworkGetResponseBody = CdpMessage<\n 'Network.getResponseBody',\n Protocol.Network.GetResponseBodyRequest,\n Protocol.Network.GetResponseBodyResponse\n>;\n"],"names":["NETWORK_RESPONSE_STORAGE","NetworkResponseHandler","Map","MessageHandler","storage","handleDeviceMessage","message","method","requestId","requestInfo","params","set","handleDebuggerMessage","has","sendToDebugger","id","result","get"],"mappings":"AAAA;;;;;;;;;;;IAeaA,wBAAwB,MAAxBA,wBAAwB;IAKxBC,sBAAsB,MAAtBA,sBAAsB;;gCAlBJ,mBAAmB;AAa3C,MAAMD,wBAAwB,GAAG,IAAIE,GAAG,EAG5C,AAAC;AAEG,MAAMD,sBAAsB,SAASE,eAAc,eAAA;IACxD,8CAA8C,GAC9CC,OAAO,GAAGJ,wBAAwB,CAAC;IAEnCK,mBAAmB,CAACC,OAAmD,EAAE;QACvE,IAAIA,OAAO,CAACC,MAAM,KAAK,oCAAoC,EAAE;YAC3D,MAAM,EAAEC,SAAS,CAAA,EAAE,GAAGC,WAAW,EAAE,GAAGH,OAAO,CAACI,MAAM,AAAC;YACrD,IAAI,CAACN,OAAO,CAACO,GAAG,CAACH,SAAS,EAAEC,WAAW,CAAC,CAAC;YACzC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,KAAK,CAAC;IACf;IAEAG,qBAAqB,CAACN,OAAgD,EAAE;QACtE,IACEA,OAAO,CAACC,MAAM,KAAK,yBAAyB,IAC5C,IAAI,CAACH,OAAO,CAACS,GAAG,CAACP,OAAO,CAACI,MAAM,CAACF,SAAS,CAAC,EAC1C;YACA,OAAO,IAAI,CAACM,cAAc,CAAyC;gBACjEC,EAAE,EAAET,OAAO,CAACS,EAAE;gBACdC,MAAM,EAAE,IAAI,CAACZ,OAAO,CAACa,GAAG,CAACX,OAAO,CAACI,MAAM,CAACF,SAAS,CAAC;aACnD,CAAC,CAAC;QACL,CAAC;QAED,OAAO,KAAK,CAAC;IACf;CACD"}
@@ -19,9 +19,9 @@ function _crypto() {
19
19
  };
20
20
  return data;
21
21
  }
22
- function _js() {
23
- const data = require("metro/src/DeltaBundler/Serializers/helpers/js");
24
- _js = function() {
22
+ function _jsJs() {
23
+ const data = require("metro/src/DeltaBundler/Serializers/helpers/js.js");
24
+ _jsJs = function() {
25
25
  return data;
26
26
  };
27
27
  return data;
@@ -74,7 +74,7 @@ function hashString(str) {
74
74
  function getCssModules(dependencies, { processModuleFilter , projectRoot }) {
75
75
  const promises = [];
76
76
  for (const module of dependencies.values()){
77
- if ((0, _js().isJsModule)(module) && processModuleFilter(module) && (0, _js().getJsOutput)(module).type === "js/module" && _path().default.relative(projectRoot, module.path) !== "package.json") {
77
+ if ((0, _jsJs().isJsModule)(module) && processModuleFilter(module) && (0, _jsJs().getJsOutput)(module).type === "js/module" && _path().default.relative(projectRoot, module.path) !== "package.json") {
78
78
  const cssMetadata = getCssMetadata(module);
79
79
  if (cssMetadata) {
80
80
  const contents = cssMetadata.code;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/getCssModulesFromBundler.ts"],"sourcesContent":["import { MetroConfig } from '@expo/metro-config';\nimport crypto from 'crypto';\nimport type { Module } from 'metro';\nimport { getJsOutput, isJsModule } from 'metro/src/DeltaBundler/Serializers/helpers/js';\nimport type { ReadOnlyDependencies } from 'metro/src/DeltaBundler/types';\nimport type IncrementalBundler from 'metro/src/IncrementalBundler';\nimport splitBundleOptions from 'metro/src/lib/splitBundleOptions';\nimport path from 'path';\n\ntype Options = {\n processModuleFilter: (modules: Module) => boolean;\n assetPlugins: readonly string[];\n platform?: string | null;\n projectRoot: string;\n publicPath: string;\n};\n\ntype MetroModuleCSSMetadata = {\n code: string;\n lineCount: number;\n map: any[];\n};\n\nexport type CSSAsset = {\n // 'styles.css'\n originFilename: string;\n // '_expo/static/css/bc6aa0a69dcebf8e8cac1faa76705756.css'\n filename: string;\n // '\\ndiv {\\n background: cyan;\\n}\\n\\n'\n source: string;\n};\n\n// s = static\nconst STATIC_EXPORT_DIRECTORY = '_expo/static/css';\n\n/** @returns the static CSS assets used in a given bundle. CSS assets are only enabled if the `@expo/metro-config` `transformerPath` is used. */\nexport async function getCssModulesFromBundler(\n config: MetroConfig,\n incrementalBundler: IncrementalBundler,\n options: any\n): Promise<CSSAsset[]> {\n // Static CSS is a web-only feature.\n if (options.platform !== 'web') {\n return [];\n }\n\n const { entryFile, onProgress, resolverOptions, transformOptions } = splitBundleOptions(options);\n\n const dependencies = await incrementalBundler.getDependencies(\n [entryFile],\n transformOptions,\n resolverOptions,\n { onProgress, shallow: false, lazy: false }\n );\n\n return getCssModules(dependencies, {\n processModuleFilter: config.serializer.processModuleFilter,\n assetPlugins: config.transformer.assetPlugins,\n platform: transformOptions.platform,\n projectRoot: config.server.unstable_serverRoot ?? config.projectRoot,\n publicPath: config.transformer.publicPath,\n });\n}\n\nfunction hashString(str: string) {\n return crypto.createHash('md5').update(str).digest('hex');\n}\n\nfunction getCssModules(\n dependencies: ReadOnlyDependencies,\n { processModuleFilter, projectRoot }: Options\n) {\n const promises = [];\n\n for (const module of dependencies.values()) {\n if (\n isJsModule(module) &&\n processModuleFilter(module) &&\n getJsOutput(module).type === 'js/module' &&\n path.relative(projectRoot, module.path) !== 'package.json'\n ) {\n const cssMetadata = getCssMetadata(module);\n if (cssMetadata) {\n const contents = cssMetadata.code;\n const filename = path.join(\n // Consistent location\n STATIC_EXPORT_DIRECTORY,\n // Hashed file contents + name for caching\n getFileName(module.path) + '-' + hashString(module.path + contents) + '.css'\n );\n promises.push({\n originFilename: path.relative(projectRoot, module.path),\n filename,\n source: contents,\n });\n }\n }\n }\n\n return promises;\n}\n\nfunction getCssMetadata(module: Module): MetroModuleCSSMetadata | null {\n const data = module.output[0]?.data;\n if (data && typeof data === 'object' && 'css' in data) {\n if (typeof data.css !== 'object' || !('code' in (data as any).css)) {\n throw new Error(\n `Unexpected CSS metadata in Metro module (${module.path}): ${JSON.stringify(data.css)}`\n );\n }\n return data.css as MetroModuleCSSMetadata;\n }\n return null;\n}\n\nexport function getFileName(module: string) {\n return path.basename(module).replace(/\\.[^.]+$/, '');\n}\n"],"names":["getCssModulesFromBundler","getFileName","STATIC_EXPORT_DIRECTORY","config","incrementalBundler","options","platform","entryFile","onProgress","resolverOptions","transformOptions","splitBundleOptions","dependencies","getDependencies","shallow","lazy","getCssModules","processModuleFilter","serializer","assetPlugins","transformer","projectRoot","server","unstable_serverRoot","publicPath","hashString","str","crypto","createHash","update","digest","promises","module","values","isJsModule","getJsOutput","type","path","relative","cssMetadata","getCssMetadata","contents","code","filename","join","push","originFilename","source","data","output","css","Error","JSON","stringify","basename","replace"],"mappings":"AAAA;;;;;;;;;;;IAoCsBA,wBAAwB,MAAxBA,wBAAwB;IA+E9BC,WAAW,MAAXA,WAAW;;;8DAlHR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KAAAA,CAAsB,GAAtBA,GAAgB,CAAEgB,IAAI,AAAC;IACpC,IAAIA,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,IAAI,KAAK,IAAIA,IAAI,EAAE;QACrD,IAAI,OAAOA,IAAI,CAACE,GAAG,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,IAAI,AAACF,IAAI,CAASE,GAAG,CAAC,EAAE;YAClE,MAAM,IAAIC,KAAK,CACb,CAAC,yCAAyC,EAAEnB,MAAM,CAACK,IAAI,CAAC,GAAG,EAAEe,IAAI,CAACC,SAAS,CAACL,IAAI,CAACE,GAAG,CAAC,CAAC,CAAC,CACxF,CAAC;QACJ,CAAC;QACD,OAAOF,IAAI,CAACE,GAAG,CAA2B;IAC5C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAEM,SAASjD,WAAW,CAAC+B,MAAc,EAAE;IAC1C,OAAOK,KAAI,EAAA,QAAA,CAACiB,QAAQ,CAACtB,MAAM,CAAC,CAACuB,OAAO,aAAa,EAAE,CAAC,CAAC;AACvD,CAAC"}
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/getCssModulesFromBundler.ts"],"sourcesContent":["import { MetroConfig } from '@expo/metro-config';\nimport crypto from 'crypto';\nimport type { Module } from 'metro';\nimport { getJsOutput, isJsModule } from 'metro/src/DeltaBundler/Serializers/helpers/js.js';\nimport type { ReadOnlyDependencies } from 'metro/src/DeltaBundler/types';\nimport type IncrementalBundler from 'metro/src/IncrementalBundler';\nimport splitBundleOptions from 'metro/src/lib/splitBundleOptions';\nimport path from 'path';\n\ntype Options = {\n processModuleFilter: (modules: Module) => boolean;\n assetPlugins: readonly string[];\n platform?: string | null;\n projectRoot: string;\n publicPath: string;\n};\n\ntype MetroModuleCSSMetadata = {\n code: string;\n lineCount: number;\n map: any[];\n};\n\nexport type CSSAsset = {\n // 'styles.css'\n originFilename: string;\n // '_expo/static/css/bc6aa0a69dcebf8e8cac1faa76705756.css'\n filename: string;\n // '\\ndiv {\\n background: cyan;\\n}\\n\\n'\n source: string;\n};\n\n// s = static\nconst STATIC_EXPORT_DIRECTORY = '_expo/static/css';\n\n/** @returns the static CSS assets used in a given bundle. CSS assets are only enabled if the `@expo/metro-config` `transformerPath` is used. */\nexport async function getCssModulesFromBundler(\n config: MetroConfig,\n incrementalBundler: IncrementalBundler,\n options: any\n): Promise<CSSAsset[]> {\n // Static CSS is a web-only feature.\n if (options.platform !== 'web') {\n return [];\n }\n\n const { entryFile, onProgress, resolverOptions, transformOptions } = splitBundleOptions(options);\n\n const dependencies = await incrementalBundler.getDependencies(\n [entryFile],\n transformOptions,\n resolverOptions,\n { onProgress, shallow: false, lazy: false }\n );\n\n return getCssModules(dependencies, {\n processModuleFilter: config.serializer.processModuleFilter,\n assetPlugins: config.transformer.assetPlugins,\n platform: transformOptions.platform,\n projectRoot: config.server.unstable_serverRoot ?? config.projectRoot,\n publicPath: config.transformer.publicPath,\n });\n}\n\nfunction hashString(str: string) {\n return crypto.createHash('md5').update(str).digest('hex');\n}\n\nfunction getCssModules(\n dependencies: ReadOnlyDependencies,\n { processModuleFilter, projectRoot }: Options\n) {\n const promises = [];\n\n for (const module of dependencies.values()) {\n if (\n isJsModule(module) &&\n processModuleFilter(module) &&\n getJsOutput(module).type === 'js/module' &&\n path.relative(projectRoot, module.path) !== 'package.json'\n ) {\n const cssMetadata = getCssMetadata(module);\n if (cssMetadata) {\n const contents = cssMetadata.code;\n const filename = path.join(\n // Consistent location\n STATIC_EXPORT_DIRECTORY,\n // Hashed file contents + name for caching\n getFileName(module.path) + '-' + hashString(module.path + contents) + '.css'\n );\n promises.push({\n originFilename: path.relative(projectRoot, module.path),\n filename,\n source: contents,\n });\n }\n }\n }\n\n return promises;\n}\n\nfunction getCssMetadata(module: Module): MetroModuleCSSMetadata | null {\n const data = module.output[0]?.data;\n if (data && typeof data === 'object' && 'css' in data) {\n if (typeof data.css !== 'object' || !('code' in (data as any).css)) {\n throw new Error(\n `Unexpected CSS metadata in Metro module (${module.path}): ${JSON.stringify(data.css)}`\n );\n }\n return data.css as MetroModuleCSSMetadata;\n }\n return null;\n}\n\nexport function getFileName(module: string) {\n return path.basename(module).replace(/\\.[^.]+$/, '');\n}\n"],"names":["getCssModulesFromBundler","getFileName","STATIC_EXPORT_DIRECTORY","config","incrementalBundler","options","platform","entryFile","onProgress","resolverOptions","transformOptions","splitBundleOptions","dependencies","getDependencies","shallow","lazy","getCssModules","processModuleFilter","serializer","assetPlugins","transformer","projectRoot","server","unstable_serverRoot","publicPath","hashString","str","crypto","createHash","update","digest","promises","module","values","isJsModule","getJsOutput","type","path","relative","cssMetadata","getCssMetadata","contents","code","filename","join","push","originFilename","source","data","output","css","Error","JSON","stringify","basename","replace"],"mappings":"AAAA;;;;;;;;;;;IAoCsBA,wBAAwB,MAAxBA,wBAAwB;IA+E9BC,WAAW,MAAXA,WAAW;;;8DAlHR,QAAQ;;;;;;;yBAEa,kDAAkD;;;;;;;8DAG3D,kCAAkC;;;;;;;8DAChD,MAAM;;;;;;;;;;;AAyBvB,aAAa;AACb,MAAMC,uBAAuB,GAAG,kBAAkB,AAAC;AAG5C,eAAeF,wBAAwB,CAC5CG,MAAmB,EACnBC,kBAAsC,EACtCC,OAAY,EACS;IACrB,oCAAoC;IACpC,IAAIA,OAAO,CAACC,QAAQ,KAAK,KAAK,EAAE;QAC9B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,EAAEC,SAAS,CAAA,EAAEC,UAAU,CAAA,EAAEC,eAAe,CAAA,EAAEC,gBAAgB,CAAA,EAAE,GAAGC,IAAAA,mBAAkB,EAAA,QAAA,EAACN,OAAO,CAAC,AAAC;IAEjG,MAAMO,YAAY,GAAG,MAAMR,kBAAkB,CAACS,eAAe,CAC3D;QAACN,SAAS;KAAC,EACXG,gBAAgB,EAChBD,eAAe,EACf;QAAED,UAAU;QAAEM,OAAO,EAAE,KAAK;QAAEC,IAAI,EAAE,KAAK;KAAE,CAC5C,AAAC;IAEF,OAAOC,aAA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@ async function loadMetroConfigAsync(projectRoot, options, { exp , isExporting ,
176
176
  }
177
177
  if (serverActionsEnabled) {
178
178
  var ref9;
179
- _log.Log.warn(`Experimental React Server Functions are enabled. Production exports are not supported yet.`);
180
- if (!((ref9 = exp.experiments) == null ? void 0 : ref9.reactServerComponentRoutes)) {
181
- _log.Log.warn(`- React Server Component routes are NOT enabled. Routes will render in client mode.`);
182
- }
179
+ _log.Log.warn(`React Server Functions (beta) are enabled. Route rendering mode: ${((ref9 = exp.experiments) == null ? void 0 : ref9.reactServerComponentRoutes) ? "server" : "client"}`);
183
180
  }
184
181
  config = await (0, _withMetroMultiPlatform.withMetroMultiPlatformAsync)(projectRoot, {
185
182
  config,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/instantiateMetro.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport { getMetroServerRoot } from '@expo/config/paths';\nimport { getDefaultConfig, LoadOptions } from '@expo/metro-config';\nimport chalk from 'chalk';\nimport http from 'http';\nimport type Metro from 'metro';\nimport { ReadOnlyGraph } from 'metro';\nimport Bundler from 'metro/src/Bundler';\nimport type { TransformOptions } from 'metro/src/DeltaBundler/Worker';\nimport MetroHmrServer from 'metro/src/HmrServer';\nimport RevisionNotFoundError from 'metro/src/IncrementalBundler/RevisionNotFoundError';\nimport formatBundlingError from 'metro/src/lib/formatBundlingError';\nimport { loadConfig, resolveConfig, ConfigT } from 'metro-config';\nimport { Terminal } from 'metro-core';\nimport util from 'node:util';\nimport path from 'path';\n\nimport { createDevToolsPluginWebsocketEndpoint } from './DevToolsPluginWebsocketEndpoint';\nimport { MetroBundlerDevServer } from './MetroBundlerDevServer';\nimport { MetroTerminalReporter } from './MetroTerminalReporter';\nimport { attachAtlasAsync } from './debugging/attachAtlas';\nimport { createDebugMiddleware } from './debugging/createDebugMiddleware';\nimport { createMetroMiddleware } from './dev-server/createMetroMiddleware';\nimport { runServer } from './runServer-fork';\nimport { withMetroMultiPlatformAsync } from './withMetroMultiPlatform';\nimport { Log } from '../../../log';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { createCorsMiddleware } from '../middleware/CorsMiddleware';\nimport { createJsInspectorMiddleware } from '../middleware/inspector/createJsInspectorMiddleware';\nimport { prependMiddleware } from '../middleware/mutations';\nimport { getPlatformBundlers } from '../platformBundlers';\n\n// From expo/dev-server but with ability to use custom logger.\ntype MessageSocket = {\n broadcast: (method: string, params?: Record<string, any> | undefined) => void;\n};\n\n// Wrap terminal and polyfill console.log so we can log during bundling without breaking the indicator.\nclass LogRespectingTerminal extends Terminal {\n constructor(stream: import('node:net').Socket | import('node:stream').Writable) {\n super(stream);\n\n const sendLog = (...args: any[]) => {\n this._logLines.push(\n // format args like console.log\n util.format(...args)\n );\n this._scheduleUpdate();\n\n // Flush the logs to the terminal immediately so logs at the end of the process are not lost.\n this.flush();\n };\n\n console.log = sendLog;\n console.info = sendLog;\n }\n}\n\n// Share one instance of Terminal for all instances of Metro.\nconst terminal = new LogRespectingTerminal(process.stdout);\n\nexport async function loadMetroConfigAsync(\n projectRoot: string,\n options: LoadOptions,\n {\n exp,\n isExporting,\n getMetroBundler,\n }: { exp: ExpoConfig; isExporting: boolean; getMetroBundler: () => Bundler }\n) {\n let reportEvent: ((event: any) => void) | undefined;\n\n const serverActionsEnabled =\n exp.experiments?.reactServerFunctions ?? env.EXPO_UNSTABLE_SERVER_FUNCTIONS;\n\n if (serverActionsEnabled) {\n process.env.EXPO_UNSTABLE_SERVER_FUNCTIONS = '1';\n }\n\n // NOTE: Enable all the experimental Metro flags when RSC is enabled.\n if (exp.experiments?.reactServerComponentRoutes || serverActionsEnabled) {\n process.env.EXPO_USE_METRO_REQUIRE = '1';\n process.env.EXPO_USE_FAST_RESOLVER = '1';\n }\n\n const serverRoot = getMetroServerRoot(projectRoot);\n const terminalReporter = new MetroTerminalReporter(serverRoot, terminal);\n\n const hasConfig = await resolveConfig(options.config, projectRoot);\n let config: ConfigT = {\n ...(await loadConfig(\n { cwd: projectRoot, projectRoot, ...options },\n // If the project does not have a metro.config.js, then we use the default config.\n hasConfig.isEmpty ? getDefaultConfig(projectRoot) : undefined\n )),\n reporter: {\n update(event: any) {\n terminalReporter.update(event);\n if (reportEvent) {\n reportEvent(event);\n }\n },\n },\n };\n\n // @ts-expect-error: Set the global require cycle ignore patterns for SSR bundles. This won't work with custom global prefixes, but we don't use those.\n globalThis.__requireCycleIgnorePatterns = config.resolver?.requireCycleIgnorePatterns;\n\n if (isExporting) {\n // This token will be used in the asset plugin to ensure the path is correct for writing locally.\n // @ts-expect-error: typed as readonly.\n config.transformer.publicPath = `/assets?export_path=${\n (exp.experiments?.baseUrl ?? '') + '/assets'\n }`;\n } else {\n // @ts-expect-error: typed as readonly\n config.transformer.publicPath = '/assets/?unstable_path=.';\n }\n\n const platformBundlers = getPlatformBundlers(projectRoot, exp);\n\n if (exp.experiments?.reactCompiler) {\n Log.warn(`Experimental React Compiler is enabled.`);\n }\n\n if (env.EXPO_UNSTABLE_TREE_SHAKING && !env.EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH) {\n throw new CommandError(\n 'EXPO_UNSTABLE_TREE_SHAKING requires EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH to be enabled.'\n );\n }\n\n if (env.EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH) {\n Log.warn(`Experimental bundle optimization is enabled.`);\n }\n if (env.EXPO_UNSTABLE_TREE_SHAKING) {\n Log.warn(`Experimental tree shaking is enabled.`);\n }\n\n if (serverActionsEnabled) {\n Log.warn(\n `Experimental React Server Functions are enabled. Production exports are not supported yet.`\n );\n if (!exp.experiments?.reactServerComponentRoutes) {\n Log.warn(\n `- React Server Component routes are NOT enabled. Routes will render in client mode.`\n );\n }\n }\n\n config = await withMetroMultiPlatformAsync(projectRoot, {\n config,\n exp,\n platformBundlers,\n isTsconfigPathsEnabled: exp.experiments?.tsconfigPaths ?? true,\n isFastResolverEnabled: env.EXPO_USE_FAST_RESOLVER,\n isExporting,\n isReactCanaryEnabled:\n (exp.experiments?.reactServerComponentRoutes ||\n serverActionsEnabled ||\n exp.experiments?.reactCanary) ??\n false,\n isNamedRequiresEnabled: env.EXPO_USE_METRO_REQUIRE,\n isReactServerComponentsEnabled: !!exp.experiments?.reactServerComponentRoutes,\n getMetroBundler,\n });\n\n return {\n config,\n setEventReporter: (logger: (event: any) => void) => (reportEvent = logger),\n reporter: terminalReporter,\n };\n}\n\n/** The most generic possible setup for Metro bundler. */\nexport async function instantiateMetroAsync(\n metroBundler: MetroBundlerDevServer,\n options: Omit<LoadOptions, 'logger'>,\n {\n isExporting,\n exp = getConfig(metroBundler.projectRoot, {\n skipSDKVersionRequirement: true,\n }).exp,\n }: { isExporting: boolean; exp?: ExpoConfig }\n): Promise<{\n metro: Metro.Server;\n hmrServer: MetroHmrServer | null;\n server: http.Server;\n middleware: any;\n messageSocket: MessageSocket;\n}> {\n const projectRoot = metroBundler.projectRoot;\n\n const { config: metroConfig, setEventReporter } = await loadMetroConfigAsync(\n projectRoot,\n options,\n {\n exp,\n isExporting,\n getMetroBundler() {\n return metro.getBundler().getBundler();\n },\n }\n );\n\n // Create the core middleware stack for Metro, including websocket listeners\n const { middleware, messagesSocket, eventsSocket, websocketEndpoints } =\n createMetroMiddleware(metroConfig);\n\n if (!isExporting) {\n // Enable correct CORS headers for Expo Router features\n prependMiddleware(middleware, createCorsMiddleware(exp));\n\n // Enable debug middleware for CDP-related debugging\n const { debugMiddleware, debugWebsocketEndpoints } = createDebugMiddleware(metroBundler);\n Object.assign(websocketEndpoints, debugWebsocketEndpoints);\n middleware.use(debugMiddleware);\n middleware.use('/_expo/debugger', createJsInspectorMiddleware());\n\n // TODO(cedric): `enhanceMiddleware` is deprecated, but is currently used to unify the middleware stacks\n // See: https://github.com/facebook/metro/commit/22e85fde85ec454792a1b70eba4253747a2587a9\n // See: https://github.com/facebook/metro/commit/d0d554381f119bb80ab09dbd6a1d310b54737e52\n const customEnhanceMiddleware = metroConfig.server.enhanceMiddleware;\n // @ts-expect-error: can't mutate readonly config\n metroConfig.server.enhanceMiddleware = (metroMiddleware: any, server: Metro.Server) => {\n if (customEnhanceMiddleware) {\n metroMiddleware = customEnhanceMiddleware(metroMiddleware, server);\n }\n return middleware.use(metroMiddleware);\n };\n }\n\n // Attach Expo Atlas if enabled\n await attachAtlasAsync({\n isExporting,\n exp,\n projectRoot,\n middleware,\n metroConfig,\n // NOTE(cedric): reset the Atlas file once, and reuse it for static exports\n resetAtlasFile: isExporting,\n });\n\n const { server, hmrServer, metro } = await runServer(\n metroBundler,\n metroConfig,\n {\n websocketEndpoints: {\n ...websocketEndpoints,\n ...createDevToolsPluginWebsocketEndpoint(),\n },\n watch: !isExporting && isWatchEnabled(),\n },\n {\n mockServer: isExporting,\n }\n );\n\n // Patch transform file to remove inconvenient customTransformOptions which are only used in single well-known files.\n const originalTransformFile = metro\n .getBundler()\n .getBundler()\n .transformFile.bind(metro.getBundler().getBundler());\n\n metro.getBundler().getBundler().transformFile = async function (\n filePath: string,\n transformOptions: TransformOptions,\n fileBuffer?: Buffer\n ) {\n return originalTransformFile(\n filePath,\n pruneCustomTransformOptions(\n filePath,\n // Clone the options so we don't mutate the original.\n {\n ...transformOptions,\n customTransformOptions: {\n __proto__: null,\n ...transformOptions.customTransformOptions,\n },\n }\n ),\n fileBuffer\n );\n };\n\n setEventReporter(eventsSocket.reportMetroEvent);\n\n // This function ensures that modules in source maps are sorted in the same\n // order as in a plain JS bundle.\n metro._getSortedModules = function (this: Metro.Server, graph: ReadOnlyGraph) {\n const modules = [...graph.dependencies.values()];\n\n const ctx = {\n platform: graph.transformOptions.platform,\n environment: graph.transformOptions.customTransformOptions?.environment,\n };\n // Assign IDs to modules in a consistent order\n for (const module of modules) {\n // @ts-expect-error\n this._createModuleId(module.path, ctx);\n }\n // Sort by IDs\n return modules.sort(\n // @ts-expect-error\n (a, b) => this._createModuleId(a.path, ctx) - this._createModuleId(b.path, ctx)\n );\n };\n\n if (hmrServer) {\n let hmrJSBundle: typeof import('@expo/metro-config/build/serializer/fork/hmrJSBundle').default;\n\n try {\n hmrJSBundle = require('@expo/metro-config/build/serializer/fork/hmrJSBundle').default;\n } catch {\n // Add fallback for monorepo tests up until the fork is merged.\n Log.warn('Failed to load HMR serializer from @expo/metro-config, using fallback version.');\n hmrJSBundle = require('metro/src/DeltaBundler/Serializers/hmrJSBundle');\n }\n\n // Patch HMR Server to send more info to the `_createModuleId` function for deterministic module IDs and add support for serializing HMR updates the same as all other bundles.\n hmrServer._prepareMessage = async function (this: MetroHmrServer, group, options, changeEvent) {\n // Fork of https://github.com/facebook/metro/blob/3b3e0aaf725cfa6907bf2c8b5fbc0da352d29efe/packages/metro/src/HmrServer.js#L327-L393\n // with patch for `_createModuleId`.\n const logger = !options.isInitialUpdate ? changeEvent?.logger : null;\n try {\n const revPromise = this._bundler.getRevision(group.revisionId);\n if (!revPromise) {\n return {\n type: 'error',\n body: formatBundlingError(new RevisionNotFoundError(group.revisionId)),\n };\n }\n logger?.point('updateGraph_start');\n const { revision, delta } = await this._bundler.updateGraph(await revPromise, false);\n logger?.point('updateGraph_end');\n this._clientGroups.delete(group.revisionId);\n group.revisionId = revision.id;\n for (const client of group.clients) {\n client.revisionIds = client.revisionIds.filter(\n (revisionId) => revisionId !== group.revisionId\n );\n client.revisionIds.push(revision.id);\n }\n this._clientGroups.set(group.revisionId, group);\n logger?.point('serialize_start');\n // NOTE(EvanBacon): This is the patch\n const moduleIdContext = {\n platform: revision.graph.transformOptions.platform,\n environment: revision.graph.transformOptions.customTransformOptions?.environment,\n };\n const hmrUpdate = hmrJSBundle(delta, revision.graph, {\n clientUrl: group.clientUrl,\n // NOTE(EvanBacon): This is also the patch\n createModuleId: (moduleId: string) => {\n // @ts-expect-error\n return this._createModuleId(moduleId, moduleIdContext);\n },\n includeAsyncPaths: group.graphOptions.lazy,\n projectRoot: this._config.projectRoot,\n serverRoot: this._config.server.unstable_serverRoot ?? this._config.projectRoot,\n });\n logger?.point('serialize_end');\n return {\n type: 'update',\n body: {\n revisionId: revision.id,\n isInitialUpdate: options.isInitialUpdate,\n ...hmrUpdate,\n },\n };\n } catch (error: any) {\n const formattedError = formatBundlingError(error);\n this._config.reporter.update({\n type: 'bundling_error',\n error,\n });\n return {\n type: 'error',\n body: formattedError,\n };\n }\n };\n }\n\n return {\n metro,\n hmrServer,\n server,\n middleware,\n messageSocket: messagesSocket,\n };\n}\n\n// TODO: Fork the entire transform function so we can simply regex the file contents for keywords instead.\nfunction pruneCustomTransformOptions(\n filePath: string,\n transformOptions: TransformOptions\n): TransformOptions {\n // Normalize the filepath for cross platform checking.\n filePath = filePath.split(path.sep).join('/');\n\n if (\n transformOptions.customTransformOptions?.dom &&\n // The only generated file that needs the dom root is `expo/dom/entry.js`\n !filePath.match(/expo\\/dom\\/entry\\.js$/)\n ) {\n // Clear the dom root option if we aren't transforming the magic entry file, this ensures\n // that cached artifacts from other DOM component bundles can be reused.\n transformOptions.customTransformOptions.dom = 'true';\n }\n\n if (\n transformOptions.customTransformOptions?.routerRoot &&\n // The router root is used all over expo-router (`process.env.EXPO_ROUTER_ABS_APP_ROOT`, `process.env.EXPO_ROUTER_APP_ROOT`) so we'll just ignore the entire package.\n !(filePath.match(/\\/expo-router\\/_ctx/) || filePath.match(/\\/expo-router\\/build\\//))\n ) {\n // Set to the default value.\n transformOptions.customTransformOptions.routerRoot = 'app';\n }\n if (\n transformOptions.customTransformOptions?.asyncRoutes &&\n // The async routes settings are also used in `expo-router/_ctx.ios.js` (and other platform variants) via `process.env.EXPO_ROUTER_IMPORT_MODE`\n !(filePath.match(/\\/expo-router\\/_ctx/) || filePath.match(/\\/expo-router\\/build\\//))\n ) {\n delete transformOptions.customTransformOptions.asyncRoutes;\n }\n\n if (\n transformOptions.customTransformOptions?.clientBoundaries &&\n // The client boundaries are only used in `@expo/metro-runtime/src/virtual.js` for production RSC exports.\n !filePath.match(/\\/@expo\\/metro-runtime\\/rsc\\/virtual\\.js$/)\n ) {\n delete transformOptions.customTransformOptions.clientBoundaries;\n }\n\n return transformOptions;\n}\n\n/**\n * Simplify and communicate if Metro is running without watching file updates,.\n * Exposed for testing.\n */\nexport function isWatchEnabled() {\n if (env.CI) {\n Log.log(\n chalk`Metro is running in CI mode, reloads are disabled. Remove {bold CI=true} to enable watch mode.`\n );\n }\n\n return !env.CI;\n}\n"],"names":["loadMetroConfigAsync","instantiateMetroAsync","isWatchEnabled","LogRespectingTerminal","Terminal","constructor","stream","sendLog","args","_logLines","push","util","format","_scheduleUpdate","flush","console","log","info","terminal","process","stdout","projectRoot","options","exp","isExporting","getMetroBundler","config","reportEvent","serverActionsEnabled","experiments","reactServerFunctions","env","EXPO_UNSTABLE_SERVER_FUNCTIONS","reactServerComponentRoutes","EXPO_USE_METRO_REQUIRE","EXPO_USE_FAST_RESOLVER","serverRoot","getMetroServerRoot","terminalReporter","MetroTerminalReporter","hasConfig","resolveConfig","loadConfig","cwd","isEmpty","getDefaultConfig","undefined","reporter","update","event","globalThis","__requireCycleIgnorePatterns","resolver","requireCycleIgnorePatterns","transformer","publicPath","baseUrl","platformBundlers","getPlatformBundlers","reactCompiler","Log","warn","EXPO_UNSTABLE_TREE_SHAKING","EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH","CommandError","withMetroMultiPlatformAsync","isTsconfigPathsEnabled","tsconfigPaths","isFastResolverEnabled","isReactCanaryEnabled","reactCanary","isNamedRequiresEnabled","isReactServerComponentsEnabled","setEventReporter","logger","metroBundler","getConfig","skipSDKVersionRequirement","metroConfig","metro","getBundler","middleware","messagesSocket","eventsSocket","websocketEndpoints","createMetroMiddleware","prependMiddleware","createCorsMiddleware","debugMiddleware","debugWebsocketEndpoints","createDebugMiddleware","Object","assign","use","createJsInspectorMiddleware","customEnhanceMiddleware","server","enhanceMiddleware","metroMiddleware","attachAtlasAsync","resetAtlasFile","hmrServer","runServer","createDevToolsPluginWebsocketEndpoint","watch","mockServer","originalTransformFile","transformFile","bind","filePath","transformOptions","fileBuffer","pruneCustomTransformOptions","customTransformOptions","__proto__","reportMetroEvent","_getSortedModules","graph","modules","dependencies","values","ctx","platform","environment","module","_createModuleId","path","sort","a","b","hmrJSBundle","require","default","_prepareMessage","group","changeEvent","isInitialUpdate","revision","revPromise","_bundler","getRevision","revisionId","type","body","formatBundlingError","RevisionNotFoundError","point","delta","updateGraph","_clientGroups","delete","id","client","clients","revisionIds","filter","set","moduleIdContext","hmrUpdate","clientUrl","createModuleId","moduleId","includeAsyncPaths","graphOptions","lazy","_config","unstable_serverRoot","error","formattedError","messageSocket","split","sep","join","dom","match","routerRoot","asyncRoutes","clientBoundaries","CI","chalk"],"mappings":"AAAA;;;;;;;;;;;IA8DsBA,oBAAoB,MAApBA,oBAAoB;IAiHpBC,qBAAqB,MAArBA,qBAAqB;IA4Q3BC,cAAc,MAAdA,cAAc;;;yBA3bQ,cAAc;;;;;;;yBACjB,oBAAoB;;;;;;;yBACT,oBAAoB;;;;;;;8DAChD,OAAO;;;;;;;8DAOS,oDAAoD;;;;;;;8DACtD,mCAAmC;;;;;;;yBAChB,cAAc;;;;;;;yBACxC,YAAY;;;;;;;8DACpB,WAAW;;;;;;;8DACX,MAAM;;;;;;iDAE+B,mCAAmC;uCAEnD,yBAAyB;6BAC9B,yBAAyB;uCACpB,mCAAmC;uCACnC,oCAAoC;+BAChD,kBAAkB;wCACA,0BAA0B;qBAClD,cAAc;qBACd,oBAAoB;wBACX,uBAAuB;gCACf,8BAA8B;6CACvB,qDAAqD;2BAC/D,yBAAyB;kCACvB,qBAAqB;;;;;;AAOzD,uGAAuG;AACvG,MAAMC,qBAAqB,SAASC,UAAQ,EAAA,SAAA;IAC1CC,YAAYC,MAAkE,CAAE;QAC9E,KAAK,CAACA,MAAM,CAAC,CAAC;QAEd,MAAMC,OAAO,GAAG,CAAC,GAAGC,IAAI,AAAO,GAAK;YAClC,IAAI,CAACC,SAAS,CAACC,IAAI,CACjB,+BAA+B;YAC/BC,SAAI,EAAA,QAAA,CAACC,MAAM,I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AA4B;QAC5BhE,gBAAgB,CAACG,sBAAsB,CAAC8D,UAAU,GAAG,KAAK,CAAC;IAC7D,CAAC;IACD,IACEjE,CAAAA,CAAAA,IAAuC,GAAvCA,gBAAgB,CAACG,sBAAsB,SAAa,GAApDH,KAAAA,CAAoD,GAApDA,IAAuC,CAAEkE,WAAW,CAAA,IACpD,+IAA+I;IAC/I,CAAC,CAACnE,QAAQ,CAACiE,KAAK,uBAAuB,IAAIjE,QAAQ,CAACiE,KAAK,0BAA0B,CAAC,EACpF;QACA,OAAOhE,gBAAgB,CAACG,sBAAsB,CAAC+D,WAAW,CAAC;IAC7D,CAAC;IAED,IACElE,CAAAA,CAAAA,IAAuC,GAAvCA,gBAAgB,CAACG,sBAAsB,SAAkB,GAAzDH,KAAAA,CAAyD,GAAzDA,IAAuC,CAAEmE,gBAAgB,CAAA,IACzD,0GAA0G;IAC1G,CAACpE,QAAQ,CAACiE,KAAK,6CAA6C,EAC5D;QACA,OAAOhE,gBAAgB,CAACG,sBAAsB,CAACgE,gBAAgB,CAAC;IAClE,CAAC;IAED,OAAOnE,gBAAgB,CAAC;AAC1B,CAAC;AAMM,SAAS5G,cAAc,GAAG;IAC/B,IAAI6B,IAAG,IAAA,CAACmJ,EAAE,EAAE;QACVtH,IAAG,IAAA,CAAC5C,GAAG,CACLmK,IAAAA,MAAK,EAAA,QAAA,CAAA,CAAC,8FAA8F,CAAC,CACtG,CAAC;IACJ,CAAC;IAED,OAAO,CAACpJ,IAAG,IAAA,CAACmJ,EAAE,CAAC;AACjB,CAAC"}
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/instantiateMetro.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport { getMetroServerRoot } from '@expo/config/paths';\nimport { getDefaultConfig, LoadOptions } from '@expo/metro-config';\nimport chalk from 'chalk';\nimport http from 'http';\nimport type Metro from 'metro';\nimport { ReadOnlyGraph } from 'metro';\nimport Bundler from 'metro/src/Bundler';\nimport type { TransformOptions } from 'metro/src/DeltaBundler/Worker';\nimport MetroHmrServer from 'metro/src/HmrServer';\nimport RevisionNotFoundError from 'metro/src/IncrementalBundler/RevisionNotFoundError';\nimport formatBundlingError from 'metro/src/lib/formatBundlingError';\nimport { loadConfig, resolveConfig, ConfigT } from 'metro-config';\nimport { Terminal } from 'metro-core';\nimport util from 'node:util';\nimport path from 'path';\n\nimport { createDevToolsPluginWebsocketEndpoint } from './DevToolsPluginWebsocketEndpoint';\nimport { MetroBundlerDevServer } from './MetroBundlerDevServer';\nimport { MetroTerminalReporter } from './MetroTerminalReporter';\nimport { attachAtlasAsync } from './debugging/attachAtlas';\nimport { createDebugMiddleware } from './debugging/createDebugMiddleware';\nimport { createMetroMiddleware } from './dev-server/createMetroMiddleware';\nimport { runServer } from './runServer-fork';\nimport { withMetroMultiPlatformAsync } from './withMetroMultiPlatform';\nimport { Log } from '../../../log';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { createCorsMiddleware } from '../middleware/CorsMiddleware';\nimport { createJsInspectorMiddleware } from '../middleware/inspector/createJsInspectorMiddleware';\nimport { prependMiddleware } from '../middleware/mutations';\nimport { getPlatformBundlers } from '../platformBundlers';\n\n// From expo/dev-server but with ability to use custom logger.\ntype MessageSocket = {\n broadcast: (method: string, params?: Record<string, any> | undefined) => void;\n};\n\n// Wrap terminal and polyfill console.log so we can log during bundling without breaking the indicator.\nclass LogRespectingTerminal extends Terminal {\n constructor(stream: import('node:net').Socket | import('node:stream').Writable) {\n super(stream);\n\n const sendLog = (...args: any[]) => {\n this._logLines.push(\n // format args like console.log\n util.format(...args)\n );\n this._scheduleUpdate();\n\n // Flush the logs to the terminal immediately so logs at the end of the process are not lost.\n this.flush();\n };\n\n console.log = sendLog;\n console.info = sendLog;\n }\n}\n\n// Share one instance of Terminal for all instances of Metro.\nconst terminal = new LogRespectingTerminal(process.stdout);\n\nexport async function loadMetroConfigAsync(\n projectRoot: string,\n options: LoadOptions,\n {\n exp,\n isExporting,\n getMetroBundler,\n }: { exp: ExpoConfig; isExporting: boolean; getMetroBundler: () => Bundler }\n) {\n let reportEvent: ((event: any) => void) | undefined;\n\n const serverActionsEnabled =\n exp.experiments?.reactServerFunctions ?? env.EXPO_UNSTABLE_SERVER_FUNCTIONS;\n\n if (serverActionsEnabled) {\n process.env.EXPO_UNSTABLE_SERVER_FUNCTIONS = '1';\n }\n\n // NOTE: Enable all the experimental Metro flags when RSC is enabled.\n if (exp.experiments?.reactServerComponentRoutes || serverActionsEnabled) {\n process.env.EXPO_USE_METRO_REQUIRE = '1';\n process.env.EXPO_USE_FAST_RESOLVER = '1';\n }\n\n const serverRoot = getMetroServerRoot(projectRoot);\n const terminalReporter = new MetroTerminalReporter(serverRoot, terminal);\n\n const hasConfig = await resolveConfig(options.config, projectRoot);\n let config: ConfigT = {\n ...(await loadConfig(\n { cwd: projectRoot, projectRoot, ...options },\n // If the project does not have a metro.config.js, then we use the default config.\n hasConfig.isEmpty ? getDefaultConfig(projectRoot) : undefined\n )),\n reporter: {\n update(event: any) {\n terminalReporter.update(event);\n if (reportEvent) {\n reportEvent(event);\n }\n },\n },\n };\n\n // @ts-expect-error: Set the global require cycle ignore patterns for SSR bundles. This won't work with custom global prefixes, but we don't use those.\n globalThis.__requireCycleIgnorePatterns = config.resolver?.requireCycleIgnorePatterns;\n\n if (isExporting) {\n // This token will be used in the asset plugin to ensure the path is correct for writing locally.\n // @ts-expect-error: typed as readonly.\n config.transformer.publicPath = `/assets?export_path=${\n (exp.experiments?.baseUrl ?? '') + '/assets'\n }`;\n } else {\n // @ts-expect-error: typed as readonly\n config.transformer.publicPath = '/assets/?unstable_path=.';\n }\n\n const platformBundlers = getPlatformBundlers(projectRoot, exp);\n\n if (exp.experiments?.reactCompiler) {\n Log.warn(`Experimental React Compiler is enabled.`);\n }\n\n if (env.EXPO_UNSTABLE_TREE_SHAKING && !env.EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH) {\n throw new CommandError(\n 'EXPO_UNSTABLE_TREE_SHAKING requires EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH to be enabled.'\n );\n }\n\n if (env.EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH) {\n Log.warn(`Experimental bundle optimization is enabled.`);\n }\n if (env.EXPO_UNSTABLE_TREE_SHAKING) {\n Log.warn(`Experimental tree shaking is enabled.`);\n }\n\n if (serverActionsEnabled) {\n Log.warn(\n `React Server Functions (beta) are enabled. Route rendering mode: ${exp.experiments?.reactServerComponentRoutes ? 'server' : 'client'}`\n );\n }\n\n config = await withMetroMultiPlatformAsync(projectRoot, {\n config,\n exp,\n platformBundlers,\n isTsconfigPathsEnabled: exp.experiments?.tsconfigPaths ?? true,\n isFastResolverEnabled: env.EXPO_USE_FAST_RESOLVER,\n isExporting,\n isReactCanaryEnabled:\n (exp.experiments?.reactServerComponentRoutes ||\n serverActionsEnabled ||\n exp.experiments?.reactCanary) ??\n false,\n isNamedRequiresEnabled: env.EXPO_USE_METRO_REQUIRE,\n isReactServerComponentsEnabled: !!exp.experiments?.reactServerComponentRoutes,\n getMetroBundler,\n });\n\n return {\n config,\n setEventReporter: (logger: (event: any) => void) => (reportEvent = logger),\n reporter: terminalReporter,\n };\n}\n\n/** The most generic possible setup for Metro bundler. */\nexport async function instantiateMetroAsync(\n metroBundler: MetroBundlerDevServer,\n options: Omit<LoadOptions, 'logger'>,\n {\n isExporting,\n exp = getConfig(metroBundler.projectRoot, {\n skipSDKVersionRequirement: true,\n }).exp,\n }: { isExporting: boolean; exp?: ExpoConfig }\n): Promise<{\n metro: Metro.Server;\n hmrServer: MetroHmrServer | null;\n server: http.Server;\n middleware: any;\n messageSocket: MessageSocket;\n}> {\n const projectRoot = metroBundler.projectRoot;\n\n const { config: metroConfig, setEventReporter } = await loadMetroConfigAsync(\n projectRoot,\n options,\n {\n exp,\n isExporting,\n getMetroBundler() {\n return metro.getBundler().getBundler();\n },\n }\n );\n\n // Create the core middleware stack for Metro, including websocket listeners\n const { middleware, messagesSocket, eventsSocket, websocketEndpoints } =\n createMetroMiddleware(metroConfig);\n\n if (!isExporting) {\n // Enable correct CORS headers for Expo Router features\n prependMiddleware(middleware, createCorsMiddleware(exp));\n\n // Enable debug middleware for CDP-related debugging\n const { debugMiddleware, debugWebsocketEndpoints } = createDebugMiddleware(metroBundler);\n Object.assign(websocketEndpoints, debugWebsocketEndpoints);\n middleware.use(debugMiddleware);\n middleware.use('/_expo/debugger', createJsInspectorMiddleware());\n\n // TODO(cedric): `enhanceMiddleware` is deprecated, but is currently used to unify the middleware stacks\n // See: https://github.com/facebook/metro/commit/22e85fde85ec454792a1b70eba4253747a2587a9\n // See: https://github.com/facebook/metro/commit/d0d554381f119bb80ab09dbd6a1d310b54737e52\n const customEnhanceMiddleware = metroConfig.server.enhanceMiddleware;\n // @ts-expect-error: can't mutate readonly config\n metroConfig.server.enhanceMiddleware = (metroMiddleware: any, server: Metro.Server) => {\n if (customEnhanceMiddleware) {\n metroMiddleware = customEnhanceMiddleware(metroMiddleware, server);\n }\n return middleware.use(metroMiddleware);\n };\n }\n\n // Attach Expo Atlas if enabled\n await attachAtlasAsync({\n isExporting,\n exp,\n projectRoot,\n middleware,\n metroConfig,\n // NOTE(cedric): reset the Atlas file once, and reuse it for static exports\n resetAtlasFile: isExporting,\n });\n\n const { server, hmrServer, metro } = await runServer(\n metroBundler,\n metroConfig,\n {\n websocketEndpoints: {\n ...websocketEndpoints,\n ...createDevToolsPluginWebsocketEndpoint(),\n },\n watch: !isExporting && isWatchEnabled(),\n },\n {\n mockServer: isExporting,\n }\n );\n\n // Patch transform file to remove inconvenient customTransformOptions which are only used in single well-known files.\n const originalTransformFile = metro\n .getBundler()\n .getBundler()\n .transformFile.bind(metro.getBundler().getBundler());\n\n metro.getBundler().getBundler().transformFile = async function (\n filePath: string,\n transformOptions: TransformOptions,\n fileBuffer?: Buffer\n ) {\n return originalTransformFile(\n filePath,\n pruneCustomTransformOptions(\n filePath,\n // Clone the options so we don't mutate the original.\n {\n ...transformOptions,\n customTransformOptions: {\n __proto__: null,\n ...transformOptions.customTransformOptions,\n },\n }\n ),\n fileBuffer\n );\n };\n\n setEventReporter(eventsSocket.reportMetroEvent);\n\n // This function ensures that modules in source maps are sorted in the same\n // order as in a plain JS bundle.\n metro._getSortedModules = function (this: Metro.Server, graph: ReadOnlyGraph) {\n const modules = [...graph.dependencies.values()];\n\n const ctx = {\n platform: graph.transformOptions.platform,\n environment: graph.transformOptions.customTransformOptions?.environment,\n };\n // Assign IDs to modules in a consistent order\n for (const module of modules) {\n // @ts-expect-error\n this._createModuleId(module.path, ctx);\n }\n // Sort by IDs\n return modules.sort(\n // @ts-expect-error\n (a, b) => this._createModuleId(a.path, ctx) - this._createModuleId(b.path, ctx)\n );\n };\n\n if (hmrServer) {\n let hmrJSBundle: typeof import('@expo/metro-config/build/serializer/fork/hmrJSBundle').default;\n\n try {\n hmrJSBundle = require('@expo/metro-config/build/serializer/fork/hmrJSBundle').default;\n } catch {\n // Add fallback for monorepo tests up until the fork is merged.\n Log.warn('Failed to load HMR serializer from @expo/metro-config, using fallback version.');\n hmrJSBundle = require('metro/src/DeltaBundler/Serializers/hmrJSBundle');\n }\n\n // Patch HMR Server to send more info to the `_createModuleId` function for deterministic module IDs and add support for serializing HMR updates the same as all other bundles.\n hmrServer._prepareMessage = async function (this: MetroHmrServer, group, options, changeEvent) {\n // Fork of https://github.com/facebook/metro/blob/3b3e0aaf725cfa6907bf2c8b5fbc0da352d29efe/packages/metro/src/HmrServer.js#L327-L393\n // with patch for `_createModuleId`.\n const logger = !options.isInitialUpdate ? changeEvent?.logger : null;\n try {\n const revPromise = this._bundler.getRevision(group.revisionId);\n if (!revPromise) {\n return {\n type: 'error',\n body: formatBundlingError(new RevisionNotFoundError(group.revisionId)),\n };\n }\n logger?.point('updateGraph_start');\n const { revision, delta } = await this._bundler.updateGraph(await revPromise, false);\n logger?.point('updateGraph_end');\n this._clientGroups.delete(group.revisionId);\n group.revisionId = revision.id;\n for (const client of group.clients) {\n client.revisionIds = client.revisionIds.filter(\n (revisionId) => revisionId !== group.revisionId\n );\n client.revisionIds.push(revision.id);\n }\n this._clientGroups.set(group.revisionId, group);\n logger?.point('serialize_start');\n // NOTE(EvanBacon): This is the patch\n const moduleIdContext = {\n platform: revision.graph.transformOptions.platform,\n environment: revision.graph.transformOptions.customTransformOptions?.environment,\n };\n const hmrUpdate = hmrJSBundle(delta, revision.graph, {\n clientUrl: group.clientUrl,\n // NOTE(EvanBacon): This is also the patch\n createModuleId: (moduleId: string) => {\n // @ts-expect-error\n return this._createModuleId(moduleId, moduleIdContext);\n },\n includeAsyncPaths: group.graphOptions.lazy,\n projectRoot: this._config.projectRoot,\n serverRoot: this._config.server.unstable_serverRoot ?? this._config.projectRoot,\n });\n logger?.point('serialize_end');\n return {\n type: 'update',\n body: {\n revisionId: revision.id,\n isInitialUpdate: options.isInitialUpdate,\n ...hmrUpdate,\n },\n };\n } catch (error: any) {\n const formattedError = formatBundlingError(error);\n this._config.reporter.update({\n type: 'bundling_error',\n error,\n });\n return {\n type: 'error',\n body: formattedError,\n };\n }\n };\n }\n\n return {\n metro,\n hmrServer,\n server,\n middleware,\n messageSocket: messagesSocket,\n };\n}\n\n// TODO: Fork the entire transform function so we can simply regex the file contents for keywords instead.\nfunction pruneCustomTransformOptions(\n filePath: string,\n transformOptions: TransformOptions\n): TransformOptions {\n // Normalize the filepath for cross platform checking.\n filePath = filePath.split(path.sep).join('/');\n\n if (\n transformOptions.customTransformOptions?.dom &&\n // The only generated file that needs the dom root is `expo/dom/entry.js`\n !filePath.match(/expo\\/dom\\/entry\\.js$/)\n ) {\n // Clear the dom root option if we aren't transforming the magic entry file, this ensures\n // that cached artifacts from other DOM component bundles can be reused.\n transformOptions.customTransformOptions.dom = 'true';\n }\n\n if (\n transformOptions.customTransformOptions?.routerRoot &&\n // The router root is used all over expo-router (`process.env.EXPO_ROUTER_ABS_APP_ROOT`, `process.env.EXPO_ROUTER_APP_ROOT`) so we'll just ignore the entire package.\n !(filePath.match(/\\/expo-router\\/_ctx/) || filePath.match(/\\/expo-router\\/build\\//))\n ) {\n // Set to the default value.\n transformOptions.customTransformOptions.routerRoot = 'app';\n }\n if (\n transformOptions.customTransformOptions?.asyncRoutes &&\n // The async routes settings are also used in `expo-router/_ctx.ios.js` (and other platform variants) via `process.env.EXPO_ROUTER_IMPORT_MODE`\n !(filePath.match(/\\/expo-router\\/_ctx/) || filePath.match(/\\/expo-router\\/build\\//))\n ) {\n delete transformOptions.customTransformOptions.asyncRoutes;\n }\n\n if (\n transformOptions.customTransformOptions?.clientBoundaries &&\n // The client boundaries are only used in `@expo/metro-runtime/src/virtual.js` for production RSC exports.\n !filePath.match(/\\/@expo\\/metro-runtime\\/rsc\\/virtual\\.js$/)\n ) {\n delete transformOptions.customTransformOptions.clientBoundaries;\n }\n\n return transformOptions;\n}\n\n/**\n * Simplify and communicate if Metro is running without watching file updates,.\n * Exposed for testing.\n */\nexport function isWatchEnabled() {\n if (env.CI) {\n Log.log(\n chalk`Metro is running in CI mode, reloads are disabled. Remove {bold CI=true} to enable watch mode.`\n );\n }\n\n return !env.CI;\n}\n"],"names":["loadMetroConfigAsync","instantiateMetroAsync","isWatchEnabled","LogRespectingTerminal","Terminal","constructor","stream","sendLog","args","_logLines","push","util","format","_scheduleUpdate","flush","console","log","info","terminal","process","stdout","projectRoot","options","exp","isExporting","getMetroBundler","config","reportEvent","serverActionsEnabled","experiments","reactServerFunctions","env","EXPO_UNSTABLE_SERVER_FUNCTIONS","reactServerComponentRoutes","EXPO_USE_METRO_REQUIRE","EXPO_USE_FAST_RESOLVER","serverRoot","getMetroServerRoot","terminalReporter","MetroTerminalReporter","hasConfig","resolveConfig","loadConfig","cwd","isEmpty","getDefaultConfig","undefined","reporter","update","event","globalThis","__requireCycleIgnorePatterns","resolver","requireCycleIgnorePatterns","transformer","publicPath","baseUrl","platformBundlers","getPlatformBundlers","reactCompiler","Log","warn","EXPO_UNSTABLE_TREE_SHAKING","EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH","CommandError","withMetroMultiPlatformAsync","isTsconfigPathsEnabled","tsconfigPaths","isFastResolverEnabled","isReactCanaryEnabled","reactCanary","isNamedRequiresEnabled","isReactServerComponentsEnabled","setEventReporter","logger","metroBundler","getConfig","skipSDKVersionRequirement","metroConfig","metro","getBundler","middleware","messagesSocket","eventsSocket","websocketEndpoints","createMetroMiddleware","prependMiddleware","createCorsMiddleware","debugMiddleware","debugWebsocketEndpoints","createDebugMiddleware","Object","assign","use","createJsInspectorMiddleware","customEnhanceMiddleware","server","enhanceMiddleware","metroMiddleware","attachAtlasAsync","resetAtlasFile","hmrServer","runServer","createDevToolsPluginWebsocketEndpoint","watch","mockServer","originalTransformFile","transformFile","bind","filePath","transformOptions","fileBuffer","pruneCustomTransformOptions","customTransformOptions","__proto__","reportMetroEvent","_getSortedModules","graph","modules","dependencies","values","ctx","platform","environment","module","_createModuleId","path","sort","a","b","hmrJSBundle","require","default","_prepareMessage","group","changeEvent","isInitialUpdate","revision","revPromise","_bundler","getRevision","revisionId","type","body","formatBundlingError","RevisionNotFoundError","point","delta","updateGraph","_clientGroups","delete","id","client","clients","revisionIds","filter","set","moduleIdContext","hmrUpdate","clientUrl","createModuleId","moduleId","includeAsyncPaths","graphOptions","lazy","_config","unstable_serverRoot","error","formattedError","messageSocket","split","sep","join","dom","match","routerRoot","asyncRoutes","clientBoundaries","CI","chalk"],"mappings":"AAAA;;;;;;;;;;;IA8DsBA,oBAAoB,MAApBA,oBAAoB;IA4GpBC,qBAAqB,MAArBA,qBAAqB;IA4Q3BC,cAAc,MAAdA,cAAc;;;yBAtbQ,cAAc;;;;;;;yBACjB,oBAAoB;;;;;;;yBACT,oBAAoB;;;;;;;8DAChD,OAAO;;;;;;;8DAOS,oDAAoD;;;;;;;8DACtD,mCAAmC;;;;;;;yBAChB,cAAc;;;;;;;yBACxC,YAAY;;;;;;;8DACpB,WAAW;;;;;;;8DACX,MAAM;;;;;;iDAE+B,mCAAmC;uCAEnD,yBAAyB;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