@expo/cli 56.1.16 → 57.0.0

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 CHANGED
@@ -139,7 +139,7 @@ const args = (0, _arg().default)({
139
139
  });
140
140
  if (args['--version']) {
141
141
  // Version is added in the build script.
142
- console.log("56.1.16");
142
+ console.log("57.0.0");
143
143
  process.exit(0);
144
144
  }
145
145
  if (args['--non-interactive']) {
@@ -76,7 +76,7 @@ function getInitMetadata() {
76
76
  return {
77
77
  format: 'v0-jsonl',
78
78
  // Version is added in the build script.
79
- version: "56.1.16" ?? 'UNVERSIONED'
79
+ version: "57.0.0" ?? 'UNVERSIONED'
80
80
  };
81
81
  }
82
82
  function getWellKnownTemporaryLogFile(projectRoot, command) {
@@ -22,9 +22,9 @@ function _paths() {
22
22
  };
23
23
  return data;
24
24
  }
25
- function _assert() {
26
- const data = /*#__PURE__*/ _interop_require_default(require("assert"));
27
- _assert = function() {
25
+ function _html() {
26
+ const data = require("@expo/router-server/build/utils/html");
27
+ _html = function() {
28
28
  return data;
29
29
  };
30
30
  return data;
@@ -36,16 +36,23 @@ function _chalk() {
36
36
  };
37
37
  return data;
38
38
  }
39
- function _fs() {
40
- const data = /*#__PURE__*/ _interop_require_default(require("fs"));
41
- _fs = function() {
39
+ function _nodeassert() {
40
+ const data = /*#__PURE__*/ _interop_require_default(require("node:assert"));
41
+ _nodeassert = function() {
42
42
  return data;
43
43
  };
44
44
  return data;
45
45
  }
46
- function _path() {
47
- const data = /*#__PURE__*/ _interop_require_default(require("path"));
48
- _path = function() {
46
+ function _nodefs() {
47
+ const data = /*#__PURE__*/ _interop_require_default(require("node:fs"));
48
+ _nodefs = function() {
49
+ return data;
50
+ };
51
+ return data;
52
+ }
53
+ function _nodepath() {
54
+ const data = /*#__PURE__*/ _interop_require_default(require("node:path"));
55
+ _nodepath = function() {
49
56
  return data;
50
57
  };
51
58
  return data;
@@ -154,7 +161,7 @@ async function exportAppAsync(projectRoot, { platforms, outputDir, clear, dev, d
154
161
  }
155
162
  const mode = dev ? 'development' : 'production';
156
163
  const publicPath = (0, _publicFolder.getPublicFolderPath)(projectRoot);
157
- const outputPath = _path().default.resolve(projectRoot, outputDir);
164
+ const outputPath = _nodepath().default.resolve(projectRoot, outputDir);
158
165
  // Write the JS bundles to disk, and get the bundle file names (this could change with async chunk loading support).
159
166
  const files = new Map();
160
167
  const devServerManager = await _DevServerManager.DevServerManager.startMetroAsync(projectRoot, {
@@ -167,7 +174,7 @@ async function exportAppAsync(projectRoot, { platforms, outputDir, clear, dev, d
167
174
  maxWorkers
168
175
  });
169
176
  const devServer = devServerManager.getDefaultDevServer();
170
- (0, _assert().default)(devServer instanceof _MetroBundlerDevServer.MetroBundlerDevServer);
177
+ (0, _nodeassert().default)(devServer instanceof _MetroBundlerDevServer.MetroBundlerDevServer);
171
178
  const bundles = {};
172
179
  const domComponentAssetsMetadata = {};
173
180
  const spaPlatforms = // TODO: Support server and static rendering for server component exports.
@@ -177,7 +184,7 @@ async function exportAppAsync(projectRoot, { platforms, outputDir, clear, dev, d
177
184
  // In RSC mode, we only need these to be in the client dir.
178
185
  // TODO: Merge back with other copy after we add SSR.
179
186
  try {
180
- await (0, _publicFolder.copyPublicFolderAsync)(publicPath, _path().default.join(outputPath, 'client'));
187
+ await (0, _publicFolder.copyPublicFolderAsync)(publicPath, _nodepath().default.join(outputPath, 'client'));
181
188
  } catch (error) {
182
189
  _log.error('Failed to copy public directory to dist directory');
183
190
  throw error;
@@ -267,28 +274,25 @@ async function exportAppAsync(projectRoot, { platforms, outputDir, clear, dev, d
267
274
  ];
268
275
  }));
269
276
  if (platform === 'web') {
277
+ const faviconAsset = await (0, _favicon.generateFaviconAssetAsync)(projectRoot, {
278
+ outputDir,
279
+ baseUrl,
280
+ files,
281
+ exp: projectConfig.exp
282
+ });
270
283
  // TODO: Unify with exportStaticAsync
271
284
  // TODO: Maybe move to the serializer.
272
- let html = await (0, _serializeHtml.serializeHtmlWithAssets)({
285
+ const html = (0, _serializeHtml.serializeHtmlWithAssets)({
273
286
  isExporting: true,
274
287
  resources: bundle.artifacts,
275
288
  template: await (0, _webTemplate.createTemplateHtmlFromExpoConfigAsync)(projectRoot, {
276
289
  scripts: [],
277
290
  cssLinks: [],
291
+ extraHead: faviconAsset ? (0, _html().createFaviconAsString)(faviconAsset.href) : undefined,
278
292
  exp: projectConfig.exp
279
293
  }),
280
294
  baseUrl
281
295
  });
282
- // Add the favicon assets to the HTML.
283
- const modifyHtml = await (0, _favicon.getVirtualFaviconAssetsAsync)(projectRoot, {
284
- outputDir,
285
- baseUrl,
286
- files,
287
- exp: projectConfig.exp
288
- });
289
- if (modifyHtml) {
290
- html = modifyHtml(html);
291
- }
292
296
  // HACK: This is used for adding SSR shims in React Server Components.
293
297
  templateHtml = html;
294
298
  // Generate SPA-styled HTML file.
@@ -347,7 +351,7 @@ async function exportAppAsync(projectRoot, { platforms, outputDir, clear, dev, d
347
351
  const exportServer = ((_exp_web2 = exp.web) == null ? void 0 : _exp_web2.output) === 'server';
348
352
  if (exportServer) {
349
353
  // TODO: Remove when this is abstracted into the files map
350
- await (0, _publicFolder.copyPublicFolderAsync)(publicPath, _path().default.resolve(outputPath, 'client'));
354
+ await (0, _publicFolder.copyPublicFolderAsync)(publicPath, _nodepath().default.resolve(outputPath, 'client'));
351
355
  }
352
356
  if (skipSSG) {
353
357
  _log.log('Skipping static site generation');
@@ -358,8 +362,8 @@ async function exportAppAsync(projectRoot, { platforms, outputDir, clear, dev, d
358
362
  });
359
363
  // Output a placeholder index.html if one doesn't exist in the public directory.
360
364
  // This ensures native + API routes have some content at the root URL.
361
- const placeholderIndex = _path().default.resolve(outputPath, 'client/index.html');
362
- if (!_fs().default.existsSync(placeholderIndex)) {
365
+ const placeholderIndex = _nodepath().default.resolve(outputPath, 'client/index.html');
366
+ if (!_nodefs().default.existsSync(placeholderIndex)) {
363
367
  files.set('index.html', {
364
368
  contents: `<html><body></body></html>`,
365
369
  targetDomain: 'client'
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/exportApp.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport type { Platform } from '@expo/config';\nimport { resolveRelativeEntryPoint } from '@expo/config/paths';\nimport type { SerialAsset } from '@expo/metro-config/build/serializer/serializerAssets';\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { type PlatformMetadata, createMetadataJson } from './createMetadataJson';\nimport { exportAssetsAsync } from './exportAssets';\nimport {\n addDomBundleToMetadataAsync,\n exportDomComponentAsync,\n transformNativeBundleForMd5Filename,\n transformDomEntryForMd5Filename,\n} from './exportDomComponents';\nimport { assertEngineMismatchAsync, isEnableHermesManaged } from './exportHermes';\nimport { exportApiRoutesStandaloneAsync, exportFromServerAsync } from './exportStaticAsync';\nimport { getVirtualFaviconAssetsAsync } from './favicon';\nimport { getPublicExpoManifestAsync } from './getPublicExpoManifest';\nimport { copyPublicFolderAsync, getPublicFolderPath } from './publicFolder';\nimport type { Options } from './resolveOptions';\nimport type { ExportAssetMap, BundleOutput, BundleAssetWithFileHashes } from './saveAssets';\nimport { getFilesFromSerialAssets, persistMetroFilesAsync } from './saveAssets';\nimport { createAssetMap } from './writeContents';\nimport * as Log from '../log';\nimport { WebSupportProjectPrerequisite } from '../start/doctor/web/WebSupportProjectPrerequisite';\nimport { DevServerManager } from '../start/server/DevServerManager';\nimport { MetroBundlerDevServer } from '../start/server/metro/MetroBundlerDevServer';\nimport { getRouterDirectoryModuleIdWithManifest } from '../start/server/metro/router';\nimport { serializeHtmlWithAssets } from '../start/server/metro/serializeHtml';\nimport { getBaseUrlFromExpoConfig } from '../start/server/middleware/metroOptions';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../start/server/webTemplate';\nimport { env } from '../utils/env';\nimport { CommandError } from '../utils/errors';\nimport { setNodeEnv, loadEnvFiles } from '../utils/nodeEnv';\n\nexport async function exportAppAsync(\n projectRoot: string,\n {\n platforms,\n outputDir,\n clear,\n dev,\n dumpAssetmap,\n sourceMaps,\n inlineSourceMaps,\n minify,\n bytecode,\n maxWorkers,\n skipSSG,\n hostedNative,\n }: Pick<\n Options,\n | 'dumpAssetmap'\n | 'sourceMaps'\n | 'inlineSourceMaps'\n | 'dev'\n | 'clear'\n | 'outputDir'\n | 'platforms'\n | 'minify'\n | 'bytecode'\n | 'maxWorkers'\n | 'skipSSG'\n | 'hostedNative'\n >\n): Promise<void> {\n // Force the environment during export and do not allow overriding it.\n const environment = dev ? 'development' : 'production';\n process.env.NODE_ENV = environment;\n setNodeEnv(environment);\n loadEnvFiles(projectRoot);\n\n const projectConfig = getConfig(projectRoot);\n const exp = await getPublicExpoManifestAsync(projectRoot, {\n // Web doesn't require validation.\n skipValidation: platforms.length === 1 && platforms[0] === 'web',\n });\n\n if (platforms.includes('web')) {\n await new WebSupportProjectPrerequisite(projectRoot).assertAsync();\n }\n\n const useServerRendering = ['static', 'server'].includes(exp.web?.output ?? '');\n\n if (skipSSG && exp.web?.output !== 'server') {\n throw new CommandError('--no-ssg can only be used with `web.output: server`');\n }\n\n const baseUrl = getBaseUrlFromExpoConfig(exp);\n\n if (!bytecode && (platforms.includes('ios') || platforms.includes('android'))) {\n Log.warn(\n `Bytecode makes the app startup faster, disabling bytecode is highly discouraged and should only be used for debugging purposes.`\n );\n }\n\n // Print out logs\n if (baseUrl) {\n Log.log();\n Log.log(chalk.gray`Using (experimental) base path: ${baseUrl}`);\n // Warn if not using an absolute path.\n if (!baseUrl.startsWith('/')) {\n Log.log(\n chalk.yellow` Base path does not start with a slash. Requests will not be absolute.`\n );\n }\n }\n\n const mode = dev ? 'development' : 'production';\n const publicPath = getPublicFolderPath(projectRoot);\n const outputPath = path.resolve(projectRoot, outputDir);\n\n // Write the JS bundles to disk, and get the bundle file names (this could change with async chunk loading support).\n\n const files: ExportAssetMap = new Map();\n\n const devServerManager = await DevServerManager.startMetroAsync(projectRoot, {\n minify,\n mode,\n port: 8081,\n isExporting: true,\n location: {},\n resetDevServer: clear,\n maxWorkers,\n });\n\n const devServer = devServerManager.getDefaultDevServer();\n assert(devServer instanceof MetroBundlerDevServer);\n\n const bundles: Partial<Record<Platform, BundleOutput>> = {};\n const domComponentAssetsMetadata: Partial<Record<Platform, PlatformMetadata['assets']>> = {};\n\n const spaPlatforms =\n // TODO: Support server and static rendering for server component exports.\n useServerRendering && !devServer.isReactServerComponentsEnabled\n ? platforms.filter((platform) => platform !== 'web')\n : platforms;\n\n try {\n if (devServer.isReactServerComponentsEnabled) {\n // In RSC mode, we only need these to be in the client dir.\n // TODO: Merge back with other copy after we add SSR.\n try {\n await copyPublicFolderAsync(publicPath, path.join(outputPath, 'client'));\n } catch (error) {\n Log.error('Failed to copy public directory to dist directory');\n throw error;\n }\n } else {\n // NOTE(kitten): The public folder is currently always copied, regardless of targetDomain\n // split. Hence, there's another separate `copyPublicFolderAsync` call below for `web`\n await copyPublicFolderAsync(publicPath, outputPath);\n }\n\n let templateHtml: string | undefined;\n // Can be empty during web-only SSG.\n if (spaPlatforms.length) {\n await Promise.all(\n spaPlatforms.map(async (platform) => {\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 const isHermes = isEnableHermesManaged(exp, platform);\n if (isHermes) {\n await assertEngineMismatchAsync(projectRoot, exp, platform);\n }\n\n let bundle: {\n artifacts: SerialAsset[];\n assets: readonly BundleAssetWithFileHashes[];\n files?: ExportAssetMap;\n };\n\n try {\n // Run metro bundler and create the JS bundles/source maps.\n bundle = await devServer.nativeExportBundleAsync(\n exp,\n {\n platform,\n splitChunks:\n !env.EXPO_NO_BUNDLE_SPLITTING &&\n ((devServer.isReactServerComponentsEnabled && !bytecode) || platform === 'web'),\n mainModuleName: resolveRelativeEntryPoint(projectRoot, {\n platform,\n pkg: projectConfig.pkg,\n }),\n mode: dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n serializerIncludeMaps: sourceMaps || inlineSourceMaps,\n inlineSourceMap: inlineSourceMaps,\n bytecode: bytecode && isHermes,\n reactCompiler: !!exp.experiments?.reactCompiler,\n hosted: hostedNative,\n },\n files\n );\n } catch (error) {\n Log.log('');\n if (error instanceof Error) {\n Log.exception(error);\n } else {\n Log.error('Failed to bundle the app');\n Log.log(error as any);\n }\n process.exit(1);\n }\n\n bundles[platform] = bundle;\n\n getFilesFromSerialAssets(bundle.artifacts, {\n includeSourceMaps: sourceMaps,\n files,\n isServerHosted: devServer.isReactServerComponentsEnabled || hostedNative,\n });\n\n const expoDomComponentReferences = [\n ...new Set(\n bundle.artifacts\n .map((artifact) =>\n Array.isArray(artifact.metadata.expoDomComponentReferences)\n ? artifact.metadata.expoDomComponentReferences\n : []\n )\n .flat()\n ),\n ];\n await Promise.all(\n // TODO: Make a version of this which uses `this.metro.getBundler().buildGraphForEntries([])` to bundle all the DOM components at once.\n expoDomComponentReferences.map(async (filePath) => {\n const { bundle: platformDomComponentsBundle, htmlOutputName } =\n await exportDomComponentAsync({\n filePath,\n projectRoot,\n dev,\n devServer,\n isHermes,\n includeSourceMaps: sourceMaps,\n exp,\n files,\n useMd5Filename: true,\n });\n\n // Merge the assets from the DOM component into the output assets, deduplicating by hash.\n const existingHashes = new Set(bundle.assets.map((a) => a.hash));\n (bundle.assets as (typeof bundle.assets)[0][]).push(\n ...platformDomComponentsBundle.assets.filter((a) => !existingHashes.has(a.hash))\n );\n\n transformNativeBundleForMd5Filename({\n domComponentReference: filePath,\n nativeBundle: bundle,\n files,\n htmlOutputName,\n });\n domComponentAssetsMetadata[platform] = [\n ...(domComponentAssetsMetadata[platform] || []),\n ...(await addDomBundleToMetadataAsync(platformDomComponentsBundle)),\n ...transformDomEntryForMd5Filename({\n files,\n htmlOutputName,\n }),\n ];\n })\n );\n\n if (platform === 'web') {\n // TODO: Unify with exportStaticAsync\n // TODO: Maybe move to the serializer.\n let html = await serializeHtmlWithAssets({\n isExporting: true,\n resources: bundle.artifacts,\n template: await createTemplateHtmlFromExpoConfigAsync(projectRoot, {\n scripts: [],\n cssLinks: [],\n exp: projectConfig.exp,\n }),\n baseUrl,\n });\n\n // Add the favicon assets to the HTML.\n const modifyHtml = await getVirtualFaviconAssetsAsync(projectRoot, {\n outputDir,\n baseUrl,\n files,\n exp: projectConfig.exp,\n });\n if (modifyHtml) {\n html = modifyHtml(html);\n }\n\n // HACK: This is used for adding SSR shims in React Server Components.\n templateHtml = html;\n\n // Generate SPA-styled HTML file.\n // If web exists, then write the template HTML file.\n files.set('index.html', {\n contents: html,\n targetDomain: devServer.isReactServerComponentsEnabled ? 'server' : 'client',\n });\n }\n })\n );\n\n if (devServer.isReactServerComponentsEnabled) {\n const isWeb = platforms.includes('web');\n\n await exportApiRoutesStandaloneAsync(devServer, {\n files,\n platform: 'web',\n apiRoutesOnly: !isWeb,\n templateHtml,\n });\n }\n\n // TODO: Use same asset system across platforms again.\n const { assets, embeddedHashSet } = await exportAssetsAsync(projectRoot, {\n files,\n exp,\n outputDir: outputPath,\n bundles,\n baseUrl,\n hostedNative,\n });\n\n if (dumpAssetmap) {\n Log.log('Creating asset map');\n files.set('assetmap.json', { contents: JSON.stringify(createAssetMap({ assets })) });\n }\n\n const targetDomain = devServer.isReactServerComponentsEnabled ? 'client/' : '';\n const fileNames = Object.fromEntries(\n Object.entries(bundles).map(([platform, bundle]) => [\n platform,\n bundle.artifacts\n .filter((asset) => asset.type === 'js')\n .map((asset) => targetDomain + asset.filename),\n ])\n );\n\n // Generate a `metadata.json` for EAS Update.\n const contents = createMetadataJson({\n bundles,\n fileNames,\n embeddedHashSet,\n domComponentAssetsMetadata,\n });\n files.set('metadata.json', { contents: JSON.stringify(contents) });\n }\n\n // Additional web-only steps...\n\n if (platforms.includes('web') && useServerRendering) {\n const exportServer = exp.web?.output === 'server';\n\n if (exportServer) {\n // TODO: Remove when this is abstracted into the files map\n await copyPublicFolderAsync(publicPath, path.resolve(outputPath, 'client'));\n }\n\n if (skipSSG) {\n Log.log('Skipping static site generation');\n await exportApiRoutesStandaloneAsync(devServer, {\n files,\n platform: 'web',\n apiRoutesOnly: true,\n });\n\n // Output a placeholder index.html if one doesn't exist in the public directory.\n // This ensures native + API routes have some content at the root URL.\n const placeholderIndex = path.resolve(outputPath, 'client/index.html');\n if (!fs.existsSync(placeholderIndex)) {\n files.set('index.html', {\n contents: `<html><body></body></html>`,\n targetDomain: 'client',\n });\n }\n } else if (\n // TODO: Support static export with RSC.\n !devServer.isReactServerComponentsEnabled\n ) {\n await exportFromServerAsync(projectRoot, devServer, {\n mode,\n files,\n clear: !!clear,\n outputDir: outputPath,\n minify,\n baseUrl,\n includeSourceMaps: sourceMaps,\n routerRoot: getRouterDirectoryModuleIdWithManifest(projectRoot, exp),\n reactCompiler: !!exp.experiments?.reactCompiler,\n exportServer,\n maxWorkers,\n isExporting: true,\n exp: projectConfig.exp,\n });\n }\n }\n } finally {\n await devServerManager.stopAsync();\n }\n\n // Write all files at the end for unified logging.\n await persistMetroFilesAsync(files, outputPath);\n}\n"],"names":["exportAppAsync","projectRoot","platforms","outputDir","clear","dev","dumpAssetmap","sourceMaps","inlineSourceMaps","minify","bytecode","maxWorkers","skipSSG","hostedNative","exp","environment","process","env","NODE_ENV","setNodeEnv","loadEnvFiles","projectConfig","getConfig","getPublicExpoManifestAsync","skipValidation","length","includes","WebSupportProjectPrerequisite","assertAsync","useServerRendering","web","output","CommandError","baseUrl","getBaseUrlFromExpoConfig","Log","warn","log","chalk","gray","startsWith","yellow","mode","publicPath","getPublicFolderPath","outputPath","path","resolve","files","Map","devServerManager","DevServerManager","startMetroAsync","port","isExporting","location","resetDevServer","devServer","getDefaultDevServer","assert","MetroBundlerDevServer","bundles","domComponentAssetsMetadata","spaPlatforms","isReactServerComponentsEnabled","filter","platform","copyPublicFolderAsync","join","error","templateHtml","Promise","all","map","isHermes","isEnableHermesManaged","assertEngineMismatchAsync","bundle","nativeExportBundleAsync","splitChunks","EXPO_NO_BUNDLE_SPLITTING","mainModuleName","resolveRelativeEntryPoint","pkg","engine","undefined","serializerIncludeMaps","inlineSourceMap","reactCompiler","experiments","hosted","Error","exception","exit","getFilesFromSerialAssets","artifacts","includeSourceMaps","isServerHosted","expoDomComponentReferences","Set","artifact","Array","isArray","metadata","flat","filePath","platformDomComponentsBundle","htmlOutputName","exportDomComponentAsync","useMd5Filename","existingHashes","assets","a","hash","push","has","transformNativeBundleForMd5Filename","domComponentReference","nativeBundle","addDomBundleToMetadataAsync","transformDomEntryForMd5Filename","html","serializeHtmlWithAssets","resources","template","createTemplateHtmlFromExpoConfigAsync","scripts","cssLinks","modifyHtml","getVirtualFaviconAssetsAsync","set","contents","targetDomain","isWeb","exportApiRoutesStandaloneAsync","apiRoutesOnly","embeddedHashSet","exportAssetsAsync","JSON","stringify","createAssetMap","fileNames","Object","fromEntries","entries","asset","type","filename","createMetadataJson","exportServer","placeholderIndex","fs","existsSync","exportFromServerAsync","routerRoot","getRouterDirectoryModuleIdWithManifest","stopAsync","persistMetroFilesAsync"],"mappings":";;;;+BAsCsBA;;;eAAAA;;;;yBAtCI;;;;;;;yBAEgB;;;;;;;gEAEvB;;;;;;;gEACD;;;;;;;gEACH;;;;;;;gEACE;;;;;;oCAEyC;8BACxB;qCAM3B;8BAC0D;mCACK;yBACzB;uCACF;8BACgB;4BAGM;+BAClC;6DACV;+CACyB;kCACb;uCACK;wBACiB;+BACf;8BACC;6BACa;qBAClC;wBACS;yBACY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElC,eAAeA,eACpBC,WAAmB,EACnB,EACEC,SAAS,EACTC,SAAS,EACTC,KAAK,EACLC,GAAG,EACHC,YAAY,EACZC,UAAU,EACVC,gBAAgB,EAChBC,MAAM,EACNC,QAAQ,EACRC,UAAU,EACVC,OAAO,EACPC,YAAY,EAeb;QAkBwDC,UAE1CA;IAlBf,sEAAsE;IACtE,MAAMC,cAAcV,MAAM,gBAAgB;IAC1CW,QAAQC,GAAG,CAACC,QAAQ,GAAGH;IACvBI,IAAAA,mBAAU,EAACJ;IACXK,I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YG,eAAI,CAACC,OAAO,CAACF,YAAY;YACnE;YAEA,IAAIjC,SAAS;gBACXuB,KAAIE,GAAG,CAAC;gBACR,MAAMiG,IAAAA,iDAA8B,EAAC7E,WAAW;oBAC9CT;oBACAkB,UAAU;oBACVqE,eAAe;gBACjB;gBAEA,gFAAgF;gBAChF,sEAAsE;gBACtE,MAAMe,mBAAmBxG,eAAI,CAACC,OAAO,CAACF,YAAY;gBAClD,IAAI,CAAC0G,aAAE,CAACC,UAAU,CAACF,mBAAmB;oBACpCtG,MAAMkF,GAAG,CAAC,cAAc;wBACtBC,UAAU,CAAC,0BAA0B,CAAC;wBACtCC,cAAc;oBAChB;gBACF;YACF,OAAO,IACL,wCAAwC;YACxC,CAAC3E,UAAUO,8BAA8B,EACzC;oBAUmBlD;gBATnB,MAAM2I,IAAAA,wCAAqB,EAACxJ,aAAawD,WAAW;oBAClDf;oBACAM;oBACA5C,OAAO,CAAC,CAACA;oBACTD,WAAW0C;oBACXpC;oBACAwB;oBACA+D,mBAAmBzF;oBACnBmJ,YAAYC,IAAAA,8CAAsC,EAAC1J,aAAaa;oBAChE0E,eAAe,CAAC,GAAC1E,mBAAAA,IAAI2E,WAAW,qBAAf3E,iBAAiB0E,aAAa;oBAC/C6D;oBACA1I;oBACA2C,aAAa;oBACbxC,KAAKO,cAAcP,GAAG;gBACxB;YACF;QACF;IACF,SAAU;QACR,MAAMoC,iBAAiB0G,SAAS;IAClC;IAEA,kDAAkD;IAClD,MAAMC,IAAAA,kCAAsB,EAAC7G,OAAOH;AACtC"}
1
+ {"version":3,"sources":["../../../src/export/exportApp.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport type { Platform } from '@expo/config';\nimport { resolveRelativeEntryPoint } from '@expo/config/paths';\nimport type { SerialAsset } from '@expo/metro-config/build/serializer/serializerAssets';\nimport { createFaviconAsString } from '@expo/router-server/build/utils/html';\nimport chalk from 'chalk';\nimport assert from 'node:assert';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { type PlatformMetadata, createMetadataJson } from './createMetadataJson';\nimport { exportAssetsAsync } from './exportAssets';\nimport {\n addDomBundleToMetadataAsync,\n exportDomComponentAsync,\n transformNativeBundleForMd5Filename,\n transformDomEntryForMd5Filename,\n} from './exportDomComponents';\nimport { assertEngineMismatchAsync, isEnableHermesManaged } from './exportHermes';\nimport { exportApiRoutesStandaloneAsync, exportFromServerAsync } from './exportStaticAsync';\nimport { generateFaviconAssetAsync } from './favicon';\nimport { getPublicExpoManifestAsync } from './getPublicExpoManifest';\nimport { copyPublicFolderAsync, getPublicFolderPath } from './publicFolder';\nimport type { Options } from './resolveOptions';\nimport type { ExportAssetMap, BundleOutput, BundleAssetWithFileHashes } from './saveAssets';\nimport { getFilesFromSerialAssets, persistMetroFilesAsync } from './saveAssets';\nimport { createAssetMap } from './writeContents';\nimport * as Log from '../log';\nimport { WebSupportProjectPrerequisite } from '../start/doctor/web/WebSupportProjectPrerequisite';\nimport { DevServerManager } from '../start/server/DevServerManager';\nimport { MetroBundlerDevServer } from '../start/server/metro/MetroBundlerDevServer';\nimport { getRouterDirectoryModuleIdWithManifest } from '../start/server/metro/router';\nimport { serializeHtmlWithAssets } from '../start/server/metro/serializeHtml';\nimport { getBaseUrlFromExpoConfig } from '../start/server/middleware/metroOptions';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../start/server/webTemplate';\nimport { env } from '../utils/env';\nimport { CommandError } from '../utils/errors';\nimport { setNodeEnv, loadEnvFiles } from '../utils/nodeEnv';\n\nexport async function exportAppAsync(\n projectRoot: string,\n {\n platforms,\n outputDir,\n clear,\n dev,\n dumpAssetmap,\n sourceMaps,\n inlineSourceMaps,\n minify,\n bytecode,\n maxWorkers,\n skipSSG,\n hostedNative,\n }: Pick<\n Options,\n | 'dumpAssetmap'\n | 'sourceMaps'\n | 'inlineSourceMaps'\n | 'dev'\n | 'clear'\n | 'outputDir'\n | 'platforms'\n | 'minify'\n | 'bytecode'\n | 'maxWorkers'\n | 'skipSSG'\n | 'hostedNative'\n >\n): Promise<void> {\n // Force the environment during export and do not allow overriding it.\n const environment = dev ? 'development' : 'production';\n process.env.NODE_ENV = environment;\n setNodeEnv(environment);\n loadEnvFiles(projectRoot);\n\n const projectConfig = getConfig(projectRoot);\n const exp = await getPublicExpoManifestAsync(projectRoot, {\n // Web doesn't require validation.\n skipValidation: platforms.length === 1 && platforms[0] === 'web',\n });\n\n if (platforms.includes('web')) {\n await new WebSupportProjectPrerequisite(projectRoot).assertAsync();\n }\n\n const useServerRendering = ['static', 'server'].includes(exp.web?.output ?? '');\n\n if (skipSSG && exp.web?.output !== 'server') {\n throw new CommandError('--no-ssg can only be used with `web.output: server`');\n }\n\n const baseUrl = getBaseUrlFromExpoConfig(exp);\n\n if (!bytecode && (platforms.includes('ios') || platforms.includes('android'))) {\n Log.warn(\n `Bytecode makes the app startup faster, disabling bytecode is highly discouraged and should only be used for debugging purposes.`\n );\n }\n\n // Print out logs\n if (baseUrl) {\n Log.log();\n Log.log(chalk.gray`Using (experimental) base path: ${baseUrl}`);\n // Warn if not using an absolute path.\n if (!baseUrl.startsWith('/')) {\n Log.log(\n chalk.yellow` Base path does not start with a slash. Requests will not be absolute.`\n );\n }\n }\n\n const mode = dev ? 'development' : 'production';\n const publicPath = getPublicFolderPath(projectRoot);\n const outputPath = path.resolve(projectRoot, outputDir);\n\n // Write the JS bundles to disk, and get the bundle file names (this could change with async chunk loading support).\n\n const files: ExportAssetMap = new Map();\n\n const devServerManager = await DevServerManager.startMetroAsync(projectRoot, {\n minify,\n mode,\n port: 8081,\n isExporting: true,\n location: {},\n resetDevServer: clear,\n maxWorkers,\n });\n\n const devServer = devServerManager.getDefaultDevServer();\n assert(devServer instanceof MetroBundlerDevServer);\n\n const bundles: Partial<Record<Platform, BundleOutput>> = {};\n const domComponentAssetsMetadata: Partial<Record<Platform, PlatformMetadata['assets']>> = {};\n\n const spaPlatforms =\n // TODO: Support server and static rendering for server component exports.\n useServerRendering && !devServer.isReactServerComponentsEnabled\n ? platforms.filter((platform) => platform !== 'web')\n : platforms;\n\n try {\n if (devServer.isReactServerComponentsEnabled) {\n // In RSC mode, we only need these to be in the client dir.\n // TODO: Merge back with other copy after we add SSR.\n try {\n await copyPublicFolderAsync(publicPath, path.join(outputPath, 'client'));\n } catch (error) {\n Log.error('Failed to copy public directory to dist directory');\n throw error;\n }\n } else {\n // NOTE(kitten): The public folder is currently always copied, regardless of targetDomain\n // split. Hence, there's another separate `copyPublicFolderAsync` call below for `web`\n await copyPublicFolderAsync(publicPath, outputPath);\n }\n\n let templateHtml: string | undefined;\n // Can be empty during web-only SSG.\n if (spaPlatforms.length) {\n await Promise.all(\n spaPlatforms.map(async (platform) => {\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 const isHermes = isEnableHermesManaged(exp, platform);\n if (isHermes) {\n await assertEngineMismatchAsync(projectRoot, exp, platform);\n }\n\n let bundle: {\n artifacts: SerialAsset[];\n assets: readonly BundleAssetWithFileHashes[];\n files?: ExportAssetMap;\n };\n\n try {\n // Run metro bundler and create the JS bundles/source maps.\n bundle = await devServer.nativeExportBundleAsync(\n exp,\n {\n platform,\n splitChunks:\n !env.EXPO_NO_BUNDLE_SPLITTING &&\n ((devServer.isReactServerComponentsEnabled && !bytecode) || platform === 'web'),\n mainModuleName: resolveRelativeEntryPoint(projectRoot, {\n platform,\n pkg: projectConfig.pkg,\n }),\n mode: dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n serializerIncludeMaps: sourceMaps || inlineSourceMaps,\n inlineSourceMap: inlineSourceMaps,\n bytecode: bytecode && isHermes,\n reactCompiler: !!exp.experiments?.reactCompiler,\n hosted: hostedNative,\n },\n files\n );\n } catch (error) {\n Log.log('');\n if (error instanceof Error) {\n Log.exception(error);\n } else {\n Log.error('Failed to bundle the app');\n Log.log(error as any);\n }\n process.exit(1);\n }\n\n bundles[platform] = bundle;\n\n getFilesFromSerialAssets(bundle.artifacts, {\n includeSourceMaps: sourceMaps,\n files,\n isServerHosted: devServer.isReactServerComponentsEnabled || hostedNative,\n });\n\n const expoDomComponentReferences = [\n ...new Set(\n bundle.artifacts\n .map((artifact) =>\n Array.isArray(artifact.metadata.expoDomComponentReferences)\n ? artifact.metadata.expoDomComponentReferences\n : []\n )\n .flat()\n ),\n ];\n await Promise.all(\n // TODO: Make a version of this which uses `this.metro.getBundler().buildGraphForEntries([])` to bundle all the DOM components at once.\n expoDomComponentReferences.map(async (filePath) => {\n const { bundle: platformDomComponentsBundle, htmlOutputName } =\n await exportDomComponentAsync({\n filePath,\n projectRoot,\n dev,\n devServer,\n isHermes,\n includeSourceMaps: sourceMaps,\n exp,\n files,\n useMd5Filename: true,\n });\n\n // Merge the assets from the DOM component into the output assets, deduplicating by hash.\n const existingHashes = new Set(bundle.assets.map((a) => a.hash));\n (bundle.assets as (typeof bundle.assets)[0][]).push(\n ...platformDomComponentsBundle.assets.filter((a) => !existingHashes.has(a.hash))\n );\n\n transformNativeBundleForMd5Filename({\n domComponentReference: filePath,\n nativeBundle: bundle,\n files,\n htmlOutputName,\n });\n domComponentAssetsMetadata[platform] = [\n ...(domComponentAssetsMetadata[platform] || []),\n ...(await addDomBundleToMetadataAsync(platformDomComponentsBundle)),\n ...transformDomEntryForMd5Filename({\n files,\n htmlOutputName,\n }),\n ];\n })\n );\n\n if (platform === 'web') {\n const faviconAsset = await generateFaviconAssetAsync(projectRoot, {\n outputDir,\n baseUrl,\n files,\n exp: projectConfig.exp,\n });\n\n // TODO: Unify with exportStaticAsync\n // TODO: Maybe move to the serializer.\n const html = serializeHtmlWithAssets({\n isExporting: true,\n resources: bundle.artifacts,\n template: await createTemplateHtmlFromExpoConfigAsync(projectRoot, {\n scripts: [],\n cssLinks: [],\n extraHead: faviconAsset ? createFaviconAsString(faviconAsset.href) : undefined,\n exp: projectConfig.exp,\n }),\n baseUrl,\n });\n\n // HACK: This is used for adding SSR shims in React Server Components.\n templateHtml = html;\n\n // Generate SPA-styled HTML file.\n // If web exists, then write the template HTML file.\n files.set('index.html', {\n contents: html,\n targetDomain: devServer.isReactServerComponentsEnabled ? 'server' : 'client',\n });\n }\n })\n );\n\n if (devServer.isReactServerComponentsEnabled) {\n const isWeb = platforms.includes('web');\n\n await exportApiRoutesStandaloneAsync(devServer, {\n files,\n platform: 'web',\n apiRoutesOnly: !isWeb,\n templateHtml,\n });\n }\n\n // TODO: Use same asset system across platforms again.\n const { assets, embeddedHashSet } = await exportAssetsAsync(projectRoot, {\n files,\n exp,\n outputDir: outputPath,\n bundles,\n baseUrl,\n hostedNative,\n });\n\n if (dumpAssetmap) {\n Log.log('Creating asset map');\n files.set('assetmap.json', { contents: JSON.stringify(createAssetMap({ assets })) });\n }\n\n const targetDomain = devServer.isReactServerComponentsEnabled ? 'client/' : '';\n const fileNames = Object.fromEntries(\n Object.entries(bundles).map(([platform, bundle]) => [\n platform,\n bundle.artifacts\n .filter((asset) => asset.type === 'js')\n .map((asset) => targetDomain + asset.filename),\n ])\n );\n\n // Generate a `metadata.json` for EAS Update.\n const contents = createMetadataJson({\n bundles,\n fileNames,\n embeddedHashSet,\n domComponentAssetsMetadata,\n });\n files.set('metadata.json', { contents: JSON.stringify(contents) });\n }\n\n // Additional web-only steps...\n\n if (platforms.includes('web') && useServerRendering) {\n const exportServer = exp.web?.output === 'server';\n\n if (exportServer) {\n // TODO: Remove when this is abstracted into the files map\n await copyPublicFolderAsync(publicPath, path.resolve(outputPath, 'client'));\n }\n\n if (skipSSG) {\n Log.log('Skipping static site generation');\n await exportApiRoutesStandaloneAsync(devServer, {\n files,\n platform: 'web',\n apiRoutesOnly: true,\n });\n\n // Output a placeholder index.html if one doesn't exist in the public directory.\n // This ensures native + API routes have some content at the root URL.\n const placeholderIndex = path.resolve(outputPath, 'client/index.html');\n if (!fs.existsSync(placeholderIndex)) {\n files.set('index.html', {\n contents: `<html><body></body></html>`,\n targetDomain: 'client',\n });\n }\n } else if (\n // TODO: Support static export with RSC.\n !devServer.isReactServerComponentsEnabled\n ) {\n await exportFromServerAsync(projectRoot, devServer, {\n mode,\n files,\n clear: !!clear,\n outputDir: outputPath,\n minify,\n baseUrl,\n includeSourceMaps: sourceMaps,\n routerRoot: getRouterDirectoryModuleIdWithManifest(projectRoot, exp),\n reactCompiler: !!exp.experiments?.reactCompiler,\n exportServer,\n maxWorkers,\n isExporting: true,\n exp: projectConfig.exp,\n });\n }\n }\n } finally {\n await devServerManager.stopAsync();\n }\n\n // Write all files at the end for unified logging.\n await persistMetroFilesAsync(files, outputPath);\n}\n"],"names":["exportAppAsync","projectRoot","platforms","outputDir","clear","dev","dumpAssetmap","sourceMaps","inlineSourceMaps","minify","bytecode","maxWorkers","skipSSG","hostedNative","exp","environment","process","env","NODE_ENV","setNodeEnv","loadEnvFiles","projectConfig","getConfig","getPublicExpoManifestAsync","skipValidation","length","includes","WebSupportProjectPrerequisite","assertAsync","useServerRendering","web","output","CommandError","baseUrl","getBaseUrlFromExpoConfig","Log","warn","log","chalk","gray","startsWith","yellow","mode","publicPath","getPublicFolderPath","outputPath","path","resolve","files","Map","devServerManager","DevServerManager","startMetroAsync","port","isExporting","location","resetDevServer","devServer","getDefaultDevServer","assert","MetroBundlerDevServer","bundles","domComponentAssetsMetadata","spaPlatforms","isReactServerComponentsEnabled","filter","platform","copyPublicFolderAsync","join","error","templateHtml","Promise","all","map","isHermes","isEnableHermesManaged","assertEngineMismatchAsync","bundle","nativeExportBundleAsync","splitChunks","EXPO_NO_BUNDLE_SPLITTING","mainModuleName","resolveRelativeEntryPoint","pkg","engine","undefined","serializerIncludeMaps","inlineSourceMap","reactCompiler","experiments","hosted","Error","exception","exit","getFilesFromSerialAssets","artifacts","includeSourceMaps","isServerHosted","expoDomComponentReferences","Set","artifact","Array","isArray","metadata","flat","filePath","platformDomComponentsBundle","htmlOutputName","exportDomComponentAsync","useMd5Filename","existingHashes","assets","a","hash","push","has","transformNativeBundleForMd5Filename","domComponentReference","nativeBundle","addDomBundleToMetadataAsync","transformDomEntryForMd5Filename","faviconAsset","generateFaviconAssetAsync","html","serializeHtmlWithAssets","resources","template","createTemplateHtmlFromExpoConfigAsync","scripts","cssLinks","extraHead","createFaviconAsString","href","set","contents","targetDomain","isWeb","exportApiRoutesStandaloneAsync","apiRoutesOnly","embeddedHashSet","exportAssetsAsync","JSON","stringify","createAssetMap","fileNames","Object","fromEntries","entries","asset","type","filename","createMetadataJson","exportServer","placeholderIndex","fs","existsSync","exportFromServerAsync","routerRoot","getRouterDirectoryModuleIdWithManifest","stopAsync","persistMetroFilesAsync"],"mappings":";;;;+BAuCsBA;;;eAAAA;;;;yBAvCI;;;;;;;yBAEgB;;;;;;;yBAEJ;;;;;;;gEACpB;;;;;;;gEACC;;;;;;;gEACJ;;;;;;;gEACE;;;;;;oCAEyC;8BACxB;qCAM3B;8BAC0D;mCACK;yBAC5B;uCACC;8BACgB;4BAGM;+BAClC;6DACV;+CACyB;kCACb;uCACK;wBACiB;+BACf;8BACC;6BACa;qBAClC;wBACS;yBACY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElC,eAAeA,eACpBC,WAAmB,EACnB,EACEC,SAAS,EACTC,SAAS,EACTC,KAAK,EACLC,GAAG,EACHC,YAAY,EACZC,UAAU,EACVC,gBAAgB,EAChBC,MAAM,EACNC,QAAQ,EACRC,UAAU,EACVC,OAAO,EACPC,YAAY,EAeb;QAkBwDC,UAE1CA;IAlBf,sEAAsE;IACtE,MAAMC,cAAcV,MAAM,gBAAgB;IAC1CW,QAAQC,GAAG,CAACC,QAAQ,GAAGH;IACvBI,IAAAA,mBAAU,EAACJ;IACXK,IAAAA,qBAAY,EAACnB;IAEb,MAAMoB,gBAAgBC,IAAAA,mBAAS,EAACrB;IAChC,MAAMa,MAAM,MAAMS,IAAAA,iDAA0B,EAACtB,aAAa;QACxD,kCAAkC;QAClCuB,gBAAgBtB,UAAUuB,MAAM,KAAK,KAAKvB,SAAS,CAAC,EAAE,KAAK;IAC7D;IAEA,IAAIA,UAAUwB,QAAQ,C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ACC,OAAO,CAACF,YAAY;gBAClD,IAAI,CAAC6G,iBAAE,CAACC,UAAU,CAACF,mBAAmB;oBACpCzG,MAAMqF,GAAG,CAAC,cAAc;wBACtBC,UAAU,CAAC,0BAA0B,CAAC;wBACtCC,cAAc;oBAChB;gBACF;YACF,OAAO,IACL,wCAAwC;YACxC,CAAC9E,UAAUO,8BAA8B,EACzC;oBAUmBlD;gBATnB,MAAM8I,IAAAA,wCAAqB,EAAC3J,aAAawD,WAAW;oBAClDf;oBACAM;oBACA5C,OAAO,CAAC,CAACA;oBACTD,WAAW0C;oBACXpC;oBACAwB;oBACA+D,mBAAmBzF;oBACnBsJ,YAAYC,IAAAA,8CAAsC,EAAC7J,aAAaa;oBAChE0E,eAAe,CAAC,GAAC1E,mBAAAA,IAAI2E,WAAW,qBAAf3E,iBAAiB0E,aAAa;oBAC/CgE;oBACA7I;oBACA2C,aAAa;oBACbxC,KAAKO,cAAcP,GAAG;gBACxB;YACF;QACF;IACF,SAAU;QACR,MAAMoC,iBAAiB6G,SAAS;IAClC;IAEA,kDAAkD;IAClD,MAAMC,IAAAA,kCAAsB,EAAChH,OAAOH;AACtC"}
@@ -192,7 +192,7 @@ async function exportFromServerAsync(projectRoot, devServer, { outputDir, baseUr
192
192
  const isExporting = true;
193
193
  const isExportingWithSSR = exportServer && useServerRendering && !devServer.isReactServerComponentsEnabled;
194
194
  const appDir = _path().default.join(projectRoot, routerRoot);
195
- const injectFaviconTag = await (0, _favicon.getVirtualFaviconAssetsAsync)(projectRoot, {
195
+ const faviconAsset = await (0, _favicon.generateFaviconAssetAsync)(projectRoot, {
196
196
  outputDir,
197
197
  baseUrl,
198
198
  files,
@@ -219,7 +219,7 @@ async function exportFromServerAsync(projectRoot, devServer, { outputDir, baseUr
219
219
  var _exp_extra_router, _exp_extra;
220
220
  const normalizedPathname = pathname === '' ? '/' : pathname.startsWith('/') ? pathname : `/${pathname}`;
221
221
  const useServerLoaders = exp == null ? void 0 : (_exp_extra = exp.extra) == null ? void 0 : (_exp_extra_router = _exp_extra.router) == null ? void 0 : _exp_extra_router.unstable_useServerDataLoaders;
222
- let renderOpts;
222
+ const renderOpts = {};
223
223
  if (useServerLoaders) {
224
224
  const loaderResponse = await executeLoaderAsync(normalizedPathname, route);
225
225
  if (loaderResponse !== undefined) {
@@ -233,14 +233,19 @@ async function exportFromServerAsync(projectRoot, devServer, { outputDir, baseUr
233
233
  targetDomain: 'client',
234
234
  loaderId: loaderKey
235
235
  });
236
- renderOpts = {
237
- loader: {
238
- data,
239
- key: loaderKey
240
- }
236
+ renderOpts.loader = {
237
+ data,
238
+ key: loaderKey
241
239
  };
242
240
  }
243
241
  }
242
+ if (faviconAsset) {
243
+ renderOpts.assets = {
244
+ css: [],
245
+ js: [],
246
+ favicon: faviconAsset.href
247
+ };
248
+ }
244
249
  const template = await renderAsync(normalizedPathname, route, renderOpts);
245
250
  let html = (0, _serializeHtml.serializeHtmlWithAssets)({
246
251
  isExporting,
@@ -250,9 +255,6 @@ async function exportFromServerAsync(projectRoot, devServer, { outputDir, baseUr
250
255
  route,
251
256
  hydrate: true
252
257
  });
253
- if (injectFaviconTag) {
254
- html = injectFaviconTag(html);
255
- }
256
258
  if (scriptTags) {
257
259
  // Inject script tags into the HTML.
258
260
  // <script type="type/expo" data-platform="ios" src="..." />
@@ -317,6 +319,11 @@ async function exportFromServerAsync(projectRoot, devServer, { outputDir, baseUr
317
319
  }
318
320
  const toAssetUrl = (filename)=>baseUrl ? `${baseUrl}/${filename}` : `/${filename}`;
319
321
  const cssAssets = resources.artifacts.filter((asset)=>asset.type === 'css').map((asset)=>toAssetUrl(asset.filename));
322
+ // External stylesheets (`@import url(https://...)`) are extracted out of the bundled CSS.
323
+ const externalCssAssets = resources.artifacts.filter((asset)=>asset.type === 'css-external').map((asset)=>({
324
+ href: asset.filename,
325
+ media: asset.metadata.media
326
+ }));
320
327
  const jsArtifacts = resources.artifacts.filter((asset)=>asset.type === 'js');
321
328
  const orderedJsAssets = (0, _serializeHtml.assetsRequiresSort)(jsArtifacts);
322
329
  const syncJs = orderedJsAssets.filter((asset)=>!asset.metadata.isAsync);
@@ -353,8 +360,9 @@ async function exportFromServerAsync(projectRoot, devServer, { outputDir, baseUr
353
360
  callback: (manifest)=>{
354
361
  manifest.assets = {
355
362
  css: cssAssets,
363
+ externalCss: externalCssAssets,
356
364
  js: syncJsAssets,
357
- favicon: injectFaviconTag ? `${baseUrl}/favicon.ico` : undefined
365
+ favicon: faviconAsset == null ? void 0 : faviconAsset.href
358
366
  };
359
367
  manifest.rendering = {
360
368
  mode: 'ssr',
@@ -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 type { ExpoConfig } from '@expo/config';\nimport type { SerialAsset } from '@expo/metro-config/build/serializer/serializerAssets';\nimport chalk from 'chalk';\nimport type { RouteNode } from 'expo-router/build/Route';\nimport { getContextKey, stripGroupSegmentsFromPath } from 'expo-router/build/matchers';\nimport { shouldLinkExternally } from 'expo-router/build/utils/url';\nimport type { RoutesManifest } from 'expo-server/private';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport { inspect } from 'util';\n\nimport { getVirtualFaviconAssetsAsync } from './favicon';\nimport { persistMetroAssetsAsync } from './persistMetroAssets';\nimport type { ExportAssetMap } from './saveAssets';\nimport { getFilesFromSerialAssets } from './saveAssets';\nimport { Log } from '../log';\nimport type {\n ExpoRouterRuntimeManifest,\n MetroBundlerDevServer,\n} from '../start/server/metro/MetroBundlerDevServer';\nimport { logMetroErrorAsync } from '../start/server/metro/metroErrorInterface';\nimport { getApiRoutesForDirectory, getMiddlewareForDirectory } from '../start/server/metro/router';\nimport {\n assetsRequiresSort,\n serializeHtmlWithAssets,\n sortMatchedAssetsByEntryPoints,\n} from '../start/server/metro/serializeHtml';\nimport { learnMore } from '../utils/link';\n\nconst debug = require('debug')('expo:export:generateStaticRoutes') as typeof console.log;\n\ntype ExtraScriptTag = {\n platform: string;\n src: string;\n};\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 exp?: ExpoConfig;\n // <script type=\"type/expo\" data-platform=\"ios\" src=\"...\" />\n scriptTags?: ExtraScriptTag[];\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\nexport function injectScriptTags(html: string, scriptTags: ExtraScriptTag[]): string {\n const scriptTagsHtml = scriptTags\n .map((tag) =>\n tag.platform === 'web'\n ? `<script src=\"${tag.src}\"></script>`\n : `<script type=\"type/expo\" src=\"${tag.src}\" data-platform=\"${tag.platform}\"></script>`\n )\n .join('\\n');\n html = html.replace('</head>', `${scriptTagsHtml}\\n</head>`);\n return html;\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 serverManifest,\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 skipHtmlPrerendering,\n // name : contents\n files = new Map(),\n }: {\n manifest: ExpoRouterRuntimeManifest;\n serverManifest: RoutesManifest;\n renderAsync: (requestLocation: HtmlRequestLocation) => Promise<string>;\n exportServer?: boolean;\n /**\n * Skip HTML pre-rendering when SSR is enabled (HTML will be rendered at runtime).\n *\n * This is separate from `exportServer` because RSC mode also uses `exportServer: true`,\n * but still needs placeholder HTML files.\n */\n skipHtmlPrerendering?: boolean;\n files?: ExportAssetMap;\n }\n): Promise<ExportAssetMap> {\n if (!exportServer && serverManifest) {\n // When we're not exporting a `server` output, we provide a `_expo/.routes.json` for\n // EAS Hosting to recognize the `headers` and `redirects` configs\n const subsetServerManifest = {\n headers: serverManifest.headers,\n redirects: serverManifest.redirects,\n };\n files.set('_expo/.routes.json', {\n contents: JSON.stringify(subsetServerManifest, null, 2),\n targetDomain: 'client',\n });\n }\n\n // Skip HTML pre-rendering in SSR mode since HTML will be rendered at runtime.\n if (skipHtmlPrerendering) {\n return files;\n }\n\n await Promise.all(\n getHtmlFiles({ manifest, includeGroupVariations: !exportServer }).map(\n async ({ route, filePath, pathname }) => {\n // Rewrite routes should not be statically generated\n if (route.type === 'rewrite') {\n return;\n }\n\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 // TODO(@hassankhan): ENG-16577\n if (shouldLinkExternally(entryPoint)) {\n return entryPoint;\n }\n\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 {\n outputDir,\n baseUrl,\n exportServer,\n includeSourceMaps,\n routerRoot,\n files = new Map(),\n exp,\n scriptTags,\n }: Options\n): Promise<ExportAssetMap> {\n const useServerRendering = exp?.extra?.router?.unstable_useServerRendering ?? false;\n\n const logOutput =\n exp?.web?.output === 'server' && useServerRendering\n ? `Server rendering is enabled. ${learnMore('https://docs.expo.dev/router/web/server-rendering/')}`\n : `Static rendering is enabled. ${learnMore('https://docs.expo.dev/router/web/static-rendering/')}`;\n Log.log(logOutput);\n\n const platform = 'web';\n const isExporting = true;\n const isExportingWithSSR =\n exportServer && useServerRendering && !devServer.isReactServerComponentsEnabled;\n const appDir = path.join(projectRoot, routerRoot);\n const injectFaviconTag = await getVirtualFaviconAssetsAsync(projectRoot, {\n outputDir,\n baseUrl,\n files,\n exp,\n });\n\n const [resources, { manifest, serverManifest, renderAsync, executeLoaderAsync }] =\n 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 serverManifest,\n exportServer,\n skipHtmlPrerendering: isExportingWithSSR,\n async renderAsync({ pathname, route }) {\n const normalizedPathname =\n pathname === '' ? '/' : pathname.startsWith('/') ? pathname : `/${pathname}`;\n\n const useServerLoaders = exp?.extra?.router?.unstable_useServerDataLoaders;\n let renderOpts;\n\n if (useServerLoaders) {\n const loaderResponse = await executeLoaderAsync(normalizedPathname, route);\n\n if (loaderResponse !== undefined) {\n const data = await loaderResponse.json();\n // Transforms a `route.contextKey` into a normalized path. For example,\n // `./nested/[id]/index.tsx` becomes `/nested/[id]/index`\n const loaderKey = getContextKey(route.contextKey);\n const fileSystemPath = `_expo/loaders${loaderKey}`;\n files.set(fileSystemPath, {\n contents: JSON.stringify(data, null, 2),\n targetDomain: 'client',\n loaderId: loaderKey,\n });\n\n renderOpts = { loader: { data, key: loaderKey } };\n }\n }\n\n const template = await renderAsync(normalizedPathname, route, renderOpts);\n let html = serializeHtmlWithAssets({\n isExporting,\n resources: resources.artifacts,\n template,\n baseUrl,\n route,\n hydrate: true,\n });\n\n if (injectFaviconTag) {\n html = injectFaviconTag(html);\n }\n\n if (scriptTags) {\n // Inject script tags into the HTML.\n // <script type=\"type/expo\" data-platform=\"ios\" src=\"...\" />\n html = injectScriptTags(html, scriptTags);\n }\n\n return html;\n },\n });\n\n getFilesFromSerialAssets(resources.artifacts, {\n platform,\n includeSourceMaps,\n files,\n isServerHosted: true,\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(projectRoot, resources.assets, {\n files,\n platform,\n outputDirectory: outputDir,\n baseUrl,\n });\n }\n\n if (exportServer) {\n const apiRoutes = await exportApiRoutesAsync({\n platform: 'web',\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\n // Export SSR render module and add SSR configuration to routes manifest\n if (isExportingWithSSR) {\n await devServer.exportExpoRouterRenderModuleAsync({\n files,\n includeSourceMaps: true,\n platform: 'web',\n });\n\n // Export loader bundles for routes that have loader exports\n const useServerLoaders = exp?.extra?.router?.unstable_useServerDataLoaders;\n if (useServerLoaders) {\n // Get `loaderReferences` from client bundle metadata to determine which routes have loaders\n const loaderReferences = resources.artifacts?.flatMap(\n (artifact) => artifact.metadata?.loaderReferences ?? []\n );\n\n await exportLoadersAsync({\n devServer,\n serverManifest,\n appDir,\n files,\n platform: 'web',\n loaderReferences,\n });\n }\n\n const toAssetUrl = (filename: string) =>\n baseUrl ? `${baseUrl}/${filename}` : `/${filename}`;\n\n const cssAssets = resources.artifacts\n .filter((asset) => asset.type === 'css')\n .map((asset) => toAssetUrl(asset.filename));\n\n const jsArtifacts = resources.artifacts.filter((asset) => asset.type === 'js');\n const orderedJsAssets = assetsRequiresSort(jsArtifacts);\n const syncJs = orderedJsAssets.filter((asset) => !asset.metadata.isAsync);\n const asyncJs = orderedJsAssets.filter((asset) => asset.metadata.isAsync);\n\n const syncJsAssets = syncJs.map((asset) => toAssetUrl(asset.filename));\n\n const htmlRoutes = getHtmlFiles({ manifest, includeGroupVariations: false });\n\n // Build per-route async chunk assignments\n const routeAssets = new Map<string, string[]>();\n for (const { route } of htmlRoutes) {\n if (!route.entryPoints || !Array.isArray(route.entryPoints)) {\n continue;\n }\n\n const matchedChunks: SerialAsset[] = [];\n for (const asyncChunk of asyncJs) {\n if (!asyncChunk.metadata.modulePaths || !Array.isArray(asyncChunk.metadata.modulePaths)) {\n continue;\n }\n const hasRouteEntryPoint = route.entryPoints.some((entryPoint) =>\n (asyncChunk.metadata.modulePaths as string[]).includes(entryPoint)\n );\n if (hasRouteEntryPoint) {\n matchedChunks.push(asyncChunk);\n }\n }\n\n if (matchedChunks.length > 0) {\n const sorted = sortMatchedAssetsByEntryPoints(matchedChunks, route.entryPoints);\n routeAssets.set(\n route.contextKey,\n sorted.map((chunk) => toAssetUrl(chunk.filename))\n );\n }\n }\n\n // Add assets and rendering config to the routes manifest\n updateExportManifestInFiles({\n files,\n callback: (manifest) => {\n manifest.assets = {\n css: cssAssets,\n js: syncJsAssets,\n favicon: injectFaviconTag ? `${baseUrl}/favicon.ico` : undefined,\n };\n manifest.rendering = {\n mode: 'ssr',\n file: '_expo/server/render.js',\n };\n\n for (const route of manifest.htmlRoutes) {\n const asyncChunks = routeAssets.get(route.file);\n if (asyncChunks) {\n route.assets = { css: [], js: asyncChunks };\n }\n }\n },\n });\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 [key, value] of Object.entries(screens)) {\n let leaf: string | null = null;\n if (typeof value === 'string') {\n leaf = value;\n } else if (value.screens && Object.keys(value.screens).length === 0) {\n // Ensure the trailing index is accounted for.\n if (key === value.path + '/index') {\n leaf = key;\n } else {\n leaf = value.path;\n }\n\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 // The __root slot has no path.\n const newPath = value.path ? baseUrl + value.path + '/' : baseUrl;\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 (head && 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 (head && current) {\n current = `${current}/${head}`;\n } else {\n current = head ?? current;\n }\n\n generateVariations(rest, current);\n }\n\n generateVariations(segments);\n\n return Array.from(variations);\n}\n\nexport async function exportApiRoutesStandaloneAsync(\n devServer: MetroBundlerDevServer,\n {\n files = new Map(),\n platform,\n apiRoutesOnly,\n templateHtml,\n }: {\n files?: ExportAssetMap;\n platform: string;\n apiRoutesOnly: boolean;\n templateHtml?: string;\n }\n) {\n const { serverManifest, htmlManifest } = await devServer.getServerManifestAsync();\n\n const apiRoutes = await exportApiRoutesAsync({\n server: devServer,\n manifest: serverManifest,\n // NOTE(kitten): For now, we always output source maps for API route exports\n includeSourceMaps: true,\n platform,\n apiRoutesOnly,\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\n if (templateHtml && devServer.isReactServerComponentsEnabled) {\n // TODO: Export an HTML entry for each file. This is a temporary solution until we have SSR/SSG for RSC.\n await getFilesToExportFromServerAsync(devServer.projectRoot, {\n manifest: htmlManifest,\n serverManifest,\n exportServer: true,\n files,\n renderAsync: async ({ pathname, filePath }) => {\n files.set(filePath, {\n contents: templateHtml!,\n routeId: pathname,\n targetDomain: 'server',\n });\n return templateHtml!;\n },\n });\n }\n\n return files;\n}\n\nasync function exportApiRoutesAsync({\n includeSourceMaps,\n server,\n platform,\n apiRoutesOnly,\n ...props\n}: Pick<Options, 'includeSourceMaps'> & {\n server: MetroBundlerDevServer;\n manifest: RoutesManifest<string>;\n platform: string;\n apiRoutesOnly?: boolean;\n}): Promise<ExportAssetMap> {\n const { manifest, files } = await server.exportExpoRouterApiRoutesAsync({\n outputDir: '_expo/functions',\n prerenderManifest: props.manifest,\n includeSourceMaps,\n platform,\n });\n\n // HACK: Clear out the HTML and 404 routes if we're only exporting API routes. This is used for native apps that are using API routes but haven't implemented web support yet.\n if (apiRoutesOnly) {\n manifest.htmlRoutes = [];\n manifest.notFoundRoutes = [];\n }\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 const middlewareFile = getMiddlewareForDirectory(appDir);\n if (middlewareFile) {\n Log.warn(\n chalk.yellow`Skipping export for middleware because \\`web.output\\` is not \"server\". You may want to remove ${path.relative(appDir, middlewareFile)}`\n );\n }\n}\n\n/**\n * Export loader bundles for routes that have loader exports and updates routes in the manifest\n * with a `loader` property.\n */\nasync function exportLoadersAsync({\n devServer,\n serverManifest,\n appDir,\n files,\n platform,\n loaderReferences,\n}: {\n devServer: MetroBundlerDevServer;\n serverManifest: RoutesManifest<string>;\n appDir: string;\n files: ExportAssetMap;\n platform: string;\n /** File paths of modules with loader exports from client bundle metadata */\n loaderReferences: string[];\n}): Promise<void> {\n const entryPoints: { file: string; page: string }[] = [];\n\n for (const route of serverManifest.htmlRoutes) {\n // Skip generated routes\n if (route.generated) {\n continue;\n }\n\n const filePath = path.isAbsolute(route.file) ? route.file : path.join(appDir, route.file);\n\n if (loaderReferences.includes(filePath)) {\n entryPoints.push({\n file: filePath,\n page: route.page,\n });\n }\n }\n\n if (entryPoints.length === 0) {\n debug('No routes with loaders to bundle');\n return;\n }\n\n const entryPointModules = entryPoints.map((e) => e.page);\n debug('Bundling loaders for routes:', entryPointModules);\n\n await devServer.exportExpoRouterLoadersAsync({\n platform,\n entryPoints,\n files,\n outputDir: '_expo/loaders',\n includeSourceMaps: true,\n });\n\n // Update `htmlRoutes` in routes manifest for routes that have loaders\n updateExportManifestInFiles({\n files,\n callback: (manifest) => {\n const routesWithLoaders = new Set(entryPointModules);\n for (const route of manifest.htmlRoutes) {\n if (routesWithLoaders.has(route.page)) {\n route.loader = `_expo/loaders${route.page}.js`;\n }\n }\n },\n });\n\n debug('Exported loaders for routes:', entryPointModules);\n}\n\n// NOTE(@hassankhan): We should ideally persist the manifest to `files` only once instead of\n// modifying it afterwards.\nfunction updateExportManifestInFiles({\n files,\n callback,\n}: {\n files: ExportAssetMap;\n callback: (manifest: RoutesManifest<string>) => void;\n}) {\n const routesJsonEntry = files.get('_expo/routes.json');\n if (routesJsonEntry) {\n const manifest = JSON.parse(routesJsonEntry.contents as string);\n callback(manifest);\n\n files.set('_expo/routes.json', {\n ...routesJsonEntry,\n contents: JSON.stringify(manifest, null, 2),\n });\n }\n}\n"],"names":["exportApiRoutesStandaloneAsync","exportFromServerAsync","getFilesToExportFromServerAsync","getHtmlFiles","getPathVariations","injectScriptTags","debug","require","html","scriptTags","scriptTagsHtml","map","tag","platform","src","join","replace","matchGroupName","name","match","projectRoot","manifest","serverManifest","renderAsync","exportServer","skipHtmlPrerendering","files","Map","subsetServerManifest","headers","redirects","set","contents","JSON","stringify","targetDomain","Promise","all","includeGroupVariations","route","filePath","pathname","type","data","routeId","e","logMetroErrorAsync","error","Error","modifyRouteNodeInRuntimeManifest","callback","iterateScreens","screens","Object","values","value","_route","makeRuntimeEntryPointsAbsolute","appDir","Array","isArray","entryPoints","entryPoint","shouldLinkExternally","startsWith","path","resolve","isAbsolute","resolveFrom","devServer","outputDir","baseUrl","includeSourceMaps","routerRoot","exp","useServerRendering","extra","router","unstable_useServerRendering","logOutput","web","output","learnMore","Log","log","isExporting","isExportingWithSSR","isReactServerComponentsEnabled","injectFaviconTag","getVirtualFaviconAssetsAsync","resources","executeLoaderAsync","getStaticResourcesAsync","getStaticRenderFunctionAsync","inspect","colors","depth","normalizedPathname","useServerLoaders","unstable_useServerDataLoaders","renderOpts","loaderResponse","undefined","json","loaderKey","getContextKey","contextKey","fileSystemPath","loaderId","loader","key","template","serializeHtmlWithAssets","artifacts","hydrate","getFilesFromSerialAssets","isServerHosted","assets","persistMetroAssetsAsync","outputDirectory","apiRoutes","exportApiRoutesAsync","server","exportExpoRouterRenderModuleAsync","loaderReferences","flatMap","artifact","metadata","exportLoadersAsync","toAssetUrl","filename","cssAssets","filter","asset","jsArtifacts","orderedJsAssets","assetsRequiresSort","syncJs","isAsync","asyncJs","syncJsAssets","htmlRoutes","routeAssets","matchedChunks","asyncChunk","modulePaths","hasRouteEntryPoint","some","includes","push","length","sorted","sortMatchedAssetsByEntryPoints","chunk","updateExportManifestInFiles","css","js","favicon","rendering","mode","file","asyncChunks","get","warnPossibleInvalidExportType","htmlFiles","Set","traverseScreens","entries","leaf","keys","endsWith","slice","stripGroupSegmentsFromPath","addOptionalGroups","add","newPath","variations","variation","uniqueBy","from","parts","split","partsWithGroups","part","filePathLocation","array","seen","result","id","has","routePath","segments","generateVariations","current","head","rest","groups","group","trim","apiRoutesOnly","templateHtml","htmlManifest","getServerManifestAsync","props","exportExpoRouterApiRoutesAsync","prerenderManifest","notFoundRoutes","getApiRoutesForDirectory","warn","chalk","yellow","v","relative","middlewareFile","getMiddlewareForDirectory","generated","page","entryPointModules","exportExpoRouterLoadersAsync","routesWithLoaders","routesJsonEntry","parse"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;QA0kBqBA;eAAAA;;QAxYAC;eAAAA;;QAhHAC;eAAAA;;QA2VNC;eAAAA;;QAqHAC;eAAAA;;QAjeAC;eAAAA;;;;gEA9DE;;;;;;;yBAEwC;;;;;;;yBACrB;;;;;;;gEAEpB;;;;;;;gEACO;;;;;;;yBACA;;;;;;yBAEqB;oCACL;4BAEC;qBACrB;qCAKe;wBACiC;+BAK7D;sBACmB;;;;;;AAE1B,MAAMC,QAAQC,QAAQ,SAAS;AAmCxB,SAASF,iBAAiBG,IAAY,EAAEC,UAA4B;IACzE,MAAMC,iBAAiBD,WACpBE,GAAG,CAAC,CAACC,MACJA,IAAIC,QAAQ,KAAK,QACb,CAAC,aAAa,EAAED,IAAIE,GAAG,CAAC,WAAW,CAAC,GACpC,CAAC,8BAA8B,EAAEF,IAAIE,GAAG,CAAC,iBAAiB,EAAEF,IAAIC,QAAQ,CAAC,WAAW,CAAC,EAE1FE,IAAI,CAAC;IACRP,OAAOA,KAAKQ,OAAO,CAAC,WAAW,GAAGN,eAAe,SAAS,CAAC;IAC3D,OAAOF;AACT;AAEA,6BAA6B,GAC7B,SAASS,eAAeC,IAAY;QAC3BA;IAAP,QAAOA,cAAAA,KAAKC,KAAK,CAAC,sCAAXD,WAA8B,CAAC,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E2K,IAAI;IACvDlN,MAAM,gCAAgCmN;IAEtC,MAAMpJ,UAAUqJ,4BAA4B,CAAC;QAC3C7M;QACAgD;QACAnC;QACA4C,WAAW;QACXE,mBAAmB;IACrB;IAEA,sEAAsE;IACtEkF,4BAA4B;QAC1BhI;QACAwB,UAAU,CAAC7B;YACT,MAAMsM,oBAAoB,IAAItD,IAAIoD;YAClC,KAAK,MAAMlL,SAASlB,SAASwH,UAAU,CAAE;gBACvC,IAAI8E,kBAAkB9B,GAAG,CAACtJ,MAAMiL,IAAI,GAAG;oBACrCjL,MAAMsE,MAAM,GAAG,CAAC,aAAa,EAAEtE,MAAMiL,IAAI,CAAC,GAAG,CAAC;gBAChD;YACF;QACF;IACF;IAEAlN,MAAM,gCAAgCmN;AACxC;AAEA,4FAA4F;AAC5F,2BAA2B;AAC3B,SAAS/D,4BAA4B,EACnChI,KAAK,EACLwB,QAAQ,EAIT;IACC,MAAM0K,kBAAkBlM,MAAMwI,GAAG,CAAC;IAClC,IAAI0D,iBAAiB;QACnB,MAAMvM,WAAWY,KAAK4L,KAAK,CAACD,gBAAgB5L,QAAQ;QACpDkB,SAAS7B;QAETK,MAAMK,GAAG,CAAC,qBAAqB;YAC7B,GAAG6L,eAAe;YAClB5L,UAAUC,KAAKC,SAAS,CAACb,UAAU,MAAM;QAC3C;IACF;AACF"}
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 type { ExpoConfig } from '@expo/config';\nimport type { SerialAsset } from '@expo/metro-config/build/serializer/serializerAssets';\nimport type { GetStaticContentOptions } from '@expo/router-server/build/static/renderStaticContent';\nimport chalk from 'chalk';\nimport type { RouteNode } from 'expo-router/build/Route';\nimport { getContextKey, stripGroupSegmentsFromPath } from 'expo-router/build/matchers';\nimport { shouldLinkExternally } from 'expo-router/build/utils/url';\nimport type { RoutesManifest } from 'expo-server/private';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport { inspect } from 'util';\n\nimport { generateFaviconAssetAsync } from './favicon';\nimport { persistMetroAssetsAsync } from './persistMetroAssets';\nimport type { ExportAssetMap } from './saveAssets';\nimport { getFilesFromSerialAssets } from './saveAssets';\nimport { Log } from '../log';\nimport type {\n ExpoRouterRuntimeManifest,\n MetroBundlerDevServer,\n} from '../start/server/metro/MetroBundlerDevServer';\nimport { logMetroErrorAsync } from '../start/server/metro/metroErrorInterface';\nimport { getApiRoutesForDirectory, getMiddlewareForDirectory } from '../start/server/metro/router';\nimport {\n assetsRequiresSort,\n serializeHtmlWithAssets,\n sortMatchedAssetsByEntryPoints,\n} from '../start/server/metro/serializeHtml';\nimport { learnMore } from '../utils/link';\n\nconst debug = require('debug')('expo:export:generateStaticRoutes') as typeof console.log;\n\ntype ExtraScriptTag = {\n platform: string;\n src: string;\n};\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 exp?: ExpoConfig;\n // <script type=\"type/expo\" data-platform=\"ios\" src=\"...\" />\n scriptTags?: ExtraScriptTag[];\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\nexport function injectScriptTags(html: string, scriptTags: ExtraScriptTag[]): string {\n const scriptTagsHtml = scriptTags\n .map((tag) =>\n tag.platform === 'web'\n ? `<script src=\"${tag.src}\"></script>`\n : `<script type=\"type/expo\" src=\"${tag.src}\" data-platform=\"${tag.platform}\"></script>`\n )\n .join('\\n');\n html = html.replace('</head>', `${scriptTagsHtml}\\n</head>`);\n return html;\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 serverManifest,\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 skipHtmlPrerendering,\n // name : contents\n files = new Map(),\n }: {\n manifest: ExpoRouterRuntimeManifest;\n serverManifest: RoutesManifest;\n renderAsync: (requestLocation: HtmlRequestLocation) => Promise<string>;\n exportServer?: boolean;\n /**\n * Skip HTML pre-rendering when SSR is enabled (HTML will be rendered at runtime).\n *\n * This is separate from `exportServer` because RSC mode also uses `exportServer: true`,\n * but still needs placeholder HTML files.\n */\n skipHtmlPrerendering?: boolean;\n files?: ExportAssetMap;\n }\n): Promise<ExportAssetMap> {\n if (!exportServer && serverManifest) {\n // When we're not exporting a `server` output, we provide a `_expo/.routes.json` for\n // EAS Hosting to recognize the `headers` and `redirects` configs\n const subsetServerManifest = {\n headers: serverManifest.headers,\n redirects: serverManifest.redirects,\n };\n files.set('_expo/.routes.json', {\n contents: JSON.stringify(subsetServerManifest, null, 2),\n targetDomain: 'client',\n });\n }\n\n // Skip HTML pre-rendering in SSR mode since HTML will be rendered at runtime.\n if (skipHtmlPrerendering) {\n return files;\n }\n\n await Promise.all(\n getHtmlFiles({ manifest, includeGroupVariations: !exportServer }).map(\n async ({ route, filePath, pathname }) => {\n // Rewrite routes should not be statically generated\n if (route.type === 'rewrite') {\n return;\n }\n\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 // TODO(@hassankhan): ENG-16577\n if (shouldLinkExternally(entryPoint)) {\n return entryPoint;\n }\n\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 {\n outputDir,\n baseUrl,\n exportServer,\n includeSourceMaps,\n routerRoot,\n files = new Map(),\n exp,\n scriptTags,\n }: Options\n): Promise<ExportAssetMap> {\n const useServerRendering = exp?.extra?.router?.unstable_useServerRendering ?? false;\n\n const logOutput =\n exp?.web?.output === 'server' && useServerRendering\n ? `Server rendering is enabled. ${learnMore('https://docs.expo.dev/router/web/server-rendering/')}`\n : `Static rendering is enabled. ${learnMore('https://docs.expo.dev/router/web/static-rendering/')}`;\n Log.log(logOutput);\n\n const platform = 'web';\n const isExporting = true;\n const isExportingWithSSR =\n exportServer && useServerRendering && !devServer.isReactServerComponentsEnabled;\n const appDir = path.join(projectRoot, routerRoot);\n const faviconAsset = await generateFaviconAssetAsync(projectRoot, {\n outputDir,\n baseUrl,\n files,\n exp,\n });\n\n const [resources, { manifest, serverManifest, renderAsync, executeLoaderAsync }] =\n 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 serverManifest,\n exportServer,\n skipHtmlPrerendering: isExportingWithSSR,\n async renderAsync({ pathname, route }) {\n const normalizedPathname =\n pathname === '' ? '/' : pathname.startsWith('/') ? pathname : `/${pathname}`;\n\n const useServerLoaders = exp?.extra?.router?.unstable_useServerDataLoaders;\n const renderOpts: GetStaticContentOptions = {};\n\n if (useServerLoaders) {\n const loaderResponse = await executeLoaderAsync(normalizedPathname, route);\n\n if (loaderResponse !== undefined) {\n const data = await loaderResponse.json();\n // Transforms a `route.contextKey` into a normalized path. For example,\n // `./nested/[id]/index.tsx` becomes `/nested/[id]/index`\n const loaderKey = getContextKey(route.contextKey);\n const fileSystemPath = `_expo/loaders${loaderKey}`;\n files.set(fileSystemPath, {\n contents: JSON.stringify(data, null, 2),\n targetDomain: 'client',\n loaderId: loaderKey,\n });\n\n renderOpts.loader = { data, key: loaderKey };\n }\n }\n\n if (faviconAsset) {\n renderOpts.assets = { css: [], js: [], favicon: faviconAsset.href };\n }\n\n const template = await renderAsync(normalizedPathname, route, renderOpts);\n let html = serializeHtmlWithAssets({\n isExporting,\n resources: resources.artifacts,\n template,\n baseUrl,\n route,\n hydrate: true,\n });\n\n if (scriptTags) {\n // Inject script tags into the HTML.\n // <script type=\"type/expo\" data-platform=\"ios\" src=\"...\" />\n html = injectScriptTags(html, scriptTags);\n }\n\n return html;\n },\n });\n\n getFilesFromSerialAssets(resources.artifacts, {\n platform,\n includeSourceMaps,\n files,\n isServerHosted: true,\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(projectRoot, resources.assets, {\n files,\n platform,\n outputDirectory: outputDir,\n baseUrl,\n });\n }\n\n if (exportServer) {\n const apiRoutes = await exportApiRoutesAsync({\n platform: 'web',\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\n // Export SSR render module and add SSR configuration to routes manifest\n if (isExportingWithSSR) {\n await devServer.exportExpoRouterRenderModuleAsync({\n files,\n includeSourceMaps: true,\n platform: 'web',\n });\n\n // Export loader bundles for routes that have loader exports\n const useServerLoaders = exp?.extra?.router?.unstable_useServerDataLoaders;\n if (useServerLoaders) {\n // Get `loaderReferences` from client bundle metadata to determine which routes have loaders\n const loaderReferences = resources.artifacts?.flatMap(\n (artifact) => artifact.metadata?.loaderReferences ?? []\n );\n\n await exportLoadersAsync({\n devServer,\n serverManifest,\n appDir,\n files,\n platform: 'web',\n loaderReferences,\n });\n }\n\n const toAssetUrl = (filename: string) =>\n baseUrl ? `${baseUrl}/${filename}` : `/${filename}`;\n\n const cssAssets = resources.artifacts\n .filter((asset) => asset.type === 'css')\n .map((asset) => toAssetUrl(asset.filename));\n\n // External stylesheets (`@import url(https://...)`) are extracted out of the bundled CSS.\n const externalCssAssets = resources.artifacts\n .filter((asset) => asset.type === 'css-external')\n .map((asset) => ({\n href: asset.filename,\n media: asset.metadata.media,\n }));\n\n const jsArtifacts = resources.artifacts.filter((asset) => asset.type === 'js');\n const orderedJsAssets = assetsRequiresSort(jsArtifacts);\n const syncJs = orderedJsAssets.filter((asset) => !asset.metadata.isAsync);\n const asyncJs = orderedJsAssets.filter((asset) => asset.metadata.isAsync);\n\n const syncJsAssets = syncJs.map((asset) => toAssetUrl(asset.filename));\n\n const htmlRoutes = getHtmlFiles({ manifest, includeGroupVariations: false });\n\n // Build per-route async chunk assignments\n const routeAssets = new Map<string, string[]>();\n for (const { route } of htmlRoutes) {\n if (!route.entryPoints || !Array.isArray(route.entryPoints)) {\n continue;\n }\n\n const matchedChunks: SerialAsset[] = [];\n for (const asyncChunk of asyncJs) {\n if (!asyncChunk.metadata.modulePaths || !Array.isArray(asyncChunk.metadata.modulePaths)) {\n continue;\n }\n const hasRouteEntryPoint = route.entryPoints.some((entryPoint) =>\n (asyncChunk.metadata.modulePaths as string[]).includes(entryPoint)\n );\n if (hasRouteEntryPoint) {\n matchedChunks.push(asyncChunk);\n }\n }\n\n if (matchedChunks.length > 0) {\n const sorted = sortMatchedAssetsByEntryPoints(matchedChunks, route.entryPoints);\n routeAssets.set(\n route.contextKey,\n sorted.map((chunk) => toAssetUrl(chunk.filename))\n );\n }\n }\n\n // Add assets and rendering config to the routes manifest\n updateExportManifestInFiles({\n files,\n callback: (manifest) => {\n manifest.assets = {\n css: cssAssets,\n externalCss: externalCssAssets,\n js: syncJsAssets,\n favicon: faviconAsset?.href,\n };\n manifest.rendering = {\n mode: 'ssr',\n file: '_expo/server/render.js',\n };\n\n for (const route of manifest.htmlRoutes) {\n const asyncChunks = routeAssets.get(route.file);\n if (asyncChunks) {\n route.assets = { css: [], js: asyncChunks };\n }\n }\n },\n });\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 [key, value] of Object.entries(screens)) {\n let leaf: string | null = null;\n if (typeof value === 'string') {\n leaf = value;\n } else if (value.screens && Object.keys(value.screens).length === 0) {\n // Ensure the trailing index is accounted for.\n if (key === value.path + '/index') {\n leaf = key;\n } else {\n leaf = value.path;\n }\n\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 // The __root slot has no path.\n const newPath = value.path ? baseUrl + value.path + '/' : baseUrl;\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 (head && 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 (head && current) {\n current = `${current}/${head}`;\n } else {\n current = head ?? current;\n }\n\n generateVariations(rest, current);\n }\n\n generateVariations(segments);\n\n return Array.from(variations);\n}\n\nexport async function exportApiRoutesStandaloneAsync(\n devServer: MetroBundlerDevServer,\n {\n files = new Map(),\n platform,\n apiRoutesOnly,\n templateHtml,\n }: {\n files?: ExportAssetMap;\n platform: string;\n apiRoutesOnly: boolean;\n templateHtml?: string;\n }\n) {\n const { serverManifest, htmlManifest } = await devServer.getServerManifestAsync();\n\n const apiRoutes = await exportApiRoutesAsync({\n server: devServer,\n manifest: serverManifest,\n // NOTE(kitten): For now, we always output source maps for API route exports\n includeSourceMaps: true,\n platform,\n apiRoutesOnly,\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\n if (templateHtml && devServer.isReactServerComponentsEnabled) {\n // TODO: Export an HTML entry for each file. This is a temporary solution until we have SSR/SSG for RSC.\n await getFilesToExportFromServerAsync(devServer.projectRoot, {\n manifest: htmlManifest,\n serverManifest,\n exportServer: true,\n files,\n renderAsync: async ({ pathname, filePath }) => {\n files.set(filePath, {\n contents: templateHtml!,\n routeId: pathname,\n targetDomain: 'server',\n });\n return templateHtml!;\n },\n });\n }\n\n return files;\n}\n\nasync function exportApiRoutesAsync({\n includeSourceMaps,\n server,\n platform,\n apiRoutesOnly,\n ...props\n}: Pick<Options, 'includeSourceMaps'> & {\n server: MetroBundlerDevServer;\n manifest: RoutesManifest<string>;\n platform: string;\n apiRoutesOnly?: boolean;\n}): Promise<ExportAssetMap> {\n const { manifest, files } = await server.exportExpoRouterApiRoutesAsync({\n outputDir: '_expo/functions',\n prerenderManifest: props.manifest,\n includeSourceMaps,\n platform,\n });\n\n // HACK: Clear out the HTML and 404 routes if we're only exporting API routes. This is used for native apps that are using API routes but haven't implemented web support yet.\n if (apiRoutesOnly) {\n manifest.htmlRoutes = [];\n manifest.notFoundRoutes = [];\n }\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 const middlewareFile = getMiddlewareForDirectory(appDir);\n if (middlewareFile) {\n Log.warn(\n chalk.yellow`Skipping export for middleware because \\`web.output\\` is not \"server\". You may want to remove ${path.relative(appDir, middlewareFile)}`\n );\n }\n}\n\n/**\n * Export loader bundles for routes that have loader exports and updates routes in the manifest\n * with a `loader` property.\n */\nasync function exportLoadersAsync({\n devServer,\n serverManifest,\n appDir,\n files,\n platform,\n loaderReferences,\n}: {\n devServer: MetroBundlerDevServer;\n serverManifest: RoutesManifest<string>;\n appDir: string;\n files: ExportAssetMap;\n platform: string;\n /** File paths of modules with loader exports from client bundle metadata */\n loaderReferences: string[];\n}): Promise<void> {\n const entryPoints: { file: string; page: string }[] = [];\n\n for (const route of serverManifest.htmlRoutes) {\n // Skip generated routes\n if (route.generated) {\n continue;\n }\n\n const filePath = path.isAbsolute(route.file) ? route.file : path.join(appDir, route.file);\n\n if (loaderReferences.includes(filePath)) {\n entryPoints.push({\n file: filePath,\n page: route.page,\n });\n }\n }\n\n if (entryPoints.length === 0) {\n debug('No routes with loaders to bundle');\n return;\n }\n\n const entryPointModules = entryPoints.map((e) => e.page);\n debug('Bundling loaders for routes:', entryPointModules);\n\n await devServer.exportExpoRouterLoadersAsync({\n platform,\n entryPoints,\n files,\n outputDir: '_expo/loaders',\n includeSourceMaps: true,\n });\n\n // Update `htmlRoutes` in routes manifest for routes that have loaders\n updateExportManifestInFiles({\n files,\n callback: (manifest) => {\n const routesWithLoaders = new Set(entryPointModules);\n for (const route of manifest.htmlRoutes) {\n if (routesWithLoaders.has(route.page)) {\n route.loader = `_expo/loaders${route.page}.js`;\n }\n }\n },\n });\n\n debug('Exported loaders for routes:', entryPointModules);\n}\n\n// NOTE(@hassankhan): We should ideally persist the manifest to `files` only once instead of\n// modifying it afterwards.\nfunction updateExportManifestInFiles({\n files,\n callback,\n}: {\n files: ExportAssetMap;\n callback: (manifest: RoutesManifest<string>) => void;\n}) {\n const routesJsonEntry = files.get('_expo/routes.json');\n if (routesJsonEntry) {\n const manifest = JSON.parse(routesJsonEntry.contents as string);\n callback(manifest);\n\n files.set('_expo/routes.json', {\n ...routesJsonEntry,\n contents: JSON.stringify(manifest, null, 2),\n });\n }\n}\n"],"names":["exportApiRoutesStandaloneAsync","exportFromServerAsync","getFilesToExportFromServerAsync","getHtmlFiles","getPathVariations","injectScriptTags","debug","require","html","scriptTags","scriptTagsHtml","map","tag","platform","src","join","replace","matchGroupName","name","match","projectRoot","manifest","serverManifest","renderAsync","exportServer","skipHtmlPrerendering","files","Map","subsetServerManifest","headers","redirects","set","contents","JSON","stringify","targetDomain","Promise","all","includeGroupVariations","route","filePath","pathname","type","data","routeId","e","logMetroErrorAsync","error","Error","modifyRouteNodeInRuntimeManifest","callback","iterateScreens","screens","Object","values","value","_route","makeRuntimeEntryPointsAbsolute","appDir","Array","isArray","entryPoints","entryPoint","shouldLinkExternally","startsWith","path","resolve","isAbsolute","resolveFrom","devServer","outputDir","baseUrl","includeSourceMaps","routerRoot","exp","useServerRendering","extra","router","unstable_useServerRendering","logOutput","web","output","learnMore","Log","log","isExporting","isExportingWithSSR","isReactServerComponentsEnabled","faviconAsset","generateFaviconAssetAsync","resources","executeLoaderAsync","getStaticResourcesAsync","getStaticRenderFunctionAsync","inspect","colors","depth","normalizedPathname","useServerLoaders","unstable_useServerDataLoaders","renderOpts","loaderResponse","undefined","json","loaderKey","getContextKey","contextKey","fileSystemPath","loaderId","loader","key","assets","css","js","favicon","href","template","serializeHtmlWithAssets","artifacts","hydrate","getFilesFromSerialAssets","isServerHosted","persistMetroAssetsAsync","outputDirectory","apiRoutes","exportApiRoutesAsync","server","exportExpoRouterRenderModuleAsync","loaderReferences","flatMap","artifact","metadata","exportLoadersAsync","toAssetUrl","filename","cssAssets","filter","asset","externalCssAssets","media","jsArtifacts","orderedJsAssets","assetsRequiresSort","syncJs","isAsync","asyncJs","syncJsAssets","htmlRoutes","routeAssets","matchedChunks","asyncChunk","modulePaths","hasRouteEntryPoint","some","includes","push","length","sorted","sortMatchedAssetsByEntryPoints","chunk","updateExportManifestInFiles","externalCss","rendering","mode","file","asyncChunks","get","warnPossibleInvalidExportType","htmlFiles","Set","traverseScreens","entries","leaf","keys","endsWith","slice","stripGroupSegmentsFromPath","addOptionalGroups","add","newPath","variations","variation","uniqueBy","from","parts","split","partsWithGroups","part","filePathLocation","array","seen","result","id","has","routePath","segments","generateVariations","current","head","rest","groups","group","trim","apiRoutesOnly","templateHtml","htmlManifest","getServerManifestAsync","props","exportExpoRouterApiRoutesAsync","prerenderManifest","notFoundRoutes","getApiRoutesForDirectory","warn","chalk","yellow","v","relative","middlewareFile","getMiddlewareForDirectory","generated","page","entryPointModules","exportExpoRouterLoadersAsync","routesWithLoaders","routesJsonEntry","parse"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;QAolBqBA;eAAAA;;QAjZAC;eAAAA;;QAhHAC;eAAAA;;QAoWNC;eAAAA;;QAqHAC;eAAAA;;QA1eAC;eAAAA;;;;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