@expo/cli 0.18.18 → 0.18.19
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/export/createMetadataJson.js.map +1 -1
- package/build/src/export/embed/exportEmbedAsync.js +41 -110
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/export/embed/resolveOptions.js +1 -0
- package/build/src/export/embed/resolveOptions.js.map +1 -1
- package/build/src/export/exportApp.js +92 -130
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportAssets.js.map +1 -1
- package/build/src/export/exportHermes.js +0 -15
- package/build/src/export/exportHermes.js.map +1 -1
- package/build/src/export/exportStaticAsync.js +48 -3
- package/build/src/export/exportStaticAsync.js.map +1 -1
- package/build/src/export/fork-bundleAsync.js +284 -0
- package/build/src/export/fork-bundleAsync.js.map +1 -0
- package/build/src/export/saveAssets.js.map +1 -1
- package/build/src/run/startBundler.js +8 -1
- package/build/src/run/startBundler.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +2 -9
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +1 -13
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/getStaticRenderFunctions.js +123 -9
- package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +102 -391
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/createServerRouteMiddleware.js +9 -0
- package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +12 -19
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/metroErrorInterface.js +2 -49
- package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
- package/build/src/start/server/metro/runServer-fork.js +20 -28
- package/build/src/start/server/metro/runServer-fork.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +9 -8
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +3 -6
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/metroOptions.js +3 -11
- package/build/src/start/server/middleware/metroOptions.js.map +1 -1
- package/build/src/start/server/middleware/resolveAssets.js.map +1 -1
- package/build/src/utils/telemetry/getContext.js +1 -1
- package/package.json +3 -3
- package/build/src/start/server/metro/metroPrivateServer.js +0 -26
- package/build/src/start/server/metro/metroPrivateServer.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/export/exportStaticAsync.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport chalk from 'chalk';\nimport { RouteNode } from 'expo-router/build/Route';\nimport { stripGroupSegmentsFromPath } from 'expo-router/build/matchers';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport { inspect } from 'util';\n\nimport { getVirtualFaviconAssetsAsync } from './favicon';\nimport { persistMetroAssetsAsync } from './persistMetroAssets';\nimport { ExportAssetMap, getFilesFromSerialAssets } from './saveAssets';\nimport { Log } from '../log';\nimport {\n ExpoRouterRuntimeManifest,\n MetroBundlerDevServer,\n} from '../start/server/metro/MetroBundlerDevServer';\nimport { ExpoRouterServerManifestV1 } from '../start/server/metro/fetchRouterManifest';\nimport { logMetroErrorAsync } from '../start/server/metro/metroErrorInterface';\nimport { getApiRoutesForDirectory } from '../start/server/metro/router';\nimport { serializeHtmlWithAssets } from '../start/server/metro/serializeHtml';\nimport { learnMore } from '../utils/link';\n\nconst debug = require('debug')('expo:export:generateStaticRoutes') as typeof console.log;\n\ntype Options = {\n mode: 'production' | 'development';\n files?: ExportAssetMap;\n outputDir: string;\n minify: boolean;\n exportServer: boolean;\n baseUrl: string;\n includeSourceMaps: boolean;\n entryPoint?: string;\n clear: boolean;\n routerRoot: string;\n reactCompiler: boolean;\n maxWorkers?: number;\n isExporting: boolean;\n};\n\ntype HtmlRequestLocation = {\n /** The output file path name to use relative to the static folder. */\n filePath: string;\n /** The pathname to make requests to in order to fetch the HTML. */\n pathname: string;\n /** The runtime route node object, used to associate async modules with the static HTML. */\n route: RouteNode;\n};\n\n/** Match `(page)` -> `page` */\nfunction matchGroupName(name: string): string | undefined {\n return name.match(/^\\(([^/]+?)\\)$/)?.[1];\n}\n\nexport async function getFilesToExportFromServerAsync(\n projectRoot: string,\n {\n manifest,\n renderAsync,\n // Servers can handle group routes automatically and therefore\n // don't require the build-time generation of every possible group\n // variation.\n exportServer,\n // name : contents\n files = new Map(),\n }: {\n manifest: ExpoRouterRuntimeManifest;\n renderAsync: (requestLocation: HtmlRequestLocation) => Promise<string>;\n exportServer?: boolean;\n files?: ExportAssetMap;\n }\n): Promise<ExportAssetMap> {\n await Promise.all(\n getHtmlFiles({ manifest, includeGroupVariations: !exportServer }).map(\n async ({ route, filePath, pathname }) => {\n try {\n const targetDomain = exportServer ? 'server' : 'client';\n files.set(filePath, { contents: '', targetDomain });\n const data = await renderAsync({ route, filePath, pathname });\n files.set(filePath, {\n contents: data,\n routeId: pathname,\n targetDomain,\n });\n } catch (e: any) {\n await logMetroErrorAsync({ error: e, projectRoot });\n throw new Error('Failed to statically export route: ' + pathname);\n }\n }\n )\n );\n\n return files;\n}\n\nfunction modifyRouteNodeInRuntimeManifest(\n manifest: ExpoRouterRuntimeManifest,\n callback: (route: RouteNode) => any\n) {\n const iterateScreens = (screens: ExpoRouterRuntimeManifest['screens']) => {\n Object.values(screens).map((value) => {\n if (typeof value !== 'string') {\n if (value._route) callback(value._route);\n iterateScreens(value.screens);\n }\n });\n };\n\n iterateScreens(manifest.screens);\n}\n\n// TODO: Do this earlier in the process.\nfunction makeRuntimeEntryPointsAbsolute(manifest: ExpoRouterRuntimeManifest, appDir: string) {\n modifyRouteNodeInRuntimeManifest(manifest, (route) => {\n if (Array.isArray(route.entryPoints)) {\n route.entryPoints = route.entryPoints.map((entryPoint) => {\n if (entryPoint.startsWith('.')) {\n return path.resolve(appDir, entryPoint);\n } else if (!path.isAbsolute(entryPoint)) {\n return resolveFrom(appDir, entryPoint);\n }\n return entryPoint;\n });\n }\n });\n}\n\n/** Perform all fs commits */\nexport async function exportFromServerAsync(\n projectRoot: string,\n devServer: MetroBundlerDevServer,\n { outputDir, baseUrl, exportServer, includeSourceMaps, routerRoot, files = new Map() }: Options\n): Promise<ExportAssetMap> {\n Log.log(\n `Static rendering is enabled. ` +\n learnMore('https://docs.expo.dev/router/reference/static-rendering/')\n );\n\n const platform = 'web';\n const isExporting = true;\n const appDir = path.join(projectRoot, routerRoot);\n const injectFaviconTag = await getVirtualFaviconAssetsAsync(projectRoot, {\n outputDir,\n baseUrl,\n files,\n });\n\n const [resources, { manifest, serverManifest, renderAsync }] = await Promise.all([\n devServer.getStaticResourcesAsync({\n includeSourceMaps,\n }),\n devServer.getStaticRenderFunctionAsync(),\n ]);\n\n makeRuntimeEntryPointsAbsolute(manifest, appDir);\n\n debug('Routes:\\n', inspect(manifest, { colors: true, depth: null }));\n\n await getFilesToExportFromServerAsync(projectRoot, {\n files,\n manifest,\n exportServer,\n async renderAsync({ pathname, route }) {\n const template = await renderAsync(pathname);\n let html = await serializeHtmlWithAssets({\n isExporting,\n resources: resources.artifacts,\n template,\n baseUrl,\n route,\n });\n\n if (injectFaviconTag) {\n html = injectFaviconTag(html);\n }\n\n return html;\n },\n });\n\n getFilesFromSerialAssets(resources.artifacts, {\n platform,\n includeSourceMaps,\n files,\n });\n\n if (resources.assets) {\n // TODO: Collect files without writing to disk.\n // NOTE(kitten): Re. above, this is now using `files` except for iOS catalog output, which isn't used here\n await persistMetroAssetsAsync(resources.assets, {\n files,\n platform,\n outputDirectory: outputDir,\n baseUrl,\n });\n }\n\n if (exportServer) {\n const apiRoutes = await exportApiRoutesAsync({\n outputDir,\n server: devServer,\n manifest: serverManifest,\n // NOTE(kitten): For now, we always output source maps for API route exports\n includeSourceMaps: true,\n });\n\n // Add the api routes to the files to export.\n for (const [route, contents] of apiRoutes) {\n files.set(route, contents);\n }\n } else {\n warnPossibleInvalidExportType(appDir);\n }\n\n return files;\n}\n\nexport function getHtmlFiles({\n manifest,\n includeGroupVariations,\n}: {\n manifest: ExpoRouterRuntimeManifest;\n includeGroupVariations?: boolean;\n}): HtmlRequestLocation[] {\n const htmlFiles = new Set<Omit<HtmlRequestLocation, 'pathname'>>();\n\n function traverseScreens(\n screens: ExpoRouterRuntimeManifest['screens'],\n route: RouteNode | null,\n baseUrl = ''\n ) {\n for (const value of Object.values(screens)) {\n let leaf: string | null = null;\n if (typeof value === 'string') {\n leaf = value;\n } else if (Object.keys(value.screens).length === 0) {\n leaf = value.path;\n route = value._route ?? null;\n }\n\n if (leaf != null) {\n let filePath = baseUrl + leaf;\n\n if (leaf === '') {\n filePath =\n baseUrl === ''\n ? 'index'\n : baseUrl.endsWith('/')\n ? baseUrl + 'index'\n : baseUrl.slice(0, -1);\n } else if (\n // If the path is a collection of group segments leading to an index route, append `/index`.\n stripGroupSegmentsFromPath(filePath) === ''\n ) {\n filePath += '/index';\n }\n\n // This should never happen, the type of `string | object` originally comes from React Navigation.\n if (!route) {\n throw new Error(\n `Internal error: Route not found for \"${filePath}\" while collecting static export paths.`\n );\n }\n\n if (includeGroupVariations) {\n // TODO: Dedupe requests for alias routes.\n addOptionalGroups(filePath, route);\n } else {\n htmlFiles.add({\n filePath,\n route,\n });\n }\n } else if (typeof value === 'object' && value?.screens) {\n const newPath = baseUrl + value.path + '/';\n traverseScreens(value.screens, value._route ?? null, newPath);\n }\n }\n }\n\n function addOptionalGroups(path: string, route: RouteNode) {\n const variations = getPathVariations(path);\n for (const variation of variations) {\n htmlFiles.add({ filePath: variation, route });\n }\n }\n\n traverseScreens(manifest.screens, null);\n\n return uniqueBy(Array.from(htmlFiles), (value) => value.filePath).map((value) => {\n const parts = value.filePath.split('/');\n // Replace `:foo` with `[foo]` and `*foo` with `[...foo]`\n const partsWithGroups = parts.map((part) => {\n if (part === '*not-found') {\n return `+not-found`;\n } else if (part.startsWith(':')) {\n return `[${part.slice(1)}]`;\n } else if (part.startsWith('*')) {\n return `[...${part.slice(1)}]`;\n }\n return part;\n });\n const filePathLocation = partsWithGroups.join('/');\n const filePath = filePathLocation + '.html';\n return {\n ...value,\n filePath,\n pathname: filePathLocation.replace(/(\\/?index)?$/, ''),\n };\n });\n}\n\nfunction uniqueBy<T>(array: T[], key: (value: T) => string): T[] {\n const seen = new Set<string>();\n const result: T[] = [];\n for (const value of array) {\n const id = key(value);\n if (!seen.has(id)) {\n seen.add(id);\n result.push(value);\n }\n }\n return result;\n}\n\n// Given a route like `(foo)/bar/(baz)`, return all possible variations of the route.\n// e.g. `(foo)/bar/(baz)`, `(foo)/bar/baz`, `foo/bar/(baz)`, `foo/bar/baz`,\nexport function getPathVariations(routePath: string): string[] {\n const variations = new Set<string>();\n const segments = routePath.split('/');\n\n function generateVariations(segments: string[], current = ''): void {\n if (segments.length === 0) {\n if (current) variations.add(current);\n return;\n }\n\n const [head, ...rest] = segments;\n\n if (matchGroupName(head)) {\n const groups = head.slice(1, -1).split(',');\n\n if (groups.length > 1) {\n for (const group of groups) {\n // If there are multiple groups, recurse on each group.\n generateVariations([`(${group.trim()})`, ...rest], current);\n }\n return;\n } else {\n // Start a fork where this group is included\n generateVariations(rest, current ? `${current}/(${groups[0]})` : `(${groups[0]})`);\n // This code will continue and add paths without this group included`\n }\n } else if (current) {\n current = `${current}/${head}`;\n } else {\n current = head;\n }\n\n generateVariations(rest, current);\n }\n\n generateVariations(segments);\n\n return Array.from(variations);\n}\n\nasync function exportApiRoutesAsync({\n includeSourceMaps,\n outputDir,\n server,\n ...props\n}: Pick<Options, 'outputDir' | 'includeSourceMaps'> & {\n server: MetroBundlerDevServer;\n manifest: ExpoRouterServerManifestV1;\n}): Promise<ExportAssetMap> {\n const { manifest, files } = await server.exportExpoRouterApiRoutesAsync({\n outputDir: '_expo/functions',\n prerenderManifest: props.manifest,\n includeSourceMaps,\n });\n\n Log.log(chalk.bold`Exporting ${files.size} API Routes.`);\n\n files.set('_expo/routes.json', {\n contents: JSON.stringify(manifest, null, 2),\n targetDomain: 'server',\n });\n\n return files;\n}\n\nfunction warnPossibleInvalidExportType(appDir: string) {\n const apiRoutes = getApiRoutesForDirectory(appDir);\n if (apiRoutes.length) {\n // TODO: Allow API Routes for native-only.\n Log.warn(\n chalk.yellow`Skipping export for API routes because \\`web.output\\` is not \"server\". You may want to remove the routes: ${apiRoutes\n .map((v) => path.relative(appDir, v))\n .join(', ')}`\n );\n }\n}\n"],"names":["getFilesToExportFromServerAsync","exportFromServerAsync","getHtmlFiles","getPathVariations","debug","require","matchGroupName","name","match","projectRoot","manifest","renderAsync","exportServer","files","Map","Promise","all","includeGroupVariations","map","route","filePath","pathname","targetDomain","set","contents","data","routeId","e","logMetroErrorAsync","error","Error","modifyRouteNodeInRuntimeManifest","callback","iterateScreens","screens","Object","values","value","_route","makeRuntimeEntryPointsAbsolute","appDir","Array","isArray","entryPoints","entryPoint","startsWith","path","resolve","isAbsolute","resolveFrom","devServer","outputDir","baseUrl","includeSourceMaps","routerRoot","Log","log","learnMore","platform","isExporting","join","injectFaviconTag","getVirtualFaviconAssetsAsync","resources","serverManifest","getStaticResourcesAsync","getStaticRenderFunctionAsync","inspect","colors","depth","template","html","serializeHtmlWithAssets","artifacts","getFilesFromSerialAssets","assets","persistMetroAssetsAsync","outputDirectory","apiRoutes","exportApiRoutesAsync","server","warnPossibleInvalidExportType","htmlFiles","Set","traverseScreens","leaf","keys","length","endsWith","slice","stripGroupSegmentsFromPath","addOptionalGroups","add","newPath","variations","variation","uniqueBy","from","parts","split","partsWithGroups","part","filePathLocation","replace","array","key","seen","result","id","has","push","routePath","segments","generateVariations","current","head","rest","groups","group","trim","props","exportExpoRouterApiRoutesAsync","prerenderManifest","chalk","bold","size","JSON","stringify","getApiRoutesForDirectory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iB,EAAEF,KAAK,CAAC9G,QAAQ;QACjC2C,iBAAiB;KAClB,CAAC,AAAC;IAEHE,IAAG,IAAA,CAACC,GAAG,CAACmE,MAAK,EAAA,QAAA,CAACC,IAAI,CAAC,UAAU,EAAE/G,KAAK,CAACgH,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAEzDhH,KAAK,CAACU,GAAG,CAAC,mBAAmB,EAAE;QAC7BC,QAAQ,EAAEsG,IAAI,CAACC,SAAS,CAACrH,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3CY,YAAY,EAAE,QAAQ;KACvB,CAAC,CAAC;IAEH,OAAOT,KAAK,CAAC;AACf,CAAC;AAED,SAASoE,6BAA6B,CAACzC,MAAc,EAAE;IACrD,MAAMsC,SAAS,GAAGkD,IAAAA,OAAwB,yBAAA,EAACxF,MAAM,CAAC,AAAC;IACnD,IAAIsC,SAAS,CAACS,MAAM,EAAE;QACpB,0CAA0C;QAC1ChC,IAAG,IAAA,CAAC0E,IAAI,CACNN,MAAK,EAAA,QAAA,CAACO,MAAM,CAAC,0GAA0G,EAAEpD,SAAS,CAC/H5D,GAAG,CAAC,CAACiH,CAAC,GAAKrF,KAAI,EAAA,QAAA,CAACsF,QAAQ,CAAC5F,MAAM,EAAE2F,CAAC,CAAC,CAAC,CACpCvE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAChB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/export/exportStaticAsync.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport { RouteNode } from 'expo-router/build/Route';\nimport { stripGroupSegmentsFromPath } from 'expo-router/build/matchers';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport { inspect } from 'util';\n\nimport { getVirtualFaviconAssetsAsync } from './favicon';\nimport { persistMetroAssetsAsync } from './persistMetroAssets';\nimport { ExportAssetMap, getFilesFromSerialAssets } from './saveAssets';\nimport { Log } from '../log';\nimport { DevServerManager } from '../start/server/DevServerManager';\nimport {\n ExpoRouterRuntimeManifest,\n MetroBundlerDevServer,\n} from '../start/server/metro/MetroBundlerDevServer';\nimport { ExpoRouterServerManifestV1 } from '../start/server/metro/fetchRouterManifest';\nimport { logMetroErrorAsync } from '../start/server/metro/metroErrorInterface';\nimport { getApiRoutesForDirectory } from '../start/server/metro/router';\nimport { serializeHtmlWithAssets } from '../start/server/metro/serializeHtml';\nimport { learnMore } from '../utils/link';\nimport { getFreePortAsync } from '../utils/port';\n\nconst debug = require('debug')('expo:export:generateStaticRoutes') as typeof console.log;\n\ntype Options = {\n mode: 'production' | 'development';\n files?: ExportAssetMap;\n outputDir: string;\n minify: boolean;\n exportServer: boolean;\n baseUrl: string;\n includeSourceMaps: boolean;\n entryPoint?: string;\n clear: boolean;\n routerRoot: string;\n maxWorkers?: number;\n isExporting: boolean;\n};\n\ntype HtmlRequestLocation = {\n /** The output file path name to use relative to the static folder. */\n filePath: string;\n /** The pathname to make requests to in order to fetch the HTML. */\n pathname: string;\n /** The runtime route node object, used to associate async modules with the static HTML. */\n route: RouteNode;\n};\n\n/** @private */\nexport async function unstable_exportStaticAsync(projectRoot: string, options: Options) {\n Log.log(\n `Static rendering is enabled. ` +\n learnMore('https://docs.expo.dev/router/reference/static-rendering/')\n );\n\n // Useful for running parallel e2e tests in CI.\n const port = await getFreePortAsync(8082);\n\n // TODO: Prevent starting the watcher.\n const devServerManager = new DevServerManager(projectRoot, {\n minify: options.minify,\n mode: options.mode,\n port,\n isExporting: true,\n location: {},\n resetDevServer: options.clear,\n maxWorkers: options.maxWorkers,\n });\n\n await devServerManager.startAsync([\n {\n type: 'metro',\n options: {\n port,\n mode: options.mode,\n location: {},\n isExporting: true,\n minify: options.minify,\n resetDevServer: options.clear,\n maxWorkers: options.maxWorkers,\n },\n },\n ]);\n\n try {\n return await exportFromServerAsync(projectRoot, devServerManager, options);\n } finally {\n await devServerManager.stopAsync();\n }\n}\n\n/** Match `(page)` -> `page` */\nfunction matchGroupName(name: string): string | undefined {\n return name.match(/^\\(([^/]+?)\\)$/)?.[1];\n}\n\nexport async function getFilesToExportFromServerAsync(\n projectRoot: string,\n {\n manifest,\n renderAsync,\n // Servers can handle group routes automatically and therefore\n // don't require the build-time generation of every possible group\n // variation.\n exportServer,\n // name : contents\n files = new Map(),\n }: {\n manifest: ExpoRouterRuntimeManifest;\n renderAsync: (requestLocation: HtmlRequestLocation) => Promise<string>;\n exportServer?: boolean;\n files?: ExportAssetMap;\n }\n): Promise<ExportAssetMap> {\n await Promise.all(\n getHtmlFiles({ manifest, includeGroupVariations: !exportServer }).map(\n async ({ route, filePath, pathname }) => {\n try {\n const targetDomain = exportServer ? 'server' : 'client';\n files.set(filePath, { contents: '', targetDomain });\n const data = await renderAsync({ route, filePath, pathname });\n files.set(filePath, {\n contents: data,\n routeId: pathname,\n targetDomain,\n });\n } catch (e: any) {\n await logMetroErrorAsync({ error: e, projectRoot });\n throw new Error('Failed to statically export route: ' + pathname);\n }\n }\n )\n );\n\n return files;\n}\n\nfunction modifyRouteNodeInRuntimeManifest(\n manifest: ExpoRouterRuntimeManifest,\n callback: (route: RouteNode) => any\n) {\n const iterateScreens = (screens: ExpoRouterRuntimeManifest['screens']) => {\n Object.values(screens).map((value) => {\n if (typeof value !== 'string') {\n if (value._route) callback(value._route);\n iterateScreens(value.screens);\n }\n });\n };\n\n iterateScreens(manifest.screens);\n}\n\n// TODO: Do this earlier in the process.\nfunction makeRuntimeEntryPointsAbsolute(manifest: ExpoRouterRuntimeManifest, appDir: string) {\n modifyRouteNodeInRuntimeManifest(manifest, (route) => {\n if (Array.isArray(route.entryPoints)) {\n route.entryPoints = route.entryPoints.map((entryPoint) => {\n if (entryPoint.startsWith('.')) {\n return path.resolve(appDir, entryPoint);\n } else if (!path.isAbsolute(entryPoint)) {\n return resolveFrom(appDir, entryPoint);\n }\n return entryPoint;\n });\n }\n });\n}\n\n/** Perform all fs commits */\nasync function exportFromServerAsync(\n projectRoot: string,\n devServerManager: DevServerManager,\n { outputDir, baseUrl, exportServer, includeSourceMaps, routerRoot, files = new Map() }: Options\n): Promise<ExportAssetMap> {\n const platform = 'web';\n const isExporting = true;\n const appDir = path.join(projectRoot, routerRoot);\n const injectFaviconTag = await getVirtualFaviconAssetsAsync(projectRoot, {\n outputDir,\n baseUrl,\n files,\n });\n\n const devServer = devServerManager.getDefaultDevServer();\n assert(devServer instanceof MetroBundlerDevServer);\n\n const [resources, { manifest, serverManifest, renderAsync }] = await Promise.all([\n devServer.getStaticResourcesAsync({\n includeSourceMaps,\n }),\n devServer.getStaticRenderFunctionAsync(),\n ]);\n\n makeRuntimeEntryPointsAbsolute(manifest, appDir);\n\n debug('Routes:\\n', inspect(manifest, { colors: true, depth: null }));\n\n await getFilesToExportFromServerAsync(projectRoot, {\n files,\n manifest,\n exportServer,\n async renderAsync({ pathname, route }) {\n const template = await renderAsync(pathname);\n let html = await serializeHtmlWithAssets({\n isExporting,\n resources: resources.artifacts,\n template,\n baseUrl,\n route,\n });\n\n if (injectFaviconTag) {\n html = injectFaviconTag(html);\n }\n\n return html;\n },\n });\n\n getFilesFromSerialAssets(resources.artifacts, {\n platform,\n includeSourceMaps,\n files,\n });\n\n if (resources.assets) {\n // TODO: Collect files without writing to disk.\n // NOTE(kitten): Re. above, this is now using `files` except for iOS catalog output, which isn't used here\n await persistMetroAssetsAsync(resources.assets, {\n files,\n platform,\n outputDirectory: outputDir,\n baseUrl,\n });\n }\n\n if (exportServer) {\n const apiRoutes = await exportApiRoutesAsync({\n outputDir,\n server: devServer,\n manifest: serverManifest,\n // NOTE(kitten): For now, we always output source maps for API route exports\n includeSourceMaps: true,\n });\n\n // Add the api routes to the files to export.\n for (const [route, contents] of apiRoutes) {\n files.set(route, contents);\n }\n } else {\n warnPossibleInvalidExportType(appDir);\n }\n\n return files;\n}\n\nexport function getHtmlFiles({\n manifest,\n includeGroupVariations,\n}: {\n manifest: ExpoRouterRuntimeManifest;\n includeGroupVariations?: boolean;\n}): HtmlRequestLocation[] {\n const htmlFiles = new Set<Omit<HtmlRequestLocation, 'pathname'>>();\n\n function traverseScreens(\n screens: ExpoRouterRuntimeManifest['screens'],\n route: RouteNode | null,\n baseUrl = ''\n ) {\n for (const value of Object.values(screens)) {\n let leaf: string | null = null;\n if (typeof value === 'string') {\n leaf = value;\n } else if (Object.keys(value.screens).length === 0) {\n leaf = value.path;\n route = value._route ?? null;\n }\n\n if (leaf != null) {\n let filePath = baseUrl + leaf;\n\n if (leaf === '') {\n filePath =\n baseUrl === ''\n ? 'index'\n : baseUrl.endsWith('/')\n ? baseUrl + 'index'\n : baseUrl.slice(0, -1);\n } else if (\n // If the path is a collection of group segments leading to an index route, append `/index`.\n stripGroupSegmentsFromPath(filePath) === ''\n ) {\n filePath += '/index';\n }\n\n // This should never happen, the type of `string | object` originally comes from React Navigation.\n if (!route) {\n throw new Error(\n `Internal error: Route not found for \"${filePath}\" while collecting static export paths.`\n );\n }\n\n if (includeGroupVariations) {\n // TODO: Dedupe requests for alias routes.\n addOptionalGroups(filePath, route);\n } else {\n htmlFiles.add({\n filePath,\n route,\n });\n }\n } else if (typeof value === 'object' && value?.screens) {\n const newPath = baseUrl + value.path + '/';\n traverseScreens(value.screens, value._route ?? null, newPath);\n }\n }\n }\n\n function addOptionalGroups(path: string, route: RouteNode) {\n const variations = getPathVariations(path);\n for (const variation of variations) {\n htmlFiles.add({ filePath: variation, route });\n }\n }\n\n traverseScreens(manifest.screens, null);\n\n return uniqueBy(Array.from(htmlFiles), (value) => value.filePath).map((value) => {\n const parts = value.filePath.split('/');\n // Replace `:foo` with `[foo]` and `*foo` with `[...foo]`\n const partsWithGroups = parts.map((part) => {\n if (part === '*not-found') {\n return `+not-found`;\n } else if (part.startsWith(':')) {\n return `[${part.slice(1)}]`;\n } else if (part.startsWith('*')) {\n return `[...${part.slice(1)}]`;\n }\n return part;\n });\n const filePathLocation = partsWithGroups.join('/');\n const filePath = filePathLocation + '.html';\n return {\n ...value,\n filePath,\n pathname: filePathLocation.replace(/(\\/?index)?$/, ''),\n };\n });\n}\n\nfunction uniqueBy<T>(array: T[], key: (value: T) => string): T[] {\n const seen = new Set<string>();\n const result: T[] = [];\n for (const value of array) {\n const id = key(value);\n if (!seen.has(id)) {\n seen.add(id);\n result.push(value);\n }\n }\n return result;\n}\n\n// Given a route like `(foo)/bar/(baz)`, return all possible variations of the route.\n// e.g. `(foo)/bar/(baz)`, `(foo)/bar/baz`, `foo/bar/(baz)`, `foo/bar/baz`,\nexport function getPathVariations(routePath: string): string[] {\n const variations = new Set<string>();\n const segments = routePath.split('/');\n\n function generateVariations(segments: string[], current = ''): void {\n if (segments.length === 0) {\n if (current) variations.add(current);\n return;\n }\n\n const [head, ...rest] = segments;\n\n if (matchGroupName(head)) {\n const groups = head.slice(1, -1).split(',');\n\n if (groups.length > 1) {\n for (const group of groups) {\n // If there are multiple groups, recurse on each group.\n generateVariations([`(${group.trim()})`, ...rest], current);\n }\n return;\n } else {\n // Start a fork where this group is included\n generateVariations(rest, current ? `${current}/(${groups[0]})` : `(${groups[0]})`);\n // This code will continue and add paths without this group included`\n }\n } else if (current) {\n current = `${current}/${head}`;\n } else {\n current = head;\n }\n\n generateVariations(rest, current);\n }\n\n generateVariations(segments);\n\n return Array.from(variations);\n}\n\nasync function exportApiRoutesAsync({\n includeSourceMaps,\n outputDir,\n server,\n ...props\n}: Pick<Options, 'outputDir' | 'includeSourceMaps'> & {\n server: MetroBundlerDevServer;\n manifest: ExpoRouterServerManifestV1;\n}): Promise<ExportAssetMap> {\n const { manifest, files } = await server.exportExpoRouterApiRoutesAsync({\n outputDir: '_expo/functions',\n prerenderManifest: props.manifest,\n includeSourceMaps,\n });\n\n Log.log(chalk.bold`Exporting ${files.size} API Routes.`);\n\n files.set('_expo/routes.json', {\n contents: JSON.stringify(manifest, null, 2),\n targetDomain: 'server',\n });\n\n return files;\n}\n\nfunction warnPossibleInvalidExportType(appDir: string) {\n const apiRoutes = getApiRoutesForDirectory(appDir);\n if (apiRoutes.length) {\n // TODO: Allow API Routes for native-only.\n Log.warn(\n chalk.yellow`Skipping export for API routes because \\`web.output\\` is not \"server\". You may want to remove the routes: ${apiRoutes\n .map((v) => path.relative(appDir, v))\n .join(', ')}`\n );\n }\n}\n"],"names":["unstable_exportStaticAsync","getFilesToExportFromServerAsync","getHtmlFiles","getPathVariations","debug","require","projectRoot","options","Log","log","learnMore","port","getFreePortAsync","devServerManager","DevServerManager","minify","mode","isExporting","location","resetDevServer","clear","maxWorkers","startAsync","type","exportFromServerAsync","stopAsync","matchGroupName","name","match","manifest","renderAsync","exportServer","files","Map","Promise","all","includeGroupVariations","map","route","filePath","pathname","targetDomain","set","contents","data","routeId","e","logMetroErrorAsync","error","Error","modifyRouteNodeInRuntimeManifest","callback","iterateScreens","screens","Object","values","value","_route","makeRuntimeEntryPointsAbsolute","appDir","Array","isArray","entryPoints","entryPoint","startsWith","path","resolve","isAbsolute","resolveFrom","outputDir","baseUrl","includeSourceMaps","routerRoot","platform","join","injectFaviconTag","getVirtualFaviconAssetsAsync","devServer","getDefaultDevServer","assert","MetroBundlerDevServer","resources","serverManifest","getStaticResourcesAsync","getStaticRenderFunctionAsync","inspect","colors","depth","template","html","serializeHtmlWithAssets","artifacts","getFilesFromSerialAssets","assets","persistMetroAssetsAsync","outputDirectory","apiRoutes","exportApiRoutesAsync","server","warnPossibleInvalidExportType","htmlFiles","Set","traverseScreens","leaf","keys","length","endsWith","slice","stripGroupSegmentsFromPath","addOptionalGroups","add","newPath","variations","variation","uniqueBy","from","parts","split","partsWithGroups","part","filePathLocation","replace","array","key","seen","result","id","has","push","routePath","segments","generateVariations","current","head","rest","groups","group","trim","props","exportExpoRouterApiRoutesAsync","prerenderManifest","chalk","bold","size","JSON","stringify","getApiRoutesForDirectory","warn","yellow","v","relative"],"mappings":"AAAA;;;;;CAKC,GACD;;;;;;;;;;;IAm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;IAEH/D,IAAG,IAAA,CAACC,GAAG,CAACoI,MAAK,EAAA,QAAA,CAACC,IAAI,CAAC,UAAU,EAAE9G,KAAK,CAAC+G,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAEzD/G,KAAK,CAACU,GAAG,CAAC,mBAAmB,EAAE;QAC7BC,QAAQ,EAAEqG,IAAI,CAACC,SAAS,CAACpH,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3CY,YAAY,EAAE,QAAQ;KACvB,CAAC,CAAC;IAEH,OAAOT,KAAK,CAAC;AACf,CAAC;AAED,SAASmE,6BAA6B,CAACxC,MAAc,EAAE;IACrD,MAAMqC,SAAS,GAAGkD,IAAAA,OAAwB,yBAAA,EAACvF,MAAM,CAAC,AAAC;IACnD,IAAIqC,SAAS,CAACS,MAAM,EAAE;QACpB,0CAA0C;QAC1CjG,IAAG,IAAA,CAAC2I,IAAI,CACNN,MAAK,EAAA,QAAA,CAACO,MAAM,CAAC,0GAA0G,EAAEpD,SAAS,CAC/H3D,GAAG,CAAC,CAACgH,CAAC,GAAKpF,KAAI,EAAA,QAAA,CAACqF,QAAQ,CAAC3F,MAAM,EAAE0F,CAAC,CAAC,CAAC,CACpC3E,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAChB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
createBundlesAsync: ()=>createBundlesAsync,
|
|
13
|
+
getAssets: ()=>getAssets
|
|
14
|
+
});
|
|
15
|
+
function _config() {
|
|
16
|
+
const data = require("@expo/config");
|
|
17
|
+
_config = function() {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
function _getAssets() {
|
|
23
|
+
const data = /*#__PURE__*/ _interopRequireDefault(require("@expo/metro-config/build/transform-worker/getAssets"));
|
|
24
|
+
_getAssets = function() {
|
|
25
|
+
return data;
|
|
26
|
+
};
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
function _assert() {
|
|
30
|
+
const data = /*#__PURE__*/ _interopRequireDefault(require("assert"));
|
|
31
|
+
_assert = function() {
|
|
32
|
+
return data;
|
|
33
|
+
};
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
function _metro() {
|
|
37
|
+
const data = /*#__PURE__*/ _interopRequireDefault(require("metro"));
|
|
38
|
+
_metro = function() {
|
|
39
|
+
return data;
|
|
40
|
+
};
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
function _server() {
|
|
44
|
+
const data = /*#__PURE__*/ _interopRequireDefault(require("metro/src/Server"));
|
|
45
|
+
_server = function() {
|
|
46
|
+
return data;
|
|
47
|
+
};
|
|
48
|
+
return data;
|
|
49
|
+
}
|
|
50
|
+
function _splitBundleOptions() {
|
|
51
|
+
const data = /*#__PURE__*/ _interopRequireDefault(require("metro/src/lib/splitBundleOptions"));
|
|
52
|
+
_splitBundleOptions = function() {
|
|
53
|
+
return data;
|
|
54
|
+
};
|
|
55
|
+
return data;
|
|
56
|
+
}
|
|
57
|
+
function _path() {
|
|
58
|
+
const data = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
59
|
+
_path = function() {
|
|
60
|
+
return data;
|
|
61
|
+
};
|
|
62
|
+
return data;
|
|
63
|
+
}
|
|
64
|
+
const _exportHermes = require("./exportHermes");
|
|
65
|
+
const _attachAtlas = require("../start/server/metro/debugging/attachAtlas");
|
|
66
|
+
const _instantiateMetro = require("../start/server/metro/instantiateMetro");
|
|
67
|
+
const _manifestMiddleware = require("../start/server/middleware/ManifestMiddleware");
|
|
68
|
+
const _metroOptions = require("../start/server/middleware/metroOptions");
|
|
69
|
+
const _env = require("../utils/env");
|
|
70
|
+
const _errors = require("../utils/errors");
|
|
71
|
+
function _interopRequireDefault(obj) {
|
|
72
|
+
return obj && obj.__esModule ? obj : {
|
|
73
|
+
default: obj
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
let nextBuildID = 0;
|
|
77
|
+
async function assertEngineMismatchAsync(projectRoot, exp, platform) {
|
|
78
|
+
const isHermesManaged = (0, _exportHermes.isEnableHermesManaged)(exp, platform);
|
|
79
|
+
const paths = (0, _config().getConfigFilePaths)(projectRoot);
|
|
80
|
+
var _dynamicConfigPath, ref;
|
|
81
|
+
const configFilePath = (ref = (_dynamicConfigPath = paths.dynamicConfigPath) != null ? _dynamicConfigPath : paths.staticConfigPath) != null ? ref : "app.json";
|
|
82
|
+
await (0, _exportHermes.maybeThrowFromInconsistentEngineAsync)(projectRoot, configFilePath, platform, isHermesManaged);
|
|
83
|
+
}
|
|
84
|
+
async function createBundlesAsync(projectRoot, projectConfig, bundleOptions) {
|
|
85
|
+
if (!bundleOptions.platforms.length) {
|
|
86
|
+
return {};
|
|
87
|
+
}
|
|
88
|
+
const { exp , pkg } = projectConfig;
|
|
89
|
+
var _entryPoint;
|
|
90
|
+
const bundles = await bundleProductionMetroClientAsync(projectRoot, exp, {
|
|
91
|
+
// If not legacy, ignore the target option to prevent warnings from being thrown.
|
|
92
|
+
resetCache: bundleOptions.clear,
|
|
93
|
+
maxWorkers: bundleOptions.maxWorkers
|
|
94
|
+
}, bundleOptions.platforms.map((platform)=>({
|
|
95
|
+
platform,
|
|
96
|
+
entryPoint: (_entryPoint = bundleOptions.entryPoint) != null ? _entryPoint : (0, _manifestMiddleware.getEntryWithServerRoot)(projectRoot, {
|
|
97
|
+
platform,
|
|
98
|
+
pkg
|
|
99
|
+
}),
|
|
100
|
+
sourcemaps: bundleOptions.sourcemaps,
|
|
101
|
+
minify: bundleOptions.minify,
|
|
102
|
+
bytecode: bundleOptions.bytecode,
|
|
103
|
+
dev: bundleOptions.dev
|
|
104
|
+
})));
|
|
105
|
+
// { ios: bundle, android: bundle }
|
|
106
|
+
return bundleOptions.platforms.reduce((prev, platform, index)=>({
|
|
107
|
+
...prev,
|
|
108
|
+
[platform]: bundles[index]
|
|
109
|
+
}), {});
|
|
110
|
+
}
|
|
111
|
+
function assertMetroConfig(config) {
|
|
112
|
+
var ref;
|
|
113
|
+
if (!((ref = config.serializer) == null ? void 0 : ref.customSerializer)) {
|
|
114
|
+
throw new _errors.CommandError("METRO_CONFIG_MALFORMED", `The Metro bundler configuration is missing required features from 'expo/metro-config' and cannot be used with Expo CLI. Ensure the metro.config.js file is extending 'expo/metro-config'. Learn more: https://docs.expo.dev/guides/customizing-metro`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
async function bundleProductionMetroClientAsync(projectRoot, expoConfig, metroOptions, bundles) {
|
|
118
|
+
// Assert early so the user doesn't have to wait until bundling is complete to find out that
|
|
119
|
+
// Hermes won't be available.
|
|
120
|
+
await Promise.all(bundles.map(({ platform })=>assertEngineMismatchAsync(projectRoot, expoConfig, platform)));
|
|
121
|
+
const { config , reporter } = await (0, _instantiateMetro.loadMetroConfigAsync)(projectRoot, metroOptions, {
|
|
122
|
+
exp: expoConfig,
|
|
123
|
+
isExporting: true,
|
|
124
|
+
getMetroBundler () {
|
|
125
|
+
return metroServer.getBundler().getBundler();
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
assertMetroConfig(config);
|
|
129
|
+
// Attach Expo Atlas if enabled
|
|
130
|
+
await (0, _attachAtlas.attachAtlasAsync)({
|
|
131
|
+
exp: expoConfig,
|
|
132
|
+
projectRoot,
|
|
133
|
+
metroConfig: config,
|
|
134
|
+
isExporting: true,
|
|
135
|
+
resetAtlasFile: true
|
|
136
|
+
});
|
|
137
|
+
const metroServer = await _metro().default.runMetro(config, {
|
|
138
|
+
watch: false
|
|
139
|
+
});
|
|
140
|
+
const buildAsync = async (bundle)=>{
|
|
141
|
+
const buildID = `bundle_${nextBuildID++}_${bundle.platform}`;
|
|
142
|
+
const isHermes = (0, _exportHermes.isEnableHermesManaged)(expoConfig, bundle.platform);
|
|
143
|
+
if (isHermes) {
|
|
144
|
+
await assertEngineMismatchAsync(projectRoot, expoConfig, bundle.platform);
|
|
145
|
+
}
|
|
146
|
+
const bundleOptions = {
|
|
147
|
+
..._server().default.DEFAULT_BUNDLE_OPTIONS,
|
|
148
|
+
sourceMapUrl: bundle.sourceMapUrl,
|
|
149
|
+
...(0, _metroOptions.getMetroDirectBundleOptionsForExpoConfig)(projectRoot, expoConfig, {
|
|
150
|
+
splitChunks: !_env.env.EXPO_NO_BUNDLE_SPLITTING && bundle.platform === "web",
|
|
151
|
+
minify: bundle.minify,
|
|
152
|
+
mainModuleName: bundle.entryPoint,
|
|
153
|
+
platform: bundle.platform,
|
|
154
|
+
mode: bundle.dev ? "development" : "production",
|
|
155
|
+
engine: isHermes ? "hermes" : undefined,
|
|
156
|
+
serializerIncludeMaps: bundle.sourcemaps,
|
|
157
|
+
bytecode: bundle.bytecode && isHermes,
|
|
158
|
+
// Bundle splitting on web-only for now.
|
|
159
|
+
// serializerOutput: bundle.platform === 'web' ? 'static' : undefined,
|
|
160
|
+
serializerOutput: "static",
|
|
161
|
+
isExporting: true
|
|
162
|
+
}),
|
|
163
|
+
bundleType: "bundle",
|
|
164
|
+
inlineSourceMap: false,
|
|
165
|
+
createModuleIdFactory: config.serializer.createModuleIdFactory,
|
|
166
|
+
onProgress: (transformedFileCount, totalFileCount)=>{
|
|
167
|
+
reporter.update({
|
|
168
|
+
buildID,
|
|
169
|
+
type: "bundle_transform_progressed",
|
|
170
|
+
transformedFileCount,
|
|
171
|
+
totalFileCount
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
const bundleDetails = {
|
|
176
|
+
...bundleOptions,
|
|
177
|
+
buildID
|
|
178
|
+
};
|
|
179
|
+
reporter.update({
|
|
180
|
+
buildID,
|
|
181
|
+
type: "bundle_build_started",
|
|
182
|
+
bundleDetails
|
|
183
|
+
});
|
|
184
|
+
try {
|
|
185
|
+
const artifacts = await forkMetroBuildAsync(metroServer, bundleOptions);
|
|
186
|
+
reporter.update({
|
|
187
|
+
buildID,
|
|
188
|
+
type: "bundle_build_done"
|
|
189
|
+
});
|
|
190
|
+
return artifacts;
|
|
191
|
+
} catch (error) {
|
|
192
|
+
reporter.update({
|
|
193
|
+
buildID,
|
|
194
|
+
type: "bundle_build_failed"
|
|
195
|
+
});
|
|
196
|
+
throw error;
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
try {
|
|
200
|
+
return await Promise.all(bundles.map((bundle)=>buildAsync(bundle)));
|
|
201
|
+
} catch (error) {
|
|
202
|
+
// New line so errors don't show up inline with the progress bar
|
|
203
|
+
console.log("");
|
|
204
|
+
throw error;
|
|
205
|
+
} finally{
|
|
206
|
+
metroServer.end();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
async function getAssets(metro, options) {
|
|
210
|
+
const { entryFile , onProgress , resolverOptions , transformOptions } = (0, _splitBundleOptions().default)(options);
|
|
211
|
+
// @ts-expect-error: _bundler isn't exposed on the type.
|
|
212
|
+
const dependencies = await metro._bundler.getDependencies([
|
|
213
|
+
entryFile
|
|
214
|
+
], transformOptions, resolverOptions, {
|
|
215
|
+
onProgress,
|
|
216
|
+
shallow: false,
|
|
217
|
+
lazy: false
|
|
218
|
+
});
|
|
219
|
+
// @ts-expect-error
|
|
220
|
+
const _config = metro._config;
|
|
221
|
+
return (0, _getAssets().default)(dependencies, {
|
|
222
|
+
processModuleFilter: _config.serializer.processModuleFilter,
|
|
223
|
+
assetPlugins: _config.transformer.assetPlugins,
|
|
224
|
+
platform: transformOptions.platform,
|
|
225
|
+
projectRoot: _config.projectRoot,
|
|
226
|
+
publicPath: _config.transformer.publicPath
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
function isMetroServerInstance(metro) {
|
|
230
|
+
return "_shouldAddModuleToIgnoreList" in metro;
|
|
231
|
+
}
|
|
232
|
+
async function forkMetroBuildAsync(metro, options) {
|
|
233
|
+
var ref;
|
|
234
|
+
if (!isMetroServerInstance(metro)) {
|
|
235
|
+
throw new Error("Expected Metro server instance to have private functions exposed.");
|
|
236
|
+
}
|
|
237
|
+
if (((ref = options.serializerOptions) == null ? void 0 : ref.output) !== "static") {
|
|
238
|
+
throw new Error("Only multi-serializer output is supported.");
|
|
239
|
+
}
|
|
240
|
+
const { entryFile , graphOptions , onProgress , resolverOptions , serializerOptions , transformOptions , } = (0, _splitBundleOptions().default)(options);
|
|
241
|
+
const { prepend , graph } = await metro._bundler.buildGraph(entryFile, transformOptions, resolverOptions, {
|
|
242
|
+
onProgress,
|
|
243
|
+
shallow: graphOptions.shallow,
|
|
244
|
+
// @ts-expect-error
|
|
245
|
+
lazy: graphOptions.lazy
|
|
246
|
+
});
|
|
247
|
+
const entryPoint = metro._getEntryPointAbsolutePath(entryFile);
|
|
248
|
+
var _unstable_serverRoot;
|
|
249
|
+
const bundleOptions = {
|
|
250
|
+
asyncRequireModulePath: await metro._resolveRelativePath(metro._config.transformer.asyncRequireModulePath, {
|
|
251
|
+
relativeTo: "project",
|
|
252
|
+
resolverOptions,
|
|
253
|
+
transformOptions
|
|
254
|
+
}),
|
|
255
|
+
processModuleFilter: metro._config.serializer.processModuleFilter,
|
|
256
|
+
createModuleId: metro._createModuleId,
|
|
257
|
+
getRunModuleStatement: metro._config.serializer.getRunModuleStatement,
|
|
258
|
+
dev: transformOptions.dev,
|
|
259
|
+
includeAsyncPaths: graphOptions.lazy,
|
|
260
|
+
projectRoot: metro._config.projectRoot,
|
|
261
|
+
modulesOnly: serializerOptions.modulesOnly,
|
|
262
|
+
runBeforeMainModule: metro._config.serializer.getModulesRunBeforeMainModule(_path().default.relative(metro._config.projectRoot, entryPoint)),
|
|
263
|
+
runModule: serializerOptions.runModule,
|
|
264
|
+
sourceMapUrl: serializerOptions.sourceMapUrl,
|
|
265
|
+
sourceUrl: serializerOptions.sourceUrl,
|
|
266
|
+
inlineSourceMap: serializerOptions.inlineSourceMap,
|
|
267
|
+
serverRoot: (_unstable_serverRoot = metro._config.server.unstable_serverRoot) != null ? _unstable_serverRoot : metro._config.projectRoot,
|
|
268
|
+
shouldAddToIgnoreList: (module)=>metro._shouldAddModuleToIgnoreList(module),
|
|
269
|
+
// Custom options we pass to the serializer to emulate the URL query parameters.
|
|
270
|
+
serializerOptions: options.serializerOptions
|
|
271
|
+
};
|
|
272
|
+
assertMetroConfig(metro._config);
|
|
273
|
+
const bundle = await metro._config.serializer.customSerializer(entryPoint, // @ts-expect-error: Metro is typed incorrectly
|
|
274
|
+
prepend, graph, bundleOptions);
|
|
275
|
+
try {
|
|
276
|
+
const parsed = typeof bundle === "string" ? JSON.parse(bundle) : bundle;
|
|
277
|
+
(0, _assert().default)("artifacts" in parsed && Array.isArray(parsed.artifacts), "Expected serializer to return an object with key artifacts to contain an array of serial assets.");
|
|
278
|
+
return parsed;
|
|
279
|
+
} catch (error) {
|
|
280
|
+
throw new Error("Serializer did not return expected format. The project copy of `expo/metro-config` may be out of date. Error: " + error.message);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
//# sourceMappingURL=fork-bundleAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/export/fork-bundleAsync.ts"],"sourcesContent":["import { ExpoConfig, getConfigFilePaths, Platform, ProjectConfig } from '@expo/config';\nimport { LoadOptions } from '@expo/metro-config';\nimport { SerialAsset } from '@expo/metro-config/build/serializer/serializerAssets';\nimport getMetroAssets from '@expo/metro-config/build/transform-worker/getAssets';\nimport assert from 'assert';\nimport Metro, { MixedOutput, Module, ReadOnlyGraph } from 'metro';\nimport type { TransformInputOptions } from 'metro/src/DeltaBundler/types';\nimport IncrementalBundler from 'metro/src/IncrementalBundler';\nimport Server from 'metro/src/Server';\nimport splitBundleOptions from 'metro/src/lib/splitBundleOptions';\nimport type {\n ResolverInputOptions,\n BundleOptions as MetroBundleOptions,\n} from 'metro/src/shared/types';\nimport { ConfigT } from 'metro-config';\nimport path from 'path';\n\nimport { isEnableHermesManaged, maybeThrowFromInconsistentEngineAsync } from './exportHermes';\nimport { attachAtlasAsync } from '../start/server/metro/debugging/attachAtlas';\nimport { loadMetroConfigAsync } from '../start/server/metro/instantiateMetro';\nimport { getEntryWithServerRoot } from '../start/server/middleware/ManifestMiddleware';\nimport {\n ExpoMetroBundleOptions,\n getMetroDirectBundleOptionsForExpoConfig,\n} from '../start/server/middleware/metroOptions';\nimport { env } from '../utils/env';\nimport { CommandError } from '../utils/errors';\n\nexport type MetroDevServerOptions = LoadOptions;\n\nexport type BundleOptions = {\n entryPoint: string;\n platform: 'android' | 'ios' | 'web';\n dev?: boolean;\n minify?: boolean;\n bytecode: boolean;\n sourceMapUrl?: string;\n sourcemaps?: boolean;\n};\nexport type BundleAssetWithFileHashes = Metro.AssetData & {\n fileHashes: string[]; // added by the hashAssets asset plugin\n};\nexport type BundleOutput = {\n artifacts: SerialAsset[];\n assets: readonly BundleAssetWithFileHashes[];\n};\n\nlet nextBuildID = 0;\n\nasync function assertEngineMismatchAsync(\n projectRoot: string,\n exp: Pick<ExpoConfig, 'ios' | 'android' | 'jsEngine'>,\n platform: Platform\n) {\n const isHermesManaged = isEnableHermesManaged(exp, platform);\n\n const paths = getConfigFilePaths(projectRoot);\n const configFilePath = paths.dynamicConfigPath ?? paths.staticConfigPath ?? 'app.json';\n await maybeThrowFromInconsistentEngineAsync(\n projectRoot,\n configFilePath,\n platform,\n isHermesManaged\n );\n}\n\nexport async function createBundlesAsync(\n projectRoot: string,\n projectConfig: ProjectConfig,\n bundleOptions: {\n clear?: boolean;\n maxWorkers?: number;\n platforms: Platform[];\n dev?: boolean;\n minify?: boolean;\n bytecode: boolean;\n sourcemaps?: boolean;\n entryPoint?: string;\n }\n): Promise<Partial<Record<Platform, BundleOutput>>> {\n if (!bundleOptions.platforms.length) {\n return {};\n }\n const { exp, pkg } = projectConfig;\n\n const bundles = await bundleProductionMetroClientAsync(\n projectRoot,\n exp,\n {\n // If not legacy, ignore the target option to prevent warnings from being thrown.\n resetCache: bundleOptions.clear,\n maxWorkers: bundleOptions.maxWorkers,\n },\n bundleOptions.platforms.map((platform: Platform) => ({\n platform,\n entryPoint:\n bundleOptions.entryPoint ?? getEntryWithServerRoot(projectRoot, { platform, pkg }),\n sourcemaps: bundleOptions.sourcemaps,\n minify: bundleOptions.minify,\n bytecode: bundleOptions.bytecode,\n dev: bundleOptions.dev,\n }))\n );\n\n // { ios: bundle, android: bundle }\n return bundleOptions.platforms.reduce<Partial<Record<Platform, BundleOutput>>>(\n (prev, platform, index) => ({\n ...prev,\n [platform]: bundles[index],\n }),\n {}\n );\n}\n\nfunction assertMetroConfig(\n config: ConfigT\n): asserts config is ConfigT & { serializer: NonNullable<ConfigT['serializer']> } {\n if (!config.serializer?.customSerializer) {\n throw new CommandError(\n 'METRO_CONFIG_MALFORMED',\n `The Metro bundler configuration is missing required features from 'expo/metro-config' and cannot be used with Expo CLI. Ensure the metro.config.js file is extending 'expo/metro-config'. Learn more: https://docs.expo.dev/guides/customizing-metro`\n );\n }\n}\n\nasync function bundleProductionMetroClientAsync(\n projectRoot: string,\n expoConfig: ExpoConfig,\n metroOptions: MetroDevServerOptions,\n bundles: BundleOptions[]\n): Promise<BundleOutput[]> {\n // Assert early so the user doesn't have to wait until bundling is complete to find out that\n // Hermes won't be available.\n await Promise.all(\n bundles.map(({ platform }) => assertEngineMismatchAsync(projectRoot, expoConfig, platform))\n );\n\n const { config, reporter } = await loadMetroConfigAsync(projectRoot, metroOptions, {\n exp: expoConfig,\n isExporting: true,\n getMetroBundler() {\n return metroServer.getBundler().getBundler();\n },\n });\n\n assertMetroConfig(config);\n\n // Attach Expo Atlas if enabled\n await attachAtlasAsync({\n exp: expoConfig,\n projectRoot,\n metroConfig: config,\n isExporting: true,\n resetAtlasFile: true, // NOTE(cedric): reset the Atlas file once, and reuse it for static exports\n });\n\n const metroServer = await Metro.runMetro(config, {\n watch: false,\n });\n\n const buildAsync = async (bundle: BundleOptions): Promise<BundleOutput> => {\n const buildID = `bundle_${nextBuildID++}_${bundle.platform}`;\n const isHermes = isEnableHermesManaged(expoConfig, bundle.platform);\n if (isHermes) {\n await assertEngineMismatchAsync(projectRoot, expoConfig, bundle.platform);\n }\n const bundleOptions: MetroBundleOptions = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n sourceMapUrl: bundle.sourceMapUrl,\n ...getMetroDirectBundleOptionsForExpoConfig(projectRoot, expoConfig, {\n splitChunks: !env.EXPO_NO_BUNDLE_SPLITTING && bundle.platform === 'web',\n minify: bundle.minify,\n mainModuleName: bundle.entryPoint,\n platform: bundle.platform,\n mode: bundle.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n serializerIncludeMaps: bundle.sourcemaps,\n bytecode: bundle.bytecode && isHermes,\n // Bundle splitting on web-only for now.\n // serializerOutput: bundle.platform === 'web' ? 'static' : undefined,\n serializerOutput: 'static',\n isExporting: true,\n }),\n bundleType: 'bundle',\n inlineSourceMap: false,\n createModuleIdFactory: config.serializer.createModuleIdFactory,\n onProgress: (transformedFileCount: number, totalFileCount: number) => {\n reporter.update({\n buildID,\n type: 'bundle_transform_progressed',\n transformedFileCount,\n totalFileCount,\n });\n },\n };\n\n const bundleDetails = {\n ...bundleOptions,\n buildID,\n };\n reporter.update({\n buildID,\n type: 'bundle_build_started',\n bundleDetails,\n });\n try {\n const artifacts = await forkMetroBuildAsync(metroServer, bundleOptions);\n reporter.update({\n buildID,\n type: 'bundle_build_done',\n });\n return artifacts;\n } catch (error) {\n reporter.update({\n buildID,\n type: 'bundle_build_failed',\n });\n\n throw error;\n }\n };\n\n try {\n return await Promise.all(bundles.map((bundle) => buildAsync(bundle)));\n } catch (error) {\n // New line so errors don't show up inline with the progress bar\n console.log('');\n throw error;\n } finally {\n metroServer.end();\n }\n}\n\n// Forked out of Metro because the `this._getServerRootDir()` doesn't match the development\n// behavior.\nexport async function getAssets(metro: Metro.Server, options: MetroBundleOptions) {\n const { entryFile, onProgress, resolverOptions, transformOptions } = splitBundleOptions(options);\n\n // @ts-expect-error: _bundler isn't exposed on the type.\n const dependencies = await metro._bundler.getDependencies(\n [entryFile],\n transformOptions,\n resolverOptions,\n { onProgress, shallow: false, lazy: false }\n );\n\n // @ts-expect-error\n const _config = metro._config as ConfigT;\n\n return getMetroAssets(dependencies, {\n processModuleFilter: _config.serializer.processModuleFilter,\n assetPlugins: _config.transformer.assetPlugins,\n platform: transformOptions.platform!,\n projectRoot: _config.projectRoot, // this._getServerRootDir(),\n publicPath: _config.transformer.publicPath,\n });\n}\n\nfunction isMetroServerInstance(metro: Metro.Server): metro is Metro.Server & {\n _shouldAddModuleToIgnoreList: (module: Module<MixedOutput>) => boolean;\n _bundler: IncrementalBundler;\n _config: ConfigT;\n _createModuleId: (path: string) => number;\n _resolveRelativePath(\n filePath: string,\n {\n relativeTo,\n resolverOptions,\n transformOptions,\n }: {\n relativeTo: 'project' | 'server';\n resolverOptions: ResolverInputOptions;\n transformOptions: TransformInputOptions;\n }\n ): Promise<string>;\n _getEntryPointAbsolutePath(entryFile: string): string;\n _getSortedModules(graph: ReadOnlyGraph): Module<MixedOutput>[];\n} {\n return '_shouldAddModuleToIgnoreList' in metro;\n}\n\nasync function forkMetroBuildAsync(\n metro: Metro.Server,\n options: ExpoMetroBundleOptions\n): Promise<{ artifacts: SerialAsset[]; assets: readonly BundleAssetWithFileHashes[] }> {\n if (!isMetroServerInstance(metro)) {\n throw new Error('Expected Metro server instance to have private functions exposed.');\n }\n\n if (options.serializerOptions?.output !== 'static') {\n throw new Error('Only multi-serializer output is supported.');\n }\n\n const {\n entryFile,\n graphOptions,\n onProgress,\n resolverOptions,\n serializerOptions,\n transformOptions,\n } = splitBundleOptions(options);\n\n const { prepend, graph } = await metro._bundler.buildGraph(\n entryFile,\n transformOptions,\n resolverOptions,\n {\n onProgress,\n shallow: graphOptions.shallow,\n // @ts-expect-error\n lazy: graphOptions.lazy,\n }\n );\n\n const entryPoint = metro._getEntryPointAbsolutePath(entryFile);\n\n const bundleOptions = {\n asyncRequireModulePath: await metro._resolveRelativePath(\n metro._config.transformer.asyncRequireModulePath,\n {\n relativeTo: 'project',\n resolverOptions,\n transformOptions,\n }\n ),\n processModuleFilter: metro._config.serializer.processModuleFilter,\n createModuleId: metro._createModuleId,\n getRunModuleStatement: metro._config.serializer.getRunModuleStatement,\n dev: transformOptions.dev,\n includeAsyncPaths: graphOptions.lazy,\n projectRoot: metro._config.projectRoot,\n modulesOnly: serializerOptions.modulesOnly,\n runBeforeMainModule: metro._config.serializer.getModulesRunBeforeMainModule(\n path.relative(metro._config.projectRoot, entryPoint)\n ),\n runModule: serializerOptions.runModule,\n sourceMapUrl: serializerOptions.sourceMapUrl,\n sourceUrl: serializerOptions.sourceUrl,\n inlineSourceMap: serializerOptions.inlineSourceMap,\n serverRoot: metro._config.server.unstable_serverRoot ?? metro._config.projectRoot,\n shouldAddToIgnoreList: (module: Module<MixedOutput>) =>\n metro._shouldAddModuleToIgnoreList(module),\n // Custom options we pass to the serializer to emulate the URL query parameters.\n serializerOptions: options.serializerOptions,\n };\n\n assertMetroConfig(metro._config);\n\n const bundle = await metro._config.serializer.customSerializer!(\n entryPoint,\n // @ts-expect-error: Metro is typed incorrectly\n prepend,\n graph,\n bundleOptions\n );\n\n try {\n const parsed = typeof bundle === 'string' ? JSON.parse(bundle) : bundle;\n\n assert(\n 'artifacts' in parsed && Array.isArray(parsed.artifacts),\n 'Expected serializer to return an object with key artifacts to contain an array of serial assets.'\n );\n return parsed;\n } catch (error: any) {\n throw new Error(\n 'Serializer did not return expected format. The project copy of `expo/metro-config` may be out of date. Error: ' +\n error.message\n );\n }\n}\n"],"names":["createBundlesAsync","getAssets","nextBuildID","assertEngineMismatchAsync","projectRoot","exp","platform","isHermesManaged","isEnableHermesManaged","paths","getConfigFilePaths","configFilePath","dynamicConfigPath","staticConfigPath","maybeThrowFromInconsistentEngineAsync","projectConfig","bundleOptions","platforms","length","pkg","bundles","bundleProductionMetroClientAsync","resetCache","clear","maxWorkers","map","entryPoint","getEntryWithServerRoot","sourcemaps","minify","bytecode","dev","reduce","prev","index","assertMetroConfig","config","serializer","customSerializer","CommandError","expoConfig","metroOptions","Promise","all","reporter","loadMetroConfigAsync","isExporting","getMetroBundler","metroServer","getBundler","attachAtlasAsync","metroConfig","resetAtlasFile","Metro","runMetro","watch","buildAsync","bundle","buildID","isHermes","Server","DEFAULT_BUNDLE_OPTIONS","sourceMapUrl","getMetroDirectBundleOptionsForExpoConfig","splitChunks","env","EXPO_NO_BUNDLE_SPLITTING","mainModuleName","mode","engine","undefined","serializerIncludeMaps","serializerOutput","bundleType","inlineSourceMap","createModuleIdFactory","onProgress","transformedFileCount","totalFileCount","update","type","bundleDetails","artifacts","forkMetroBuildAsync","error","console","log","end","metro","options","entryFile","resolverOptions","transformOptions","splitBundleOptions","dependencies","_bundler","getDependencies","shallow","lazy","_config","getMetroAssets","processModuleFilter","assetPlugins","transformer","publicPath","isMetroServerInstance","Error","serializerOptions","output","graphOptions","prepend","graph","buildGraph","_getEntryPointAbsolutePath","asyncRequireModulePath","_resolveRelativePath","relativeTo","createModuleId","_createModuleId","getRunModuleStatement","includeAsyncPaths","modulesOnly","runBeforeMainModule","getModulesRunBeforeMainModule","path","relative","runModule","sourceUrl","serverRoot","server","unstable_serverRoot","shouldAddToIgnoreList","module","_shouldAddModuleToIgnoreList","parsed","JSON","parse","assert","Array","isArray","message"],"mappings":"AAAA;;;;;;;;;;;IAkEsBA,kBAAkB,MAAlBA,kBAAkB;IAyKlBC,SAAS,MAATA,SAAS;;;yBA3OyC,cAAc;;;;;;;8DAG3D,qDAAqD;;;;;;;8DAC7D,QAAQ;;;;;;;8DAC+B,OAAO;;;;;;;8DAG9C,kBAAkB;;;;;;;8DACN,kCAAkC;;;;;;;8DAMhD,MAAM;;;;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AO,CAAC,CAAC;IAEjC,MAAM1C,MAAM,GAAG,MAAM+B,KAAK,CAACW,OAAO,CAAC9D,UAAU,CAACC,gBAAgB,CAC5DZ,UAAU,EACV,+CAA+C;IAC/CoF,OAAO,EACPC,KAAK,EACL/F,aAAa,CACd,AAAC;IAEF,IAAI;QACF,MAAMsH,MAAM,GAAG,OAAO7E,MAAM,KAAK,QAAQ,GAAG8E,IAAI,CAACC,KAAK,CAAC/E,MAAM,CAAC,GAAGA,MAAM,AAAC;QAExEgF,IAAAA,OAAM,EAAA,QAAA,EACJ,WAAW,IAAIH,MAAM,IAAII,KAAK,CAACC,OAAO,CAACL,MAAM,CAACpD,SAAS,CAAC,EACxD,kGAAkG,CACnG,CAAC;QACF,OAAOoD,MAAM,CAAC;IAChB,EAAE,OAAOlD,KAAK,EAAO;QACnB,MAAM,IAAIsB,KAAK,CACb,gHAAgH,GAC9GtB,KAAK,CAACwD,OAAO,CAChB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/export/saveAssets.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 { SerialAsset } from '@expo/metro-config/build/serializer/serializerAssets';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport Metro from 'metro';\nimport path from 'path';\nimport prettyBytes from 'pretty-bytes';\n\nimport { Log } from '../log';\n\nexport type BundleOptions = {\n entryPoint: string;\n platform: 'android' | 'ios' | 'web';\n dev?: boolean;\n minify?: boolean;\n bytecode: boolean;\n sourceMapUrl?: string;\n sourcemaps?: boolean;\n};\n\nexport type BundleAssetWithFileHashes = Metro.AssetData & {\n fileHashes: string[]; // added by the hashAssets asset plugin\n};\n\nexport type BundleOutput = {\n artifacts: SerialAsset[];\n assets: readonly BundleAssetWithFileHashes[];\n};\n\nexport type ManifestAsset = { fileHashes: string[]; files: string[]; hash: string };\n\nexport type Asset = ManifestAsset | BundleAssetWithFileHashes;\n\nexport type ExportAssetDescriptor = {\n contents: string | Buffer;\n originFilename?: string;\n /** An identifier for grouping together variations of the same asset. */\n assetId?: string;\n /** Expo Router route path for formatting the HTML output. */\n routeId?: string;\n /** A key for grouping together output files by server- or client-side. */\n targetDomain?: 'server' | 'client';\n};\n\nexport type ExportAssetMap = Map<string, ExportAssetDescriptor>;\n\nexport async function persistMetroFilesAsync(files: ExportAssetMap, outputDir: string) {\n if (!files.size) {\n return;\n }\n fs.mkdirSync(path.join(outputDir), { recursive: true });\n\n // Test fixtures:\n // Log.log(\n // JSON.stringify(\n // Object.fromEntries([...files.entries()].map(([k, v]) => [k, { ...v, contents: '' }]))\n // )\n // );\n\n const assetEntries: [string, ExportAssetDescriptor][] = [];\n const routeEntries: [string, ExportAssetDescriptor][] = [];\n const remainingEntries: [string, ExportAssetDescriptor][] = [];\n\n let hasServerOutput = false;\n for (const asset of files.entries()) {\n hasServerOutput = hasServerOutput || asset[1].targetDomain === 'server';\n if (asset[1].assetId) assetEntries.push(asset);\n else if (asset[1].routeId != null) routeEntries.push(asset);\n else remainingEntries.push(asset);\n }\n\n const groups = groupBy(assetEntries, ([, { assetId }]) => assetId!);\n\n const contentSize = (contents: string | Buffer) => {\n const length =\n typeof contents === 'string' ? Buffer.byteLength(contents, 'utf8') : contents.length;\n return length;\n };\n\n const sizeStr = (contents: string | Buffer) => {\n const length = contentSize(contents);\n const size = chalk.gray`(${prettyBytes(length)})`;\n return size;\n };\n\n if (routeEntries.length) {\n const plural = routeEntries.length === 1 ? '' : 's';\n\n Log.log('');\n Log.log(chalk.bold`Exporting ${routeEntries.length} static route${plural}:`);\n\n for (const [, assets] of routeEntries.sort((a, b) => a[0].length - b[0].length)) {\n const id = assets.routeId!;\n Log.log('/' + (id === '' ? chalk.gray(' (index)') : id), sizeStr(assets.contents));\n }\n }\n\n const assetGroups = [...groups.entries()].sort((a, b) => a[0].localeCompare(b[0])) as [\n string,\n [string, ExportAssetDescriptor][],\n ][];\n\n if (assetGroups.length) {\n const totalAssets = assetGroups.reduce((sum, [, assets]) => sum + assets.length, 0);\n const plural = totalAssets === 1 ? '' : 's';\n\n Log.log('');\n Log.log(chalk.bold`Exporting ${totalAssets} asset${plural}:`);\n\n for (const [assetId, assets] of assetGroups) {\n const averageContentSize =\n assets.reduce((sum, [, { contents }]) => sum + contentSize(contents), 0) / assets.length;\n Log.log(\n assetId,\n chalk.gray(\n `(${[\n assets.length > 1 ? `${assets.length} variations` : '',\n `${prettyBytes(averageContentSize)}`,\n ]\n .filter(Boolean)\n .join(' | ')})`\n )\n );\n }\n }\n\n const bundles: Map<string, [string, ExportAssetDescriptor][]> = new Map();\n const other: [string, ExportAssetDescriptor][] = [];\n\n remainingEntries.forEach(([filepath, asset]) => {\n if (!filepath.match(/_expo\\/static\\//)) {\n other.push([filepath, asset]);\n } else {\n const platform = filepath.match(/_expo\\/static\\/js\\/([^/]+)\\//)?.[1] ?? 'web';\n if (!bundles.has(platform)) bundles.set(platform, []);\n\n bundles.get(platform)!.push([filepath, asset]);\n }\n });\n\n [...bundles.entries()].forEach(([platform, assets]) => {\n Log.log('');\n const plural = assets.length === 1 ? '' : 's';\n Log.log(chalk.bold`Exporting ${assets.length} bundle${plural} for ${platform}:`);\n\n const allAssets = assets.sort((a, b) => a[0].localeCompare(b[0]));\n while (allAssets.length) {\n const [filePath, asset] = allAssets.shift()!;\n Log.log(filePath, sizeStr(asset.contents));\n if (filePath.match(/\\.(js|hbc)$/)) {\n // Get source map\n const sourceMapIndex = allAssets.findIndex(([fp]) => fp === filePath + '.map');\n if (sourceMapIndex !== -1) {\n const [sourceMapFilePath, sourceMapAsset] = allAssets.splice(sourceMapIndex, 1)[0];\n Log.log(chalk.gray(sourceMapFilePath), sizeStr(sourceMapAsset.contents));\n }\n }\n }\n });\n\n if (other.length) {\n Log.log('');\n const plural = other.length === 1 ? '' : 's';\n Log.log(chalk.bold`Exporting ${other.length} file${plural}:`);\n\n for (const [filePath, asset] of other.sort((a, b) => a[0].localeCompare(b[0]))) {\n Log.log(filePath, sizeStr(asset.contents));\n }\n }\n\n // Decouple logging from writing for better performance.\n\n await Promise.all(\n [...files.entries()]\n .sort(([a], [b]) => a.localeCompare(b))\n .map(async ([file, { contents, targetDomain }]) => {\n // NOTE: Only use `targetDomain` if we have at least one server asset\n const domain = (hasServerOutput && targetDomain) || '';\n const outputPath = path.join(outputDir, domain, file);\n await fs.promises.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.promises.writeFile(outputPath, contents);\n })\n );\n\n Log.log('');\n}\n\nfunction groupBy<T>(array: T[], key: (item: T) => string): Map<string, T[]> {\n const map = new Map<string, T[]>();\n array.forEach((item) => {\n const group = key(item);\n const list = map.get(group) ?? [];\n list.push(item);\n map.set(group, list);\n });\n return map;\n}\n\n// TODO: Move source map modification to the serializer\nexport function getFilesFromSerialAssets(\n resources: SerialAsset[],\n {\n includeSourceMaps,\n files = new Map(),\n platform,\n }: {\n includeSourceMaps: boolean;\n files?: ExportAssetMap;\n platform?: string;\n }\n) {\n resources.forEach((resource) => {\n files.set(resource.filename, {\n contents: resource.source,\n originFilename: resource.originFilename,\n targetDomain: platform === 'web' ? 'client' : undefined,\n });\n });\n\n return files;\n}\n"],"names":["persistMetroFilesAsync","getFilesFromSerialAssets","files","outputDir","size","fs","mkdirSync","path","join","recursive","assetEntries","routeEntries","remainingEntries","hasServerOutput","asset","entries","targetDomain","assetId","push","routeId","groups","groupBy","contentSize","contents","length","Buffer","byteLength","sizeStr","chalk","gray","prettyBytes","plural","Log","log","bold","assets","sort","a","b","id","assetGroups","localeCompare","totalAssets","reduce","sum","averageContentSize","filter","Boolean","bundles","Map","other","forEach","filepath","match","platform","has","set","get","allAssets","filePath","shift","sourceMapIndex","findIndex","fp","sourceMapFilePath","sourceMapAsset","splice","Promise","all","map","file","domain","outputPath","promises","mkdir","dirname","writeFile","array","key","item","group","list","resources","includeSourceMaps","resource","filename","source","originFilename","undefined"],"mappings":"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E,MAAM;YACzBC,cAAc,EAAEH,QAAQ,CAACG,cAAc;YACvCvE,YAAY,EAAEsC,QAAQ,KAAK,KAAK,GAAG,QAAQ,GAAGkC,SAAS;SACxD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAOtF,KAAK,CAAC;AACf,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/export/saveAssets.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 { SerialAsset } from '@expo/metro-config/build/serializer/serializerAssets';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\nimport prettyBytes from 'pretty-bytes';\n\nimport { BundleAssetWithFileHashes } from './fork-bundleAsync';\nimport { Log } from '../log';\n\nexport type ManifestAsset = { fileHashes: string[]; files: string[]; hash: string };\n\nexport type Asset = ManifestAsset | BundleAssetWithFileHashes;\n\nexport type ExportAssetDescriptor = {\n contents: string | Buffer;\n originFilename?: string;\n /** An identifier for grouping together variations of the same asset. */\n assetId?: string;\n /** Expo Router route path for formatting the HTML output. */\n routeId?: string;\n /** A key for grouping together output files by server- or client-side. */\n targetDomain?: 'server' | 'client';\n};\n\nexport type ExportAssetMap = Map<string, ExportAssetDescriptor>;\n\nexport async function persistMetroFilesAsync(files: ExportAssetMap, outputDir: string) {\n if (!files.size) {\n return;\n }\n fs.mkdirSync(path.join(outputDir), { recursive: true });\n\n // Test fixtures:\n // Log.log(\n // JSON.stringify(\n // Object.fromEntries([...files.entries()].map(([k, v]) => [k, { ...v, contents: '' }]))\n // )\n // );\n\n const assetEntries: [string, ExportAssetDescriptor][] = [];\n const routeEntries: [string, ExportAssetDescriptor][] = [];\n const remainingEntries: [string, ExportAssetDescriptor][] = [];\n\n let hasServerOutput = false;\n for (const asset of files.entries()) {\n hasServerOutput = hasServerOutput || asset[1].targetDomain === 'server';\n if (asset[1].assetId) assetEntries.push(asset);\n else if (asset[1].routeId != null) routeEntries.push(asset);\n else remainingEntries.push(asset);\n }\n\n const groups = groupBy(assetEntries, ([, { assetId }]) => assetId!);\n\n const contentSize = (contents: string | Buffer) => {\n const length =\n typeof contents === 'string' ? Buffer.byteLength(contents, 'utf8') : contents.length;\n return length;\n };\n\n const sizeStr = (contents: string | Buffer) => {\n const length = contentSize(contents);\n const size = chalk.gray`(${prettyBytes(length)})`;\n return size;\n };\n\n if (routeEntries.length) {\n const plural = routeEntries.length === 1 ? '' : 's';\n\n Log.log('');\n Log.log(chalk.bold`Exporting ${routeEntries.length} static route${plural}:`);\n\n for (const [, assets] of routeEntries.sort((a, b) => a[0].length - b[0].length)) {\n const id = assets.routeId!;\n Log.log('/' + (id === '' ? chalk.gray(' (index)') : id), sizeStr(assets.contents));\n }\n }\n\n const assetGroups = [...groups.entries()].sort((a, b) => a[0].localeCompare(b[0])) as [\n string,\n [string, ExportAssetDescriptor][],\n ][];\n\n if (assetGroups.length) {\n const totalAssets = assetGroups.reduce((sum, [, assets]) => sum + assets.length, 0);\n const plural = totalAssets === 1 ? '' : 's';\n\n Log.log('');\n Log.log(chalk.bold`Exporting ${totalAssets} asset${plural}:`);\n\n for (const [assetId, assets] of assetGroups) {\n const averageContentSize =\n assets.reduce((sum, [, { contents }]) => sum + contentSize(contents), 0) / assets.length;\n Log.log(\n assetId,\n chalk.gray(\n `(${[\n assets.length > 1 ? `${assets.length} variations` : '',\n `${prettyBytes(averageContentSize)}`,\n ]\n .filter(Boolean)\n .join(' | ')})`\n )\n );\n }\n }\n\n const bundles: Map<string, [string, ExportAssetDescriptor][]> = new Map();\n const other: [string, ExportAssetDescriptor][] = [];\n\n remainingEntries.forEach(([filepath, asset]) => {\n if (!filepath.match(/_expo\\/static\\//)) {\n other.push([filepath, asset]);\n } else {\n const platform = filepath.match(/_expo\\/static\\/js\\/([^/]+)\\//)?.[1] ?? 'web';\n if (!bundles.has(platform)) bundles.set(platform, []);\n\n bundles.get(platform)!.push([filepath, asset]);\n }\n });\n\n [...bundles.entries()].forEach(([platform, assets]) => {\n Log.log('');\n const plural = assets.length === 1 ? '' : 's';\n Log.log(chalk.bold`Exporting ${assets.length} bundle${plural} for ${platform}:`);\n\n const allAssets = assets.sort((a, b) => a[0].localeCompare(b[0]));\n while (allAssets.length) {\n const [filePath, asset] = allAssets.shift()!;\n Log.log(filePath, sizeStr(asset.contents));\n if (filePath.match(/\\.(js|hbc)$/)) {\n // Get source map\n const sourceMapIndex = allAssets.findIndex(([fp]) => fp === filePath + '.map');\n if (sourceMapIndex !== -1) {\n const [sourceMapFilePath, sourceMapAsset] = allAssets.splice(sourceMapIndex, 1)[0];\n Log.log(chalk.gray(sourceMapFilePath), sizeStr(sourceMapAsset.contents));\n }\n }\n }\n });\n\n if (other.length) {\n Log.log('');\n const plural = other.length === 1 ? '' : 's';\n Log.log(chalk.bold`Exporting ${other.length} file${plural}:`);\n\n for (const [filePath, asset] of other.sort((a, b) => a[0].localeCompare(b[0]))) {\n Log.log(filePath, sizeStr(asset.contents));\n }\n }\n\n // Decouple logging from writing for better performance.\n\n await Promise.all(\n [...files.entries()]\n .sort(([a], [b]) => a.localeCompare(b))\n .map(async ([file, { contents, targetDomain }]) => {\n // NOTE: Only use `targetDomain` if we have at least one server asset\n const domain = (hasServerOutput && targetDomain) || '';\n const outputPath = path.join(outputDir, domain, file);\n await fs.promises.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.promises.writeFile(outputPath, contents);\n })\n );\n\n Log.log('');\n}\n\nfunction groupBy<T>(array: T[], key: (item: T) => string): Map<string, T[]> {\n const map = new Map<string, T[]>();\n array.forEach((item) => {\n const group = key(item);\n const list = map.get(group) ?? [];\n list.push(item);\n map.set(group, list);\n });\n return map;\n}\n\n// TODO: Move source map modification to the serializer\nexport function getFilesFromSerialAssets(\n resources: SerialAsset[],\n {\n includeSourceMaps,\n files = new Map(),\n platform,\n }: {\n includeSourceMaps: boolean;\n files?: ExportAssetMap;\n platform?: string;\n }\n) {\n resources.forEach((resource) => {\n files.set(resource.filename, {\n contents: resource.source,\n originFilename: resource.originFilename,\n targetDomain: platform === 'web' ? 'client' : undefined,\n });\n });\n\n return files;\n}\n"],"names":["persistMetroFilesAsync","getFilesFromSerialAssets","files","outputDir","size","fs","mkdirSync","path","join","recursive","assetEntries","routeEntries","remainingEntries","hasServerOutput","asset","entries","targetDomain","assetId","push","routeId","groups","groupBy","contentSize","contents","length","Buffer","byteLength","sizeStr","chalk","gray","prettyBytes","plural","Log","log","bold","assets","sort","a","b","id","assetGroups","localeCompare","totalAssets","reduce","sum","averageContentSize","filter","Boolean","bundles","Map","other","forEach","filepath","match","platform","has","set","get","allAssets","filePath","shift","sourceMapIndex","findIndex","fp","sourceMapFilePath","sourceMapAsset","splice","Promise","all","map","file","domain","outputPath","promises","mkdir","dirname","writeFile","array","key","item","group","list","resources","includeSourceMaps","resource","filename","source","originFilename","undefined"],"mappings":"AAAA;;;;;CAKC,GACD;;;;;;;;;;;IA0BsBA,sBAAsB,MAAtBA,sBAAsB;IAyJ5BC,wBAAwB,MAAxBA,wBAAwB;;;8DAlLtB,OAAO;;;;;;;8DACV,IAAI;;;;;;;8DACF,MAAM;;;;;;;8DACC,cAAc;;;;;;qBAGlB,QAAQ;;;;;;AAmBrB,eAAeD,sBAAsB,CAACE,KAAqB,EAAEC,SAAiB,EAAE;IACrF,IAAI,CAACD,KAAK,CAACE,IAAI,EAAE;QACf,OAAO;IACT,CAAC;IACDC,GAAE,EAAA,QAAA,CAACC,SAAS,CAACC,KAAI,EAAA,QAAA,CAACC,IAAI,CAACL,SAAS,CAAC,EAAE;QAAEM,SAAS,EAAE,IAAI;KAAE,CAAC,CAAC;IAExD,iBAAiB;IACjB,WAAW;IACX,oBAAoB;IACpB,4FAA4F;IAC5F,MAAM;IACN,KAAK;IAEL,MAAMC,YAAY,GAAsC,EAAE,AAAC;IAC3D,MAAMC,YAAY,GAAsC,EAAE,AAAC;IAC3D,MAAMC,gBAAgB,GAAsC,EAAE,AAAC;IAE/D,IAAIC,eA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AdA,GAAG,CAACZ,GAAG,CAACuB,KAAK,CAAC,YAAdX,GAAc,GAAI,EAAE,AAAC;QAClCY,IAAI,CAAC/D,IAAI,CAAC6D,IAAI,CAAC,CAAC;QAChBV,GAAG,CAACb,GAAG,CAACwB,KAAK,EAAEC,IAAI,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;IACH,OAAOZ,GAAG,CAAC;AACb,CAAC;AAGM,SAASpE,wBAAwB,CACtCiF,SAAwB,EACxB,EACEC,iBAAiB,CAAA,EACjBjF,KAAK,EAAG,IAAI+C,GAAG,EAAE,CAAA,EACjBK,QAAQ,CAAA,EAKT,EACD;IACA4B,SAAS,CAAC/B,OAAO,CAAC,CAACiC,QAAQ,GAAK;QAC9BlF,KAAK,CAACsD,GAAG,CAAC4B,QAAQ,CAACC,QAAQ,EAAE;YAC3B9D,QAAQ,EAAE6D,QAAQ,CAACE,MAAM;YACzBC,cAAc,EAAEH,QAAQ,CAACG,cAAc;YACvCvE,YAAY,EAAEsC,QAAQ,KAAK,KAAK,GAAG,QAAQ,GAAGkC,SAAS;SACxD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAOtF,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -79,7 +79,14 @@ async function startBundlerAsync(projectRoot, { port , headless , scheme }) {
|
|
|
79
79
|
scheme
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
|
-
const devServerManager =
|
|
82
|
+
const devServerManager = new _devServerManager.DevServerManager(projectRoot, options);
|
|
83
|
+
await devServerManager.startAsync([
|
|
84
|
+
{
|
|
85
|
+
// TODO: Allow swapping this value for another bundler.
|
|
86
|
+
type: "metro",
|
|
87
|
+
options
|
|
88
|
+
},
|
|
89
|
+
]);
|
|
83
90
|
// Present the Terminal UI.
|
|
84
91
|
if (!headless && (0, _interactive.isInteractive)()) {
|
|
85
92
|
// Only read the config if we are going to use the results.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/run/startBundler.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport chalk from 'chalk';\n\nimport * as Log from '../log';\nimport { startInterfaceAsync } from '../start/interface/startInterface';\nimport { BundlerStartOptions } from '../start/server/BundlerDevServer';\nimport { DevServerManager } from '../start/server/DevServerManager';\nimport { env } from '../utils/env';\nimport { isInteractive } from '../utils/interactive';\n\nexport async function startBundlerAsync(\n projectRoot: string,\n {\n port,\n headless,\n scheme,\n }: {\n port: number;\n headless?: boolean;\n scheme?: string;\n }\n): Promise<DevServerManager> {\n const options: BundlerStartOptions = {\n port,\n headless,\n devClient: true,\n minify: false,\n\n location: {\n scheme,\n },\n };\n\n const devServerManager =
|
|
1
|
+
{"version":3,"sources":["../../../src/run/startBundler.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport chalk from 'chalk';\n\nimport * as Log from '../log';\nimport { startInterfaceAsync } from '../start/interface/startInterface';\nimport { BundlerStartOptions } from '../start/server/BundlerDevServer';\nimport { DevServerManager } from '../start/server/DevServerManager';\nimport { env } from '../utils/env';\nimport { isInteractive } from '../utils/interactive';\n\nexport async function startBundlerAsync(\n projectRoot: string,\n {\n port,\n headless,\n scheme,\n }: {\n port: number;\n headless?: boolean;\n scheme?: string;\n }\n): Promise<DevServerManager> {\n const options: BundlerStartOptions = {\n port,\n headless,\n devClient: true,\n minify: false,\n\n location: {\n scheme,\n },\n };\n\n const devServerManager = new DevServerManager(projectRoot, options);\n\n await devServerManager.startAsync([\n {\n // TODO: Allow swapping this value for another bundler.\n type: 'metro',\n options,\n },\n ]);\n\n // Present the Terminal UI.\n if (!headless && isInteractive()) {\n // Only read the config if we are going to use the results.\n const { exp } = getConfig(projectRoot, {\n // We don't need very many fields here, just use the lightest possible read.\n skipSDKVersionRequirement: true,\n skipPlugins: true,\n });\n await startInterfaceAsync(devServerManager, {\n platforms: exp.platforms ?? [],\n });\n } else {\n // Display the server location in CI...\n const url = devServerManager.getDefaultDevServer()?.getDevServerUrl();\n\n if (url) {\n if (env.__EXPO_E2E_TEST) {\n // Print the URL to stdout for tests\n console.info(`[__EXPO_E2E_TEST:server] ${JSON.stringify({ url })}`);\n }\n Log.log(chalk`Waiting on {underline ${url}}`);\n }\n }\n\n if (!options.headless) {\n await devServerManager.watchEnvironmentVariables();\n await devServerManager.bootstrapTypeScriptAsync();\n }\n\n return devServerManager;\n}\n"],"names":["startBundlerAsync","projectRoot","port","headless","scheme","options","devClient","minify","location","devServerManager","DevServerManager","startAsync","type","isInteractive","exp","getConfig","skipSDKVersionRequirement","skipPlugins","startInterfaceAsync","platforms","url","getDefaultDevServer","getDevServerUrl","env","__EXPO_E2E_TEST","console","info","JSON","stringify","Log","log","chalk","watchEnvironmentVariables","bootstrapTypeScriptAsync"],"mappings":"AAAA;;;;+BAUsBA,mBAAiB;;aAAjBA,iBAAiB;;;yBAVb,cAAc;;;;;;;8DACtB,OAAO;;;;;;2DAEJ,QAAQ;gCACO,mCAAmC;kCAEtC,kCAAkC;qBAC/C,cAAc;6BACJ,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE7C,eAAeA,iBAAiB,CACrCC,WAAmB,EACnB,EACEC,IAAI,CAAA,EACJC,QAAQ,CAAA,EACRC,MAAM,CAAA,EAKP,EAC0B;IAC3B,MAAMC,OAAO,GAAwB;QACnCH,IAAI;QACJC,QAAQ;QACRG,SAAS,EAAE,IAAI;QACfC,MAAM,EAAE,KAAK;QAEbC,QAAQ,EAAE;YACRJ,MAAM;SACP;KACF,AAAC;IAEF,MAAMK,gBAAgB,GAAG,IAAIC,iBAAgB,iBAAA,CAACT,WAAW,EAAEI,OAAO,CAAC,AAAC;IAEpE,MAAMI,gBAAgB,CAACE,UAAU,CAAC;QAChC;YACE,uDAAuD;YACvDC,IAAI,EAAE,OAAO;YACbP,OAAO;SACR;KACF,CAAC,CAAC;IAEH,2BAA2B;IAC3B,IAAI,CAACF,QAAQ,IAAIU,IAAAA,YAAa,cAAA,GAAE,EAAE;QAChC,2DAA2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|
|
171
|
-
this.watchConfig();
|
|
172
|
-
}
|
|
170
|
+
this.watchConfig();
|
|
173
171
|
}
|
|
174
172
|
watchConfig() {
|
|
175
173
|
var ref;
|
|
@@ -249,16 +247,11 @@ class BundlerDevServer {
|
|
|
249
247
|
// Close the server.
|
|
250
248
|
debug(`Stopping dev server (bundler: ${this.name})`);
|
|
251
249
|
if ((ref = this.instance) == null ? void 0 : ref.server) {
|
|
252
|
-
// Check if server is even running.
|
|
253
250
|
this.instance.server.close((error)=>{
|
|
254
251
|
debug(`Stopped dev server (bundler: ${this.name})`);
|
|
255
252
|
this.instance = null;
|
|
256
253
|
if (error) {
|
|
257
|
-
|
|
258
|
-
resolve();
|
|
259
|
-
} else {
|
|
260
|
-
reject(error);
|
|
261
|
-
}
|
|
254
|
+
reject(error);
|
|
262
255
|
} else {
|
|
263
256
|
resolve();
|
|
264
257
|
}
|