@expo/cli 55.0.22 → 55.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bin/cli +1 -1
- package/build/src/events/index.js +1 -1
- package/build/src/expoUpdatesExports.js +46 -3
- package/build/src/expoUpdatesExports.js.map +1 -1
- package/build/src/export/embed/exportEmbedAsync.js +13 -4
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/export/embed/index.js +1 -1
- package/build/src/export/embed/index.js.map +1 -1
- package/build/src/export/exportApp.js +8 -2
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportDomComponents.js +11 -4
- package/build/src/export/exportDomComponents.js.map +1 -1
- package/build/src/start/doctor/ngrok/ExternalModule.js +11 -6
- package/build/src/start/doctor/ngrok/ExternalModule.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +6 -6
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/createExpoFallbackResolver.js +39 -0
- package/build/src/start/server/metro/createExpoFallbackResolver.js.map +1 -1
- package/build/src/start/server/middleware/DomComponentsMiddleware.js +14 -5
- package/build/src/start/server/middleware/DomComponentsMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +4 -41
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/utils/filePath.js +3 -29
- package/build/src/utils/filePath.js.map +1 -1
- package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
- package/build/src/utils/telemetry/utils/context.js +1 -1
- package/package.json +11 -11
- package/build/src/utils/resolveGlobal.js +0 -195
- package/build/src/utils/resolveGlobal.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/export/exportDomComponents.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config';\nimport assert from 'assert';\nimport crypto from 'crypto';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport url from 'url';\n\nimport { type PlatformMetadata } from './createMetadataJson';\nimport { type BundleOutput, type ExportAssetMap, getFilesFromSerialAssets } from './saveAssets';\nimport { type MetroBundlerDevServer } from '../start/server/metro/MetroBundlerDevServer';\nimport { serializeHtmlWithAssets } from '../start/server/metro/serializeHtml';\nimport {\n getDomComponentHtml,\n DOM_COMPONENTS_BUNDLE_DIR,\n} from '../start/server/middleware/DomComponentsMiddleware';\nimport { env } from '../utils/env';\nimport { resolveRealEntryFilePath, toPosixPath } from '../utils/filePath';\n\nconst debug = require('debug')('expo:export:exportDomComponents') as typeof console.log;\n\n// TODO(EvanBacon): determine how to support DOM Components with hosting.\nexport async function exportDomComponentAsync({\n filePath,\n projectRoot,\n dev,\n devServer,\n isHermes,\n includeSourceMaps,\n exp,\n files,\n useMd5Filename = false,\n}: {\n filePath: string;\n projectRoot: string;\n dev: boolean;\n devServer: MetroBundlerDevServer;\n isHermes: boolean;\n includeSourceMaps: boolean;\n exp: ExpoConfig;\n files: ExportAssetMap;\n useMd5Filename?: boolean;\n}): Promise<{\n bundle: BundleOutput;\n htmlOutputName: string;\n}> {\n const virtualEntry = toPosixPath(resolveFrom(projectRoot, 'expo/dom/entry.js'));\n debug('Bundle DOM Component:', filePath);\n // MUST MATCH THE BABEL PLUGIN!\n const hash = crypto.createHash('md5').update(filePath).digest('hex');\n const outputName = `${DOM_COMPONENTS_BUNDLE_DIR}/${hash}.html`;\n const generatedEntryPath = toPosixPath(\n filePath.startsWith('file://') ? url.fileURLToPath(filePath) : filePath\n );\n const baseUrl = `/${DOM_COMPONENTS_BUNDLE_DIR}`;\n // The relative import path will be used like URI so it must be POSIX.\n const relativeImport = './' + path.posix.relative(path.dirname(virtualEntry), generatedEntryPath);\n // Run metro bundler and create the JS bundles/source maps.\n const bundle = await devServer.legacySinglePageExportBundleAsync({\n platform: 'web',\n domRoot: encodeURI(relativeImport),\n splitChunks: !env.EXPO_NO_BUNDLE_SPLITTING,\n mainModuleName: resolveRealEntryFilePath(projectRoot, virtualEntry),\n mode: dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n serializerIncludeMaps: includeSourceMaps,\n bytecode: false,\n reactCompiler: !!exp.experiments?.reactCompiler,\n baseUrl: './',\n useMd5Filename,\n // Minify may be false because it's skipped on native when Hermes is enabled, default to true.\n minify: true,\n });\n\n if (useMd5Filename) {\n for (const artifact of bundle.artifacts) {\n const md5 = crypto.createHash('md5').update(artifact.source).digest('hex');\n artifact.filename = `${md5}.${artifact.type}`;\n }\n }\n\n const html = await serializeHtmlWithAssets({\n isExporting: true,\n resources: bundle.artifacts,\n template: getDomComponentHtml(),\n baseUrl: './',\n });\n\n const serialAssets = bundle.artifacts.map((a) => {\n return {\n ...a,\n filename: path.join(baseUrl, a.filename),\n };\n });\n\n getFilesFromSerialAssets(serialAssets, {\n includeSourceMaps,\n files,\n platform: 'web',\n });\n\n files.set(outputName, {\n contents: html,\n });\n\n return {\n bundle,\n htmlOutputName: outputName,\n };\n}\n\n//#region `npx export` for updates\n\n/**\n * Add the DOM component bundle to the metadata for updates.\n */\nexport function addDomBundleToMetadataAsync(bundle: BundleOutput): PlatformMetadata['assets'] {\n const assetsMetadata: PlatformMetadata['assets'] = [];\n for (const artifact of bundle.artifacts) {\n if (artifact.type === 'map') {\n continue;\n }\n assetsMetadata.push({\n path: `${DOM_COMPONENTS_BUNDLE_DIR}/${artifact.filename}`,\n ext: artifact.type,\n });\n }\n return assetsMetadata;\n}\n\n/**\n * Transform the DOM component entry (*.html) to use MD5 filename by its content.\n */\nexport function transformDomEntryForMd5Filename({\n files,\n htmlOutputName,\n}: {\n files: ExportAssetMap;\n htmlOutputName: string;\n}): PlatformMetadata['assets'] {\n const htmlContent = files.get(htmlOutputName);\n assert(htmlContent);\n const htmlMd5 = crypto.createHash('md5').update(htmlContent.contents.toString()).digest('hex');\n const htmlMd5Filename = `${DOM_COMPONENTS_BUNDLE_DIR}/${htmlMd5}.html`;\n files.set(htmlMd5Filename, htmlContent);\n files.delete(htmlOutputName);\n return [\n {\n path: htmlMd5Filename,\n ext: 'html',\n },\n ];\n}\n\n/**\n * Post-transform the native bundle to use MD5 filename based on DOM component entry content.\n */\nexport function transformNativeBundleForMd5Filename({\n domComponentReference,\n nativeBundle,\n files,\n htmlOutputName,\n}: {\n domComponentReference: string;\n nativeBundle: BundleOutput;\n files: ExportAssetMap;\n htmlOutputName: string;\n}) {\n const htmlContent = files.get(htmlOutputName);\n assert(htmlContent);\n const htmlMd5 = crypto.createHash('md5').update(htmlContent.contents.toString()).digest('hex');\n const hash = crypto.createHash('md5').update(domComponentReference).digest('hex');\n for (const artifact of nativeBundle.artifacts) {\n if (artifact.type !== 'js') {\n continue;\n }\n const assetEntity = files.get(artifact.filename);\n assert(assetEntity);\n if (Buffer.isBuffer(assetEntity.contents)) {\n const searchBuffer = Buffer.from(`${hash}.html`, 'utf8');\n const replaceBuffer = Buffer.from(`${htmlMd5}.html`, 'utf8');\n assert(searchBuffer.length === replaceBuffer.length);\n let index = assetEntity.contents.indexOf(searchBuffer, 0);\n while (index !== -1) {\n replaceBuffer.copy(assetEntity.contents, index);\n index = assetEntity.contents.indexOf(searchBuffer, index + searchBuffer.length);\n }\n } else {\n const search = `${hash}.html`;\n const replace = `${htmlMd5}.html`;\n assert(search.length === replace.length);\n assetEntity.contents = assetEntity.contents.toString().replaceAll(search, replace);\n }\n }\n}\n\n//#endregion `npx export` for updates\n"],"names":["addDomBundleToMetadataAsync","exportDomComponentAsync","transformDomEntryForMd5Filename","transformNativeBundleForMd5Filename","debug","require","filePath","projectRoot","dev","devServer","isHermes","includeSourceMaps","exp","files","useMd5Filename","virtualEntry","toPosixPath","resolveFrom","hash","crypto","createHash","update","digest","outputName","DOM_COMPONENTS_BUNDLE_DIR","generatedEntryPath","startsWith","url","fileURLToPath","baseUrl","relativeImport","path","posix","relative","dirname","bundle","legacySinglePageExportBundleAsync","platform","domRoot","encodeURI","splitChunks","env","EXPO_NO_BUNDLE_SPLITTING","mainModuleName","resolveRealEntryFilePath","mode","engine","undefined","serializerIncludeMaps","bytecode","reactCompiler","experiments","minify","artifact","artifacts","md5","source","filename","type","html","serializeHtmlWithAssets","isExporting","resources","template","getDomComponentHtml","serialAssets","map","a","join","getFilesFromSerialAssets","set","contents","htmlOutputName","assetsMetadata","push","ext","htmlContent","get","assert","htmlMd5","toString","htmlMd5Filename","delete","domComponentReference","nativeBundle","assetEntity","Buffer","isBuffer","searchBuffer","from","replaceBuffer","length","index","indexOf","copy","search","replace","replaceAll"],"mappings":";;;;;;;;;;;IAmHgBA,2BAA2B;eAA3BA;;IA9FMC,uBAAuB;eAAvBA;;IA+GNC,+BAA+B;eAA/BA;;IAwBAC,mCAAmC;eAAnCA;;;;gEA3JG;;;;;;;gEACA;;;;;;;gEACF;;;;;;;gEACO;;;;;;;gEACR;;;;;;4BAGiE;+BAEzC;yCAIjC;qBACa;0BACkC;;;;;;AAEtD,MAAMC,QAAQC,QAAQ,SAAS;AAGxB,eAAeJ,wBAAwB,EAC5CK,QAAQ,EACRC,WAAW,EACXC,GAAG,EACHC,SAAS,EACTC,QAAQ,EACRC,iBAAiB,EACjBC,GAAG,EACHC,KAAK,EACLC,iBAAiB,KAAK,EAWvB;QAyBoBF;IArBnB,MAAMG,eAAeC,IAAAA,qBAAW,EAACC,IAAAA,sBAAW,EAACV,aAAa;IAC1DH,MAAM,yBAAyBE;IAC/B,+BAA+B;IAC/B,MAAMY,OAAOC,iBAAM,CAACC,UAAU,CAAC,OAAOC,MAAM,CAACf,UAAUgB,MAAM,CAAC;IAC9D,MAAMC,aAAa,GAAGC,kDAAyB,CAAC,CAAC,EAAEN,KAAK,KAAK,CAAC;IAC9D,MAAMO,qBAAqBT,IAAAA,qBAAW,EACpCV,SAASoB,UAAU,CAAC,aAAaC,cAAG,CAACC,aAAa,CAACtB,YAAYA;IAEjE,MAAMuB,UAAU,CAAC,CAAC,EAAEL,kDAAyB,EAAE;IAC/C,sEAAsE;IACtE,MAAMM,iBAAiB,OAAOC,eAAI,CAACC,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,CAACxB,SAASI,QAAQ;QAC/CqB,IAAAA,iBAAM,EAACO;QACP,IAAIC,OAAOC,QAAQ,CAACF,YAAYd,QAAQ,GAAG;YACzC,MAAMiB,eAAeF,OAAOG,IAAI,CAAC,GAAGvE,KAAK,KAAK,CAAC,EAAE;YACjD,MAAMwE,gBAAgBJ,OAAOG,IAAI,CAAC,GAAGV,QAAQ,KAAK,CAAC,EAAE;YACrDD,IAAAA,iBAAM,EAACU,aAAaG,MAAM,KAAKD,cAAcC,MAAM;YACnD,IAAIC,QAAQP,YAAYd,QAAQ,CAACsB,OAAO,CAACL,cAAc;YACvD,MAAOI,UAAU,CAAC,EAAG;gBACnBF,cAAcI,IAAI,CAACT,YAAYd,QAAQ,EAAEqB;gBACzCA,QAAQP,YAAYd,QAAQ,CAACsB,OAAO,CAACL,cAAcI,QAAQJ,aAAaG,MAAM;YAChF;QACF,OAAO;YACL,MAAMI,SAAS,GAAG7E,KAAK,KAAK,CAAC;YAC7B,MAAM8E,UAAU,GAAGjB,QAAQ,KAAK,CAAC;YACjCD,IAAAA,iBAAM,EAACiB,OAAOJ,MAAM,KAAKK,QAAQL,MAAM;YACvCN,YAAYd,QAAQ,GAAGc,YAAYd,QAAQ,CAACS,QAAQ,GAAGiB,UAAU,CAACF,QAAQC;QAC5E;IACF;AACF,EAEA,qCAAqC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/export/exportDomComponents.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config';\nimport { convertEntryPointToRelative } from '@expo/config/paths';\nimport assert from 'assert';\nimport crypto from 'crypto';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport url from 'url';\n\nimport { type PlatformMetadata } from './createMetadataJson';\nimport { type BundleOutput, type ExportAssetMap, getFilesFromSerialAssets } from './saveAssets';\nimport { type MetroBundlerDevServer } from '../start/server/metro/MetroBundlerDevServer';\nimport { serializeHtmlWithAssets } from '../start/server/metro/serializeHtml';\nimport {\n getDomComponentHtml,\n DOM_COMPONENTS_BUNDLE_DIR,\n} from '../start/server/middleware/DomComponentsMiddleware';\nimport { env } from '../utils/env';\nimport { toPosixPath } from '../utils/filePath';\n\nconst debug = require('debug')('expo:export:exportDomComponents') as typeof console.log;\n\n// TODO(EvanBacon): determine how to support DOM Components with hosting.\nexport async function exportDomComponentAsync({\n filePath,\n projectRoot,\n dev,\n devServer,\n isHermes,\n includeSourceMaps,\n exp,\n files,\n useMd5Filename = false,\n}: {\n filePath: string;\n projectRoot: string;\n dev: boolean;\n devServer: MetroBundlerDevServer;\n isHermes: boolean;\n includeSourceMaps: boolean;\n exp: ExpoConfig;\n files: ExportAssetMap;\n useMd5Filename?: boolean;\n}): Promise<{\n bundle: BundleOutput;\n htmlOutputName: string;\n}> {\n const virtualEntry = resolveFrom(projectRoot, 'expo/dom/entry.js');\n debug('Bundle DOM Component:', filePath);\n // MUST MATCH THE BABEL PLUGIN!\n const hash = crypto.createHash('md5').update(filePath).digest('hex');\n const outputName = `${DOM_COMPONENTS_BUNDLE_DIR}/${hash}.html`;\n const generatedEntryPath = path.resolve(\n filePath.startsWith('file://') ? url.fileURLToPath(filePath) : filePath\n );\n const baseUrl = `/${DOM_COMPONENTS_BUNDLE_DIR}`;\n // The relative import path will be used like URI so it must be POSIX.\n const relativeImport =\n './' + toPosixPath(path.relative(path.dirname(virtualEntry), generatedEntryPath));\n // Run metro bundler and create the JS bundles/source maps.\n const bundle = await devServer.legacySinglePageExportBundleAsync({\n platform: 'web',\n domRoot: encodeURI(relativeImport),\n splitChunks: !env.EXPO_NO_BUNDLE_SPLITTING,\n mainModuleName: convertEntryPointToRelative(projectRoot, virtualEntry),\n mode: dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n serializerIncludeMaps: includeSourceMaps,\n bytecode: false,\n reactCompiler: !!exp.experiments?.reactCompiler,\n baseUrl: './',\n useMd5Filename,\n // Minify may be false because it's skipped on native when Hermes is enabled, default to true.\n minify: true,\n });\n\n if (useMd5Filename) {\n for (const artifact of bundle.artifacts) {\n const md5 = crypto.createHash('md5').update(artifact.source).digest('hex');\n artifact.filename = `${md5}.${artifact.type}`;\n }\n }\n\n const html = await serializeHtmlWithAssets({\n isExporting: true,\n resources: bundle.artifacts,\n template: getDomComponentHtml(),\n baseUrl: './',\n });\n\n const serialAssets = bundle.artifacts.map((a) => {\n return {\n ...a,\n filename: path.join(baseUrl, a.filename),\n };\n });\n\n getFilesFromSerialAssets(serialAssets, {\n includeSourceMaps,\n files,\n platform: 'web',\n });\n\n files.set(outputName, {\n contents: html,\n });\n\n return {\n bundle,\n htmlOutputName: outputName,\n };\n}\n\n//#region `npx export` for updates\n\n/**\n * Add the DOM component bundle to the metadata for updates.\n */\nexport function addDomBundleToMetadataAsync(bundle: BundleOutput): PlatformMetadata['assets'] {\n const assetsMetadata: PlatformMetadata['assets'] = [];\n for (const artifact of bundle.artifacts) {\n if (artifact.type === 'map') {\n continue;\n }\n assetsMetadata.push({\n path: `${DOM_COMPONENTS_BUNDLE_DIR}/${artifact.filename}`,\n ext: artifact.type,\n });\n }\n return assetsMetadata;\n}\n\n/**\n * Transform the DOM component entry (*.html) to use MD5 filename by its content.\n */\nexport function transformDomEntryForMd5Filename({\n files,\n htmlOutputName,\n}: {\n files: ExportAssetMap;\n htmlOutputName: string;\n}): PlatformMetadata['assets'] {\n const htmlContent = files.get(htmlOutputName);\n assert(htmlContent);\n const htmlMd5 = crypto.createHash('md5').update(htmlContent.contents.toString()).digest('hex');\n const htmlMd5Filename = `${DOM_COMPONENTS_BUNDLE_DIR}/${htmlMd5}.html`;\n files.set(htmlMd5Filename, htmlContent);\n files.delete(htmlOutputName);\n return [\n {\n path: htmlMd5Filename,\n ext: 'html',\n },\n ];\n}\n\n/**\n * Post-transform the native bundle to use MD5 filename based on DOM component entry content.\n */\nexport function transformNativeBundleForMd5Filename({\n domComponentReference,\n nativeBundle,\n files,\n htmlOutputName,\n}: {\n domComponentReference: string;\n nativeBundle: BundleOutput;\n files: ExportAssetMap;\n htmlOutputName: string;\n}) {\n const htmlContent = files.get(htmlOutputName);\n assert(htmlContent);\n const htmlMd5 = crypto.createHash('md5').update(htmlContent.contents.toString()).digest('hex');\n const hash = crypto.createHash('md5').update(domComponentReference).digest('hex');\n for (const artifact of nativeBundle.artifacts) {\n if (artifact.type !== 'js') {\n continue;\n }\n const assetEntity = files.get(artifact.filename);\n assert(assetEntity);\n if (Buffer.isBuffer(assetEntity.contents)) {\n const searchBuffer = Buffer.from(`${hash}.html`, 'utf8');\n const replaceBuffer = Buffer.from(`${htmlMd5}.html`, 'utf8');\n assert(searchBuffer.length === replaceBuffer.length);\n let index = assetEntity.contents.indexOf(searchBuffer, 0);\n while (index !== -1) {\n replaceBuffer.copy(assetEntity.contents, index);\n index = assetEntity.contents.indexOf(searchBuffer, index + searchBuffer.length);\n }\n } else {\n const search = `${hash}.html`;\n const replace = `${htmlMd5}.html`;\n assert(search.length === replace.length);\n assetEntity.contents = assetEntity.contents.toString().replaceAll(search, replace);\n }\n }\n}\n\n//#endregion `npx export` for updates\n"],"names":["addDomBundleToMetadataAsync","exportDomComponentAsync","transformDomEntryForMd5Filename","transformNativeBundleForMd5Filename","debug","require","filePath","projectRoot","dev","devServer","isHermes","includeSourceMaps","exp","files","useMd5Filename","virtualEntry","resolveFrom","hash","crypto","createHash","update","digest","outputName","DOM_COMPONENTS_BUNDLE_DIR","generatedEntryPath","path","resolve","startsWith","url","fileURLToPath","baseUrl","relativeImport","toPosixPath","relative","dirname","bundle","legacySinglePageExportBundleAsync","platform","domRoot","encodeURI","splitChunks","env","EXPO_NO_BUNDLE_SPLITTING","mainModuleName","convertEntryPointToRelative","mode","engine","undefined","serializerIncludeMaps","bytecode","reactCompiler","experiments","minify","artifact","artifacts","md5","source","filename","type","html","serializeHtmlWithAssets","isExporting","resources","template","getDomComponentHtml","serialAssets","map","a","join","getFilesFromSerialAssets","set","contents","htmlOutputName","assetsMetadata","push","ext","htmlContent","get","assert","htmlMd5","toString","htmlMd5Filename","delete","domComponentReference","nativeBundle","assetEntity","Buffer","isBuffer","searchBuffer","from","replaceBuffer","length","index","indexOf","copy","search","replace","replaceAll"],"mappings":";;;;;;;;;;;IAqHgBA,2BAA2B;eAA3BA;;IA/FMC,uBAAuB;eAAvBA;;IAgHNC,+BAA+B;eAA/BA;;IAwBAC,mCAAmC;eAAnCA;;;;yBA7J4B;;;;;;;gEACzB;;;;;;;gEACA;;;;;;;gEACF;;;;;;;gEACO;;;;;;;gEACR;;;;;;4BAGiE;+BAEzC;yCAIjC;qBACa;0BACQ;;;;;;AAE5B,MAAMC,QAAQC,QAAQ,SAAS;AAGxB,eAAeJ,wBAAwB,EAC5CK,QAAQ,EACRC,WAAW,EACXC,GAAG,EACHC,SAAS,EACTC,QAAQ,EACRC,iBAAiB,EACjBC,GAAG,EACHC,KAAK,EACLC,iBAAiB,KAAK,EAWvB;QA0BoBF;IAtBnB,MAAMG,eAAeC,IAAAA,sBAAW,EAACT,aAAa;IAC9CH,MAAM,yBAAyBE;IAC/B,+BAA+B;IAC/B,MAAMW,OAAOC,iBAAM,CAACC,UAAU,CAAC,OAAOC,MAAM,CAACd,UAAUe,MAAM,CAAC;IAC9D,MAAMC,aAAa,GAAGC,kDAAyB,CAAC,CAAC,EAAEN,KAAK,KAAK,CAAC;IAC9D,MAAMO,qBAAqBC,eAAI,CAACC,OAAO,CACrCpB,SAASqB,UAAU,CAAC,aAAaC,cAAG,CAACC,aAAa,CAACvB,YAAYA;IAEjE,MAAMwB,UAAU,CAAC,CAAC,EAAEP,kDAAyB,EAAE;IAC/C,sEAAsE;IACtE,MAAMQ,iBACJ,OAAOC,IAAAA,qBAAW,EAACP,eAAI,CAACQ,QAAQ,CAACR,eAAI,CAACS,OAAO,CAACnB,eAAeS;IAC/D,2DAA2D;IAC3D,MAAMW,SAAS,MAAM1B,UAAU2B,iCAAiC,CAAC;QAC/DC,UAAU;QACVC,SAASC,UAAUR;QACnBS,aAAa,CAACC,QAAG,CAACC,wBAAwB;QAC1CC,gBAAgBC,IAAA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C,GAAGV,QAAQ,KAAK,CAAC,EAAE;YACrDD,IAAAA,iBAAM,EAACU,aAAaG,MAAM,KAAKD,cAAcC,MAAM;YACnD,IAAIC,QAAQP,YAAYd,QAAQ,CAACsB,OAAO,CAACL,cAAc;YACvD,MAAOI,UAAU,CAAC,EAAG;gBACnBF,cAAcI,IAAI,CAACT,YAAYd,QAAQ,EAAEqB;gBACzCA,QAAQP,YAAYd,QAAQ,CAACsB,OAAO,CAACL,cAAcI,QAAQJ,aAAaG,MAAM;YAChF;QACF,OAAO;YACL,MAAMI,SAAS,GAAG9E,KAAK,KAAK,CAAC;YAC7B,MAAM+E,UAAU,GAAGjB,QAAQ,KAAK,CAAC;YACjCD,IAAAA,iBAAM,EAACiB,OAAOJ,MAAM,KAAKK,QAAQL,MAAM;YACvCN,YAAYd,QAAQ,GAAGc,YAAYd,QAAQ,CAACS,QAAQ,GAAGiB,UAAU,CAACF,QAAQC;QAC5E;IACF;AACF,EAEA,qCAAqC"}
|
|
@@ -23,9 +23,9 @@ function _packagemanager() {
|
|
|
23
23
|
};
|
|
24
24
|
return data;
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
const data =
|
|
28
|
-
|
|
26
|
+
function _requireutils() {
|
|
27
|
+
const data = require("@expo/require-utils");
|
|
28
|
+
_requireutils = function() {
|
|
29
29
|
return data;
|
|
30
30
|
};
|
|
31
31
|
return data;
|
|
@@ -42,7 +42,6 @@ const _delay = require("../../../utils/delay");
|
|
|
42
42
|
const _env = require("../../../utils/env");
|
|
43
43
|
const _errors = require("../../../utils/errors");
|
|
44
44
|
const _prompts = require("../../../utils/prompts");
|
|
45
|
-
const _resolveGlobal = require("../../../utils/resolveGlobal");
|
|
46
45
|
function _interop_require_default(obj) {
|
|
47
46
|
return obj && obj.__esModule ? obj : {
|
|
48
47
|
default: obj
|
|
@@ -179,10 +178,16 @@ class ExternalModule {
|
|
|
179
178
|
return require(moduleId);
|
|
180
179
|
}
|
|
181
180
|
/** Resolve a copy that's installed in the project. Exposed for testing. */ _resolveLocal(moduleId) {
|
|
182
|
-
|
|
181
|
+
const target = (0, _requireutils().resolveFrom)(this.projectRoot, moduleId);
|
|
182
|
+
if (!target) {
|
|
183
|
+
throw Object.assign(new Error(`Module "${moduleId}" could not be resolved in the project.`), {
|
|
184
|
+
code: 'MODULE_NOT_FOUND'
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
return target;
|
|
183
188
|
}
|
|
184
189
|
/** Resolve a copy that's installed globally. Exposed for testing. */ _resolveGlobal(moduleId) {
|
|
185
|
-
return (0,
|
|
190
|
+
return (0, _requireutils().resolveGlobal)(moduleId);
|
|
186
191
|
}
|
|
187
192
|
/** Resolve the module and verify the version. Exposed for testing. */ _resolveModule(isLocal) {
|
|
188
193
|
const resolver = isLocal ? this._resolveLocal.bind(this) : this._resolveGlobal.bind(this);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/doctor/ngrok/ExternalModule.ts"],"sourcesContent":["import * as PackageManager from '@expo/package-manager';\nimport resolveFrom from 'resolve-from';\nimport semver from 'semver';\n\nimport * as Log from '../../../log';\nimport { delayAsync } from '../../../utils/delay';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { confirmAsync } from '../../../utils/prompts';\nimport { resolveGlobal } from '../../../utils/resolveGlobal';\n\nconst debug = require('debug')('expo:doctor:externalModule') as typeof console.log;\n\n/** An error that is thrown when a package is installed but doesn't meet the version criteria. */\nexport class ExternalModuleVersionError extends CommandError {\n constructor(\n message: string,\n public readonly shouldGloballyInstall: boolean\n ) {\n super('EXTERNAL_MODULE_VERSION', message);\n }\n}\n\ninterface PromptOptions {\n /** Should prompt the user to install, when false the module will just assert on missing packages, default `true`. Ignored when `autoInstall` is true. */\n shouldPrompt?: boolean;\n /** Should automatically install the package without prompting, default `false` */\n autoInstall?: boolean;\n}\n\nexport interface InstallPromptOptions extends PromptOptions {\n /** Should install the package globally, default `false` */\n shouldGloballyInstall?: boolean;\n}\n\nexport interface ResolvePromptOptions extends PromptOptions {\n /**\n * Prefer to install the package globally, this can be overridden if the function\n * detects that a locally installed package simply needs an upgrade, default `false`\n */\n prefersGlobalInstall?: boolean;\n}\n\n/** Resolves a local or globally installed package, prompts to install if missing. */\nexport class ExternalModule<TModule> {\n private instance: TModule | null = null;\n\n constructor(\n /** Project root for checking if the package is installed locally. */\n private projectRoot: string,\n /** Info on the external package. */\n private pkg: {\n /** NPM package name. */\n name: string;\n /** Required semver range, ex: `^1.0.0`. */\n versionRange: string;\n },\n /** A function used to create the installation prompt message. */\n private promptMessage: (pkgName: string) => string\n ) {}\n\n /** Resolve the globally or locally installed instance, or prompt to install. */\n async resolveAsync({\n prefersGlobalInstall,\n ...options\n }: ResolvePromptOptions = {}): Promise<TModule> {\n try {\n return (\n this.getVersioned() ??\n this.installAsync({\n ...options,\n shouldGloballyInstall: prefersGlobalInstall,\n })\n );\n } catch (error: any) {\n if (error instanceof ExternalModuleVersionError) {\n // If the module version in not compliant with the version range,\n // we should prompt the user to install the package where it already exists.\n return this.installAsync({\n ...options,\n shouldGloballyInstall: error.shouldGloballyInstall ?? prefersGlobalInstall,\n });\n }\n throw error;\n }\n }\n\n /** Prompt the user to install the package and try again. */\n async installAsync({\n shouldPrompt = true,\n autoInstall,\n shouldGloballyInstall,\n }: InstallPromptOptions = {}): Promise<TModule> {\n const packageName = [this.pkg.name, this.pkg.versionRange].join('@');\n if (!autoInstall) {\n // Delay the prompt so it doesn't conflict with other dev tool logs\n await delayAsync(100);\n }\n const answer =\n autoInstall ||\n (shouldPrompt &&\n (await confirmAsync({\n message: this.promptMessage(packageName),\n initial: true,\n })));\n if (answer) {\n Log.log(`Installing ${packageName}...`);\n\n // Always use npm for global installs\n const packageManager = shouldGloballyInstall\n ? new PackageManager.NpmPackageManager({\n cwd: this.projectRoot,\n log: Log.log,\n silent: !(env.EXPO_DEBUG || env.CI),\n })\n : PackageManager.createForProject(this.projectRoot, {\n silent: !(env.EXPO_DEBUG || env.CI),\n });\n\n try {\n if (shouldGloballyInstall) {\n await packageManager.addGlobalAsync([packageName]);\n } else {\n await packageManager.addDevAsync([packageName]);\n }\n Log.log(`Installed ${packageName}`);\n } catch (error: any) {\n error.message = `Failed to install ${packageName} ${\n shouldGloballyInstall ? 'globally' : 'locally'\n }: ${error.message}`;\n throw error;\n }\n return await this.resolveAsync({ shouldPrompt: false });\n }\n\n throw new CommandError('EXTERNAL_MODULE_AVAILABILITY', `Install ${packageName} and try again`);\n }\n\n /** Get the module. */\n get(): TModule | null {\n try {\n return this.getVersioned();\n } catch {\n return null;\n }\n }\n\n /** Get the module, throws if the module is not versioned correctly. */\n getVersioned(): TModule | null {\n this.instance ??= this._resolveModule(true) ?? this._resolveModule(false);\n return this.instance;\n }\n\n /** Exposed for testing. */\n _require(moduleId: string): any {\n return require(moduleId);\n }\n\n /** Resolve a copy that's installed in the project. Exposed for testing. */\n _resolveLocal(moduleId: string): string {\n return resolveFrom(this.projectRoot, moduleId);\n }\n\n /** Resolve a copy that's installed globally. Exposed for testing. */\n _resolveGlobal(moduleId: string): string {\n return resolveGlobal(moduleId);\n }\n\n /** Resolve the module and verify the version. Exposed for testing. */\n _resolveModule(isLocal: boolean): TModule | null {\n const resolver = isLocal ? this._resolveLocal.bind(this) : this._resolveGlobal.bind(this);\n try {\n const packageJsonPath = resolver(`${this.pkg.name}/package.json`);\n const packageJson = this._require(packageJsonPath);\n if (packageJson) {\n if (semver.satisfies(packageJson.version, this.pkg.versionRange)) {\n const modulePath = resolver(this.pkg.name);\n const requiredModule = this._require(modulePath);\n if (requiredModule == null) {\n throw new CommandError(\n 'EXTERNAL_MODULE_EXPORT',\n `${this.pkg.name} exports a nullish value, which is not allowed.`\n );\n }\n return requiredModule;\n }\n throw new ExternalModuleVersionError(\n `Required module '${this.pkg.name}@${packageJson.version}' does not satisfy ${this.pkg.versionRange}. Installed at: ${packageJsonPath}`,\n !isLocal\n );\n }\n } catch (error: any) {\n if (error instanceof CommandError) {\n throw error;\n } else if (error.code !== 'MODULE_NOT_FOUND') {\n debug('Failed to resolve module', error.message);\n }\n }\n return null;\n }\n}\n"],"names":["ExternalModule","ExternalModuleVersionError","debug","require","CommandError","constructor","message","shouldGloballyInstall","projectRoot","pkg","promptMessage","instance","resolveAsync","prefersGlobalInstall","options","getVersioned","installAsync","error","shouldPrompt","autoInstall","packageName","name","versionRange","join","delayAsync","answer","confirmAsync","initial","Log","log","packageManager","PackageManager","NpmPackageManager","cwd","silent","env","EXPO_DEBUG","CI","createForProject","addGlobalAsync","addDevAsync","get","_resolveModule","_require","moduleId","_resolveLocal","resolveFrom","_resolveGlobal","resolveGlobal","isLocal","resolver","bind","packageJsonPath","packageJson","semver","satisfies","version","modulePath","requiredModule","code"],"mappings":";;;;;;;;;;;IA4CaA,cAAc;eAAdA;;IA9BAC,0BAA0B;eAA1BA;;;;iEAdmB;;;;;;;gEACR;;;;;;;gEACL;;;;;;6DAEE;uBACM;qBACP;wBACS;yBACA;+BACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9B,MAAMC,QAAQC,QAAQ,SAAS;AAGxB,MAAMF,mCAAmCG,oBAAY;IAC1DC,YACEC,OAAe,EACf,AAAgBC,qBAA8B,CAC9C;QACA,KAAK,CAAC,2BAA2BD,eAFjBC,wBAAAA;IAGlB;AACF;AAuBO,MAAMP;IAGXK,YACE,mEAAmE,GACnE,AAAQG,WAAmB,EAC3B,kCAAkC,GAClC,AAAQC,GAKP,EACD,+DAA+D,GAC/D,AAAQC,aAA0C,CAClD;aAVQF,cAAAA;aAEAC,MAAAA;aAOAC,gBAAAA;aAbFC,WAA2B;IAchC;IAEH,8EAA8E,GAC9E,MAAMC,aAAa,EACjBC,oBAAoB,EACpB,GAAGC,SACkB,GAAG,CAAC,CAAC,EAAoB;QAC9C,IAAI;YACF,OACE,IAAI,CAACC,YAAY,MACjB,IAAI,CAACC,YAAY,CAAC;gBAChB,GAAGF,OAAO;gBAC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gC,cAAc,IAAI,CAACV,QAAQ,CAACS;YAClC,IAAIC,aAAa;gBACf,IAAIC,iBAAM,CAACC,SAAS,CAACF,YAAYG,OAAO,EAAE,IAAI,CAAC/C,GAAG,CAACa,YAAY,GAAG;oBAChE,MAAMmC,aAAaP,SAAS,IAAI,CAACzC,GAAG,CAACY,IAAI;oBACzC,MAAMqC,iBAAiB,IAAI,CAACf,QAAQ,CAACc;oBACrC,IAAIC,kBAAkB,MAAM;wBAC1B,MAAM,IAAItD,oBAAY,CACpB,0BACA,GAAG,IAAI,CAACK,GAAG,CAACY,IAAI,CAAC,+CAA+C,CAAC;oBAErE;oBACA,OAAOqC;gBACT;gBACA,MAAM,IAAIzD,2BACR,CAAC,iBAAiB,EAAE,IAAI,CAACQ,GAAG,CAACY,IAAI,CAAC,CAAC,EAAEgC,YAAYG,OAAO,CAAC,mBAAmB,EAAE,IAAI,CAAC/C,GAAG,CAACa,YAAY,CAAC,gBAAgB,EAAE8B,iBAAiB,EACvI,CAACH;YAEL;QACF,EAAE,OAAOhC,OAAY;YACnB,IAAIA,iBAAiBb,oBAAY,EAAE;gBACjC,MAAMa;YACR,OAAO,IAAIA,MAAM0C,IAAI,KAAK,oBAAoB;gBAC5CzD,MAAM,4BAA4Be,MAAMX,OAAO;YACjD;QACF;QACA,OAAO;IACT;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/doctor/ngrok/ExternalModule.ts"],"sourcesContent":["import * as PackageManager from '@expo/package-manager';\nimport { resolveFrom, resolveGlobal } from '@expo/require-utils';\nimport semver from 'semver';\n\nimport * as Log from '../../../log';\nimport { delayAsync } from '../../../utils/delay';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { confirmAsync } from '../../../utils/prompts';\n\nconst debug = require('debug')('expo:doctor:externalModule') as typeof console.log;\n\n/** An error that is thrown when a package is installed but doesn't meet the version criteria. */\nexport class ExternalModuleVersionError extends CommandError {\n constructor(\n message: string,\n public readonly shouldGloballyInstall: boolean\n ) {\n super('EXTERNAL_MODULE_VERSION', message);\n }\n}\n\ninterface PromptOptions {\n /** Should prompt the user to install, when false the module will just assert on missing packages, default `true`. Ignored when `autoInstall` is true. */\n shouldPrompt?: boolean;\n /** Should automatically install the package without prompting, default `false` */\n autoInstall?: boolean;\n}\n\nexport interface InstallPromptOptions extends PromptOptions {\n /** Should install the package globally, default `false` */\n shouldGloballyInstall?: boolean;\n}\n\nexport interface ResolvePromptOptions extends PromptOptions {\n /**\n * Prefer to install the package globally, this can be overridden if the function\n * detects that a locally installed package simply needs an upgrade, default `false`\n */\n prefersGlobalInstall?: boolean;\n}\n\n/** Resolves a local or globally installed package, prompts to install if missing. */\nexport class ExternalModule<TModule> {\n private instance: TModule | null = null;\n\n constructor(\n /** Project root for checking if the package is installed locally. */\n private projectRoot: string,\n /** Info on the external package. */\n private pkg: {\n /** NPM package name. */\n name: string;\n /** Required semver range, ex: `^1.0.0`. */\n versionRange: string;\n },\n /** A function used to create the installation prompt message. */\n private promptMessage: (pkgName: string) => string\n ) {}\n\n /** Resolve the globally or locally installed instance, or prompt to install. */\n async resolveAsync({\n prefersGlobalInstall,\n ...options\n }: ResolvePromptOptions = {}): Promise<TModule> {\n try {\n return (\n this.getVersioned() ??\n this.installAsync({\n ...options,\n shouldGloballyInstall: prefersGlobalInstall,\n })\n );\n } catch (error: any) {\n if (error instanceof ExternalModuleVersionError) {\n // If the module version in not compliant with the version range,\n // we should prompt the user to install the package where it already exists.\n return this.installAsync({\n ...options,\n shouldGloballyInstall: error.shouldGloballyInstall ?? prefersGlobalInstall,\n });\n }\n throw error;\n }\n }\n\n /** Prompt the user to install the package and try again. */\n async installAsync({\n shouldPrompt = true,\n autoInstall,\n shouldGloballyInstall,\n }: InstallPromptOptions = {}): Promise<TModule> {\n const packageName = [this.pkg.name, this.pkg.versionRange].join('@');\n if (!autoInstall) {\n // Delay the prompt so it doesn't conflict with other dev tool logs\n await delayAsync(100);\n }\n const answer =\n autoInstall ||\n (shouldPrompt &&\n (await confirmAsync({\n message: this.promptMessage(packageName),\n initial: true,\n })));\n if (answer) {\n Log.log(`Installing ${packageName}...`);\n\n // Always use npm for global installs\n const packageManager = shouldGloballyInstall\n ? new PackageManager.NpmPackageManager({\n cwd: this.projectRoot,\n log: Log.log,\n silent: !(env.EXPO_DEBUG || env.CI),\n })\n : PackageManager.createForProject(this.projectRoot, {\n silent: !(env.EXPO_DEBUG || env.CI),\n });\n\n try {\n if (shouldGloballyInstall) {\n await packageManager.addGlobalAsync([packageName]);\n } else {\n await packageManager.addDevAsync([packageName]);\n }\n Log.log(`Installed ${packageName}`);\n } catch (error: any) {\n error.message = `Failed to install ${packageName} ${\n shouldGloballyInstall ? 'globally' : 'locally'\n }: ${error.message}`;\n throw error;\n }\n return await this.resolveAsync({ shouldPrompt: false });\n }\n\n throw new CommandError('EXTERNAL_MODULE_AVAILABILITY', `Install ${packageName} and try again`);\n }\n\n /** Get the module. */\n get(): TModule | null {\n try {\n return this.getVersioned();\n } catch {\n return null;\n }\n }\n\n /** Get the module, throws if the module is not versioned correctly. */\n getVersioned(): TModule | null {\n this.instance ??= this._resolveModule(true) ?? this._resolveModule(false);\n return this.instance;\n }\n\n /** Exposed for testing. */\n _require(moduleId: string): any {\n return require(moduleId);\n }\n\n /** Resolve a copy that's installed in the project. Exposed for testing. */\n _resolveLocal(moduleId: string): string {\n const target = resolveFrom(this.projectRoot, moduleId);\n if (!target) {\n throw Object.assign(new Error(`Module \"${moduleId}\" could not be resolved in the project.`), {\n code: 'MODULE_NOT_FOUND',\n });\n }\n return target;\n }\n\n /** Resolve a copy that's installed globally. Exposed for testing. */\n _resolveGlobal(moduleId: string): string {\n return resolveGlobal(moduleId);\n }\n\n /** Resolve the module and verify the version. Exposed for testing. */\n _resolveModule(isLocal: boolean): TModule | null {\n const resolver = isLocal ? this._resolveLocal.bind(this) : this._resolveGlobal.bind(this);\n try {\n const packageJsonPath = resolver(`${this.pkg.name}/package.json`);\n const packageJson = this._require(packageJsonPath);\n if (packageJson) {\n if (semver.satisfies(packageJson.version, this.pkg.versionRange)) {\n const modulePath = resolver(this.pkg.name);\n const requiredModule = this._require(modulePath);\n if (requiredModule == null) {\n throw new CommandError(\n 'EXTERNAL_MODULE_EXPORT',\n `${this.pkg.name} exports a nullish value, which is not allowed.`\n );\n }\n return requiredModule;\n }\n throw new ExternalModuleVersionError(\n `Required module '${this.pkg.name}@${packageJson.version}' does not satisfy ${this.pkg.versionRange}. Installed at: ${packageJsonPath}`,\n !isLocal\n );\n }\n } catch (error: any) {\n if (error instanceof CommandError) {\n throw error;\n } else if (error.code !== 'MODULE_NOT_FOUND') {\n debug('Failed to resolve module', error.message);\n }\n }\n return null;\n }\n}\n"],"names":["ExternalModule","ExternalModuleVersionError","debug","require","CommandError","constructor","message","shouldGloballyInstall","projectRoot","pkg","promptMessage","instance","resolveAsync","prefersGlobalInstall","options","getVersioned","installAsync","error","shouldPrompt","autoInstall","packageName","name","versionRange","join","delayAsync","answer","confirmAsync","initial","Log","log","packageManager","PackageManager","NpmPackageManager","cwd","silent","env","EXPO_DEBUG","CI","createForProject","addGlobalAsync","addDevAsync","get","_resolveModule","_require","moduleId","_resolveLocal","target","resolveFrom","Object","assign","Error","code","_resolveGlobal","resolveGlobal","isLocal","resolver","bind","packageJsonPath","packageJson","semver","satisfies","version","modulePath","requiredModule"],"mappings":";;;;;;;;;;;IA2CaA,cAAc;eAAdA;;IA9BAC,0BAA0B;eAA1BA;;;;iEAbmB;;;;;;;yBACW;;;;;;;gEACxB;;;;;;6DAEE;uBACM;qBACP;wBACS;yBACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE7B,MAAMC,QAAQC,QAAQ,SAAS;AAGxB,MAAMF,mCAAmCG,oBAAY;IAC1DC,YACEC,OAAe,EACf,AAAgBC,qBAA8B,CAC9C;QACA,KAAK,CAAC,2BAA2BD,eAFjBC,wBAAAA;IAGlB;AACF;AAuBO,MAAMP;IAGXK,YACE,mE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AAIA,MAAMkC,IAAI,KAAK,oBAAoB;gBAC5CjD,MAAM,4BAA4Be,MAAMX,OAAO;YACjD;QACF;QACA,OAAO;IACT;AACF"}
|
|
@@ -124,7 +124,6 @@ const _DomComponentsMiddleware = require("../middleware/DomComponentsMiddleware"
|
|
|
124
124
|
const _FaviconMiddleware = require("../middleware/FaviconMiddleware");
|
|
125
125
|
const _HistoryFallbackMiddleware = require("../middleware/HistoryFallbackMiddleware");
|
|
126
126
|
const _InterstitialPageMiddleware = require("../middleware/InterstitialPageMiddleware");
|
|
127
|
-
const _ManifestMiddleware = require("../middleware/ManifestMiddleware");
|
|
128
127
|
const _RuntimeRedirectMiddleware = require("../middleware/RuntimeRedirectMiddleware");
|
|
129
128
|
const _ServeStaticMiddleware = require("../middleware/ServeStaticMiddleware");
|
|
130
129
|
const _metroOptions = require("../middleware/metroOptions");
|
|
@@ -429,7 +428,7 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
|
|
|
429
428
|
async getStaticResourcesAsync({ includeSourceMaps, mainModuleName, clientBoundaries = this.instanceMetroOptions.clientBoundaries ?? [], platform = 'web' } = {}) {
|
|
430
429
|
const { mode, minify, isExporting, baseUrl, reactCompiler, routerRoot, asyncRoutes } = this.instanceMetroOptions;
|
|
431
430
|
(0, _assert().default)(mode != null && isExporting != null && baseUrl != null && routerRoot != null && reactCompiler != null && asyncRoutes != null, 'The server must be started before calling getStaticResourcesAsync.');
|
|
432
|
-
const resolvedMainModuleName = mainModuleName ?? './' + (0,
|
|
431
|
+
const resolvedMainModuleName = mainModuleName ?? './' + (0, _paths().resolveRelativeEntryPoint)(this.projectRoot, {
|
|
433
432
|
platform
|
|
434
433
|
});
|
|
435
434
|
return await this.metroImportAsArtifactsAsync(resolvedMainModuleName, {
|
|
@@ -463,7 +462,7 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
|
|
|
463
462
|
mode,
|
|
464
463
|
environment: 'client',
|
|
465
464
|
reactCompiler,
|
|
466
|
-
mainModuleName: (0,
|
|
465
|
+
mainModuleName: (0, _paths().resolveRelativeEntryPoint)(this.projectRoot, {
|
|
467
466
|
platform
|
|
468
467
|
}),
|
|
469
468
|
lazy: !_env.env.EXPO_NO_METRO_LAZY,
|
|
@@ -881,6 +880,7 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
|
|
|
881
880
|
// Required for symbolication:
|
|
882
881
|
process.env.EXPO_DEV_SERVER_ORIGIN = `${protocol}://localhost:${options.port}`;
|
|
883
882
|
if (!options.isExporting) {
|
|
883
|
+
var _metro__config_server, _metro__config;
|
|
884
884
|
const manifestMiddleware = await this.getManifestMiddlewareAsync(options);
|
|
885
885
|
// Important that we noop source maps for context modules as soon as possible.
|
|
886
886
|
(0, _mutations.prependMiddleware)(middleware, new _ContextModuleSourceMapsMiddleware.ContextModuleSourceMapsMiddleware().getHandler());
|
|
@@ -910,14 +910,14 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
|
|
|
910
910
|
}
|
|
911
911
|
});
|
|
912
912
|
middleware.use(deepLinkMiddleware.getHandler());
|
|
913
|
-
const serverRoot = (0, _paths().getMetroServerRoot)(this.projectRoot);
|
|
914
913
|
const domComponentRenderer = (0, _DomComponentsMiddleware.createDomComponentsMiddleware)({
|
|
915
|
-
metroRoot: serverRoot,
|
|
916
914
|
projectRoot: this.projectRoot
|
|
917
915
|
}, instanceMetroOptions);
|
|
918
916
|
// Add support for DOM components.
|
|
919
917
|
// TODO: Maybe put behind a flag for now?
|
|
920
918
|
middleware.use(domComponentRenderer);
|
|
919
|
+
// NOTE: Optional is to accommodate mocks in tests
|
|
920
|
+
const serverRoot = ((_metro__config = metro._config) == null ? void 0 : (_metro__config_server = _metro__config.server) == null ? void 0 : _metro__config_server.unstable_serverRoot) ?? this.projectRoot;
|
|
921
921
|
middleware.use(new _CreateFileMiddleware.CreateFileMiddleware({
|
|
922
922
|
metroRoot: serverRoot,
|
|
923
923
|
projectRoot: this.projectRoot,
|
|
@@ -1624,7 +1624,7 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
|
|
|
1624
1624
|
extras.hot && this.instanceMetroOptions.isExporting !== true) {
|
|
1625
1625
|
// Register SSR HMR
|
|
1626
1626
|
const serverRoot = (0, _paths().getMetroServerRoot)(this.projectRoot);
|
|
1627
|
-
const relativePath = _path().default.relative(serverRoot, res.filename);
|
|
1627
|
+
const relativePath = (0, _filePath.toPosixPath)(_path().default.relative(serverRoot, res.filename));
|
|
1628
1628
|
const url = new URL(relativePath, this.getDevServerUrlOrAssert());
|
|
1629
1629
|
this.setupHmr(url);
|
|
1630
1630
|
}
|