@expo/cli 0.22.9 → 0.22.10

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 (42) 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 +27 -12
  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/export/publicFolder.js +6 -1
  11. package/build/src/export/publicFolder.js.map +1 -1
  12. package/build/src/export/saveAssets.js +1 -1
  13. package/build/src/export/saveAssets.js.map +1 -1
  14. package/build/src/install/installAsync.js +1 -1
  15. package/build/src/install/installAsync.js.map +1 -1
  16. package/build/src/serve/serveAsync.js +4 -2
  17. package/build/src/serve/serveAsync.js.map +1 -1
  18. package/build/src/start/doctor/dependencies/getVersionedPackages.js +4 -0
  19. package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
  20. package/build/src/start/server/getStaticRenderFunctions.js +2 -1
  21. package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
  22. package/build/src/start/server/metro/MetroBundlerDevServer.js +105 -55
  23. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  24. package/build/src/start/server/metro/createJResolver.js +15 -5
  25. package/build/src/start/server/metro/createJResolver.js.map +1 -1
  26. package/build/src/start/server/metro/createServerComponentsMiddleware.js +28 -4
  27. package/build/src/start/server/metro/createServerComponentsMiddleware.js.map +1 -1
  28. package/build/src/start/server/metro/metroErrorInterface.js +5 -1
  29. package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
  30. package/build/src/start/server/metro/withMetroMultiPlatform.js +2 -1
  31. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  32. package/build/src/start/server/middleware/ManifestMiddleware.js +6 -3
  33. package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
  34. package/build/src/start/server/middleware/metroOptions.js +1 -1
  35. package/build/src/start/server/middleware/metroOptions.js.map +1 -1
  36. package/build/src/start/startAsync.js +1 -1
  37. package/build/src/start/startAsync.js.map +1 -1
  38. package/build/src/utils/env.js +6 -0
  39. package/build/src/utils/env.js.map +1 -1
  40. package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
  41. package/build/src/utils/telemetry/utils/context.js +1 -1
  42. package/package.json +4 -4
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.22.10");
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;;;yBAhCgB,cAAc;;;;;;;8DACxD,mBAAmB;;;;;;;8DACxB,OAAO;;;;;;;8DACV,IAAI;;;;;;;yBACM,oBAAoB;;;;;;;8DAC5B,MAAM;;;;;;0BAEQ,oBAAoB;qBAC/B,WAAW;uBACI,iCAAiC;qBAExC,iBAAiB;qBACzB,iBAAiB;wBACR,oBAAoB;mCACF,sBAAsB;8BAC/B,iBAAiB;4BACA,eAAe;qCAO/D,uBAAuB;;;;;;AAE9B,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAAC,AAAC;AAO9C,eAAeF,2BAA2B,CAC/CG,WAAmB,EACnBC,SAAgC,EAChC,EACEC,GAAG,CAAA,EACHC,GAAG,CAAA,EACHC,KAAK,CAAA,EACLC,OAAO,CAAA,EAC8E,EACvF;QAoC6BH,GAAS,QA+D1BA,IAAS;IAlGrB,IAAI,CAACG,OAAO,CAACC,KAAK,EAAE;QAClB,MAAMC,+BAA+B,CAACP,WAAW,EAAEE,GAAG,CAAC,CAAC;IAC1D,CAAC;IAEDM,IAAAA,oBAAU,WAAA,EAAC,kBAAkB,CAAC,CAAC;IAE/B,4DAA4D;IAC5D,MAAMC,YAAY,GAAGC,KAAI,EAAA,QAAA,CAACC,IAAI,C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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;;;;;;0BAEQ,oBAAoB;qBAC/B,WAAW;uBACI,iCAAiC;qBAExC,iBAAiB;qBACzB,iBAAiB;wBACR,oBAAoB;mCACF,sBAAsB;8BAC/B,iBAAiB;4BACA,eAAe;qCAO/D,uBAAuB;;;;;;AAE9B,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAAC,AAAC;AAO9C,eAAeF,2BAA2B,CAC/CG,WAAmB,EACnBC,SAAgC,EAChC,EACEC,GAAG,CAAA,EACHC,GAAG,CAAA,EACHC,KAAK,CAAA,EACLC,OAAO,CAAA,EAC8E,EACvF;QAoC6BH,GAAS,QA+D1BA,IAAS;IAlGrB,IAAI,CAACG,OAAO,CAACC,KAAK,EAAE;QAClB,MAAMC,+BAA+B,CAACP,WAAW,EAAEE,GAAG,CAAC,CAAC;IAC1D,CAAC;IAEDM,IAAAA,oBAAU,WAAA,EAAC,kBAAkB,CAAC,CAAC;IAE/B,4DAA4D;IAC5D,MAAMC,YAAY,GAAGC,KAAI,EAAA,QAAA,CAACC,IAAI,CAACX,WAAW,EAAE,cAAc,EAAEK,OAAO,CAACO,QAAQ,CAAC,AAAC;IAE9E,4DAA4D;IAC5D,MAAMC,IAAAA,IAAW,YAAA,EAACJ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AiD,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,wBAAw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AAC,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,KA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AIiC,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"}
@@ -157,11 +157,24 @@ async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev
157
157
  (0, _assert().default)(devServer instanceof _metroBundlerDevServer.MetroBundlerDevServer);
158
158
  const bundles = {};
159
159
  const domComponentAssetsMetadata = {};
160
- const spaPlatforms = useServerRendering ? platforms.filter((platform)=>platform !== "web") : platforms;
160
+ const spaPlatforms = // TODO: Support server and static rendering for server component exports.
161
+ useServerRendering && !devServer.isReactServerComponentsEnabled ? platforms.filter((platform)=>platform !== "web") : platforms;
161
162
  try {
162
- // NOTE(kitten): The public folder is currently always copied, regardless of targetDomain
163
- // split. Hence, there's another separate `copyPublicFolderAsync` call below for `web`
164
- await (0, _publicFolder.copyPublicFolderAsync)(publicPath, outputPath);
163
+ if (devServer.isReactServerComponentsEnabled) {
164
+ // In RSC mode, we only need these to be in the client dir.
165
+ // TODO: Merge back with other copy after we add SSR.
166
+ try {
167
+ await (0, _publicFolder.copyPublicFolderAsync)(publicPath, _path().default.join(outputPath, "client"));
168
+ } catch (error) {
169
+ _log.error("Failed to copy public directory to dist directory");
170
+ throw error;
171
+ }
172
+ } else {
173
+ // NOTE(kitten): The public folder is currently always copied, regardless of targetDomain
174
+ // split. Hence, there's another separate `copyPublicFolderAsync` call below for `web`
175
+ await (0, _publicFolder.copyPublicFolderAsync)(publicPath, outputPath);
176
+ }
177
+ let templateHtml;
165
178
  // Can be empty during web-only SSG.
166
179
  if (spaPlatforms.length) {
167
180
  await Promise.all(spaPlatforms.map(async (platform)=>{
@@ -243,6 +256,8 @@ async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev
243
256
  if (modifyHtml) {
244
257
  html = modifyHtml(html);
245
258
  }
259
+ // HACK: This is used for adding SSR shims in React Server Components.
260
+ templateHtml = html;
246
261
  // Generate SPA-styled HTML file.
247
262
  // If web exists, then write the template HTML file.
248
263
  files.set("index.html", {
@@ -253,13 +268,12 @@ async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev
253
268
  }));
254
269
  if (devServer.isReactServerComponentsEnabled) {
255
270
  const isWeb = platforms.includes("web");
256
- if (!(isWeb && useServerRendering)) {
257
- await (0, _exportStaticAsync.exportApiRoutesStandaloneAsync)(devServer, {
258
- files,
259
- platform: "web",
260
- apiRoutesOnly: !isWeb
261
- });
262
- }
271
+ await (0, _exportStaticAsync.exportApiRoutesStandaloneAsync)(devServer, {
272
+ files,
273
+ platform: "web",
274
+ apiRoutesOnly: !isWeb,
275
+ templateHtml
276
+ });
263
277
  }
264
278
  // TODO: Use same asset system across platforms again.
265
279
  const { assets , embeddedHashSet } = await (0, _exportAssets.exportAssetsAsync)(projectRoot, {
@@ -317,7 +331,8 @@ async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev
317
331
  targetDomain: "client"
318
332
  });
319
333
  }
320
- } else {
334
+ } else if (// TODO: Support static export with RSC.
335
+ !devServer.isReactServerComponentsEnabled) {
321
336
  var ref3;
322
337
  await (0, _exportStaticAsync.exportFromServerAsync)(projectRoot, devServer, {
323
338
  mode,
@@ -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;;;;+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,CAA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C,UAAU,CAACF,gBAAgB,CAAC,EAAE;oBACpCxF,KAAK,CAACoE,GAAG,CAAC,YAAY,EAAE;wBACtBC,QAAQ,EAAE,CAAC,0BAA0B,CAAC;wBACtCC,YAAY,EAAE,QAAQ;qBACvB,CAAC,CAAC;gBACL,CAAC;YACH,OAAO;oBAUctG,IAAe;gBATlC,MAAM2H,IAAAA,kBAAqB,sBAAA,EAACtI,WAAW,EAAEoD,SAAS,EAAE;oBAClDhB,IAAI;oBACJO,KAAK;oBACLxC,KAAK,EAAE,CAAC,CAACA,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 =\n // TODO: Support server and static rendering for server component exports.\n useServerRendering && !devServer.isReactServerComponentsEnabled\n ? platforms.filter((platform) => platform !== 'web')\n : platforms;\n\n try {\n if (devServer.isReactServerComponentsEnabled) {\n // In RSC mode, we only need these to be in the client dir.\n // TODO: Merge back with other copy after we add SSR.\n try {\n await copyPublicFolderAsync(publicPath, path.join(outputPath, 'client'));\n } catch (error) {\n Log.error('Failed to copy public directory to dist directory');\n throw error;\n }\n } else {\n // NOTE(kitten): The public folder is currently always copied, regardless of targetDomain\n // split. Hence, there's another separate `copyPublicFolderAsync` call below for `web`\n await copyPublicFolderAsync(publicPath, outputPath);\n }\n\n let templateHtml: string | undefined;\n // Can be empty during web-only SSG.\n if (spaPlatforms.length) {\n await Promise.all(\n spaPlatforms.map(async (platform) => {\n // Assert early so the user doesn't have to wait until bundling is complete to find out that\n // Hermes won't be available.\n const isHermes = isEnableHermesManaged(exp, platform);\n if (isHermes) {\n await assertEngineMismatchAsync(projectRoot, exp, platform);\n }\n\n // 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\n await exportApiRoutesStandaloneAsync(devServer, {\n files,\n platform: 'web',\n apiRoutesOnly: !isWeb,\n templateHtml,\n });\n }\n\n // TODO: Use same asset system across platforms again.\n const { assets, embeddedHashSet } = await exportAssetsAsync(projectRoot, {\n files,\n exp,\n outputDir: outputPath,\n bundles,\n baseUrl,\n });\n\n if (dumpAssetmap) {\n Log.log('Creating asset map');\n files.set('assetmap.json', { contents: JSON.stringify(createAssetMap({ assets })) });\n }\n\n const targetDomain = devServer.isReactServerComponentsEnabled ? 'client/' : '';\n const fileNames = Object.fromEntries(\n Object.entries(bundles).map(([platform, bundle]) => [\n platform,\n bundle.artifacts\n .filter((asset) => asset.type === 'js')\n .map((asset) => targetDomain + asset.filename),\n ])\n );\n\n // Generate a `metadata.json` for EAS Update.\n const contents = createMetadataJson({\n bundles,\n fileNames,\n embeddedHashSet,\n domComponentAssetsMetadata,\n });\n files.set('metadata.json', { contents: JSON.stringify(contents) });\n }\n\n // Additional web-only steps...\n\n if (platforms.includes('web') && useServerRendering) {\n const exportServer = exp.web?.output === 'server';\n\n if (exportServer) {\n // TODO: Remove when this is abstracted into the files map\n await copyPublicFolderAsync(publicPath, path.resolve(outputPath, 'client'));\n }\n\n if (skipSSG) {\n Log.log('Skipping static site generation');\n await exportApiRoutesStandaloneAsync(devServer, {\n files,\n platform: 'web',\n apiRoutesOnly: true,\n });\n\n // Output a placeholder index.html if one doesn't exist in the public directory.\n // This ensures native + API routes have some content at the root URL.\n const placeholderIndex = path.resolve(outputPath, 'client/index.html');\n if (!fs.existsSync(placeholderIndex)) {\n files.set('index.html', {\n contents: `<html><body></body></html>`,\n targetDomain: 'client',\n });\n }\n } else if (\n // TODO: Support static export with RSC.\n !devServer.isReactServerComponentsEnabled\n ) {\n await exportFromServerAsync(projectRoot, devServer, {\n mode,\n files,\n clear: !!clear,\n outputDir: outputPath,\n minify,\n baseUrl,\n includeSourceMaps: sourceMaps,\n routerRoot: getRouterDirectoryModuleIdWithManifest(projectRoot, exp),\n reactCompiler: !!exp.experiments?.reactCompiler,\n exportServer,\n maxWorkers,\n isExporting: true,\n exp: projectConfig.exp,\n });\n }\n }\n } finally {\n await devServerManager.stopAsync();\n }\n\n // Write all files at the end for unified logging.\n await persistMetroFilesAsync(files, outputPath);\n}\n"],"names":["exportAppAsync","projectRoot","platforms","outputDir","clear","dev","dumpAssetmap","sourceMaps","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","isReactServerComponentsEnabled","filter","platform","copyPublicFolderAsync","join","error","templateHtml","Promise","all","map","isHermes","isEnableHermesManaged","assertEngineMismatchAsync","bundle","nativeExportBundleAsync","splitChunks","EXPO_NO_BUNDLE_SPLITTING","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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AEoD,SAAS,EAAE;oBAClDhB,IAAI;oBACJO,KAAK;oBACLxC,KAAK,EAAE,CAAC,CAACA,KAAK;oBACdD,SAAS,EAAEwC,UAAU;oBACrBnC,MAAM;oBACNoB,OAAO;oBACP2D,iBAAiB,EAAEhF,UAAU;oBAC7BoI,UAAU,EAAEC,IAAAA,OAAsC,uCAAA,EAAC3I,WAAW,EAAEW,GAAG,CAAC;oBACpEuE,aAAa,EAAE,CAAC,CAACvE,CAAAA,CAAAA,IAAe,GAAfA,GAAG,CAACwE,WAAW,SAAe,GAA9BxE,KAAAA,CAA8B,GAA9BA,IAAe,CAAEuE,aAAa,CAAA;oBAC/CmD,YAAY;oBACZ5H,UAAU;oBACVwC,WAAW,EAAE,IAAI;oBACjBtC,GAAG,EAAEI,aAAa,CAACJ,GAAG;iBACvB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,SAAU;QACR,MAAMkC,gBAAgB,CAAC+F,SAAS,EAAE,CAAC;IACrC,CAAC;IAED,kDAAkD;IAClD,MAAMC,IAAAA,WAAsB,uBAAA,EAAClG,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 }) {