@expo/cli 0.22.9 → 0.23.0-canary-20250114-804e26d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/build/bin/cli +1 -1
  2. package/build/src/export/embed/exportServer.js +13 -9
  3. package/build/src/export/embed/exportServer.js.map +1 -1
  4. package/build/src/export/embed/xcodeCompilerLogger.js +1 -0
  5. package/build/src/export/embed/xcodeCompilerLogger.js.map +1 -1
  6. package/build/src/export/exportApp.js +5 -1
  7. package/build/src/export/exportApp.js.map +1 -1
  8. package/build/src/export/exportStaticAsync.js +18 -2
  9. package/build/src/export/exportStaticAsync.js.map +1 -1
  10. package/build/src/serve/serveAsync.js +4 -2
  11. package/build/src/serve/serveAsync.js.map +1 -1
  12. package/build/src/start/server/getStaticRenderFunctions.js +2 -1
  13. package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
  14. package/build/src/start/server/metro/MetroBundlerDevServer.js +6 -2
  15. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  16. package/build/src/start/server/metro/createJResolver.js +15 -5
  17. package/build/src/start/server/metro/createJResolver.js.map +1 -1
  18. package/build/src/start/server/metro/createServerComponentsMiddleware.js +9 -0
  19. package/build/src/start/server/metro/createServerComponentsMiddleware.js.map +1 -1
  20. package/build/src/start/server/metro/metroErrorInterface.js +5 -1
  21. package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
  22. package/build/src/start/server/metro/withMetroMultiPlatform.js +2 -1
  23. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  24. package/build/src/utils/env.js +3 -0
  25. package/build/src/utils/env.js.map +1 -1
  26. package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
  27. package/build/src/utils/telemetry/utils/context.js +1 -1
  28. package/package.json +15 -15
package/build/bin/cli CHANGED
@@ -121,7 +121,7 @@ const args = (0, _arg().default)({
121
121
  });
122
122
  if (args["--version"]) {
123
123
  // Version is added in the build script.
124
- console.log("0.22.9");
124
+ console.log("0.23.0-canary-20250114-804e26d");
125
125
  process.exit(0);
126
126
  }
127
127
  if (args["--non-interactive"]) {
@@ -186,14 +186,18 @@ async function runServerDeployCommandAsync(projectRoot, { distDirectory , deploy
186
186
  if (!_env.env.EXPO_UNSTABLE_DEPLOY_SERVER) {
187
187
  return false;
188
188
  }
189
- const globalBin = getCommandBin("eas");
190
- if (!globalBin) {
191
- // This should never happen from EAS Builds.
192
- // Possible to happen when building locally with `npx expo run`
193
- (0, _xcodeCompilerLogger.logMetroErrorInXcode)(projectRoot, `eas-cli is not installed globally, skipping server deployment. Install EAS CLI with 'npm install -g eas-cli'.`);
194
- return false;
189
+ if (!_env.env.EAS_BUILD) {
190
+ // This check helps avoid running EAS if the user isn't a user of EAS.
191
+ // We only need to run it when building outside of EAS.
192
+ const globalBin = getCommandBin("eas");
193
+ if (!globalBin) {
194
+ // This should never happen from EAS Builds.
195
+ // Possible to happen when building locally with `npx expo run`
196
+ (0, _xcodeCompilerLogger.logMetroErrorInXcode)(projectRoot, `eas-cli is not installed globally, skipping server deployment. Install EAS CLI with 'npm install -g eas-cli'.`);
197
+ return false;
198
+ }
199
+ debug("Found eas-cli:", globalBin);
195
200
  }
196
- debug("Found eas-cli:", globalBin);
197
201
  let json;
198
202
  try {
199
203
  let results;
@@ -215,8 +219,8 @@ async function runServerDeployCommandAsync(projectRoot, { distDirectory , deploy
215
219
  } else {
216
220
  (0, _xcodeCompilerLogger.logInXcode)("Deploying server to link with client");
217
221
  // results = DEPLOYMENT_SUCCESS_FIXTURE;
218
- results = await (0, _spawnAsync().default)("node", [
219
- globalBin,
222
+ results = await (0, _spawnAsync().default)("npx", [
223
+ "eas-cli",
220
224
  "deploy",
221
225
  "--non-interactive",
222
226
  "--json",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/export/embed/exportServer.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { ExpoConfig, modifyConfigAsync, PackageJSONConfig } from '@expo/config';\nimport spawnAsync from '@expo/spawn-async';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport { execSync } from 'node:child_process';\nimport path from 'path';\n\nimport { disableNetwork } from '../../api/settings';\nimport { Log } from '../../log';\nimport { isSpawnResultError } from '../../start/platforms/ios/xcrun';\nimport { MetroBundlerDevServer } from '../../start/server/metro/MetroBundlerDevServer';\nimport { removeAsync } from '../../utils/dir';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { exportApiRoutesStandaloneAsync } from '../exportStaticAsync';\nimport { copyPublicFolderAsync } from '../publicFolder';\nimport { ExportAssetMap, persistMetroFilesAsync } from '../saveAssets';\nimport { Options } from './resolveOptions';\nimport {\n isExecutingFromXcodebuild,\n logInXcode,\n logMetroErrorInXcode,\n warnInXcode,\n} from './xcodeCompilerLogger';\n\nconst debug = require('debug')('expo:export:server');\n\ntype ServerDeploymentResults = {\n url: string;\n dashboardUrl?: string;\n};\n\nexport async function exportStandaloneServerAsync(\n projectRoot: string,\n devServer: MetroBundlerDevServer,\n {\n exp,\n pkg,\n files,\n options,\n }: { exp: ExpoConfig; pkg: PackageJSONConfig; files: ExportAssetMap; options: Options }\n) {\n if (!options.eager) {\n await tryRemovingGeneratedOriginAsync(projectRoot, exp);\n }\n\n logInXcode('Exporting server');\n\n // Store the server output in the project's .expo directory.\n const serverOutput = path.join(projectRoot, '.expo/server', options.platform);\n\n // Remove the previous server output to prevent stale files.\n await removeAsync(serverOutput);\n\n // Export the API routes for server rendering the React Server Components.\n await exportApiRoutesStandaloneAsync(devServer, {\n files,\n platform: 'web',\n apiRoutesOnly: true,\n });\n\n const publicPath = path.resolve(projectRoot, env.EXPO_PUBLIC_FOLDER);\n\n // Copy over public folder items\n await copyPublicFolderAsync(publicPath, serverOutput);\n\n // Copy over the server output on top of the public folder.\n await persistMetroFilesAsync(files, serverOutput);\n\n [...files.entries()].forEach(([key, value]) => {\n if (value.targetDomain === 'server') {\n // Delete server resources to prevent them from being exposed in the binary.\n files.delete(key);\n }\n });\n\n // TODO: Deprecate this in favor of a built-in prop that users should avoid setting.\n const userDefinedServerUrl = exp.extra?.router?.origin;\n let serverUrl = userDefinedServerUrl;\n\n const shouldSkipServerDeployment = (() => {\n if (!options.eager) {\n logInXcode('Skipping server deployment because the script is not running in eager mode.');\n return true;\n }\n\n // Add an opaque flag to disable server deployment.\n if (env.EXPO_NO_DEPLOY) {\n warnInXcode('Skipping server deployment because environment variable EXPO_NO_DEPLOY is set.');\n return true;\n }\n\n // Can't safely deploy from Xcode since the PATH isn't set up correctly. We could amend this in the future and allow users who customize the PATH to deploy from Xcode.\n if (isExecutingFromXcodebuild()) {\n // TODO: Don't warn when the eager bundle has been run.\n warnInXcode(\n 'Skipping server deployment because the build is running from an Xcode run script. Build with Expo CLI or EAS Build to deploy the server automatically.'\n );\n return true;\n }\n\n return false;\n })();\n\n // Deploy the server output to a hosting provider.\n const deployedServerUrl = shouldSkipServerDeployment\n ? false\n : await runServerDeployCommandAsync(projectRoot, {\n distDirectory: serverOutput,\n deployScript: getServerDeploymentScript(pkg.scripts, options.platform),\n });\n\n if (!deployedServerUrl) {\n return;\n }\n\n if (serverUrl) {\n logInXcode(\n `Using custom server URL: ${serverUrl} (ignoring deployment URL: ${deployedServerUrl})`\n );\n }\n\n // If the user-defined server URL is not defined, use the deployed server URL.\n // This allows for overwriting the server URL in the project's native files.\n serverUrl ||= deployedServerUrl;\n\n // If the user hasn't manually defined the server URL, write the deployed server URL to the app.json.\n if (userDefinedServerUrl) {\n Log.log('Skip automatically linking server origin to native container');\n return;\n }\n Log.log('Writing generated server URL to app.json');\n\n // NOTE: Is is it possible to assert that the config needs to be modifiable before building the app?\n const modification = await modifyConfigAsync(\n projectRoot,\n {\n extra: {\n ...(exp.extra ?? {}),\n router: {\n ...(exp.extra?.router ?? {}),\n generatedOrigin: serverUrl,\n },\n },\n },\n {\n skipSDKVersionRequirement: true,\n }\n );\n\n if (modification.type !== 'success') {\n throw new CommandError(\n `Failed to write generated server origin to app.json because the file is dynamic and does not extend the static config. The client will not be able to make server requests to API routes or static files. You can disable server linking with EXPO_NO_DEPLOY=1 or by disabling server output in the app.json.`\n );\n }\n}\n\nasync function dumpDeploymentLogs(projectRoot: string, logs: string, name = 'deploy') {\n const outputPath = path.join(projectRoot, `.expo/logs/${name}.log`);\n await fs.promises.mkdir(path.dirname(outputPath), { recursive: true });\n debug('Dumping server deployment logs to: ' + outputPath);\n await fs.promises.writeFile(outputPath, logs);\n return outputPath;\n}\n\nfunction getCommandBin(command: string) {\n try {\n return execSync(`command -v ${command}`, { stdio: 'pipe' }).toString().trim();\n } catch {\n return null;\n }\n}\n\nasync function runServerDeployCommandAsync(\n projectRoot: string,\n {\n distDirectory,\n deployScript,\n }: { distDirectory: string; deployScript: { scriptName: string; script: string } | null }\n): Promise<string | false> {\n const logOfflineError = () => {\n const manualScript = deployScript\n ? `npm run ${deployScript.scriptName}`\n : `npx eas deploy --export-dir ${distDirectory}`;\n\n logMetroErrorInXcode(\n projectRoot,\n chalk.red`Running CLI in offline mode, skipping server deployment. Deploy manually with: ${manualScript}`\n );\n };\n if (env.EXPO_OFFLINE) {\n logOfflineError();\n return false;\n }\n\n // TODO: Only allow EAS deployments when staging is enabled, this is because the feature is still staging-only.\n if (!env.EXPO_UNSTABLE_DEPLOY_SERVER) {\n return false;\n }\n\n const globalBin = getCommandBin('eas');\n if (!globalBin) {\n // This should never happen from EAS Builds.\n // Possible to happen when building locally with `npx expo run`\n logMetroErrorInXcode(\n projectRoot,\n `eas-cli is not installed globally, skipping server deployment. Install EAS CLI with 'npm install -g eas-cli'.`\n );\n return false;\n }\n debug('Found eas-cli:', globalBin);\n\n let json: any;\n try {\n let results: spawnAsync.SpawnResult;\n\n const spawnOptions: spawnAsync.SpawnOptions = {\n cwd: projectRoot,\n // Ensures that errors can be caught.\n stdio: 'pipe',\n };\n // TODO: Support absolute paths in EAS CLI\n const exportDir = path.relative(projectRoot, distDirectory);\n if (deployScript) {\n logInXcode(`Using custom server deploy script: ${deployScript.scriptName}`);\n // Amend the path to try and make the custom scripts work.\n\n results = await spawnAsync(\n 'npm',\n ['run', deployScript.scriptName, `--export-dir=${exportDir}`],\n spawnOptions\n );\n } else {\n logInXcode('Deploying server to link with client');\n\n // results = DEPLOYMENT_SUCCESS_FIXTURE;\n results = await spawnAsync(\n 'node',\n [globalBin, 'deploy', '--non-interactive', '--json', `--export-dir=${exportDir}`],\n spawnOptions\n );\n\n debug('Server deployment stdout:', results.stdout);\n\n // Send stderr to stderr. stdout is parsed as JSON.\n if (results.stderr) {\n process.stderr.write(results.stderr);\n }\n }\n\n const logPath = await dumpDeploymentLogs(projectRoot, results.output.join('\\n'));\n\n try {\n // {\n // \"dashboardUrl\": \"https://staging.expo.dev/projects/6460c11c-e1bc-4084-882a-fd9f57b825b1/hosting/deployments\",\n // \"identifier\": \"8a1pwbv6c5\",\n // \"url\": \"https://sep30--8a1pwbv6c5.staging.expo.app\"\n // }\n json = JSON.parse(results.stdout.trim());\n } catch {\n logMetroErrorInXcode(\n projectRoot,\n `Failed to parse server deployment JSON output. Check the logs for more information: ${logPath}`\n );\n return false;\n }\n } catch (error) {\n if (isSpawnResultError(error)) {\n const output = error.output.join('\\n').trim() || error.toString();\n Log.log(\n chalk.dim(\n 'An error occurred while deploying server. Logs stored at: ' +\n (await dumpDeploymentLogs(projectRoot, output, 'deploy-error'))\n )\n );\n\n // Likely a server offline or network error.\n if (output.match(/ENOTFOUND/)) {\n logOfflineError();\n // Print the raw error message to help provide more context.\n Log.log(chalk.dim(output));\n // Prevent any other network requests (unlikely for this command).\n disableNetwork();\n return false;\n }\n\n logInXcode(output);\n if (output.match(/spawn eas ENOENT/)) {\n // EAS not installed.\n logMetroErrorInXcode(\n projectRoot,\n `Server deployment failed because eas-cli cannot be accessed from the build script's environment (ENOENT). Install EAS CLI with 'npm install -g eas-cli'.`\n );\n return false;\n }\n\n if (error.stderr.match(/Must configure EAS project by running/)) {\n // EAS not configured, this can happen when building a project locally before building in EAS.\n // User must run `eas init`, `eas deploy`, or `eas build` first.\n\n // TODO: Should we fail the build here or just warn users?\n logMetroErrorInXcode(\n projectRoot,\n `Skipping server deployment because EAS is not configured. Run 'eas init' before trying again, or disable server output in the project.`\n );\n return false;\n }\n }\n\n // Throw unhandled server deployment errors.\n throw error;\n }\n\n // Assert json format\n assertDeploymentJsonOutput(json);\n\n // Warn about the URL not being valid. This should never happen, but might be possible with third-parties.\n if (!canParseURL(json.url)) {\n warnInXcode(`The server deployment URL is not a valid URL: ${json.url}`);\n }\n\n if (json.dashboardUrl) {\n logInXcode(`Server dashboard: ${json.dashboardUrl}`);\n }\n\n logInXcode(`Server deployed to: ${json.url}`);\n\n return json.url;\n}\n\nfunction canParseURL(url: string): boolean {\n try {\n // eslint-disable-next-line no-new\n new URL(url);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction assertDeploymentJsonOutput(json: any): asserts json is ServerDeploymentResults {\n if (!json || typeof json !== 'object' || typeof json.url !== 'string') {\n throw new Error(\n 'JSON output of server deployment command are not in the expected format: { url: \"https://...\" }'\n );\n }\n}\n\nfunction getServerDeploymentScript(\n scripts: Record<string, string> | undefined,\n platform: string\n): { scriptName: string; script: string } | null {\n // Users can overwrite the default deployment script with:\n // { scripts: { \"native:deploy\": \"eas deploy --json --non-interactive\" } }\n // A quick search on GitHub showed that `native:deploy` is not used in any public repos yet.\n // https://github.com/search?q=%22native%3Adeploy%22+path%3Apackage.json&type=code\n const DEFAULT_SCRIPT_NAME = 'native:deploy';\n\n const scriptNames = [\n // DEFAULT_SCRIPT_NAME + ':' + platform,\n DEFAULT_SCRIPT_NAME,\n ];\n\n for (const scriptName of scriptNames) {\n if (scripts?.[scriptName]) {\n return { scriptName, script: scripts[scriptName] };\n }\n }\n\n return null;\n}\n\n/** We can try to remove the generated origin from the manifest when running outside of eager mode. Bundling is the last operation to run so the config will already be embedded with the origin. */\nasync function tryRemovingGeneratedOriginAsync(projectRoot: string, exp: ExpoConfig) {\n if (env.CI) {\n // Skip in CI since nothing is committed.\n return;\n }\n if (exp.extra?.router?.generatedOrigin == null) {\n debug('No generated origin needs removing');\n return;\n }\n\n const modification = await modifyConfigAsync(\n projectRoot,\n {\n extra: {\n ...(exp.extra ?? {}),\n router: {\n ...(exp.extra?.router ?? {}),\n generatedOrigin: undefined,\n },\n },\n },\n {\n skipSDKVersionRequirement: true,\n }\n );\n\n if (modification.type !== 'success') {\n debug('Could not remove generated origin from manifest');\n } else {\n debug('Generated origin has been removed from manifest');\n }\n}\n"],"names":["exportStandaloneServerAsync","debug","require","projectRoot","devServer","exp","pkg","files","options","eager","tryRemovingGeneratedOriginAsync","logInXcode","serverOutput","path","join","platform","removeAsync","exportApiRoutesStandaloneAsync","apiRoutesOnly","publicPath","resolve","env","EXPO_PUBLIC_FOLDER","copyPublicFolderAsync","persistMetroFilesAsync","entries","forEach","key","value","targetDomain","delete","userDefinedServerUrl","extra","router","origin","serverUrl","shouldSkipServerDeployment","EXPO_NO_DEPLOY","warnInXcode","isExecutingFromXcodebuild","deployedServerUrl","runServerDeployCommandAsync","distDirectory","deployScript","getServerDeploymentScript","scripts","Log","log","modification","modifyConfigAsync","generatedOrigin","skipSDKVersionRequirement","type","CommandError","dumpDeploymentLogs","logs","name","outputPath","fs","promises","mkdir","dirname","recursive","writeFile","getCommandBin","command","execSync","stdio","toString","trim","logOfflineError","manualScript","scriptName","logMetroErrorInXcode","chalk","red","EXPO_OFFLINE","EXPO_UNSTABLE_DEPLOY_SERVER","globalBin","json","results","spawnOptions","cwd","exportDir","relative","spawnAsync","stdout","stderr","process","write","logPath","output","JSON","parse","error","isSpawnResultError","dim","match","disableNetwork","assertDeploymentJsonOutput","canParseURL","url","dashboardUrl","URL","Error","DEFAULT_SCRIPT_NAME","scriptNames","script","CI","undefined"],"mappings":"AAAA;;;;;CAKC,GACD;;;;+BAgCsBA,6BAA2B;;aAA3BA,2BAA2B;;;yBAhCg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IAAA,CAACuF,EAAE,EAAE;QACV,yCAAyC;QACzC,OAAO;IACT,CAAC;IACD,IAAIvG,CAAAA,CAAAA,GAAS,GAATA,GAAG,CAAC2B,KAAK,SAAQ,GAAjB3B,KAAAA,CAAiB,GAAjBA,QAAAA,GAAS,CAAE4B,MAAM,SAAA,GAAjB5B,KAAAA,CAAiB,QAAE6C,eAAe,AAAjB,CAAA,IAAqB,IAAI,EAAE;QAC9CjD,KAAK,CAAC,oCAAoC,CAAC,CAAC;QAC5C,OAAO;IACT,CAAC;IAED,MAAM+C,YAAY,GAAG,MAAMC,IAAAA,OAAiB,EAAA,kBAAA,EAC1C9C,WAAW,EACX;QACE6B,KAAK,EAAE;YACL,GAAI3B,GAAG,CAAC2B,KAAK,IAAI,EAAE;YACnBC,MAAM,EAAE;gBACN,GAAI5B,CAAAA,CAAAA,IAAS,GAATA,GAAG,CAAC2B,KAAK,SAAQ,GAAjB3B,KAAAA,CAAiB,GAAjBA,IAAS,CAAE4B,MAAM,CAAA,IAAI,EAAE;gBAC3BiB,eAAe,EAAE2D,SAAS;aAC3B;SACF;KACF,EACD;QACE1D,yBAAyB,EAAE,IAAI;KAChC,CACF,AAAC;IAEF,IAAIH,YAAY,CAACI,IAAI,KAAK,SAAS,EAAE;QACnCnD,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAC3D,OAAO;QACLA,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC"}
1
+ {"version":3,"sources":["../../../../src/export/embed/exportServer.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { ExpoConfig, modifyConfigAsync, PackageJSONConfig } from '@expo/config';\nimport spawnAsync from '@expo/spawn-async';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport { execSync } from 'node:child_process';\nimport path from 'path';\n\nimport { disableNetwork } from '../../api/settings';\nimport { Log } from '../../log';\nimport { isSpawnResultError } from '../../start/platforms/ios/xcrun';\nimport { MetroBundlerDevServer } from '../../start/server/metro/MetroBundlerDevServer';\nimport { removeAsync } from '../../utils/dir';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { exportApiRoutesStandaloneAsync } from '../exportStaticAsync';\nimport { copyPublicFolderAsync } from '../publicFolder';\nimport { ExportAssetMap, persistMetroFilesAsync } from '../saveAssets';\nimport { Options } from './resolveOptions';\nimport {\n isExecutingFromXcodebuild,\n logInXcode,\n logMetroErrorInXcode,\n warnInXcode,\n} from './xcodeCompilerLogger';\n\nconst debug = require('debug')('expo:export:server');\n\ntype ServerDeploymentResults = {\n url: string;\n dashboardUrl?: string;\n};\n\nexport async function exportStandaloneServerAsync(\n projectRoot: string,\n devServer: MetroBundlerDevServer,\n {\n exp,\n pkg,\n files,\n options,\n }: { exp: ExpoConfig; pkg: PackageJSONConfig; files: ExportAssetMap; options: Options }\n) {\n if (!options.eager) {\n await tryRemovingGeneratedOriginAsync(projectRoot, exp);\n }\n\n logInXcode('Exporting server');\n\n // Store the server output in the project's .expo directory.\n const serverOutput = path.join(projectRoot, '.expo/server', options.platform);\n\n // Remove the previous server output to prevent stale files.\n await removeAsync(serverOutput);\n\n // Export the API routes for server rendering the React Server Components.\n await exportApiRoutesStandaloneAsync(devServer, {\n files,\n platform: 'web',\n apiRoutesOnly: true,\n });\n\n const publicPath = path.resolve(projectRoot, env.EXPO_PUBLIC_FOLDER);\n\n // Copy over public folder items\n await copyPublicFolderAsync(publicPath, serverOutput);\n\n // Copy over the server output on top of the public folder.\n await persistMetroFilesAsync(files, serverOutput);\n\n [...files.entries()].forEach(([key, value]) => {\n if (value.targetDomain === 'server') {\n // Delete server resources to prevent them from being exposed in the binary.\n files.delete(key);\n }\n });\n\n // TODO: Deprecate this in favor of a built-in prop that users should avoid setting.\n const userDefinedServerUrl = exp.extra?.router?.origin;\n let serverUrl = userDefinedServerUrl;\n\n const shouldSkipServerDeployment = (() => {\n if (!options.eager) {\n logInXcode('Skipping server deployment because the script is not running in eager mode.');\n return true;\n }\n\n // Add an opaque flag to disable server deployment.\n if (env.EXPO_NO_DEPLOY) {\n warnInXcode('Skipping server deployment because environment variable EXPO_NO_DEPLOY is set.');\n return true;\n }\n\n // Can't safely deploy from Xcode since the PATH isn't set up correctly. We could amend this in the future and allow users who customize the PATH to deploy from Xcode.\n if (isExecutingFromXcodebuild()) {\n // TODO: Don't warn when the eager bundle has been run.\n warnInXcode(\n 'Skipping server deployment because the build is running from an Xcode run script. Build with Expo CLI or EAS Build to deploy the server automatically.'\n );\n return true;\n }\n\n return false;\n })();\n\n // Deploy the server output to a hosting provider.\n const deployedServerUrl = shouldSkipServerDeployment\n ? false\n : await runServerDeployCommandAsync(projectRoot, {\n distDirectory: serverOutput,\n deployScript: getServerDeploymentScript(pkg.scripts, options.platform),\n });\n\n if (!deployedServerUrl) {\n return;\n }\n\n if (serverUrl) {\n logInXcode(\n `Using custom server URL: ${serverUrl} (ignoring deployment URL: ${deployedServerUrl})`\n );\n }\n\n // If the user-defined server URL is not defined, use the deployed server URL.\n // This allows for overwriting the server URL in the project's native files.\n serverUrl ||= deployedServerUrl;\n\n // If the user hasn't manually defined the server URL, write the deployed server URL to the app.json.\n if (userDefinedServerUrl) {\n Log.log('Skip automatically linking server origin to native container');\n return;\n }\n Log.log('Writing generated server URL to app.json');\n\n // NOTE: Is is it possible to assert that the config needs to be modifiable before building the app?\n const modification = await modifyConfigAsync(\n projectRoot,\n {\n extra: {\n ...(exp.extra ?? {}),\n router: {\n ...(exp.extra?.router ?? {}),\n generatedOrigin: serverUrl,\n },\n },\n },\n {\n skipSDKVersionRequirement: true,\n }\n );\n\n if (modification.type !== 'success') {\n throw new CommandError(\n `Failed to write generated server origin to app.json because the file is dynamic and does not extend the static config. The client will not be able to make server requests to API routes or static files. You can disable server linking with EXPO_NO_DEPLOY=1 or by disabling server output in the app.json.`\n );\n }\n}\n\nasync function dumpDeploymentLogs(projectRoot: string, logs: string, name = 'deploy') {\n const outputPath = path.join(projectRoot, `.expo/logs/${name}.log`);\n await fs.promises.mkdir(path.dirname(outputPath), { recursive: true });\n debug('Dumping server deployment logs to: ' + outputPath);\n await fs.promises.writeFile(outputPath, logs);\n return outputPath;\n}\n\nfunction getCommandBin(command: string) {\n try {\n return execSync(`command -v ${command}`, { stdio: 'pipe' }).toString().trim();\n } catch {\n return null;\n }\n}\n\nasync function runServerDeployCommandAsync(\n projectRoot: string,\n {\n distDirectory,\n deployScript,\n }: { distDirectory: string; deployScript: { scriptName: string; script: string } | null }\n): Promise<string | false> {\n const logOfflineError = () => {\n const manualScript = deployScript\n ? `npm run ${deployScript.scriptName}`\n : `npx eas deploy --export-dir ${distDirectory}`;\n\n logMetroErrorInXcode(\n projectRoot,\n chalk.red`Running CLI in offline mode, skipping server deployment. Deploy manually with: ${manualScript}`\n );\n };\n if (env.EXPO_OFFLINE) {\n logOfflineError();\n return false;\n }\n\n // TODO: Only allow EAS deployments when staging is enabled, this is because the feature is still staging-only.\n if (!env.EXPO_UNSTABLE_DEPLOY_SERVER) {\n return false;\n }\n\n if (!env.EAS_BUILD) {\n // This check helps avoid running EAS if the user isn't a user of EAS.\n // We only need to run it when building outside of EAS.\n const globalBin = getCommandBin('eas');\n if (!globalBin) {\n // This should never happen from EAS Builds.\n // Possible to happen when building locally with `npx expo run`\n logMetroErrorInXcode(\n projectRoot,\n `eas-cli is not installed globally, skipping server deployment. Install EAS CLI with 'npm install -g eas-cli'.`\n );\n return false;\n }\n debug('Found eas-cli:', globalBin);\n }\n\n let json: any;\n try {\n let results: spawnAsync.SpawnResult;\n\n const spawnOptions: spawnAsync.SpawnOptions = {\n cwd: projectRoot,\n // Ensures that errors can be caught.\n stdio: 'pipe',\n };\n // TODO: Support absolute paths in EAS CLI\n const exportDir = path.relative(projectRoot, distDirectory);\n if (deployScript) {\n logInXcode(`Using custom server deploy script: ${deployScript.scriptName}`);\n // Amend the path to try and make the custom scripts work.\n\n results = await spawnAsync(\n 'npm',\n ['run', deployScript.scriptName, `--export-dir=${exportDir}`],\n spawnOptions\n );\n } else {\n logInXcode('Deploying server to link with client');\n\n // results = DEPLOYMENT_SUCCESS_FIXTURE;\n results = await spawnAsync(\n 'npx',\n ['eas-cli', 'deploy', '--non-interactive', '--json', `--export-dir=${exportDir}`],\n spawnOptions\n );\n\n debug('Server deployment stdout:', results.stdout);\n\n // Send stderr to stderr. stdout is parsed as JSON.\n if (results.stderr) {\n process.stderr.write(results.stderr);\n }\n }\n\n const logPath = await dumpDeploymentLogs(projectRoot, results.output.join('\\n'));\n\n try {\n // {\n // \"dashboardUrl\": \"https://staging.expo.dev/projects/6460c11c-e1bc-4084-882a-fd9f57b825b1/hosting/deployments\",\n // \"identifier\": \"8a1pwbv6c5\",\n // \"url\": \"https://sep30--8a1pwbv6c5.staging.expo.app\"\n // }\n json = JSON.parse(results.stdout.trim());\n } catch {\n logMetroErrorInXcode(\n projectRoot,\n `Failed to parse server deployment JSON output. Check the logs for more information: ${logPath}`\n );\n return false;\n }\n } catch (error) {\n if (isSpawnResultError(error)) {\n const output = error.output.join('\\n').trim() || error.toString();\n Log.log(\n chalk.dim(\n 'An error occurred while deploying server. Logs stored at: ' +\n (await dumpDeploymentLogs(projectRoot, output, 'deploy-error'))\n )\n );\n\n // Likely a server offline or network error.\n if (output.match(/ENOTFOUND/)) {\n logOfflineError();\n // Print the raw error message to help provide more context.\n Log.log(chalk.dim(output));\n // Prevent any other network requests (unlikely for this command).\n disableNetwork();\n return false;\n }\n\n logInXcode(output);\n if (output.match(/spawn eas ENOENT/)) {\n // EAS not installed.\n logMetroErrorInXcode(\n projectRoot,\n `Server deployment failed because eas-cli cannot be accessed from the build script's environment (ENOENT). Install EAS CLI with 'npm install -g eas-cli'.`\n );\n return false;\n }\n\n if (error.stderr.match(/Must configure EAS project by running/)) {\n // EAS not configured, this can happen when building a project locally before building in EAS.\n // User must run `eas init`, `eas deploy`, or `eas build` first.\n\n // TODO: Should we fail the build here or just warn users?\n logMetroErrorInXcode(\n projectRoot,\n `Skipping server deployment because EAS is not configured. Run 'eas init' before trying again, or disable server output in the project.`\n );\n return false;\n }\n }\n\n // Throw unhandled server deployment errors.\n throw error;\n }\n\n // Assert json format\n assertDeploymentJsonOutput(json);\n\n // Warn about the URL not being valid. This should never happen, but might be possible with third-parties.\n if (!canParseURL(json.url)) {\n warnInXcode(`The server deployment URL is not a valid URL: ${json.url}`);\n }\n\n if (json.dashboardUrl) {\n logInXcode(`Server dashboard: ${json.dashboardUrl}`);\n }\n\n logInXcode(`Server deployed to: ${json.url}`);\n\n return json.url;\n}\n\nfunction canParseURL(url: string): boolean {\n try {\n // eslint-disable-next-line no-new\n new URL(url);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction assertDeploymentJsonOutput(json: any): asserts json is ServerDeploymentResults {\n if (!json || typeof json !== 'object' || typeof json.url !== 'string') {\n throw new Error(\n 'JSON output of server deployment command are not in the expected format: { url: \"https://...\" }'\n );\n }\n}\n\nfunction getServerDeploymentScript(\n scripts: Record<string, string> | undefined,\n platform: string\n): { scriptName: string; script: string } | null {\n // Users can overwrite the default deployment script with:\n // { scripts: { \"native:deploy\": \"eas deploy --json --non-interactive\" } }\n // A quick search on GitHub showed that `native:deploy` is not used in any public repos yet.\n // https://github.com/search?q=%22native%3Adeploy%22+path%3Apackage.json&type=code\n const DEFAULT_SCRIPT_NAME = 'native:deploy';\n\n const scriptNames = [\n // DEFAULT_SCRIPT_NAME + ':' + platform,\n DEFAULT_SCRIPT_NAME,\n ];\n\n for (const scriptName of scriptNames) {\n if (scripts?.[scriptName]) {\n return { scriptName, script: scripts[scriptName] };\n }\n }\n\n return null;\n}\n\n/** We can try to remove the generated origin from the manifest when running outside of eager mode. Bundling is the last operation to run so the config will already be embedded with the origin. */\nasync function tryRemovingGeneratedOriginAsync(projectRoot: string, exp: ExpoConfig) {\n if (env.CI) {\n // Skip in CI since nothing is committed.\n return;\n }\n if (exp.extra?.router?.generatedOrigin == null) {\n debug('No generated origin needs removing');\n return;\n }\n\n const modification = await modifyConfigAsync(\n projectRoot,\n {\n extra: {\n ...(exp.extra ?? {}),\n router: {\n ...(exp.extra?.router ?? {}),\n generatedOrigin: undefined,\n },\n },\n },\n {\n skipSDKVersionRequirement: true,\n }\n );\n\n if (modification.type !== 'success') {\n debug('Could not remove generated origin from manifest');\n } else {\n debug('Generated origin has been removed from manifest');\n }\n}\n"],"names":["exportStandaloneServerAsync","debug","require","projectRoot","devServer","exp","pkg","files","options","eager","tryRemovingGeneratedOriginAsync","logInXcode","serverOutput","path","join","platform","removeAsync","exportApiRoutesStandaloneAsync","apiRoutesOnly","publicPath","resolve","env","EXPO_PUBLIC_FOLDER","copyPublicFolderAsync","persistMetroFilesAsync","entries","forEach","key","value","targetDomain","delete","userDefinedServerUrl","extra","router","origin","serverUrl","shouldSkipServerDeployment","EXPO_NO_DEPLOY","warnInXcode","isExecutingFromXcodebuild","deployedServerUrl","runServerDeployCommandAsync","distDirectory","deployScript","getServerDeploymentScript","scripts","Log","log","modification","modifyConfigAsync","generatedOrigin","skipSDKVersionRequirement","type","CommandError","dumpDeploymentLogs","logs","name","outputPath","fs","promises","mkdir","dirname","recursive","writeFile","getCommandBin","command","execSync","stdio","toString","trim","logOfflineError","manualScript","scriptName","logMetroErrorInXcode","chalk","red","EXPO_OFFLINE","EXPO_UNSTABLE_DEPLOY_SERVER","EAS_BUILD","globalBin","json","results","spawnOptions","cwd","exportDir","relative","spawnAsync","stdout","stderr","process","write","logPath","output","JSON","parse","error","isSpawnResultError","dim","match","disableNetwork","assertDeploymentJsonOutput","canParseURL","url","dashboardUrl","URL","Error","DEFAULT_SCRIPT_NAME","scriptNames","script","CI","undefined"],"mappings":"AAAA;;;;;CAKC,GACD;;;;+BAgCsBA,6BAA2B;;aAA3BA,2BAA2B;;;yBAhCgB,cAAc;;;;;;;8DACxD,mBAAmB;;;;;;;8DACxB,OAAO;;;;;;;8DACV,IAAI;;;;;;;yBACM,oBAAoB;;;;;;;8DAC5B,MAAM;;;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yCAAyC;QACzC,OAAO;IACT,CAAC;IACD,IAAIxG,CAAAA,CAAAA,GAAS,GAATA,GAAG,CAAC2B,KAAK,SAAQ,GAAjB3B,KAAAA,CAAiB,GAAjBA,QAAAA,GAAS,CAAE4B,MAAM,SAAA,GAAjB5B,KAAAA,CAAiB,QAAE6C,eAAe,AAAjB,CAAA,IAAqB,IAAI,EAAE;QAC9CjD,KAAK,CAAC,oCAAoC,CAAC,CAAC;QAC5C,OAAO;IACT,CAAC;IAED,MAAM+C,YAAY,GAAG,MAAMC,IAAAA,OAAiB,EAAA,kBAAA,EAC1C9C,WAAW,EACX;QACE6B,KAAK,EAAE;YACL,GAAI3B,GAAG,CAAC2B,KAAK,IAAI,EAAE;YACnBC,MAAM,EAAE;gBACN,GAAI5B,CAAAA,CAAAA,IAAS,GAATA,GAAG,CAAC2B,KAAK,SAAQ,GAAjB3B,KAAAA,CAAiB,GAAjBA,IAAS,CAAE4B,MAAM,CAAA,IAAI,EAAE;gBAC3BiB,eAAe,EAAE4D,SAAS;aAC3B;SACF;KACF,EACD;QACE3D,yBAAyB,EAAE,IAAI;KAChC,CACF,AAAC;IAEF,IAAIH,YAAY,CAACI,IAAI,KAAK,SAAS,EAAE;QACnCnD,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAC3D,OAAO;QACLA,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC"}
@@ -14,6 +14,7 @@ function _export(target, all) {
14
14
  });
15
15
  }
16
16
  _export(exports, {
17
+ isPossiblyUnableToResolveError: ()=>isPossiblyUnableToResolveError,
17
18
  getXcodeCompilerErrorMessage: ()=>getXcodeCompilerErrorMessage,
18
19
  logMetroErrorInXcode: ()=>logMetroErrorInXcode,
19
20
  logInXcode: ()=>logInXcode,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/export/embed/xcodeCompilerLogger.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport fs from 'fs';\nimport path from 'path';\n\nimport { Log } from '../../log';\n\nfunction isPossiblyUnableToResolveError(\n error: any\n): error is { message: string; originModulePath: string; targetModuleName: string } {\n return (\n 'message' in error &&\n typeof error.message === 'string' &&\n 'originModulePath' in error &&\n typeof error.originModulePath === 'string' &&\n 'targetModuleName' in error &&\n typeof error.targetModuleName === 'string'\n );\n}\nfunction isPossiblyTransformError(\n error: any\n): error is { message: string; filename: string; lineNumber: number; column?: number } {\n return (\n 'message' in error &&\n typeof error.message === 'string' &&\n 'filename' in error &&\n typeof error.filename === 'string' &&\n 'lineNumber' in error &&\n typeof error.lineNumber === 'number'\n );\n}\n\nexport function getXcodeCompilerErrorMessage(\n projectRoot: string,\n error: Error | any\n): string | null {\n const makeFilepathAbsolute = (filepath: string) =>\n filepath.startsWith('/') ? filepath : path.join(projectRoot, filepath);\n\n if (typeof error === 'string') {\n return makeXcodeCompilerLog('error', error);\n } else if ('message' in error) {\n // Metro's `UnableToResolveError`\n if (isPossiblyUnableToResolveError(error)) {\n const loc = getLineNumberForStringInFile(error.originModulePath, error.targetModuleName);\n return makeXcodeCompilerLog('error', error.message, {\n fileName: error.originModulePath,\n lineNumber: loc?.lineNumber,\n column: loc?.column,\n });\n } else if (isPossiblyTransformError(error)) {\n return makeXcodeCompilerLog('error', error.message, {\n // Metro generally returns the filename as relative from the project root.\n fileName: makeFilepathAbsolute(error.filename),\n lineNumber: error.lineNumber,\n column: error.column,\n });\n // TODO: ResourceNotFoundError, GraphNotFoundError, RevisionNotFoundError, AmbiguousModuleResolutionError\n } else {\n // Unknown error\n return makeXcodeCompilerLog('error', error.message);\n }\n }\n\n return null;\n}\n\n/** Log an error that can be parsed by Xcode and related build tools https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script */\nexport function logMetroErrorInXcode(projectRoot: string, error: Error | string) {\n const message = getXcodeCompilerErrorMessage(projectRoot, error);\n if (message != null) {\n console.error(message);\n }\n}\n\nexport function logInXcode(message: string) {\n Log.log(makeXcodeCompilerLog('note', message));\n}\n\nexport function warnInXcode(message: string) {\n Log.warn(makeXcodeCompilerLog('warning', message));\n}\n\n// Detect running in xcode build script. This means the logs need to be formatted in a way that Xcode can parse them, it also means that the shell is not reliable or interactive.\n// https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Access-script-related-files-from-environment-variables\nexport function isExecutingFromXcodebuild() {\n return !!process.env.BUILT_PRODUCTS_DIR;\n}\n\nfunction makeXcodeCompilerLog(\n type: 'error' | 'fatal error' | 'warning' | 'note',\n message: string,\n {\n fileName,\n lineNumber,\n column,\n }: {\n /** Absolute file path to link to in Xcode. */\n fileName?: string;\n lineNumber?: number;\n column?: number;\n } = {}\n) {\n if (!isExecutingFromXcodebuild()) {\n return message;\n }\n // TODO: Figure out how to support multi-line logs.\n const firstLine = message.split('\\n')[0];\n if (fileName && !fileName?.includes(':')) {\n return `${fileName}:${lineNumber || 0}:${\n column != null ? column + ':' : ''\n } ${type}: ${firstLine}`;\n }\n return `${type}: ${firstLine}`;\n}\n\n// TODO: Metro doesn't expose this info even though it knows it.\nfunction getLineNumberForStringInFile(originModulePath: string, targetModuleName: string) {\n let file;\n try {\n file = fs.readFileSync(originModulePath, 'utf8');\n } catch (error: any) {\n if (error.code === 'ENOENT' || error.code === 'EISDIR') {\n // We're probably dealing with a virtualised file system where\n // `this.originModulePath` doesn't actually exist on disk.\n // We can't show a code frame, but there's no need to let this I/O\n // error shadow the original module resolution error.\n return null;\n }\n throw error;\n }\n const lines = file.split('\\n');\n let lineNumber = 0;\n let column = -1;\n for (let line = 0; line < lines.length; line++) {\n const columnLocation = lines[line].lastIndexOf(targetModuleName);\n if (columnLocation >= 0) {\n lineNumber = line;\n column = columnLocation;\n break;\n }\n }\n return { lineNumber, column };\n}\n"],"names":["getXcodeCompilerErrorMessage","logMetroErrorInXcode","logInXcode","warnInXcode","isExecutingFromXcodebuild","isPossiblyUnableToResolveError","error","message","originModulePath","targetModuleName","isPossiblyTransformError","filename","lineNumber","projectRoot","makeFilepathAbsolute","filepath","startsWith","path","join","makeXcodeCompilerLog","loc","getLineNumberForStringInFile","fileName","column","console","Log","log","warn","process","env","BUILT_PRODUCTS_DIR","type","firstLine","split","includes","file","fs","readFileSync","code","lines","line","length","columnLocation","lastIndexOf"],"mappings":"AAAA;;;;;CAKC,GACD;;;;;;;;;;;IA8BgBA,4BAA4B,MAA5BA,4BAA4B;IAoC5BC,oBAAoB,MAApBA,oBAAoB;IAOpBC,UAAU,MAAVA,UAAU;IAIVC,WAAW,MAAXA,WAAW;IAMXC,yBAAyB,MAAzBA,yBAAyB;;;8DAnF1B,IAAI;;;;;;;8DACF,MAAM;;;;;;qBAEH,WAAW;;;;;;AAE/B,SAASC,8BAA8B,CACrCC,KAAU,EACwE;IAClF,OACE,SAAS,IAAIA,KAAK,IAClB,OAAOA,KAAK,CAACC,OAAO,KAAK,QAAQ,IACjC,kBAAkB,IAAID,KAAK,IAC3B,OAAOA,KAAK,CAACE,gBAAgB,KAAK,QAAQ,IAC1C,kBAAkB,IAAIF,KAAK,IAC3B,OAAOA,KAAK,CAACG,gBAAgB,KAAK,QAAQ,CAC1C;AACJ,CAAC;AACD,SAASC,wBAAwB,CAC/BJ,KAAU,EAC2E;IACrF,OACE,SAAS,IAAIA,KAAK,IAClB,OAAOA,KAAK,CAACC,OAAO,KAAK,QAAQ,IACjC,UAAU,IAAID,KAAK,IACnB,OAAOA,KAAK,CAACK,QAAQ,KAAK,QAAQ,IAClC,YAAY,IAAIL,KAAK,IACrB,OAAOA,KAAK,CAACM,UAAU,KAAK,QAAQ,CACpC;AACJ,CAAC;AAEM,SAASZ,4BAA4B,CAC1Ca,WAAmB,EACnBP,KAAkB,EACH;IACf,MAAMQ,oBAAoB,GAAG,CAACC,QAAgB,GAC5CA,QAAQ,CAACC,UAAU,CAAC,GAAG,CAAC,GAAGD,QAAQ,GAAGE,KAAI,EAAA,QAAA,CAACC,IAAI,C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,CAAC,CAAC;AACjC,CAAC;AAED,gEAAgE;AAChE,SAASX,4BAA4B,CAACb,gBAAwB,EAAEC,gBAAwB,EAAE;IACxF,IAAI0B,IAAI,AAAC;IACT,IAAI;QACFA,IAAI,GAAGC,GAAE,EAAA,QAAA,CAACC,YAAY,CAAC7B,gBAAgB,EAAE,MAAM,CAAC,CAAC;IACnD,EAAE,OAAOF,KAAK,EAAO;QACnB,IAAIA,KAAK,CAACgC,IAAI,KAAK,QAAQ,IAAIhC,KAAK,CAACgC,IAAI,KAAK,QAAQ,EAAE;YACtD,8DAA8D;YAC9D,0DAA0D;YAC1D,kEAAkE;YAClE,qDAAqD;YACrD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAMhC,KAAK,CAAC;IACd,CAAC;IACD,MAAMiC,KAAK,GAAGJ,IAAI,CAACF,KAAK,CAAC,IAAI,CAAC,AAAC;IAC/B,IAAIrB,UAAU,GAAG,CAAC,AAAC;IACnB,IAAIW,MAAM,GAAG,CAAC,CAAC,AAAC;IAChB,IAAK,IAAIiB,IAAI,GAAG,CAAC,EAAEA,IAAI,GAAGD,KAAK,CAACE,MAAM,EAAED,IAAI,EAAE,CAAE;QAC9C,MAAME,cAAc,GAAGH,KAAK,CAACC,IAAI,CAAC,CAACG,WAAW,CAAClC,gBAAgB,CAAC,AAAC;QACjE,IAAIiC,cAAc,IAAI,CAAC,EAAE;YACvB9B,UAAU,GAAG4B,IAAI,CAAC;YAClBjB,MAAM,GAAGmB,cAAc,CAAC;YACxB,MAAM;QACR,CAAC;IACH,CAAC;IACD,OAAO;QAAE9B,UAAU;QAAEW,MAAM;KAAE,CAAC;AAChC,CAAC"}
1
+ {"version":3,"sources":["../../../../src/export/embed/xcodeCompilerLogger.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport fs from 'fs';\nimport path from 'path';\n\nimport { Log } from '../../log';\n\nexport function isPossiblyUnableToResolveError(\n error: any\n): error is { message: string; originModulePath: string; targetModuleName: string } {\n return (\n 'message' in error &&\n typeof error.message === 'string' &&\n 'originModulePath' in error &&\n typeof error.originModulePath === 'string' &&\n 'targetModuleName' in error &&\n typeof error.targetModuleName === 'string'\n );\n}\nfunction isPossiblyTransformError(\n error: any\n): error is { message: string; filename: string; lineNumber: number; column?: number } {\n return (\n 'message' in error &&\n typeof error.message === 'string' &&\n 'filename' in error &&\n typeof error.filename === 'string' &&\n 'lineNumber' in error &&\n typeof error.lineNumber === 'number'\n );\n}\n\nexport function getXcodeCompilerErrorMessage(\n projectRoot: string,\n error: Error | any\n): string | null {\n const makeFilepathAbsolute = (filepath: string) =>\n filepath.startsWith('/') ? filepath : path.join(projectRoot, filepath);\n\n if (typeof error === 'string') {\n return makeXcodeCompilerLog('error', error);\n } else if ('message' in error) {\n // Metro's `UnableToResolveError`\n if (isPossiblyUnableToResolveError(error)) {\n const loc = getLineNumberForStringInFile(error.originModulePath, error.targetModuleName);\n return makeXcodeCompilerLog('error', error.message, {\n fileName: error.originModulePath,\n lineNumber: loc?.lineNumber,\n column: loc?.column,\n });\n } else if (isPossiblyTransformError(error)) {\n return makeXcodeCompilerLog('error', error.message, {\n // Metro generally returns the filename as relative from the project root.\n fileName: makeFilepathAbsolute(error.filename),\n lineNumber: error.lineNumber,\n column: error.column,\n });\n // TODO: ResourceNotFoundError, GraphNotFoundError, RevisionNotFoundError, AmbiguousModuleResolutionError\n } else {\n // Unknown error\n return makeXcodeCompilerLog('error', error.message);\n }\n }\n\n return null;\n}\n\n/** Log an error that can be parsed by Xcode and related build tools https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script */\nexport function logMetroErrorInXcode(projectRoot: string, error: Error | string) {\n const message = getXcodeCompilerErrorMessage(projectRoot, error);\n if (message != null) {\n console.error(message);\n }\n}\n\nexport function logInXcode(message: string) {\n Log.log(makeXcodeCompilerLog('note', message));\n}\n\nexport function warnInXcode(message: string) {\n Log.warn(makeXcodeCompilerLog('warning', message));\n}\n\n// Detect running in xcode build script. This means the logs need to be formatted in a way that Xcode can parse them, it also means that the shell is not reliable or interactive.\n// https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Access-script-related-files-from-environment-variables\nexport function isExecutingFromXcodebuild() {\n return !!process.env.BUILT_PRODUCTS_DIR;\n}\n\nfunction makeXcodeCompilerLog(\n type: 'error' | 'fatal error' | 'warning' | 'note',\n message: string,\n {\n fileName,\n lineNumber,\n column,\n }: {\n /** Absolute file path to link to in Xcode. */\n fileName?: string;\n lineNumber?: number;\n column?: number;\n } = {}\n) {\n if (!isExecutingFromXcodebuild()) {\n return message;\n }\n // TODO: Figure out how to support multi-line logs.\n const firstLine = message.split('\\n')[0];\n if (fileName && !fileName?.includes(':')) {\n return `${fileName}:${lineNumber || 0}:${\n column != null ? column + ':' : ''\n } ${type}: ${firstLine}`;\n }\n return `${type}: ${firstLine}`;\n}\n\n// TODO: Metro doesn't expose this info even though it knows it.\nfunction getLineNumberForStringInFile(originModulePath: string, targetModuleName: string) {\n let file;\n try {\n file = fs.readFileSync(originModulePath, 'utf8');\n } catch (error: any) {\n if (error.code === 'ENOENT' || error.code === 'EISDIR') {\n // We're probably dealing with a virtualised file system where\n // `this.originModulePath` doesn't actually exist on disk.\n // We can't show a code frame, but there's no need to let this I/O\n // error shadow the original module resolution error.\n return null;\n }\n throw error;\n }\n const lines = file.split('\\n');\n let lineNumber = 0;\n let column = -1;\n for (let line = 0; line < lines.length; line++) {\n const columnLocation = lines[line].lastIndexOf(targetModuleName);\n if (columnLocation >= 0) {\n lineNumber = line;\n column = columnLocation;\n break;\n }\n }\n return { lineNumber, column };\n}\n"],"names":["isPossiblyUnableToResolveError","getXcodeCompilerErrorMessage","logMetroErrorInXcode","logInXcode","warnInXcode","isExecutingFromXcodebuild","error","message","originModulePath","targetModuleName","isPossiblyTransformError","filename","lineNumber","projectRoot","makeFilepathAbsolute","filepath","startsWith","path","join","makeXcodeCompilerLog","loc","getLineNumberForStringInFile","fileName","column","console","Log","log","warn","process","env","BUILT_PRODUCTS_DIR","type","firstLine","split","includes","file","fs","readFileSync","code","lines","line","length","columnLocation","lastIndexOf"],"mappings":"AAAA;;;;;CAKC,GACD;;;;;;;;;;;IAKgBA,8BAA8B,MAA9BA,8BAA8B;IAyB9BC,4BAA4B,MAA5BA,4BAA4B;IAoC5BC,oBAAoB,MAApBA,oBAAoB;IAOpBC,UAAU,MAAVA,UAAU;IAIVC,WAAW,MAAXA,WAAW;IAMXC,yBAAyB,MAAzBA,yBAAyB;;;8DAnF1B,IAAI;;;;;;;8DACF,MAAM;;;;;;qBAEH,WAAW;;;;;;AAExB,SAASL,8BAA8B,CAC5CM,KAAU,EACwE;IAClF,OACE,SAAS,IAAIA,KAAK,IAClB,OAAOA,KAAK,CAACC,OAAO,KAAK,QAAQ,IACjC,kBAAkB,IAAID,KAAK,IAC3B,OAAOA,KAAK,CAACE,gBAAgB,KAAK,QAAQ,IAC1C,kBAAkB,IAAIF,KAAK,IAC3B,OAAOA,KAAK,CAACG,gBAAgB,KAAK,QAAQ,CAC1C;AACJ,CAAC;AACD,SAASC,wBAAwB,CAC/BJ,KAAU,EAC2E;IACrF,OACE,SAAS,IAAIA,KAAK,IAClB,OAAOA,KAAK,CAACC,OAAO,KAAK,QAAQ,IACjC,UAAU,IAAID,KAAK,IACnB,OAAOA,KAAK,CAACK,QAAQ,KAAK,QAAQ,IAClC,YAAY,IAAIL,KAAK,IACrB,OAAOA,KAAK,CAACM,UAAU,KAAK,QAAQ,CACpC;AACJ,CAAC;AAEM,SAASX,4BAA4B,CAC1CY,WAAmB,EACnBP,KAAkB,EACH;IACf,MAAMQ,oBAAoB,GAAG,CAACC,QAAgB,GAC5CA,QAAQ,CAACC,UAAU,CAAC,GAAG,CAAC,GAAGD,QAAQ,GAAGE,KAAI,EAAA,QAAA,CAACC,IAAI,CAACL,WAAW,EAAEE,QAAQ,CAAC,AAAC;IAEzE,IAAI,OAA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AA4B,CAACb,gBAAwB,EAAEC,gBAAwB,EAAE;IACxF,IAAI0B,IAAI,AAAC;IACT,IAAI;QACFA,IAAI,GAAGC,GAAE,EAAA,QAAA,CAACC,YAAY,CAAC7B,gBAAgB,EAAE,MAAM,CAAC,CAAC;IACnD,EAAE,OAAOF,KAAK,EAAO;QACnB,IAAIA,KAAK,CAACgC,IAAI,KAAK,QAAQ,IAAIhC,KAAK,CAACgC,IAAI,KAAK,QAAQ,EAAE;YACtD,8DAA8D;YAC9D,0DAA0D;YAC1D,kEAAkE;YAClE,qDAAqD;YACrD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAMhC,KAAK,CAAC;IACd,CAAC;IACD,MAAMiC,KAAK,GAAGJ,IAAI,CAACF,KAAK,CAAC,IAAI,CAAC,AAAC;IAC/B,IAAIrB,UAAU,GAAG,CAAC,AAAC;IACnB,IAAIW,MAAM,GAAG,CAAC,CAAC,AAAC;IAChB,IAAK,IAAIiB,IAAI,GAAG,CAAC,EAAEA,IAAI,GAAGD,KAAK,CAACE,MAAM,EAAED,IAAI,EAAE,CAAE;QAC9C,MAAME,cAAc,GAAGH,KAAK,CAACC,IAAI,CAAC,CAACG,WAAW,CAAClC,gBAAgB,CAAC,AAAC;QACjE,IAAIiC,cAAc,IAAI,CAAC,EAAE;YACvB9B,UAAU,GAAG4B,IAAI,CAAC;YAClBjB,MAAM,GAAGmB,cAAc,CAAC;YACxB,MAAM;QACR,CAAC;IACH,CAAC;IACD,OAAO;QAAE9B,UAAU;QAAEW,MAAM;KAAE,CAAC;AAChC,CAAC"}
@@ -162,6 +162,7 @@ async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev
162
162
  // NOTE(kitten): The public folder is currently always copied, regardless of targetDomain
163
163
  // split. Hence, there's another separate `copyPublicFolderAsync` call below for `web`
164
164
  await (0, _publicFolder.copyPublicFolderAsync)(publicPath, outputPath);
165
+ let templateHtml;
165
166
  // Can be empty during web-only SSG.
166
167
  if (spaPlatforms.length) {
167
168
  await Promise.all(spaPlatforms.map(async (platform)=>{
@@ -243,6 +244,8 @@ async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev
243
244
  if (modifyHtml) {
244
245
  html = modifyHtml(html);
245
246
  }
247
+ // HACK: This is used for adding SSR shims in React Server Components.
248
+ templateHtml = html;
246
249
  // Generate SPA-styled HTML file.
247
250
  // If web exists, then write the template HTML file.
248
251
  files.set("index.html", {
@@ -257,7 +260,8 @@ async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev
257
260
  await (0, _exportStaticAsync.exportApiRoutesStandaloneAsync)(devServer, {
258
261
  files,
259
262
  platform: "web",
260
- apiRoutesOnly: !isWeb
263
+ apiRoutesOnly: !isWeb,
264
+ templateHtml
261
265
  });
262
266
  }
263
267
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/exportApp.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport type { Platform } from '@expo/config';\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 exportDomComponentAsync,\n updateDomComponentAssetsForMD5Naming,\n} from './exportDomComponents';\nimport { assertEngineMismatchAsync, isEnableHermesManaged } from './exportHermes';\nimport { exportApiRoutesStandaloneAsync, exportFromServerAsync } from './exportStaticAsync';\nimport { getVirtualFaviconAssetsAsync } from './favicon';\nimport { getPublicExpoManifestAsync } from './getPublicExpoManifest';\nimport { copyPublicFolderAsync } from './publicFolder';\nimport { Options } from './resolveOptions';\nimport {\n ExportAssetMap,\n BundleOutput,\n getFilesFromSerialAssets,\n persistMetroFilesAsync,\n} 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 { getEntryWithServerRoot } from '../start/server/middleware/ManifestMiddleware';\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 } 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 minify,\n bytecode,\n maxWorkers,\n skipSSG,\n }: Pick<\n Options,\n | 'dumpAssetmap'\n | 'sourceMaps'\n | 'dev'\n | 'clear'\n | 'outputDir'\n | 'platforms'\n | 'minify'\n | 'bytecode'\n | 'maxWorkers'\n | 'skipSSG'\n >\n): Promise<void> {\n setNodeEnv(dev ? 'development' : 'production');\n require('@expo/env').load(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 = path.resolve(projectRoot, env.EXPO_PUBLIC_FOLDER);\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 = useServerRendering\n ? platforms.filter((platform) => platform !== 'web')\n : platforms;\n\n try {\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 // 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 // Run metro bundler and create the JS bundles/source maps.\n const bundle = await devServer.nativeExportBundleAsync(\n {\n platform,\n splitChunks:\n !env.EXPO_NO_BUNDLE_SPLITTING &&\n ((devServer.isReactServerComponentsEnabled && !bytecode) || platform === 'web'),\n mainModuleName: getEntryWithServerRoot(projectRoot, {\n platform,\n pkg: projectConfig.pkg,\n }),\n mode: dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n serializerIncludeMaps: sourceMaps,\n bytecode: bytecode && isHermes,\n reactCompiler: !!exp.experiments?.reactCompiler,\n },\n files\n );\n\n bundles[platform] = bundle;\n domComponentAssetsMetadata[platform] = [];\n\n getFilesFromSerialAssets(bundle.artifacts, {\n includeSourceMaps: sourceMaps,\n files,\n isServerHosted: devServer.isReactServerComponentsEnabled,\n });\n\n // TODO: Remove duplicates...\n const expoDomComponentReferences = bundle.artifacts\n .map((artifact) =>\n Array.isArray(artifact.metadata.expoDomComponentReferences)\n ? artifact.metadata.expoDomComponentReferences\n : []\n )\n .flat();\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 });\n\n // Merge the assets from the DOM component into the output assets.\n // @ts-expect-error: mutate assets\n bundle.assets.push(...platformDomComponentsBundle.assets);\n\n const assetsMetadata = updateDomComponentAssetsForMD5Naming({\n domComponentReference: filePath,\n nativeBundle: bundle,\n domComponentBundle: platformDomComponentsBundle,\n files,\n htmlOutputName,\n });\n domComponentAssetsMetadata[platform]?.push(...assetsMetadata);\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 // 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 if (!(isWeb && useServerRendering)) {\n await exportApiRoutesStandaloneAsync(devServer, {\n files,\n platform: 'web',\n apiRoutesOnly: !isWeb,\n });\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 });\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 {\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","minify","bytecode","maxWorkers","skipSSG","exp","setNodeEnv","require","load","projectConfig","getConfig","getPublicExpoManifestAsync","skipValidation","length","includes","WebSupportProjectPrerequisite","assertAsync","useServerRendering","web","output","CommandError","baseUrl","getBaseUrlFromExpoConfig","Log","warn","log","chalk","gray","startsWith","yellow","mode","publicPath","path","resolve","env","EXPO_PUBLIC_FOLDER","outputPath","files","Map","devServerManager","DevServerManager","startMetroAsync","port","isExporting","location","resetDevServer","devServer","getDefaultDevServer","assert","MetroBundlerDevServer","bundles","domComponentAssetsMetadata","spaPlatforms","filter","platform","copyPublicFolderAsync","Promise","all","map","isHermes","isEnableHermesManaged","assertEngineMismatchAsync","bundle","nativeExportBundleAsync","splitChunks","EXPO_NO_BUNDLE_SPLITTING","isReactServerComponentsEnabled","mainModuleName","getEntryWithServerRoot","pkg","engine","undefined","serializerIncludeMaps","reactCompiler","experiments","getFilesFromSerialAssets","artifacts","includeSourceMaps","isServerHosted","expoDomComponentReferences","artifact","Array","isArray","metadata","flat","filePath","platformDomComponentsBundle","htmlOutputName","exportDomComponentAsync","assets","push","assetsMetadata","updateDomComponentAssetsForMD5Naming","domComponentReference","nativeBundle","domComponentBundle","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":"AAAA;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A,KAAK;oBACdD,SAAS,EAAEwC,UAAU;oBACrBnC,MAAM;oBACNoB,OAAO;oBACPwD,iBAAiB,EAAE7E,UAAU;oBAC7BiI,UAAU,EAAEC,IAAAA,OAAsC,uCAAA,EAACxI,WAAW,EAAEW,GAAG,CAAC;oBACpEoE,aAAa,EAAE,CAAC,CAACpE,CAAAA,CAAAA,IAAe,GAAfA,GAAG,CAACqE,WAAW,SAAe,GAA9BrE,KAAAA,CAA8B,GAA9BA,IAAe,CAAEoE,aAAa,CAAA;oBAC/CmD,YAAY;oBACZzH,UAAU;oBACVwC,WAAW,EAAE,IAAI;oBACjBtC,GAAG,EAAEI,aAAa,CAACJ,GAAG;iBACvB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,SAAU;QACR,MAAMkC,gBAAgB,CAAC4F,SAAS,EAAE,CAAC;IACrC,CAAC;IAED,kDAAkD;IAClD,MAAMC,IAAAA,WAAsB,uBAAA,EAAC/F,KAAK,EAAED,UAAU,CAAC,CAAC;AAClD,CAAC"}
1
+ {"version":3,"sources":["../../../src/export/exportApp.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport type { Platform } from '@expo/config';\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 exportDomComponentAsync,\n updateDomComponentAssetsForMD5Naming,\n} from './exportDomComponents';\nimport { assertEngineMismatchAsync, isEnableHermesManaged } from './exportHermes';\nimport { exportApiRoutesStandaloneAsync, exportFromServerAsync } from './exportStaticAsync';\nimport { getVirtualFaviconAssetsAsync } from './favicon';\nimport { getPublicExpoManifestAsync } from './getPublicExpoManifest';\nimport { copyPublicFolderAsync } from './publicFolder';\nimport { Options } from './resolveOptions';\nimport {\n ExportAssetMap,\n BundleOutput,\n getFilesFromSerialAssets,\n persistMetroFilesAsync,\n} 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 { getEntryWithServerRoot } from '../start/server/middleware/ManifestMiddleware';\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 } 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 minify,\n bytecode,\n maxWorkers,\n skipSSG,\n }: Pick<\n Options,\n | 'dumpAssetmap'\n | 'sourceMaps'\n | 'dev'\n | 'clear'\n | 'outputDir'\n | 'platforms'\n | 'minify'\n | 'bytecode'\n | 'maxWorkers'\n | 'skipSSG'\n >\n): Promise<void> {\n setNodeEnv(dev ? 'development' : 'production');\n require('@expo/env').load(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 = path.resolve(projectRoot, env.EXPO_PUBLIC_FOLDER);\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 = useServerRendering\n ? platforms.filter((platform) => platform !== 'web')\n : platforms;\n\n try {\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 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 // Run metro bundler and create the JS bundles/source maps.\n const bundle = await devServer.nativeExportBundleAsync(\n {\n platform,\n splitChunks:\n !env.EXPO_NO_BUNDLE_SPLITTING &&\n ((devServer.isReactServerComponentsEnabled && !bytecode) || platform === 'web'),\n mainModuleName: getEntryWithServerRoot(projectRoot, {\n platform,\n pkg: projectConfig.pkg,\n }),\n mode: dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n serializerIncludeMaps: sourceMaps,\n bytecode: bytecode && isHermes,\n reactCompiler: !!exp.experiments?.reactCompiler,\n },\n files\n );\n\n bundles[platform] = bundle;\n domComponentAssetsMetadata[platform] = [];\n\n getFilesFromSerialAssets(bundle.artifacts, {\n includeSourceMaps: sourceMaps,\n files,\n isServerHosted: devServer.isReactServerComponentsEnabled,\n });\n\n // TODO: Remove duplicates...\n const expoDomComponentReferences = bundle.artifacts\n .map((artifact) =>\n Array.isArray(artifact.metadata.expoDomComponentReferences)\n ? artifact.metadata.expoDomComponentReferences\n : []\n )\n .flat();\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 });\n\n // Merge the assets from the DOM component into the output assets.\n // @ts-expect-error: mutate assets\n bundle.assets.push(...platformDomComponentsBundle.assets);\n\n const assetsMetadata = updateDomComponentAssetsForMD5Naming({\n domComponentReference: filePath,\n nativeBundle: bundle,\n domComponentBundle: platformDomComponentsBundle,\n files,\n htmlOutputName,\n });\n domComponentAssetsMetadata[platform]?.push(...assetsMetadata);\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 if (!(isWeb && useServerRendering)) {\n await exportApiRoutesStandaloneAsync(devServer, {\n files,\n platform: 'web',\n apiRoutesOnly: !isWeb,\n templateHtml,\n });\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 });\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 {\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","minify","bytecode","maxWorkers","skipSSG","exp","setNodeEnv","require","load","projectConfig","getConfig","getPublicExpoManifestAsync","skipValidation","length","includes","WebSupportProjectPrerequisite","assertAsync","useServerRendering","web","output","CommandError","baseUrl","getBaseUrlFromExpoConfig","Log","warn","log","chalk","gray","startsWith","yellow","mode","publicPath","path","resolve","env","EXPO_PUBLIC_FOLDER","outputPath","files","Map","devServerManager","DevServerManager","startMetroAsync","port","isExporting","location","resetDevServer","devServer","getDefaultDevServer","assert","MetroBundlerDevServer","bundles","domComponentAssetsMetadata","spaPlatforms","filter","platform","copyPublicFolderAsync","templateHtml","Promise","all","map","isHermes","isEnableHermesManaged","assertEngineMismatchAsync","bundle","nativeExportBundleAsync","splitChunks","EXPO_NO_BUNDLE_SPLITTING","isReactServerComponentsEnabled","mainModuleName","getEntryWithServerRoot","pkg","engine","undefined","serializerIncludeMaps","reactCompiler","experiments","getFilesFromSerialAssets","artifacts","includeSourceMaps","isServerHosted","expoDomComponentReferences","artifact","Array","isArray","metadata","flat","filePath","platformDomComponentsBundle","htmlOutputName","exportDomComponentAsync","assets","push","assetsMetadata","updateDomComponentAssetsForMD5Naming","domComponentReference","nativeBundle","domComponentBundle","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":"AAAA;;;;+BAuCsBA,gBAAc;;aAAdA,cAAc;;;yBAvCV,cAAc;;;;;;;8DAErB,QAAQ;;;;;;;8DACT,OAAO;;;;;;;8DACV,IAAI;;;;;;;8DACF,MAAM;;;;;;oCAEmC,sBAAsB;8BAC9C,gBAAgB;qCAI3C,uBAAuB;8BACmC,gBAAgB;mCACX,qBAAqB;yBAC9C,WAAW;uCACb,yBAAyB;8BAC9B,gBAAgB;4BAO/C,cAAc;+BACU,iBAAiB;2DAC3B,QAAQ;+CACiB,mDAAmD;kCAChE,kCAAkC;uCAC7B,6CAA6C;wBAC5B,8BAA8B;+BAC7C,qCAAqC;oCACtC,+CAA+C;8BAC7C,yCAAyC;6BAC5B,6BAA6B;qBAC/D,cAAc;wBACL,iBAAiB;yBACnB,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtC,eAAeA,cAAc,CAClCC,WAAmB,EACnB,EACEC,SAAS,CAAA,EACTC,SAAS,CAAA,EACTC,KAAK,CAAA,EACLC,GAAG,CAAA,EACHC,YAAY,CAAA,EACZC,UAAU,CAAA,EACVC,MAAM,CAAA,EACNC,QAAQ,CAAA,EACRC,UAAU,CAAA,EACVC,OAAO,CAAA,EAaR,EACc;QAc0CC,GAAO,EAEjDA,IAAO;IAftBC,IAAAA,QAAU,WAAA,EAACR,GAAG,GAAG,aAAa,GAAG,YAAY,CAAC,CAAC;IAC/CS,OAAO,CAAC,WAAW,CAAC,CAACC,IAAI,CAACd,WAAW,CAAC,CAAC;IAEvC,MAAMe,aAAa,GAAGC,IAAAA,OAAS,EAAA,UAAA,EAAChB,WAAW,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C,EAAE;oBACpCzF,KAAK,CAACqE,GAAG,CAAC,YAAY,EAAE;wBACtBC,QAAQ,EAAE,CAAC,0BAA0B,CAAC;wBACtCC,YAAY,EAAE,QAAQ;qBACvB,CAAC,CAAC;gBACL,CAAC;YACH,OAAO;oBAUcvG,IAAe;gBATlC,MAAM4H,IAAAA,kBAAqB,sBAAA,EAACvI,WAAW,EAAEoD,SAAS,EAAE;oBAClDhB,IAAI;oBACJO,KAAK;oBACLxC,KAAK,EAAE,CAAC,CAACA,KAAK;oBACdD,SAAS,EAAEwC,UAAU;oBACrBnC,MAAM;oBACNoB,OAAO;oBACPyD,iBAAiB,EAAE9E,UAAU;oBAC7BkI,UAAU,EAAEC,IAAAA,OAAsC,uCAAA,EAACzI,WAAW,EAAEW,GAAG,CAAC;oBACpEqE,aAAa,EAAE,CAAC,CAACrE,CAAAA,CAAAA,IAAe,GAAfA,GAAG,CAACsE,WAAW,SAAe,GAA9BtE,KAAAA,CAA8B,GAA9BA,IAAe,CAAEqE,aAAa,CAAA;oBAC/CmD,YAAY;oBACZ1H,UAAU;oBACVwC,WAAW,EAAE,IAAI;oBACjBtC,GAAG,EAAEI,aAAa,CAACJ,GAAG;iBACvB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,SAAU;QACR,MAAMkC,gBAAgB,CAAC6F,SAAS,EAAE,CAAC;IACrC,CAAC;IAED,kDAAkD;IAClD,MAAMC,IAAAA,WAAsB,uBAAA,EAAChG,KAAK,EAAED,UAAU,CAAC,CAAC;AAClD,CAAC"}
@@ -331,8 +331,8 @@ function getPathVariations(routePath) {
331
331
  generateVariations(segments);
332
332
  return Array.from(variations);
333
333
  }
334
- async function exportApiRoutesStandaloneAsync(devServer, { files =new Map() , platform , apiRoutesOnly }) {
335
- const { serverManifest } = await devServer.getServerManifestAsync();
334
+ async function exportApiRoutesStandaloneAsync(devServer, { files =new Map() , platform , apiRoutesOnly , templateHtml }) {
335
+ const { serverManifest , htmlManifest } = await devServer.getServerManifestAsync();
336
336
  const apiRoutes = await exportApiRoutesAsync({
337
337
  server: devServer,
338
338
  manifest: serverManifest,
@@ -345,6 +345,22 @@ async function exportApiRoutesStandaloneAsync(devServer, { files =new Map() , pl
345
345
  for (const [route, contents] of apiRoutes){
346
346
  files.set(route, contents);
347
347
  }
348
+ if (templateHtml && devServer.isReactServerComponentsEnabled) {
349
+ // TODO: Export an HTML entry for each file. This is a temporary solution until we have SSR/SSG for RSC.
350
+ await getFilesToExportFromServerAsync(devServer.projectRoot, {
351
+ manifest: htmlManifest,
352
+ exportServer: true,
353
+ files,
354
+ renderAsync: async ({ pathname , filePath })=>{
355
+ files.set(filePath, {
356
+ contents: templateHtml,
357
+ routeId: pathname,
358
+ targetDomain: "server"
359
+ });
360
+ return templateHtml;
361
+ }
362
+ });
363
+ }
348
364
  return files;
349
365
  }
350
366
  async function exportApiRoutesAsync({ includeSourceMaps , server , platform , apiRoutesOnly , ...props }) {
@@ -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 { ExpoConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport { RouteNode } from 'expo-router/build/Route';\nimport { stripGroupSegmentsFromPath } from 'expo-router/build/matchers';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport { inspect } from 'util';\n\nimport { getVirtualFaviconAssetsAsync } from './favicon';\nimport { persistMetroAssetsAsync } from './persistMetroAssets';\nimport { ExportAssetMap, getFilesFromSerialAssets } from './saveAssets';\nimport { Log } from '../log';\nimport {\n ExpoRouterRuntimeManifest,\n MetroBundlerDevServer,\n} from '../start/server/metro/MetroBundlerDevServer';\nimport { ExpoRouterServerManifestV1 } from '../start/server/metro/fetchRouterManifest';\nimport { logMetroErrorAsync } from '../start/server/metro/metroErrorInterface';\nimport { getApiRoutesForDirectory } from '../start/server/metro/router';\nimport { serializeHtmlWithAssets } from '../start/server/metro/serializeHtml';\nimport { learnMore } from '../utils/link';\n\nconst debug = require('debug')('expo:export:generateStaticRoutes') as typeof console.log;\n\ntype Options = {\n mode: 'production' | 'development';\n files?: ExportAssetMap;\n outputDir: string;\n minify: boolean;\n exportServer: boolean;\n baseUrl: string;\n includeSourceMaps: boolean;\n entryPoint?: string;\n clear: boolean;\n routerRoot: string;\n reactCompiler: boolean;\n maxWorkers?: number;\n isExporting: boolean;\n exp?: ExpoConfig;\n};\n\ntype HtmlRequestLocation = {\n /** The output file path name to use relative to the static folder. */\n filePath: string;\n /** The pathname to make requests to in order to fetch the HTML. */\n pathname: string;\n /** The runtime route node object, used to associate async modules with the static HTML. */\n route: RouteNode;\n};\n\n/** Match `(page)` -> `page` */\nfunction matchGroupName(name: string): string | undefined {\n return name.match(/^\\(([^/]+?)\\)$/)?.[1];\n}\n\nexport async function getFilesToExportFromServerAsync(\n projectRoot: string,\n {\n manifest,\n renderAsync,\n // Servers can handle group routes automatically and therefore\n // don't require the build-time generation of every possible group\n // variation.\n exportServer,\n // name : contents\n files = new Map(),\n }: {\n manifest: ExpoRouterRuntimeManifest;\n renderAsync: (requestLocation: HtmlRequestLocation) => Promise<string>;\n exportServer?: boolean;\n files?: ExportAssetMap;\n }\n): Promise<ExportAssetMap> {\n await Promise.all(\n getHtmlFiles({ manifest, includeGroupVariations: !exportServer }).map(\n async ({ route, filePath, pathname }) => {\n try {\n const targetDomain = exportServer ? 'server' : 'client';\n files.set(filePath, { contents: '', targetDomain });\n const data = await renderAsync({ route, filePath, pathname });\n files.set(filePath, {\n contents: data,\n routeId: pathname,\n targetDomain,\n });\n } catch (e: any) {\n await logMetroErrorAsync({ error: e, projectRoot });\n throw new Error('Failed to statically export route: ' + pathname);\n }\n }\n )\n );\n\n return files;\n}\n\nfunction modifyRouteNodeInRuntimeManifest(\n manifest: ExpoRouterRuntimeManifest,\n callback: (route: RouteNode) => any\n) {\n const iterateScreens = (screens: ExpoRouterRuntimeManifest['screens']) => {\n Object.values(screens).map((value) => {\n if (typeof value !== 'string') {\n if (value._route) callback(value._route);\n iterateScreens(value.screens);\n }\n });\n };\n\n iterateScreens(manifest.screens);\n}\n\n// TODO: Do this earlier in the process.\nfunction makeRuntimeEntryPointsAbsolute(manifest: ExpoRouterRuntimeManifest, appDir: string) {\n modifyRouteNodeInRuntimeManifest(manifest, (route) => {\n if (Array.isArray(route.entryPoints)) {\n route.entryPoints = route.entryPoints.map((entryPoint) => {\n if (entryPoint.startsWith('.')) {\n return path.resolve(appDir, entryPoint);\n } else if (!path.isAbsolute(entryPoint)) {\n return resolveFrom(appDir, entryPoint);\n }\n return entryPoint;\n });\n }\n });\n}\n\n/** Perform all fs commits */\nexport async function exportFromServerAsync(\n projectRoot: string,\n devServer: MetroBundlerDevServer,\n {\n outputDir,\n baseUrl,\n exportServer,\n includeSourceMaps,\n routerRoot,\n files = new Map(),\n exp,\n }: Options\n): Promise<ExportAssetMap> {\n Log.log(\n `Static rendering is enabled. ` +\n learnMore('https://docs.expo.dev/router/reference/static-rendering/')\n );\n\n const platform = 'web';\n const isExporting = true;\n const appDir = path.join(projectRoot, routerRoot);\n const injectFaviconTag = await getVirtualFaviconAssetsAsync(projectRoot, {\n outputDir,\n baseUrl,\n files,\n exp,\n });\n\n const [resources, { manifest, serverManifest, renderAsync }] = await Promise.all([\n devServer.getStaticResourcesAsync({\n includeSourceMaps,\n }),\n devServer.getStaticRenderFunctionAsync(),\n ]);\n\n makeRuntimeEntryPointsAbsolute(manifest, appDir);\n\n debug('Routes:\\n', inspect(manifest, { colors: true, depth: null }));\n\n await getFilesToExportFromServerAsync(projectRoot, {\n files,\n manifest,\n exportServer,\n async renderAsync({ pathname, route }) {\n const template = await renderAsync(pathname);\n let html = await serializeHtmlWithAssets({\n isExporting,\n resources: resources.artifacts,\n template,\n baseUrl,\n route,\n hydrate: true,\n });\n\n if (injectFaviconTag) {\n html = injectFaviconTag(html);\n }\n\n return html;\n },\n });\n\n getFilesFromSerialAssets(resources.artifacts, {\n platform,\n includeSourceMaps,\n files,\n 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 } 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 (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 const newPath = baseUrl + value.path + '/';\n traverseScreens(value.screens, value._route ?? null, newPath);\n }\n }\n }\n\n function addOptionalGroups(path: string, route: RouteNode) {\n const variations = getPathVariations(path);\n for (const variation of variations) {\n htmlFiles.add({ filePath: variation, route });\n }\n }\n\n traverseScreens(manifest.screens, null);\n\n return uniqueBy(Array.from(htmlFiles), (value) => value.filePath).map((value) => {\n const parts = value.filePath.split('/');\n // Replace `:foo` with `[foo]` and `*foo` with `[...foo]`\n const partsWithGroups = parts.map((part) => {\n if (part === '*not-found') {\n return `+not-found`;\n } else if (part.startsWith(':')) {\n return `[${part.slice(1)}]`;\n } else if (part.startsWith('*')) {\n return `[...${part.slice(1)}]`;\n }\n return part;\n });\n const filePathLocation = partsWithGroups.join('/');\n const filePath = filePathLocation + '.html';\n return {\n ...value,\n filePath,\n pathname: filePathLocation.replace(/(\\/?index)?$/, ''),\n };\n });\n}\n\nfunction uniqueBy<T>(array: T[], key: (value: T) => string): T[] {\n const seen = new Set<string>();\n const result: T[] = [];\n for (const value of array) {\n const id = key(value);\n if (!seen.has(id)) {\n seen.add(id);\n result.push(value);\n }\n }\n return result;\n}\n\n// Given a route like `(foo)/bar/(baz)`, return all possible variations of the route.\n// e.g. `(foo)/bar/(baz)`, `(foo)/bar/baz`, `foo/bar/(baz)`, `foo/bar/baz`,\nexport function getPathVariations(routePath: string): string[] {\n const variations = new Set<string>();\n const segments = routePath.split('/');\n\n function generateVariations(segments: string[], current = ''): void {\n if (segments.length === 0) {\n if (current) variations.add(current);\n return;\n }\n\n const [head, ...rest] = segments;\n\n if (matchGroupName(head)) {\n const groups = head.slice(1, -1).split(',');\n\n if (groups.length > 1) {\n for (const group of groups) {\n // If there are multiple groups, recurse on each group.\n generateVariations([`(${group.trim()})`, ...rest], current);\n }\n return;\n } else {\n // Start a fork where this group is included\n generateVariations(rest, current ? `${current}/(${groups[0]})` : `(${groups[0]})`);\n // This code will continue and add paths without this group included`\n }\n } else if (current) {\n current = `${current}/${head}`;\n } else {\n current = head;\n }\n\n generateVariations(rest, current);\n }\n\n generateVariations(segments);\n\n return Array.from(variations);\n}\n\nexport async function exportApiRoutesStandaloneAsync(\n devServer: MetroBundlerDevServer,\n {\n files = new Map(),\n platform,\n apiRoutesOnly,\n }: {\n files?: ExportAssetMap;\n platform: string;\n apiRoutesOnly: boolean;\n }\n) {\n const { serverManifest } = 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 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: ExpoRouterServerManifestV1;\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"],"names":["getFilesToExportFromServerAsync","exportFromServerAsync","getHtmlFiles","getPathVariations","exportApiRoutesStandaloneAsync","debug","require","matchGroupName","name","match","projectRoot","manifest","renderAsync","exportServer","files","Map","Promise","all","includeGroupVariations","map","route","filePath","pathname","targetDomain","set","contents","data","routeId","e","logMetroErrorAsync","error","Error","modifyRouteNodeInRuntimeManifest","callback","iterateScreens","screens","Object","values","value","_route","makeRuntimeEntryPointsAbsolute","appDir","Array","isArray","entryPoints","entryPoint","startsWith","path","resolve","isAbsolute","resolveFrom","devServer","outputDir","baseUrl","includeSourceMaps","routerRoot","exp","Log","log","learnMore","platform","isExporting","join","injectFaviconTag","getVirtualFaviconAssetsAsync","resources","serverManifest","getStaticResourcesAsync","getStaticRenderFunctionAsync","inspect","colors","depth","template","html","serializeHtmlWithAssets","artifacts","hydrate","getFilesFromSerialAssets","isServerHosted","assets","persistMetroAssetsAsync","outputDirectory","apiRoutes","exportApiRoutesAsync","server","warnPossibleInvalidExportType","htmlFiles","Set","traverseScreens","key","entries","leaf","keys","length","endsWith","slice","stripGroupSegmentsFromPath","addOptionalGroups","add","newPath","variations","variation","uniqueBy","from","parts","split","partsWithGroups","part","filePathLocation","replace","array","seen","result","id","has","push","routePath","segments","generateVariations","current","head","rest","groups","group","trim","apiRoutesOnly","getServerManifestAsync","props","exportExpoRouterApiRoutesAsync","prerenderManifest","htmlRoutes","notFoundRoutes","JSON","stringify","getApiRoutesForDirectory","warn","chalk","yellow","v","relative"],"mappings":"AAAA;;;;;CAKC,GACD;;;;;;;;;;;IAuDsBA,+BAA+B,MAA/BA,+BAA+B;IA0E/BC,qBAAqB,MAArBA,qBAAqB;IAoG3BC,YAAY,MAAZA,YAAY;IAoHZC,iBAAiB,MAAjBA,iBAAiB;IAwCXC,8BAA8B,MAA9BA,8BAA8B;;;8DAhYlC,OAAO;;;;;;;yBAEkB,4BAA4B;;;;;;;8DACtD,MAAM;;;;;;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I,CACNC,MAAK,EAAA,QAAA,CAACC,MAAM,CAAC,0GAA0G,EAAEvD,SAAS,CAC/H/D,GAAG,CAAC,CAACuH,CAAC,GAAK3F,KAAI,EAAA,QAAA,CAAC4F,QAAQ,CAAClG,MAAM,EAAEiG,CAAC,CAAC,CAAC,CACpC5E,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAChB,CAAC;IACJ,CAAC;AACH,CAAC"}
1
+ {"version":3,"sources":["../../../src/export/exportStaticAsync.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { ExpoConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport { RouteNode } from 'expo-router/build/Route';\nimport { stripGroupSegmentsFromPath } from 'expo-router/build/matchers';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport { inspect } from 'util';\n\nimport { getVirtualFaviconAssetsAsync } from './favicon';\nimport { persistMetroAssetsAsync } from './persistMetroAssets';\nimport { ExportAssetMap, getFilesFromSerialAssets } from './saveAssets';\nimport { Log } from '../log';\nimport {\n ExpoRouterRuntimeManifest,\n MetroBundlerDevServer,\n} from '../start/server/metro/MetroBundlerDevServer';\nimport { ExpoRouterServerManifestV1 } from '../start/server/metro/fetchRouterManifest';\nimport { logMetroErrorAsync } from '../start/server/metro/metroErrorInterface';\nimport { getApiRoutesForDirectory } from '../start/server/metro/router';\nimport { serializeHtmlWithAssets } from '../start/server/metro/serializeHtml';\nimport { learnMore } from '../utils/link';\n\nconst debug = require('debug')('expo:export:generateStaticRoutes') as typeof console.log;\n\ntype Options = {\n mode: 'production' | 'development';\n files?: ExportAssetMap;\n outputDir: string;\n minify: boolean;\n exportServer: boolean;\n baseUrl: string;\n includeSourceMaps: boolean;\n entryPoint?: string;\n clear: boolean;\n routerRoot: string;\n reactCompiler: boolean;\n maxWorkers?: number;\n isExporting: boolean;\n exp?: ExpoConfig;\n};\n\ntype HtmlRequestLocation = {\n /** The output file path name to use relative to the static folder. */\n filePath: string;\n /** The pathname to make requests to in order to fetch the HTML. */\n pathname: string;\n /** The runtime route node object, used to associate async modules with the static HTML. */\n route: RouteNode;\n};\n\n/** Match `(page)` -> `page` */\nfunction matchGroupName(name: string): string | undefined {\n return name.match(/^\\(([^/]+?)\\)$/)?.[1];\n}\n\nexport async function getFilesToExportFromServerAsync(\n projectRoot: string,\n {\n manifest,\n renderAsync,\n // Servers can handle group routes automatically and therefore\n // don't require the build-time generation of every possible group\n // variation.\n exportServer,\n // name : contents\n files = new Map(),\n }: {\n manifest: ExpoRouterRuntimeManifest;\n renderAsync: (requestLocation: HtmlRequestLocation) => Promise<string>;\n exportServer?: boolean;\n files?: ExportAssetMap;\n }\n): Promise<ExportAssetMap> {\n await Promise.all(\n getHtmlFiles({ manifest, includeGroupVariations: !exportServer }).map(\n async ({ route, filePath, pathname }) => {\n try {\n const targetDomain = exportServer ? 'server' : 'client';\n files.set(filePath, { contents: '', targetDomain });\n const data = await renderAsync({ route, filePath, pathname });\n files.set(filePath, {\n contents: data,\n routeId: pathname,\n targetDomain,\n });\n } catch (e: any) {\n await logMetroErrorAsync({ error: e, projectRoot });\n throw new Error('Failed to statically export route: ' + pathname);\n }\n }\n )\n );\n\n return files;\n}\n\nfunction modifyRouteNodeInRuntimeManifest(\n manifest: ExpoRouterRuntimeManifest,\n callback: (route: RouteNode) => any\n) {\n const iterateScreens = (screens: ExpoRouterRuntimeManifest['screens']) => {\n Object.values(screens).map((value) => {\n if (typeof value !== 'string') {\n if (value._route) callback(value._route);\n iterateScreens(value.screens);\n }\n });\n };\n\n iterateScreens(manifest.screens);\n}\n\n// TODO: Do this earlier in the process.\nfunction makeRuntimeEntryPointsAbsolute(manifest: ExpoRouterRuntimeManifest, appDir: string) {\n modifyRouteNodeInRuntimeManifest(manifest, (route) => {\n if (Array.isArray(route.entryPoints)) {\n route.entryPoints = route.entryPoints.map((entryPoint) => {\n if (entryPoint.startsWith('.')) {\n return path.resolve(appDir, entryPoint);\n } else if (!path.isAbsolute(entryPoint)) {\n return resolveFrom(appDir, entryPoint);\n }\n return entryPoint;\n });\n }\n });\n}\n\n/** Perform all fs commits */\nexport async function exportFromServerAsync(\n projectRoot: string,\n devServer: MetroBundlerDevServer,\n {\n outputDir,\n baseUrl,\n exportServer,\n includeSourceMaps,\n routerRoot,\n files = new Map(),\n exp,\n }: Options\n): Promise<ExportAssetMap> {\n Log.log(\n `Static rendering is enabled. ` +\n learnMore('https://docs.expo.dev/router/reference/static-rendering/')\n );\n\n const platform = 'web';\n const isExporting = true;\n const appDir = path.join(projectRoot, routerRoot);\n const injectFaviconTag = await getVirtualFaviconAssetsAsync(projectRoot, {\n outputDir,\n baseUrl,\n files,\n exp,\n });\n\n const [resources, { manifest, serverManifest, renderAsync }] = await Promise.all([\n devServer.getStaticResourcesAsync({\n includeSourceMaps,\n }),\n devServer.getStaticRenderFunctionAsync(),\n ]);\n\n makeRuntimeEntryPointsAbsolute(manifest, appDir);\n\n debug('Routes:\\n', inspect(manifest, { colors: true, depth: null }));\n\n await getFilesToExportFromServerAsync(projectRoot, {\n files,\n manifest,\n exportServer,\n async renderAsync({ pathname, route }) {\n const template = await renderAsync(pathname);\n let html = await serializeHtmlWithAssets({\n isExporting,\n resources: resources.artifacts,\n template,\n baseUrl,\n route,\n hydrate: true,\n });\n\n if (injectFaviconTag) {\n html = injectFaviconTag(html);\n }\n\n return html;\n },\n });\n\n getFilesFromSerialAssets(resources.artifacts, {\n platform,\n includeSourceMaps,\n files,\n 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 } 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 (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 const newPath = baseUrl + value.path + '/';\n traverseScreens(value.screens, value._route ?? null, newPath);\n }\n }\n }\n\n function addOptionalGroups(path: string, route: RouteNode) {\n const variations = getPathVariations(path);\n for (const variation of variations) {\n htmlFiles.add({ filePath: variation, route });\n }\n }\n\n traverseScreens(manifest.screens, null);\n\n return uniqueBy(Array.from(htmlFiles), (value) => value.filePath).map((value) => {\n const parts = value.filePath.split('/');\n // Replace `:foo` with `[foo]` and `*foo` with `[...foo]`\n const partsWithGroups = parts.map((part) => {\n if (part === '*not-found') {\n return `+not-found`;\n } else if (part.startsWith(':')) {\n return `[${part.slice(1)}]`;\n } else if (part.startsWith('*')) {\n return `[...${part.slice(1)}]`;\n }\n return part;\n });\n const filePathLocation = partsWithGroups.join('/');\n const filePath = filePathLocation + '.html';\n return {\n ...value,\n filePath,\n pathname: filePathLocation.replace(/(\\/?index)?$/, ''),\n };\n });\n}\n\nfunction uniqueBy<T>(array: T[], key: (value: T) => string): T[] {\n const seen = new Set<string>();\n const result: T[] = [];\n for (const value of array) {\n const id = key(value);\n if (!seen.has(id)) {\n seen.add(id);\n result.push(value);\n }\n }\n return result;\n}\n\n// Given a route like `(foo)/bar/(baz)`, return all possible variations of the route.\n// e.g. `(foo)/bar/(baz)`, `(foo)/bar/baz`, `foo/bar/(baz)`, `foo/bar/baz`,\nexport function getPathVariations(routePath: string): string[] {\n const variations = new Set<string>();\n const segments = routePath.split('/');\n\n function generateVariations(segments: string[], current = ''): void {\n if (segments.length === 0) {\n if (current) variations.add(current);\n return;\n }\n\n const [head, ...rest] = segments;\n\n if (matchGroupName(head)) {\n const groups = head.slice(1, -1).split(',');\n\n if (groups.length > 1) {\n for (const group of groups) {\n // If there are multiple groups, recurse on each group.\n generateVariations([`(${group.trim()})`, ...rest], current);\n }\n return;\n } else {\n // Start a fork where this group is included\n generateVariations(rest, current ? `${current}/(${groups[0]})` : `(${groups[0]})`);\n // This code will continue and add paths without this group included`\n }\n } else if (current) {\n current = `${current}/${head}`;\n } else {\n current = head;\n }\n\n generateVariations(rest, current);\n }\n\n generateVariations(segments);\n\n return Array.from(variations);\n}\n\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 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: ExpoRouterServerManifestV1;\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"],"names":["getFilesToExportFromServerAsync","exportFromServerAsync","getHtmlFiles","getPathVariations","exportApiRoutesStandaloneAsync","debug","require","matchGroupName","name","match","projectRoot","manifest","renderAsync","exportServer","files","Map","Promise","all","includeGroupVariations","map","route","filePath","pathname","targetDomain","set","contents","data","routeId","e","logMetroErrorAsync","error","Error","modifyRouteNodeInRuntimeManifest","callback","iterateScreens","screens","Object","values","value","_route","makeRuntimeEntryPointsAbsolute","appDir","Array","isArray","entryPoints","entryPoint","startsWith","path","resolve","isAbsolute","resolveFrom","devServer","outputDir","baseUrl","includeSourceMaps","routerRoot","exp","Log","log","learnMore","platform","isExporting","join","injectFaviconTag","getVirtualFaviconAssetsAsync","resources","serverManifest","getStaticResourcesAsync","getStaticRenderFunctionAsync","inspect","colors","depth","template","html","serializeHtmlWithAssets","artifacts","hydrate","getFilesFromSerialAssets","isServerHosted","assets","persistMetroAssetsAsync","outputDirectory","apiRoutes","exportApiRoutesAsync","server","warnPossibleInvalidExportType","htmlFiles","Set","traverseScreens","key","entries","leaf","keys","length","endsWith","slice","stripGroupSegmentsFromPath","addOptionalGroups","add","newPath","variations","variation","uniqueBy","from","parts","split","partsWithGroups","part","filePathLocation","replace","array","seen","result","id","has","push","routePath","segments","generateVariations","current","head","rest","groups","group","trim","apiRoutesOnly","templateHtml","htmlManifest","getServerManifestAsync","isReactServerComponentsEnabled","props","exportExpoRouterApiRoutesAsync","prerenderManifest","htmlRoutes","notFoundRoutes","JSON","stringify","getApiRoutesForDirectory","warn","chalk","yellow","v","relative"],"mappings":"AAAA;;;;;CAKC,GACD;;;;;;;;;;;IAuDsBA,+BAA+B,MAA/BA,+BAA+B;IA0E/BC,qBAAqB,MAArBA,qBAAqB;IAoG3BC,YAAY,MAAZA,YAAY;IAoHZC,iBAAiB,MAAjBA,iBAAiB;IAwCXC,8BAA8B,MAA9BA,8BAA8B;;;8DAhYlC,OAAO;;;;;;;yBAEkB,4BAA4B;;;;;;;8DACtD,MAAM;;;;;;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AAE;QACjBlH,QAAQ,CAAC0H,UAAU,GAAG,EAAE,CAAC;QACzB1H,QAAQ,CAAC2H,cAAc,GAAG,EAAE,CAAC;IAC/B,CAAC;IAEDxH,KAAK,CAACU,GAAG,CAAC,mBAAmB,EAAE;QAC7BC,QAAQ,EAAE8G,IAAI,CAACC,SAAS,CAAC7H,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3CY,YAAY,EAAE,QAAQ;KACvB,CAAC,CAAC;IAEH,OAAOT,KAAK,CAAC;AACf,CAAC;AAED,SAASuE,6BAA6B,CAAC5C,MAAc,EAAE;IACrD,MAAMyC,SAAS,GAAGuD,IAAAA,OAAwB,yBAAA,EAAChG,MAAM,CAAC,AAAC;IACnD,IAAIyC,SAAS,CAACW,MAAM,EAAE;QACpB,0CAA0C;QAC1CpC,IAAG,IAAA,CAACiF,IAAI,CACNC,MAAK,EAAA,QAAA,CAACC,MAAM,CAAC,0GAA0G,EAAE1D,SAAS,CAC/H/D,GAAG,CAAC,CAAC0H,CAAC,GAAK9F,KAAI,EAAA,QAAA,CAAC+F,QAAQ,CAACrG,MAAM,EAAEoG,CAAC,CAAC,CAAC,CACpC/E,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAChB,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -51,6 +51,7 @@ function _send() {
51
51
  const _log = /*#__PURE__*/ _interopRequireWildcard(require("../log"));
52
52
  const _dir = require("../utils/dir");
53
53
  const _errors = require("../utils/errors");
54
+ const _findUp = require("../utils/findUp");
54
55
  const _nodeEnv = require("../utils/nodeEnv");
55
56
  const _port = require("../utils/port");
56
57
  function _interopRequireDefault(obj) {
@@ -98,7 +99,8 @@ function _interopRequireWildcard(obj, nodeInterop) {
98
99
  return newObj;
99
100
  }
100
101
  const debug = require("debug")("expo:serve");
101
- async function serveAsync(projectRoot, options) {
102
+ async function serveAsync(inputDir, options) {
103
+ const projectRoot = (0, _findUp.findUpProjectRootOrAssert)(inputDir);
102
104
  (0, _nodeEnv.setNodeEnv)("production");
103
105
  require("@expo/env").load(projectRoot);
104
106
  const port = await (0, _port.resolvePortAsync)(projectRoot, {
@@ -109,7 +111,7 @@ async function serveAsync(projectRoot, options) {
109
111
  throw new _errors.CommandError("Could not start server. Port is not available.");
110
112
  }
111
113
  options.port = port;
112
- const serverDist = options.isDefaultDirectory ? _path().default.join(projectRoot, "dist") : projectRoot;
114
+ const serverDist = options.isDefaultDirectory ? _path().default.join(inputDir, "dist") : inputDir;
113
115
  // TODO: `.expo/server/ios`, `.expo/server/android`, etc.
114
116
  if (!await (0, _dir.directoryExistsAsync)(serverDist)) {
115
117
  throw new _errors.CommandError(`The server directory ${serverDist} does not exist. Run \`npx expo export\` first.`);