@expo/cli 0.12.0 → 0.13.1

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 (111) hide show
  1. package/build/bin/cli +2 -2
  2. package/build/src/export/createBundles.js +0 -30
  3. package/build/src/export/createBundles.js.map +1 -1
  4. package/build/src/export/createMetadataJson.js +1 -0
  5. package/build/src/export/createMetadataJson.js.map +1 -1
  6. package/build/src/export/embed/exportEmbedAsync.js +2 -0
  7. package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
  8. package/build/src/export/exportApp.js +42 -15
  9. package/build/src/export/exportApp.js.map +1 -1
  10. package/build/src/export/exportAssets.js +2 -2
  11. package/build/src/export/exportAssets.js.map +1 -1
  12. package/build/src/export/exportHermes.js +204 -0
  13. package/build/src/export/exportHermes.js.map +1 -0
  14. package/build/src/export/exportStaticAsync.js +58 -3
  15. package/build/src/export/exportStaticAsync.js.map +1 -1
  16. package/build/src/export/favicon.js +7 -7
  17. package/build/src/export/favicon.js.map +1 -1
  18. package/build/src/export/fork-bundleAsync.js +9 -11
  19. package/build/src/export/fork-bundleAsync.js.map +1 -1
  20. package/build/src/export/persistMetroAssets.js +118 -0
  21. package/build/src/export/persistMetroAssets.js.map +1 -0
  22. package/build/src/export/saveAssets.js.map +1 -1
  23. package/build/src/export/writeContents.js +2 -2
  24. package/build/src/export/writeContents.js.map +1 -1
  25. package/build/src/install/index.js +1 -0
  26. package/build/src/install/index.js.map +1 -1
  27. package/build/src/install/installAsync.js +1 -0
  28. package/build/src/install/installAsync.js.map +1 -1
  29. package/build/src/install/resolveOptions.js +7 -4
  30. package/build/src/install/resolveOptions.js.map +1 -1
  31. package/build/src/prebuild/index.js +2 -0
  32. package/build/src/prebuild/index.js.map +1 -1
  33. package/build/src/prebuild/prebuildAsync.js +2 -1
  34. package/build/src/prebuild/prebuildAsync.js.map +1 -1
  35. package/build/src/prebuild/resolveOptions.js +4 -2
  36. package/build/src/prebuild/resolveOptions.js.map +1 -1
  37. package/build/src/run/android/runAndroidAsync.js +5 -0
  38. package/build/src/run/android/runAndroidAsync.js.map +1 -1
  39. package/build/src/run/ios/runIosAsync.js +5 -0
  40. package/build/src/run/ios/runIosAsync.js.map +1 -1
  41. package/build/src/start/interface/interactiveActions.js +3 -3
  42. package/build/src/start/interface/interactiveActions.js.map +1 -1
  43. package/build/src/start/server/BundlerDevServer.js.map +1 -1
  44. package/build/src/start/server/getStaticRenderFunctions.js +7 -12
  45. package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
  46. package/build/src/start/server/metro/MetroBundlerDevServer.js +78 -54
  47. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  48. package/build/src/start/server/metro/MetroTerminalReporter.js +1 -1
  49. package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
  50. package/build/src/start/server/metro/bundleApiRoutes.js +67 -0
  51. package/build/src/start/server/metro/bundleApiRoutes.js.map +1 -0
  52. package/build/src/start/server/metro/createServerRouteMiddleware.js +112 -0
  53. package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -0
  54. package/build/src/start/server/metro/fetchRouterManifest.js +60 -0
  55. package/build/src/start/server/metro/fetchRouterManifest.js.map +1 -0
  56. package/build/src/start/server/metro/instantiateMetro.js +31 -11
  57. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  58. package/build/src/start/server/metro/metroErrorInterface.js +70 -10
  59. package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
  60. package/build/src/start/server/metro/resolveFromProject.js +13 -0
  61. package/build/src/start/server/metro/resolveFromProject.js.map +1 -1
  62. package/build/src/start/server/metro/router.js +32 -0
  63. package/build/src/start/server/metro/router.js.map +1 -1
  64. package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js +22 -0
  65. package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js.map +1 -1
  66. package/build/src/start/server/metro/withMetroMultiPlatform.js +18 -1
  67. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  68. package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js +1 -1
  69. package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js.map +1 -1
  70. package/build/src/start/server/middleware/InterstitialPageMiddleware.js +3 -3
  71. package/build/src/start/server/middleware/InterstitialPageMiddleware.js.map +1 -1
  72. package/build/src/start/server/middleware/ManifestMiddleware.js +5 -1
  73. package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
  74. package/build/src/start/server/middleware/inspector/JsInspector.js +69 -0
  75. package/build/src/start/server/middleware/inspector/JsInspector.js.map +1 -0
  76. package/build/src/start/server/middleware/inspector/LaunchBrowser.js +57 -0
  77. package/build/src/start/server/middleware/inspector/LaunchBrowser.js.map +1 -0
  78. package/build/src/start/server/middleware/inspector/LaunchBrowser.types.js +13 -0
  79. package/build/src/start/server/middleware/inspector/LaunchBrowser.types.js.map +1 -0
  80. package/build/src/start/server/middleware/inspector/LaunchBrowserImplLinux.js +79 -0
  81. package/build/src/start/server/middleware/inspector/LaunchBrowserImplLinux.js.map +1 -0
  82. package/build/src/start/server/middleware/inspector/LaunchBrowserImplMacOS.js +78 -0
  83. package/build/src/start/server/middleware/inspector/LaunchBrowserImplMacOS.js.map +1 -0
  84. package/build/src/start/server/middleware/inspector/LaunchBrowserImplWindows.js +123 -0
  85. package/build/src/start/server/middleware/inspector/LaunchBrowserImplWindows.js.map +1 -0
  86. package/build/src/start/server/middleware/inspector/createJsInspectorMiddleware.js +64 -0
  87. package/build/src/start/server/middleware/inspector/createJsInspectorMiddleware.js.map +1 -0
  88. package/build/src/start/server/middleware/inspector/middlwareMutations.js +19 -0
  89. package/build/src/start/server/middleware/inspector/middlwareMutations.js.map +1 -0
  90. package/build/src/start/server/middleware/mutations.js +19 -0
  91. package/build/src/start/server/middleware/mutations.js.map +1 -0
  92. package/build/src/start/server/middleware/remoteDevtoolsCorsMiddleware.js +31 -0
  93. package/build/src/start/server/middleware/remoteDevtoolsCorsMiddleware.js.map +1 -0
  94. package/build/src/start/server/middleware/remoteDevtoolsSecurityHeadersMiddleware.js +17 -0
  95. package/build/src/start/server/middleware/remoteDevtoolsSecurityHeadersMiddleware.js.map +1 -0
  96. package/build/src/start/server/middleware/resolveAssets.js.map +1 -1
  97. package/build/src/start/server/middleware/suppressErrorMiddleware.js +16 -0
  98. package/build/src/start/server/middleware/suppressErrorMiddleware.js.map +1 -0
  99. package/build/src/start/server/type-generation/routes.js +3 -4
  100. package/build/src/start/server/type-generation/routes.js.map +1 -1
  101. package/build/src/start/server/type-generation/startTypescriptTypeGeneration.js +1 -3
  102. package/build/src/start/server/type-generation/startTypescriptTypeGeneration.js.map +1 -1
  103. package/build/src/start/server/webpack/WebpackBundlerDevServer.js +9 -82
  104. package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
  105. package/build/src/utils/analytics/rudderstackClient.js +2 -2
  106. package/build/src/utils/codesigning.js.map +1 -1
  107. package/build/src/utils/port.js +45 -17
  108. package/build/src/utils/port.js.map +1 -1
  109. package/package.json +18 -12
  110. package/build/src/start/server/middleware/createDevServerMiddleware.js +0 -24
  111. package/build/src/start/server/middleware/createDevServerMiddleware.js.map +0 -1
package/build/bin/cli CHANGED
@@ -132,7 +132,7 @@ const args = (0, _arg).default({
132
132
  });
133
133
  if (args["--version"]) {
134
134
  // Version is added in the build script.
135
- console.log("0.12.0");
135
+ console.log("0.13.1");
136
136
  process.exit(0);
137
137
  }
138
138
  if (args["--non-interactive"]) {
@@ -262,7 +262,7 @@ commands[command]().then((exec)=>{
262
262
  logEventAsync("action", {
263
263
  action: `expo ${command}`,
264
264
  source: "expo/cli",
265
- source_version: "0.12.0"
265
+ source_version: "0.13.1"
266
266
  });
267
267
  });
268
268
 
@@ -5,29 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  exports.createBundlesAsync = createBundlesAsync;
6
6
  var _config = require("@expo/config");
7
7
  var _forkBundleAsync = require("./fork-bundleAsync");
8
- var Log = _interopRequireWildcard(require("../log"));
9
8
  var _manifestMiddleware = require("../start/server/middleware/ManifestMiddleware");
10
- function _interopRequireWildcard(obj) {
11
- if (obj && obj.__esModule) {
12
- return obj;
13
- } else {
14
- var newObj = {};
15
- if (obj != null) {
16
- for(var key in obj){
17
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
18
- var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
19
- if (desc.get || desc.set) {
20
- Object.defineProperty(newObj, key, desc);
21
- } else {
22
- newObj[key] = obj[key];
23
- }
24
- }
25
- }
26
- }
27
- newObj.default = obj;
28
- return newObj;
29
- }
30
- }
31
9
  async function createBundlesAsync(projectRoot, publishOptions = {}, bundleOptions) {
32
10
  if (!bundleOptions.platforms.length) {
33
11
  return {};
@@ -40,14 +18,6 @@ async function createBundlesAsync(projectRoot, publishOptions = {}, bundleOption
40
18
  // If not legacy, ignore the target option to prevent warnings from being thrown.
41
19
  resetCache: publishOptions.resetCache,
42
20
  maxWorkers: publishOptions.maxWorkers,
43
- logger: {
44
- info (tag, message) {
45
- Log.log(message);
46
- },
47
- error (tag, message) {
48
- Log.error(message);
49
- }
50
- },
51
21
  quiet: false
52
22
  }, bundleOptions.platforms.map((platform)=>({
53
23
  platform,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/createBundles.ts"],"sourcesContent":["import { getConfig, Platform, ProjectTarget } from '@expo/config';\n\nimport { bundleAsync, BundleOutput } from './fork-bundleAsync';\nimport * as Log from '../log';\nimport { getEntryWithServerRoot } from '../start/server/middleware/ManifestMiddleware';\n\nexport type PublishOptions = {\n releaseChannel?: string;\n target?: ProjectTarget;\n resetCache?: boolean;\n maxWorkers?: number;\n};\n\n// TODO: Reduce layers of indirection\nexport async function createBundlesAsync(\n projectRoot: string,\n publishOptions: PublishOptions = {},\n bundleOptions: { platforms: Platform[]; dev?: boolean; minify?: boolean }\n): Promise<Partial<Record<Platform, BundleOutput>>> {\n if (!bundleOptions.platforms.length) {\n return {};\n }\n const projectConfig = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n const { exp } = projectConfig;\n\n const bundles = await bundleAsync(\n projectRoot,\n exp,\n {\n // If not legacy, ignore the target option to prevent warnings from being thrown.\n resetCache: publishOptions.resetCache,\n maxWorkers: publishOptions.maxWorkers,\n logger: {\n info(tag: unknown, message: string) {\n Log.log(message);\n },\n error(tag: unknown, message: string) {\n Log.error(message);\n },\n } as any,\n quiet: false,\n },\n bundleOptions.platforms.map((platform: Platform) => ({\n platform,\n entryPoint: getEntryWithServerRoot(projectRoot, projectConfig, platform),\n minify: bundleOptions.minify,\n dev: bundleOptions.dev,\n }))\n );\n\n // { ios: bundle, android: bundle }\n return bundleOptions.platforms.reduce<Partial<Record<Platform, BundleOutput>>>(\n (prev, platform, index) => ({\n ...prev,\n [platform]: bundles[index],\n }),\n {}\n );\n}\n"],"names":["createBundlesAsync","Log","projectRoot","publishOptions","bundleOptions","platforms","length","projectConfig","getConfig","skipSDKVersionRequirement","exp","bundles","bundleAsync","resetCache","maxWorkers","logger","info","tag","message","log","error","quiet","map","platform","entryPoint","getEntryWithServerRoot","minify","dev","reduce","prev","index"],"mappings":"AAAA;;;;QAcsBA,kBAAkB,GAAlBA,kBAAkB;AAdW,IAAA,OAAc,WAAd,cAAc,CAAA;AAEvB,IAAA,gBAAoB,WAApB,oBAAoB,CAAA;AAClDC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACwB,IAAA,mBAA+C,WAA/C,+CAA+C,CAAA;;;;;;;;;;;;;;;;;;;;;;AAU/E,eAAeD,kBAAkB,CACtCE,WAAmB,EACnBC,cAA8B,GAAG,EAAE,EACnCC,aAAyE,EACvB;IAClD,IAAI,CAACA,aAAa,CAACC,SAAS,CAACC,MAAM,EAAE;QACnC,OAAO,EAAE,CAAC;KACX;IACD,MAAMC,aAAa,GAAGC,CAAAA,GAAAA,OAAS,AAAkD,CAAA,UAAlD,CAACN,WAAW,EAAE;QAAEO,yBAAyB,EAAE,IAAI;KAAE,CAAC,AAAC;IAClF,MAAM,EAAEC,GAAG,CAAA,EAAE,GAAGH,aAAa,AAAC;IAE9B,MAAMI,OAAO,GAAG,MAAMC,CAAAA,GAAAA,gBAAW,AAuBhC,CAAA,YAvBgC,CAC/BV,WAAW,EACXQ,GAAG,EACH;QACE,iFAAiF;QACjFG,UAAU,EAAEV,cAAc,CAACU,UAAU;QACrCC,UAAU,EAAEX,cAAc,CAACW,UAAU;QACrCC,MAAM,EAAE;YACNC,IAAI,EAACC,GAAY,EAAEC,OAAe,EAAE;gBAClCjB,GAAG,CAACkB,GAAG,CAACD,OAAO,CAAC,CAAC;aAClB;YACDE,KAAK,EAACH,GAAY,EAAEC,OAAe,EAAE;gBACnCjB,GAAG,CAACmB,KAAK,CAACF,OAAO,CAAC,CAAC;aACpB;SACF;QACDG,KAAK,EAAE,KAAK;KACb,EACDjB,aAAa,CAACC,SAAS,CAACiB,GAAG,CAAC,CAACC,QAAkB,GAAK,CAAC;YACnDA,QAAQ;YACRC,UAAU,EAAEC,CAAAA,GAAAA,mBAAsB,AAAsC,CAAA,uBAAtC,CAACvB,WAAW,EAAEK,aAAa,EAAEgB,QAAQ,CAAC;YACxEG,MAAM,EAAEtB,aAAa,CAACsB,MAAM;YAC5BC,GAAG,EAAEvB,aAAa,CAACuB,GAAG;SACvB,CAAC;IAAA,CAAC,CACJ,AAAC;IAEF,mCAAmC;IACnC,OAAOvB,aAAa,CAACC,SAAS,CAACuB,MAAM,CACnC,CAACC,IAAI,EAAEN,QAAQ,EAAEO,KAAK,GAAK,CAAC;YAC1B,GAAGD,IAAI;YACP,CAACN,QAAQ,CAAC,EAAEZ,OAAO,CAACmB,KAAK,CAAC;SAC3B,CAAC;IAAA,EACF,EAAE,CACH,CAAC;CACH"}
1
+ {"version":3,"sources":["../../../src/export/createBundles.ts"],"sourcesContent":["import { getConfig, Platform, ProjectTarget } from '@expo/config';\n\nimport { bundleAsync, BundleOutput } from './fork-bundleAsync';\nimport { getEntryWithServerRoot } from '../start/server/middleware/ManifestMiddleware';\n\nexport type PublishOptions = {\n releaseChannel?: string;\n target?: ProjectTarget;\n resetCache?: boolean;\n maxWorkers?: number;\n};\n\n// TODO: Reduce layers of indirection\nexport async function createBundlesAsync(\n projectRoot: string,\n publishOptions: PublishOptions = {},\n bundleOptions: { platforms: Platform[]; dev?: boolean; minify?: boolean }\n): Promise<Partial<Record<Platform, BundleOutput>>> {\n if (!bundleOptions.platforms.length) {\n return {};\n }\n const projectConfig = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n const { exp } = projectConfig;\n\n const bundles = await bundleAsync(\n projectRoot,\n exp,\n {\n // If not legacy, ignore the target option to prevent warnings from being thrown.\n resetCache: publishOptions.resetCache,\n maxWorkers: publishOptions.maxWorkers,\n quiet: false,\n },\n bundleOptions.platforms.map((platform: Platform) => ({\n platform,\n entryPoint: getEntryWithServerRoot(projectRoot, projectConfig, platform),\n minify: bundleOptions.minify,\n dev: bundleOptions.dev,\n }))\n );\n\n // { ios: bundle, android: bundle }\n return bundleOptions.platforms.reduce<Partial<Record<Platform, BundleOutput>>>(\n (prev, platform, index) => ({\n ...prev,\n [platform]: bundles[index],\n }),\n {}\n );\n}\n"],"names":["createBundlesAsync","projectRoot","publishOptions","bundleOptions","platforms","length","projectConfig","getConfig","skipSDKVersionRequirement","exp","bundles","bundleAsync","resetCache","maxWorkers","quiet","map","platform","entryPoint","getEntryWithServerRoot","minify","dev","reduce","prev","index"],"mappings":"AAAA;;;;QAasBA,kBAAkB,GAAlBA,kBAAkB;AAbW,IAAA,OAAc,WAAd,cAAc,CAAA;AAEvB,IAAA,gBAAoB,WAApB,oBAAoB,CAAA;AACvB,IAAA,mBAA+C,WAA/C,+CAA+C,CAAA;AAU/E,eAAeA,kBAAkB,CACtCC,WAAmB,EACnBC,cAA8B,GAAG,EAAE,EACnCC,aAAyE,EACvB;IAClD,IAAI,CAACA,aAAa,CAACC,SAAS,CAACC,MAAM,EAAE;QACnC,OAAO,EAAE,CAAC;KACX;IACD,MAAMC,aAAa,GAAGC,CAAAA,GAAAA,OAAS,AAAkD,CAAA,UAAlD,CAACN,WAAW,EAAE;QAAEO,yBAAyB,EAAE,IAAI;KAAE,CAAC,AAAC;IAClF,MAAM,EAAEC,GAAG,CAAA,EAAE,GAAGH,aAAa,AAAC;IAE9B,MAAMI,OAAO,GAAG,MAAMC,CAAAA,GAAAA,gBAAW,AAehC,CAAA,YAfgC,CAC/BV,WAAW,EACXQ,GAAG,EACH;QACE,iFAAiF;QACjFG,UAAU,EAAEV,cAAc,CAACU,UAAU;QACrCC,UAAU,EAAEX,cAAc,CAACW,UAAU;QACrCC,KAAK,EAAE,KAAK;KACb,EACDX,aAAa,CAACC,SAAS,CAACW,GAAG,CAAC,CAACC,QAAkB,GAAK,CAAC;YACnDA,QAAQ;YACRC,UAAU,EAAEC,CAAAA,GAAAA,mBAAsB,AAAsC,CAAA,uBAAtC,CAACjB,WAAW,EAAEK,aAAa,EAAEU,QAAQ,CAAC;YACxEG,MAAM,EAAEhB,aAAa,CAACgB,MAAM;YAC5BC,GAAG,EAAEjB,aAAa,CAACiB,GAAG;SACvB,CAAC;IAAA,CAAC,CACJ,AAAC;IAEF,mCAAmC;IACnC,OAAOjB,aAAa,CAACC,SAAS,CAACiB,MAAM,CACnC,CAACC,IAAI,EAAEN,QAAQ,EAAEO,KAAK,GAAK,CAAC;YAC1B,GAAGD,IAAI;YACP,CAACN,QAAQ,CAAC,EAAEN,OAAO,CAACa,KAAK,CAAC;SAC3B,CAAC;IAAA,EACF,EAAE,CACH,CAAC;CACH"}
@@ -15,6 +15,7 @@ function createMetadataJson({ bundles , fileNames }) {
15
15
  version: 0,
16
16
  bundler: "metro",
17
17
  fileMetadata: Object.entries(bundles).reduce((metadata, [platform, bundle])=>{
18
+ if (platform === "web") return metadata;
18
19
  return {
19
20
  ...metadata,
20
21
  [platform]: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/createMetadataJson.ts"],"sourcesContent":["import path from 'path';\n\nimport { BundleOutput } from './fork-bundleAsync';\n\nexport type BundlePlatform = 'android' | 'ios';\n\ntype PlatformMetadataAsset = { path: string; ext: string };\n\ntype PlatformMetadata = { bundle: string; assets: PlatformMetadataAsset[] };\n\ntype FileMetadata = {\n [key in BundlePlatform]: PlatformMetadata;\n};\n\nexport function createMetadataJson({\n bundles,\n fileNames,\n}: {\n bundles: Partial<Record<BundlePlatform, Pick<BundleOutput, 'assets'>>>;\n fileNames: Record<string, string>;\n}): {\n version: 0;\n bundler: 'metro';\n fileMetadata: FileMetadata;\n} {\n // Build metadata.json\n return {\n version: 0,\n bundler: 'metro',\n fileMetadata: Object.entries(bundles).reduce<Record<string, Partial<PlatformMetadata>>>(\n (metadata, [platform, bundle]) => ({\n ...metadata,\n [platform]: {\n // Get the filename for each platform's bundle.\n bundle: path.join('bundles', fileNames[platform]!),\n // Collect all of the assets and convert them to the serial format.\n assets: bundle.assets\n .map(\n (asset) =>\n // Each asset has multiple hashes which we convert and then flatten.\n asset.fileHashes?.map((hash) => ({\n path: path.join('assets', hash),\n ext: asset.type,\n }))\n )\n .filter(Boolean)\n .flat(),\n },\n }),\n {}\n ) as FileMetadata,\n };\n}\n"],"names":["createMetadataJson","bundles","fileNames","version","bundler","fileMetadata","Object","entries","reduce","metadata","platform","bundle","path","join","assets","map","asset","fileHashes","hash","ext","type","filter","Boolean","flat"],"mappings":"AAAA;;;;QAcgBA,kBAAkB,GAAlBA,kBAAkB;AAdjB,IAAA,KAAM,kCAAN,MAAM,EAAA;;;;;;AAchB,SAASA,kBAAkB,CAAC,EACjCC,OAAO,CAAA,EACPC,SAAS,CAAA,EAIV,EAIC;IACA,sBAAsB;IACtB,OAAO;QACLC,OAAO,EAAE,CAAC;QACVC,OAAO,EAAE,OAAO;QAChBC,YAAY,EAAEC,MAAM,CAACC,OAAO,CAACN,OAAO,CAAC,CAACO,MAAM,CAC1C,CAACC,QAAQ,EAAE,CAACC,QAAQ,EAAEC,MAAM,CAAC;YAAK,OAAC;gBACjC,GAAGF,QAAQ;gBACX,CAACC,QAAQ,CAAC,EAAE;oBACV,+CAA+C;oBAC/CC,MAAM,EAAEC,KAAI,QAAA,CAACC,IAAI,CAAC,SAAS,EAAEX,SAAS,CAACQ,QAAQ,CAAC,CAAE;oBAClD,mEAAmE;oBACnEI,MAAM,EAAEH,MAAM,CAACG,MAAM,CAClBC,GAAG,CACF,CAACC,KAAK;4BACJ,oEAAoE;wBACpEA,GAAgB;wBAAhBA,OAAAA,CAAAA,GAAgB,GAAhBA,KAAK,CAACC,UAAU,SAAK,GAArBD,KAAAA,CAAqB,GAArBA,GAAgB,CAAED,GAAG,CAAC,CAACG,IAAI,GAAK,CAAC;gCAC/BN,IAAI,EAAEA,KAAI,QAAA,CAACC,IAAI,CAAC,QAAQ,EAAEK,IAAI,CAAC;gCAC/BC,GAAG,EAAEH,KAAK,CAACI,IAAI;6BAChB,CAAC;wBAAA,CAAC,CAAA;qBAAA,CACN,CACAC,MAAM,CAACC,OAAO,CAAC,CACfC,IAAI,EAAE;iBACV;aACF,CAAC;SAAA,EACF,EAAE,CACH;KACF,CAAC;CACH"}
1
+ {"version":3,"sources":["../../../src/export/createMetadataJson.ts"],"sourcesContent":["import path from 'path';\n\nimport { BundleOutput } from './fork-bundleAsync';\n\nexport type BundlePlatform = 'android' | 'ios';\n\ntype PlatformMetadataAsset = { path: string; ext: string };\n\ntype PlatformMetadata = { bundle: string; assets: PlatformMetadataAsset[] };\n\ntype FileMetadata = {\n [key in BundlePlatform]: PlatformMetadata;\n};\n\nexport function createMetadataJson({\n bundles,\n fileNames,\n}: {\n bundles: Partial<Record<BundlePlatform, Pick<BundleOutput, 'assets'>>>;\n fileNames: Record<string, string>;\n}): {\n version: 0;\n bundler: 'metro';\n fileMetadata: FileMetadata;\n} {\n // Build metadata.json\n return {\n version: 0,\n bundler: 'metro',\n fileMetadata: Object.entries(bundles).reduce<Record<string, Partial<PlatformMetadata>>>(\n (metadata, [platform, bundle]) => {\n if (platform === 'web') return metadata;\n\n return {\n ...metadata,\n [platform]: {\n // Get the filename for each platform's bundle.\n bundle: path.join('bundles', fileNames[platform]!),\n // Collect all of the assets and convert them to the serial format.\n assets: bundle.assets\n .map(\n (asset) =>\n // Each asset has multiple hashes which we convert and then flatten.\n asset.fileHashes?.map((hash) => ({\n path: path.join('assets', hash),\n ext: asset.type,\n }))\n )\n .filter(Boolean)\n .flat(),\n },\n };\n },\n {}\n ) as FileMetadata,\n };\n}\n"],"names":["createMetadataJson","bundles","fileNames","version","bundler","fileMetadata","Object","entries","reduce","metadata","platform","bundle","path","join","assets","map","asset","fileHashes","hash","ext","type","filter","Boolean","flat"],"mappings":"AAAA;;;;QAcgBA,kBAAkB,GAAlBA,kBAAkB;AAdjB,IAAA,KAAM,kCAAN,MAAM,EAAA;;;;;;AAchB,SAASA,kBAAkB,CAAC,EACjCC,OAAO,CAAA,EACPC,SAAS,CAAA,EAIV,EAIC;IACA,sBAAsB;IACtB,OAAO;QACLC,OAAO,EAAE,CAAC;QACVC,OAAO,EAAE,OAAO;QAChBC,YAAY,EAAEC,MAAM,CAACC,OAAO,CAACN,OAAO,CAAC,CAACO,MAAM,CAC1C,CAACC,QAAQ,EAAE,CAACC,QAAQ,EAAEC,MAAM,CAAC,GAAK;YAChC,IAAID,QAAQ,KAAK,KAAK,EAAE,OAAOD,QAAQ,CAAC;YAExC,OAAO;gBACL,GAAGA,QAAQ;gBACX,CAACC,QAAQ,CAAC,EAAE;oBACV,+CAA+C;oBAC/CC,MAAM,EAAEC,KAAI,QAAA,CAACC,IAAI,CAAC,SAAS,EAAEX,SAAS,CAACQ,QAAQ,CAAC,CAAE;oBAClD,mEAAmE;oBACnEI,MAAM,EAAEH,MAAM,CAACG,MAAM,CAClBC,GAAG,CACF,CAACC,KAAK;4BACJ,oEAAoE;wBACpEA,GAAgB;wBAAhBA,OAAAA,CAAAA,GAAgB,GAAhBA,KAAK,CAACC,UAAU,SAAK,GAArBD,KAAAA,CAAqB,GAArBA,GAAgB,CAAED,GAAG,CAAC,CAACG,IAAI,GAAK,CAAC;gCAC/BN,IAAI,EAAEA,KAAI,QAAA,CAACC,IAAI,CAAC,QAAQ,EAAEK,IAAI,CAAC;gCAC/BC,GAAG,EAAEH,KAAK,CAACI,IAAI;6BAChB,CAAC;wBAAA,CAAC,CAAA;qBAAA,CACN,CACAC,MAAM,CAACC,OAAO,CAAC,CACfC,IAAI,EAAE;iBACV;aACF,CAAC;SACH,EACD,EAAE,CACH;KACF,CAAC;CACH"}
@@ -27,6 +27,8 @@ async function exportEmbedAsync(projectRoot, options) {
27
27
  }, {
28
28
  isExporting: true
29
29
  });
30
+ // NOTE(EvanBacon): This may need to be adjusted in the future if want to support basePath on native
31
+ // platforms when doing production embeds (unlikely).
30
32
  const saveAssets = (0, _resolveFromProject).importCliSaveAssetsFromProject(projectRoot);
31
33
  let sourceMapUrl = options.sourcemapOutput;
32
34
  if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/export/embed/exportEmbedAsync.ts"],"sourcesContent":["import fs from 'fs';\nimport Server from 'metro/src/Server';\nimport output from 'metro/src/shared/output/bundle';\nimport type { BundleOptions } from 'metro/src/shared/types';\nimport path from 'path';\n\nimport { Options } from './resolveOptions';\nimport { Log } from '../../log';\nimport { loadMetroConfigAsync } from '../../start/server/metro/instantiateMetro';\nimport { importCliSaveAssetsFromProject } from '../../start/server/metro/resolveFromProject';\nimport { setNodeEnv } from '../../utils/nodeEnv';\nimport { getAssets } from '../fork-bundleAsync';\n\nexport async function exportEmbedAsync(projectRoot: string, options: Options) {\n setNodeEnv(options.dev ? 'development' : 'production');\n require('@expo/env').load(projectRoot);\n\n const { config } = await loadMetroConfigAsync(\n projectRoot,\n {\n maxWorkers: options.maxWorkers,\n resetCache: options.resetCache,\n config: options.config,\n },\n {\n isExporting: true,\n }\n );\n\n const saveAssets = importCliSaveAssetsFromProject(projectRoot);\n\n let sourceMapUrl = options.sourcemapOutput;\n if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {\n sourceMapUrl = path.basename(sourceMapUrl);\n }\n\n const bundleRequest = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n entryFile: options.entryFile,\n sourceMapUrl,\n dev: options.dev,\n minify: !!options.minify,\n platform: options.platform,\n unstable_transformProfile:\n options.unstableTransformProfile as BundleOptions['unstable_transformProfile'],\n };\n\n const server = new Server(config, {\n watch: false,\n });\n\n try {\n const bundle = await server.build({\n ...bundleRequest,\n bundleType: 'bundle',\n });\n\n fs.mkdirSync(path.dirname(options.bundleOutput), { recursive: true, mode: 0o755 });\n\n // Persist bundle and source maps.\n await output.save(bundle, options, Log.log);\n\n // Save the assets of the bundle\n const outputAssets = await getAssets(server, {\n ...bundleRequest,\n bundleType: 'todo',\n });\n\n await saveAssets(outputAssets, options.platform, options.assetsDest, options.assetCatalogDest);\n } finally {\n server.end();\n }\n}\n"],"names":["exportEmbedAsync","projectRoot","options","setNodeEnv","dev","require","load","config","loadMetroConfigAsync","maxWorkers","resetCache","isExporting","saveAssets","importCliSaveAssetsFromProject","sourceMapUrl","sourcemapOutput","sourcemapUseAbsolutePath","path","basename","bundleRequest","Server","DEFAULT_BUNDLE_OPTIONS","entryFile","minify","platform","unstable_transformProfile","unstableTransformProfile","server","watch","bundle","build","bundleType","fs","mkdirSync","dirname","bundleOutput","recursive","mode","output","save","Log","log","outputAssets","getAssets","assetsDest","assetCatalogDest","end"],"mappings":"AAAA;;;;QAasBA,gBAAgB,GAAhBA,gBAAgB;AAbvB,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACA,IAAA,OAAkB,kCAAlB,kBAAkB,EAAA;AAClB,IAAA,OAAgC,kCAAhC,gCAAgC,EAAA;AAElC,IAAA,KAAM,kCAAN,MAAM,EAAA;AAGH,IAAA,IAAW,WAAX,WAAW,CAAA;AACM,IAAA,iBAA2C,WAA3C,2CAA2C,CAAA;AACjC,IAAA,mBAA6C,WAA7C,6CAA6C,CAAA;AACjE,I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AAA,CAACb,MAAM,EAAE;QAChCqB,KAAK,EAAE,KAAK;KACb,CAAC,AAAC;IAEH,IAAI;QACF,MAAMC,MAAM,GAAG,MAAMF,MAAM,CAACG,KAAK,CAAC;YAChC,GAAGX,aAAa;YAChBY,UAAU,EAAE,QAAQ;SACrB,CAAC,AAAC;QAEHC,GAAE,QAAA,CAACC,SAAS,CAAChB,KAAI,QAAA,CAACiB,OAAO,CAAChC,OAAO,CAACiC,YAAY,CAAC,EAAE;YAAEC,SAAS,EAAE,IAAI;YAAEC,IAAI,EAAE,GAAK;SAAE,CAAC,CAAC;QAEnF,kCAAkC;QAClC,MAAMC,OAAM,QAAA,CAACC,IAAI,CAACV,MAAM,EAAE3B,OAAO,EAAEsC,IAAG,IAAA,CAACC,GAAG,CAAC,CAAC;QAE5C,gCAAgC;QAChC,MAAMC,YAAY,GAAG,MAAMC,CAAAA,GAAAA,gBAAS,AAGlC,CAAA,UAHkC,CAAChB,MAAM,EAAE;YAC3C,GAAGR,aAAa;YAChBY,UAAU,EAAE,MAAM;SACnB,CAAC,AAAC;QAEH,MAAMnB,UAAU,CAAC8B,YAAY,EAAExC,OAAO,CAACsB,QAAQ,EAAEtB,OAAO,CAAC0C,UAAU,EAAE1C,OAAO,CAAC2C,gBAAgB,CAAC,CAAC;KAChG,QAAS;QACRlB,MAAM,CAACmB,GAAG,EAAE,CAAC;KACd;CACF"}
1
+ {"version":3,"sources":["../../../../src/export/embed/exportEmbedAsync.ts"],"sourcesContent":["import fs from 'fs';\nimport Server from 'metro/src/Server';\nimport output from 'metro/src/shared/output/bundle';\nimport type { BundleOptions } from 'metro/src/shared/types';\nimport path from 'path';\n\nimport { Options } from './resolveOptions';\nimport { Log } from '../../log';\nimport { loadMetroConfigAsync } from '../../start/server/metro/instantiateMetro';\nimport { importCliSaveAssetsFromProject } from '../../start/server/metro/resolveFromProject';\nimport { setNodeEnv } from '../../utils/nodeEnv';\nimport { getAssets } from '../fork-bundleAsync';\n\nexport async function exportEmbedAsync(projectRoot: string, options: Options) {\n setNodeEnv(options.dev ? 'development' : 'production');\n require('@expo/env').load(projectRoot);\n\n const { config } = await loadMetroConfigAsync(\n projectRoot,\n {\n maxWorkers: options.maxWorkers,\n resetCache: options.resetCache,\n config: options.config,\n },\n {\n isExporting: true,\n }\n );\n\n // NOTE(EvanBacon): This may need to be adjusted in the future if want to support basePath on native\n // platforms when doing production embeds (unlikely).\n const saveAssets = importCliSaveAssetsFromProject(projectRoot);\n\n let sourceMapUrl = options.sourcemapOutput;\n if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {\n sourceMapUrl = path.basename(sourceMapUrl);\n }\n\n const bundleRequest = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n entryFile: options.entryFile,\n sourceMapUrl,\n dev: options.dev,\n minify: !!options.minify,\n platform: options.platform,\n unstable_transformProfile:\n options.unstableTransformProfile as BundleOptions['unstable_transformProfile'],\n };\n\n const server = new Server(config, {\n watch: false,\n });\n\n try {\n const bundle = await server.build({\n ...bundleRequest,\n bundleType: 'bundle',\n });\n\n fs.mkdirSync(path.dirname(options.bundleOutput), { recursive: true, mode: 0o755 });\n\n // Persist bundle and source maps.\n await output.save(bundle, options, Log.log);\n\n // Save the assets of the bundle\n const outputAssets = await getAssets(server, {\n ...bundleRequest,\n bundleType: 'todo',\n });\n\n await saveAssets(outputAssets, options.platform, options.assetsDest, options.assetCatalogDest);\n } finally {\n server.end();\n }\n}\n"],"names":["exportEmbedAsync","projectRoot","options","setNodeEnv","dev","require","load","config","loadMetroConfigAsync","maxWorkers","resetCache","isExporting","saveAssets","importCliSaveAssetsFromProject","sourceMapUrl","sourcemapOutput","sourcemapUseAbsolutePath","path","basename","bundleRequest","Server","DEFAULT_BUNDLE_OPTIONS","entryFile","minify","platform","unstable_transformProfile","unstableTransformProfile","server","watch","bundle","build","bundleType","fs","mkdirSync","dirname","bundleOutput","recursive","mode","output","save","Log","log","outputAssets","getAssets","assetsDest","assetCatalogDest","end"],"mappings":"AAAA;;;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object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.exportAppAsync = exportAppAsync;
6
+ var _chalk = _interopRequireDefault(require("chalk"));
6
7
  var _fs = _interopRequireDefault(require("fs"));
7
8
  var _path = _interopRequireDefault(require("path"));
8
9
  var _createBundles = require("./createBundles");
@@ -10,10 +11,10 @@ var _exportAssets = require("./exportAssets");
10
11
  var _exportStaticAsync = require("./exportStaticAsync");
11
12
  var _favicon = require("./favicon");
12
13
  var _getPublicExpoManifest = require("./getPublicExpoManifest");
14
+ var _persistMetroAssets = require("./persistMetroAssets");
13
15
  var _printBundleSizes = require("./printBundleSizes");
14
16
  var _writeContents = require("./writeContents");
15
17
  var Log = _interopRequireWildcard(require("../log"));
16
- var _resolveFromProject = require("../start/server/metro/resolveFromProject");
17
18
  var _webTemplate = require("../start/server/webTemplate");
18
19
  var _dir = require("../utils/dir");
19
20
  var _env = require("../utils/env");
@@ -45,11 +46,26 @@ function _interopRequireWildcard(obj) {
45
46
  }
46
47
  }
47
48
  async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev , dumpAssetmap , dumpSourcemap , minify }) {
48
- var ref;
49
+ var ref, ref1, ref2;
49
50
  (0, _nodeEnv).setNodeEnv(dev ? "development" : "production");
50
51
  require("@expo/env").load(projectRoot);
51
52
  const exp = await (0, _getPublicExpoManifest).getPublicExpoManifestAsync(projectRoot);
52
- const useWebSSG = ((ref = exp.web) == null ? void 0 : ref.output) === "static";
53
+ var ref3;
54
+ const useServerRendering = [
55
+ "static",
56
+ "server"
57
+ ].includes((ref3 = (ref = exp.web) == null ? void 0 : ref.output) != null ? ref3 : "");
58
+ var ref4;
59
+ const basePath = ((ref4 = (ref1 = exp.experiments) == null ? void 0 : (ref2 = ref1.basePath) == null ? void 0 : ref2.replace(/\/+$/, "")) != null ? ref4 : "").trim();
60
+ // Print out logs
61
+ if (basePath) {
62
+ Log.log();
63
+ Log.log(_chalk.default.gray`Using (experimental) base path: ${basePath}`);
64
+ // Warn if not using an absolute path.
65
+ if (!basePath.startsWith("/")) {
66
+ Log.log(_chalk.default.yellow` Base path does not start with a slash. Requests will not be absolute.`);
67
+ }
68
+ }
53
69
  const publicPath = _path.default.resolve(projectRoot, _env.env.EXPO_PUBLIC_FOLDER);
54
70
  const outputPath = _path.default.resolve(projectRoot, outputDir);
55
71
  const staticFolder = outputPath;
@@ -67,7 +83,9 @@ async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev
67
83
  platforms,
68
84
  minify,
69
85
  // TODO: Breaks asset exports
70
- // platforms: useWebSSG ? platforms.filter((platform) => platform !== 'web') : platforms,
86
+ // platforms: useServerRendering
87
+ // ? platforms.filter((platform) => platform !== 'web')
88
+ // : platforms,
71
89
  dev
72
90
  });
73
91
  const bundleEntries = Object.entries(bundles);
@@ -93,32 +111,39 @@ async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev
93
111
  // Write the JS bundles to disk, and get the bundle file names (this could change with async chunk loading support).
94
112
  const { hashes , fileNames } = await (0, _writeContents).writeBundlesAsync({
95
113
  bundles,
96
- useWebSSG,
114
+ useServerRendering,
97
115
  outputDir: bundlesPath
98
116
  });
99
117
  Log.log("Finished saving JS Bundles");
100
118
  if (platforms.includes("web")) {
101
- if (useWebSSG) {
119
+ if (useServerRendering) {
120
+ var ref5;
102
121
  await (0, _exportStaticAsync).unstable_exportStaticAsync(projectRoot, {
103
122
  outputDir: outputPath,
104
- // TODO: Expose
105
123
  minify,
106
- includeMaps: dumpSourcemap
124
+ basePath,
125
+ includeMaps: dumpSourcemap,
126
+ // @ts-expect-error: server not on type yet
127
+ exportServer: ((ref5 = exp.web) == null ? void 0 : ref5.output) === "server"
107
128
  });
108
129
  Log.log("Finished saving static files");
109
130
  } else {
110
131
  const cssLinks = await (0, _exportAssets).exportCssAssetsAsync({
111
132
  outputDir,
112
- bundles
133
+ bundles,
134
+ basePath
113
135
  });
114
136
  let html = await (0, _webTemplate).createTemplateHtmlFromExpoConfigAsync(projectRoot, {
115
137
  scripts: [
116
- `/bundles/${fileNames.web}`
138
+ `${basePath}/bundles/${fileNames.web}`
117
139
  ],
118
140
  cssLinks
119
141
  });
120
142
  // Add the favicon assets to the HTML.
121
- const modifyHtml = await (0, _favicon).getVirtualFaviconAssetsAsync(projectRoot, outputDir);
143
+ const modifyHtml = await (0, _favicon).getVirtualFaviconAssetsAsync(projectRoot, {
144
+ outputDir,
145
+ basePath
146
+ });
122
147
  if (modifyHtml) {
123
148
  html = modifyHtml(html);
124
149
  }
@@ -129,10 +154,12 @@ async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev
129
154
  // TODO: Use a different mechanism for static web.
130
155
  if (bundles.web) {
131
156
  // Save assets like a typical bundler, preserving the file paths on web.
132
- const saveAssets = (0, _resolveFromProject).importCliSaveAssetsFromProject(projectRoot);
133
- await Promise.all(Object.entries(bundles).map(([platform, bundle])=>{
134
- return saveAssets(bundle.assets, platform, staticFolder, undefined);
135
- }));
157
+ // TODO: Update React Native Web to support loading files from asset hashes.
158
+ await (0, _persistMetroAssets).persistMetroAssetsAsync(bundles.web.assets, {
159
+ platform: "web",
160
+ outputDirectory: staticFolder,
161
+ basePath
162
+ });
136
163
  }
137
164
  }
138
165
  // Can be empty during web-only SSG.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/exportApp.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport { createBundlesAsync } from './createBundles';\nimport { exportAssetsAsync, exportCssAssetsAsync } from './exportAssets';\nimport { unstable_exportStaticAsync } from './exportStaticAsync';\nimport { getVirtualFaviconAssetsAsync } from './favicon';\nimport { getPublicExpoManifestAsync } from './getPublicExpoManifest';\nimport { printBundleSizes } from './printBundleSizes';\nimport { Options } from './resolveOptions';\nimport {\n writeAssetMapAsync,\n writeBundlesAsync,\n writeDebugHtmlAsync,\n writeMetadataJsonAsync,\n writeSourceMapsAsync,\n} from './writeContents';\nimport * as Log from '../log';\nimport { importCliSaveAssetsFromProject } from '../start/server/metro/resolveFromProject';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../start/server/webTemplate';\nimport { copyAsync, ensureDirectoryAsync } from '../utils/dir';\nimport { env } from '../utils/env';\nimport { setNodeEnv } from '../utils/nodeEnv';\n\n/**\n * The structure of the outputDir will be:\n *\n * ```\n * ├── assets\n * │ └── *\n * ├── bundles\n * │ ├── android-01ee6e3ab3e8c16a4d926c91808d5320.js\n * │ └── ios-ee8206cc754d3f7aa9123b7f909d94ea.js\n * └── metadata.json\n * ```\n */\nexport async function exportAppAsync(\n projectRoot: string,\n {\n platforms,\n outputDir,\n clear,\n dev,\n dumpAssetmap,\n dumpSourcemap,\n minify,\n }: Pick<\n Options,\n 'dumpAssetmap' | 'dumpSourcemap' | 'dev' | 'clear' | 'outputDir' | 'platforms' | 'minify'\n >\n): Promise<void> {\n setNodeEnv(dev ? 'development' : 'production');\n require('@expo/env').load(projectRoot);\n\n const exp = await getPublicExpoManifestAsync(projectRoot);\n\n const useWebSSG = exp.web?.output === 'static';\n\n const publicPath = path.resolve(projectRoot, env.EXPO_PUBLIC_FOLDER);\n\n const outputPath = path.resolve(projectRoot, outputDir);\n const staticFolder = outputPath;\n const assetsPath = path.join(staticFolder, 'assets');\n const bundlesPath = path.join(staticFolder, 'bundles');\n\n await Promise.all([assetsPath, bundlesPath].map(ensureDirectoryAsync));\n\n await copyPublicFolderAsync(publicPath, staticFolder);\n\n // Run metro bundler and create the JS bundles/source maps.\n const bundles = await createBundlesAsync(\n projectRoot,\n { resetCache: !!clear },\n {\n platforms,\n minify,\n // TODO: Breaks asset exports\n // platforms: useWebSSG ? platforms.filter((platform) => platform !== 'web') : platforms,\n dev,\n // TODO: Disable source map generation if we aren't outputting them.\n }\n );\n\n const bundleEntries = Object.entries(bundles);\n if (bundleEntries.length) {\n // Log bundle size info to the user\n printBundleSizes(\n Object.fromEntries(\n bundleEntries.map(([key, value]) => {\n if (!dumpSourcemap) {\n return [\n key,\n {\n ...value,\n // Remove source maps from the bundles if they aren't going to be written.\n map: undefined,\n },\n ];\n }\n\n return [key, value];\n })\n )\n );\n }\n\n // Write the JS bundles to disk, and get the bundle file names (this could change with async chunk loading support).\n const { hashes, fileNames } = await writeBundlesAsync({\n bundles,\n useWebSSG,\n outputDir: bundlesPath,\n });\n\n Log.log('Finished saving JS Bundles');\n\n if (platforms.includes('web')) {\n if (useWebSSG) {\n await unstable_exportStaticAsync(projectRoot, {\n outputDir: outputPath,\n // TODO: Expose\n minify,\n includeMaps: dumpSourcemap,\n });\n Log.log('Finished saving static files');\n } else {\n const cssLinks = await exportCssAssetsAsync({\n outputDir,\n bundles,\n });\n let html = await createTemplateHtmlFromExpoConfigAsync(projectRoot, {\n scripts: [`/bundles/${fileNames.web}`],\n cssLinks,\n });\n // Add the favicon assets to the HTML.\n const modifyHtml = await getVirtualFaviconAssetsAsync(projectRoot, outputDir);\n if (modifyHtml) {\n html = modifyHtml(html);\n }\n // Generate SPA-styled HTML file.\n // If web exists, then write the template HTML file.\n await fs.promises.writeFile(path.join(staticFolder, 'index.html'), html);\n }\n\n // TODO: Use a different mechanism for static web.\n if (bundles.web) {\n // Save assets like a typical bundler, preserving the file paths on web.\n const saveAssets = importCliSaveAssetsFromProject(projectRoot);\n await Promise.all(\n Object.entries(bundles).map(([platform, bundle]) => {\n return saveAssets(bundle.assets, platform, staticFolder, undefined);\n })\n );\n }\n }\n\n // Can be empty during web-only SSG.\n // TODO: Use same asset system across platforms again.\n if (Object.keys(fileNames).length) {\n const { assets } = await exportAssetsAsync(projectRoot, {\n exp,\n outputDir: staticFolder,\n bundles,\n });\n\n if (dumpAssetmap) {\n Log.log('Dumping asset map');\n await writeAssetMapAsync({ outputDir: staticFolder, assets });\n }\n // build source maps\n if (dumpSourcemap) {\n Log.log('Dumping source maps');\n await writeSourceMapsAsync({\n bundles,\n hashes,\n outputDir: bundlesPath,\n fileNames,\n });\n\n Log.log('Preparing additional debugging files');\n // If we output source maps, then add a debug HTML file which the user can open in\n // the web browser to inspect the output like web.\n await writeDebugHtmlAsync({\n outputDir: staticFolder,\n fileNames,\n });\n }\n\n // Generate a `metadata.json` and the export is complete.\n await writeMetadataJsonAsync({ outputDir: staticFolder, bundles, fileNames });\n }\n}\n\n/**\n * Copy the contents of the public folder into the output folder.\n * This enables users to add static files like `favicon.ico` or `serve.json`.\n *\n * The contents of this folder are completely universal since they refer to\n * static network requests which fall outside the scope of React Native's magic\n * platform resolution patterns.\n */\nasync function copyPublicFolderAsync(publicFolder: string, outputFolder: string) {\n if (fs.existsSync(publicFolder)) {\n await copyAsync(publicFolder, outputFolder);\n }\n}\n"],"names":["exportAppAsync","Log","projectRoot","platforms","outputDir","clear","dev","dumpAssetmap","dumpSourcemap","minify","exp","setNodeEnv","require","load","getPublicExpoManifestAsync","useWebSSG","web","output","publicPath","path","resolve","env","EXPO_PUBLIC_FOLDER","outputPath","staticFolder","assetsPath","join","bundlesPath","Promise","all","map","ensureDirectoryAsync","copyPublicFolderAsync","bundles","createBundlesAsync","resetCache","bundleEntries","Object","entries","length","printBundleSizes","fromEntries","key","value","undefined","hashes","fileNames","writeBundlesAsync","log","includes","unstable_exportStaticAsync","includeMaps","cssLinks","exportCssAssetsAsync","html","createTemplateHtmlFromExpoConfigAsync","scripts","modifyHtml","getVirtualFaviconAssetsAsync","fs","promises","writeFile","saveAssets","importCliSaveAssetsFromProject","platform","bundle","assets","keys","exportAssetsAsync","writeAssetMapAsync","writeSourceMapsAsync","writeDebugHtmlAsync","writeMetadataJsonAsync","publicFolder","outputFolder","existsSync","copyAsync"],"mappings":"AAAA;;;;QAoCsBA,cAAc,GAAdA,cAAc;AApCrB,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEY,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;AACI,IAAA,aAAgB,WAAhB,gBAAgB,CAAA;AAC7B,IAAA,kBAAqB,WAArB,qBAAqB,CAAA;AACnB,IAAA,QAAW,WAAX,WAAW,CAAA;AACb,IAAA,sBAAyB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D,MAAMuB,CAAAA,GAAAA,cAAmB,AAGvB,CAAA,oBAHuB,CAAC;gBACxBnE,SAAS,EAAEoB,YAAY;gBACvBsB,SAAS;aACV,CAAC,CAAC;SACJ;QAED,yDAAyD;QACzD,MAAM0B,CAAAA,GAAAA,cAAsB,AAAiD,CAAA,uBAAjD,CAAC;YAAEpE,SAAS,EAAEoB,YAAY;YAAES,OAAO;YAAEa,SAAS;SAAE,CAAC,CAAC;KAC/E;CACF;AAED;;;;;;;GAOG,CACH,eAAed,qBAAqB,CAACyC,YAAoB,EAAEC,YAAoB,EAAE;IAC/E,IAAIf,GAAE,QAAA,CAACgB,UAAU,CAACF,YAAY,CAAC,EAAE;QAC/B,MAAMG,CAAAA,GAAAA,IAAS,AAA4B,CAAA,UAA5B,CAACH,YAAY,EAAEC,YAAY,CAAC,CAAC;KAC7C;CACF"}
1
+ {"version":3,"sources":["../../../src/export/exportApp.ts"],"sourcesContent":["import chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { createBundlesAsync } from './createBundles';\nimport { exportAssetsAsync, exportCssAssetsAsync } from './exportAssets';\nimport { unstable_exportStaticAsync } from './exportStaticAsync';\nimport { getVirtualFaviconAssetsAsync } from './favicon';\nimport { getPublicExpoManifestAsync } from './getPublicExpoManifest';\nimport { persistMetroAssetsAsync } from './persistMetroAssets';\nimport { printBundleSizes } from './printBundleSizes';\nimport { Options } from './resolveOptions';\nimport {\n writeAssetMapAsync,\n writeBundlesAsync,\n writeDebugHtmlAsync,\n writeMetadataJsonAsync,\n writeSourceMapsAsync,\n} from './writeContents';\nimport * as Log from '../log';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../start/server/webTemplate';\nimport { copyAsync, ensureDirectoryAsync } from '../utils/dir';\nimport { env } from '../utils/env';\nimport { setNodeEnv } from '../utils/nodeEnv';\n\n/**\n * The structure of the outputDir will be:\n *\n * ```\n * ├── assets\n * │ └── *\n * ├── bundles\n * │ ├── android-01ee6e3ab3e8c16a4d926c91808d5320.js\n * │ └── ios-ee8206cc754d3f7aa9123b7f909d94ea.js\n * └── metadata.json\n * ```\n */\nexport async function exportAppAsync(\n projectRoot: string,\n {\n platforms,\n outputDir,\n clear,\n dev,\n dumpAssetmap,\n dumpSourcemap,\n minify,\n }: Pick<\n Options,\n 'dumpAssetmap' | 'dumpSourcemap' | 'dev' | 'clear' | 'outputDir' | 'platforms' | 'minify'\n >\n): Promise<void> {\n setNodeEnv(dev ? 'development' : 'production');\n require('@expo/env').load(projectRoot);\n\n const exp = await getPublicExpoManifestAsync(projectRoot);\n\n const useServerRendering = ['static', 'server'].includes(exp.web?.output ?? '');\n const basePath = (exp.experiments?.basePath?.replace(/\\/+$/, '') ?? '').trim();\n\n // Print out logs\n if (basePath) {\n Log.log();\n Log.log(chalk.gray`Using (experimental) base path: ${basePath}`);\n // Warn if not using an absolute path.\n if (!basePath.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 publicPath = path.resolve(projectRoot, env.EXPO_PUBLIC_FOLDER);\n\n const outputPath = path.resolve(projectRoot, outputDir);\n const staticFolder = outputPath;\n const assetsPath = path.join(staticFolder, 'assets');\n const bundlesPath = path.join(staticFolder, 'bundles');\n\n await Promise.all([assetsPath, bundlesPath].map(ensureDirectoryAsync));\n\n await copyPublicFolderAsync(publicPath, staticFolder);\n\n // Run metro bundler and create the JS bundles/source maps.\n const bundles = await createBundlesAsync(\n projectRoot,\n { resetCache: !!clear },\n {\n platforms,\n minify,\n // TODO: Breaks asset exports\n // platforms: useServerRendering\n // ? platforms.filter((platform) => platform !== 'web')\n // : platforms,\n dev,\n // TODO: Disable source map generation if we aren't outputting them.\n }\n );\n\n const bundleEntries = Object.entries(bundles);\n if (bundleEntries.length) {\n // Log bundle size info to the user\n printBundleSizes(\n Object.fromEntries(\n bundleEntries.map(([key, value]) => {\n if (!dumpSourcemap) {\n return [\n key,\n {\n ...value,\n // Remove source maps from the bundles if they aren't going to be written.\n map: undefined,\n },\n ];\n }\n\n return [key, value];\n })\n )\n );\n }\n\n // Write the JS bundles to disk, and get the bundle file names (this could change with async chunk loading support).\n const { hashes, fileNames } = await writeBundlesAsync({\n bundles,\n useServerRendering,\n outputDir: bundlesPath,\n });\n\n Log.log('Finished saving JS Bundles');\n\n if (platforms.includes('web')) {\n if (useServerRendering) {\n await unstable_exportStaticAsync(projectRoot, {\n outputDir: outputPath,\n minify,\n basePath,\n includeMaps: dumpSourcemap,\n // @ts-expect-error: server not on type yet\n exportServer: exp.web?.output === 'server',\n });\n Log.log('Finished saving static files');\n } else {\n const cssLinks = await exportCssAssetsAsync({\n outputDir,\n bundles,\n basePath,\n });\n let html = await createTemplateHtmlFromExpoConfigAsync(projectRoot, {\n scripts: [`${basePath}/bundles/${fileNames.web}`],\n cssLinks,\n });\n // Add the favicon assets to the HTML.\n const modifyHtml = await getVirtualFaviconAssetsAsync(projectRoot, {\n outputDir,\n basePath,\n });\n if (modifyHtml) {\n html = modifyHtml(html);\n }\n // Generate SPA-styled HTML file.\n // If web exists, then write the template HTML file.\n await fs.promises.writeFile(path.join(staticFolder, 'index.html'), html);\n }\n\n // TODO: Use a different mechanism for static web.\n if (bundles.web) {\n // Save assets like a typical bundler, preserving the file paths on web.\n // TODO: Update React Native Web to support loading files from asset hashes.\n await persistMetroAssetsAsync(bundles.web.assets, {\n platform: 'web',\n outputDirectory: staticFolder,\n basePath,\n });\n }\n }\n\n // Can be empty during web-only SSG.\n // TODO: Use same asset system across platforms again.\n if (Object.keys(fileNames).length) {\n const { assets } = await exportAssetsAsync(projectRoot, {\n exp,\n outputDir: staticFolder,\n bundles,\n });\n\n if (dumpAssetmap) {\n Log.log('Dumping asset map');\n await writeAssetMapAsync({ outputDir: staticFolder, assets });\n }\n // build source maps\n if (dumpSourcemap) {\n Log.log('Dumping source maps');\n await writeSourceMapsAsync({\n bundles,\n hashes,\n outputDir: bundlesPath,\n fileNames,\n });\n\n Log.log('Preparing additional debugging files');\n // If we output source maps, then add a debug HTML file which the user can open in\n // the web browser to inspect the output like web.\n await writeDebugHtmlAsync({\n outputDir: staticFolder,\n fileNames,\n });\n }\n\n // Generate a `metadata.json` and the export is complete.\n await writeMetadataJsonAsync({ outputDir: staticFolder, bundles, fileNames });\n }\n}\n\n/**\n * Copy the contents of the public folder into the output folder.\n * This enables users to add static files like `favicon.ico` or `serve.json`.\n *\n * The contents of this folder are completely universal since they refer to\n * static network requests which fall outside the scope of React Native's magic\n * platform resolution patterns.\n */\nasync function copyPublicFolderAsync(publicFolder: string, outputFolder: string) {\n if (fs.existsSync(publicFolder)) {\n await copyAsync(publicFolder, outputFolder);\n }\n}\n"],"names":["exportAppAsync","Log","projectRoot","platforms","outputDir","clear","dev","dumpAssetmap","dumpSourcemap","minify","exp","setNodeEnv","require","load","getPublicExpoManifestAsync","useServerRendering","includes","web","output","basePath","experiments","replace","trim","log","chalk","gray","startsWith","yellow","publicPath","path","resolve","env","EXPO_PUBLIC_FOLDER","outputPath","staticFolder","assetsPath","join","bundlesPath","Promise","all","map","ensureDirectoryAsync","copyPublicFolderAsync","bundles","createBundlesAsync","resetCache","bundleEntries","Object","entries","length","printBundleSizes","fromEntries","key","value","undefined","hashes","fileNames","writeBundlesAsync","unstable_exportStaticAsync","includeMaps","exportServer","cssLinks","exportCssAssetsAsync","html","createTemplateHtmlFromExpoConfigAsync","scripts","modifyHtml","getVirtualFaviconAssetsAsync","fs","promises","writeFile","persistMetroAssetsAsync","assets","platform","outputDirectory","keys","exportAssetsAsync","writeAssetMapAsync","writeSourceMapsAsync","writeDebugHtmlAsync","writeMetadataJsonAsync","publicFolder","outputFolder","existsSync","copyAsync"],"mappings":"AAAA;;;;QAqCsBA,cAAc,GAAdA,cAAc;AArClB,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEY,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;AACI,IAAA,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,CAAC;YAAE5E,SAAS,EAAE8B,YAAY;YAAES,OAAO;YAAEa,SAAS;SAAE,CAAC,CAAC;KAC/E;CACF;AAED;;;;;;;GAOG,CACH,eAAed,qBAAqB,CAACuC,YAAoB,EAAEC,YAAoB,EAAE;IAC/E,IAAId,GAAE,QAAA,CAACe,UAAU,CAACF,YAAY,CAAC,EAAE;QAC/B,MAAMG,CAAAA,GAAAA,IAAS,AAA4B,CAAA,UAA5B,CAACH,YAAY,EAAEC,YAAY,CAAC,CAAC;KAC7C;CACF"}
@@ -103,7 +103,7 @@ async function exportAssetsAsync(projectRoot, { exp , outputDir , bundles }) {
103
103
  assets
104
104
  };
105
105
  }
106
- async function exportCssAssetsAsync({ outputDir , bundles }) {
106
+ async function exportCssAssetsAsync({ outputDir , bundles , basePath }) {
107
107
  var ref;
108
108
  const assets = (0, _array).uniqBy(Object.values(bundles).flatMap((bundle)=>bundle.css
109
109
  ), (asset)=>asset.filename
@@ -115,7 +115,7 @@ async function exportCssAssetsAsync({ outputDir , bundles }) {
115
115
  });
116
116
  await Promise.all(assets.map((v)=>_fs.default.promises.writeFile(_path.default.join(outputDir, v.filename), v.source)
117
117
  ));
118
- return assets.map((v)=>"/" + v.filename
118
+ return assets.map((v)=>basePath + "/" + v.filename
119
119
  );
120
120
  }
121
121
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/exportAssets.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport { ModPlatform } from '@expo/config-plugins';\nimport fs from 'fs';\nimport minimatch from 'minimatch';\nimport path from 'path';\n\nimport { BundleOutput } from './fork-bundleAsync';\nimport { Asset, saveAssetsAsync } from './saveAssets';\nimport * as Log from '../log';\nimport { resolveGoogleServicesFile } from '../start/server/middleware/resolveAssets';\nimport { uniqBy } from '../utils/array';\n\nconst debug = require('debug')('expo:export:exportAssets') as typeof console.log;\n\n/**\n * Resolves the assetBundlePatterns from the manifest and returns a list of assets to bundle.\n *\n * @modifies {exp}\n */\nexport async function resolveAssetBundlePatternsAsync<T extends ExpoConfig>(\n projectRoot: string,\n exp: T,\n assets: Asset[]\n): Promise<Omit<T, 'assetBundlePatterns'> & { bundledAssets?: string[] }> {\n if (!exp.assetBundlePatterns?.length || !assets.length) {\n delete exp.assetBundlePatterns;\n return exp;\n }\n // Convert asset patterns to a list of asset strings that match them.\n // Assets strings are formatted as `asset_<hash>.<type>` and represent\n // the name that the file will have in the app bundle. The `asset_` prefix is\n // needed because android doesn't support assets that start with numbers.\n\n const fullPatterns: string[] = exp.assetBundlePatterns.map((p: string) =>\n path.join(projectRoot, p)\n );\n\n logPatterns(fullPatterns);\n\n const allBundledAssets = assets\n .map((asset) => {\n const shouldBundle = shouldBundleAsset(asset, fullPatterns);\n if (shouldBundle) {\n debug(`${shouldBundle ? 'Include' : 'Exclude'} asset ${asset.files?.[0]}`);\n return asset.fileHashes.map(\n (hash) => 'asset_' + hash + ('type' in asset && asset.type ? '.' + asset.type : '')\n );\n }\n return [];\n })\n .flat();\n\n // The assets returned by the RN packager has duplicates so make sure we\n // only bundle each once.\n (exp as any).bundledAssets = [...new Set(allBundledAssets)];\n delete exp.assetBundlePatterns;\n\n return exp;\n}\n\nfunction logPatterns(patterns: string[]) {\n // Only log the patterns in debug mode, if they aren't already defined in the app.json, then all files will be targeted.\n Log.log('\\nProcessing asset bundle patterns:');\n patterns.forEach((p) => Log.log('- ' + p));\n}\n\nfunction shouldBundleAsset(asset: Asset, patterns: string[]) {\n const file = asset.files?.[0];\n return !!(\n '__packager_asset' in asset &&\n asset.__packager_asset &&\n file &&\n patterns.some((pattern) => minimatch(file, pattern))\n );\n}\n\nexport async function exportAssetsAsync(\n projectRoot: string,\n {\n exp,\n outputDir,\n bundles,\n }: {\n exp: ExpoConfig;\n bundles: Partial<Record<ModPlatform, BundleOutput>>;\n outputDir: string;\n }\n) {\n const assets: Asset[] = uniqBy(\n Object.values(bundles).flatMap((bundle) => bundle!.assets),\n (asset) => asset.hash\n );\n\n if (assets[0]?.fileHashes) {\n Log.log('Saving assets');\n await saveAssetsAsync(projectRoot, { assets, outputDir });\n }\n\n // Add google services file if it exists\n await resolveGoogleServicesFile(projectRoot, exp);\n\n // Updates the manifest to reflect additional asset bundling + configs\n await resolveAssetBundlePatternsAsync(projectRoot, exp, assets);\n\n return { exp, assets };\n}\n\nexport async function exportCssAssetsAsync({\n outputDir,\n bundles,\n}: {\n bundles: Partial<Record<ModPlatform, BundleOutput>>;\n outputDir: string;\n}) {\n const assets = uniqBy(\n Object.values(bundles).flatMap((bundle) => bundle!.css),\n (asset) => asset.filename\n );\n\n const cssDirectory = assets[0]?.filename;\n if (!cssDirectory) return [];\n\n await fs.promises.mkdir(path.join(outputDir, path.dirname(cssDirectory)), { recursive: true });\n\n await Promise.all(\n assets.map((v) => fs.promises.writeFile(path.join(outputDir, v.filename), v.source))\n );\n\n return assets.map((v) => '/' + v.filename);\n}\n"],"names":["resolveAssetBundlePatternsAsync","exportAssetsAsync","exportCssAssetsAsync","Log","debug","require","projectRoot","exp","assets","assetBundlePatterns","length","fullPatterns","map","p","path","join","logPatterns","allBundledAssets","asset","shouldBundle","shouldBundleAsset","files","fileHashes","hash","type","flat","bundledAssets","Set","patterns","log","forEach","file","__packager_asset","some","pattern","minimatch","outputDir","bundles","uniqBy","Object","values","flatMap","bundle","saveAssetsAsync","resolveGoogleServicesFile","css","filename","cssDirectory","fs","promises","mkdir","dirname","recursive","Promise","all","v","writeFile","source"],"mappings":"AAAA;;;;QAmBsBA,+BAA+B,GAA/BA,+BAA+B;QAyD/BC,iBAAiB,GAAjBA,iBAAiB;QA+BjBC,oBAAoB,GAApBA,oBAAoB;AAzG3B,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACG,IAAA,UAAW,kCAAX,WAAW,EAAA;AAChB,IAAA,KAAM,kCAAN,MAAM,EAAA;AAGgB,IAAA,WAAc,WAAd,cAAc,CAAA;AACzCC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AAC2B,IAAA,cAA0C,WAA1C,0C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AEsC,QAAQ,AAAC;IACzC,IAAI,CAACC,YAAY,EAAE,OAAO,EAAE,CAAC;IAE7B,MAAMC,GAAE,QAAA,CAACC,QAAQ,CAACC,KAAK,CAACpC,KAAI,QAAA,CAACC,IAAI,CAACqB,SAAS,EAAEtB,KAAI,QAAA,CAACqC,OAAO,CAACJ,YAAY,CAAC,CAAC,EAAE;QAAEK,SAAS,EAAE,IAAI;KAAE,CAAC,CAAC;IAE/F,MAAMC,OAAO,CAACC,GAAG,CACf9C,MAAM,CAACI,GAAG,CAAC,CAAC2C,CAAC,GAAKP,GAAE,QAAA,CAACC,QAAQ,CAACO,SAAS,CAAC1C,KAAI,QAAA,CAACC,IAAI,CAACqB,SAAS,EAAEmB,CAAC,CAACT,QAAQ,CAAC,EAAES,CAAC,CAACE,MAAM,CAAC;IAAA,CAAC,CACrF,CAAC;IAEF,OAAOjD,MAAM,CAACI,GAAG,CAAC,CAAC2C,CAAC,GAAK,GAAG,GAAGA,CAAC,CAACT,QAAQ;IAAA,CAAC,CAAC;CAC5C"}
1
+ {"version":3,"sources":["../../../src/export/exportAssets.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport { ModPlatform } from '@expo/config-plugins';\nimport fs from 'fs';\nimport minimatch from 'minimatch';\nimport path from 'path';\n\nimport { BundleOutput } from './fork-bundleAsync';\nimport { Asset, saveAssetsAsync } from './saveAssets';\nimport * as Log from '../log';\nimport { resolveGoogleServicesFile } from '../start/server/middleware/resolveAssets';\nimport { uniqBy } from '../utils/array';\n\nconst debug = require('debug')('expo:export:exportAssets') as typeof console.log;\n\n/**\n * Resolves the assetBundlePatterns from the manifest and returns a list of assets to bundle.\n *\n * @modifies {exp}\n */\nexport async function resolveAssetBundlePatternsAsync<T extends ExpoConfig>(\n projectRoot: string,\n exp: T,\n assets: Asset[]\n): Promise<Omit<T, 'assetBundlePatterns'> & { bundledAssets?: string[] }> {\n if (!exp.assetBundlePatterns?.length || !assets.length) {\n delete exp.assetBundlePatterns;\n return exp;\n }\n // Convert asset patterns to a list of asset strings that match them.\n // Assets strings are formatted as `asset_<hash>.<type>` and represent\n // the name that the file will have in the app bundle. The `asset_` prefix is\n // needed because android doesn't support assets that start with numbers.\n\n const fullPatterns: string[] = exp.assetBundlePatterns.map((p: string) =>\n path.join(projectRoot, p)\n );\n\n logPatterns(fullPatterns);\n\n const allBundledAssets = assets\n .map((asset) => {\n const shouldBundle = shouldBundleAsset(asset, fullPatterns);\n if (shouldBundle) {\n debug(`${shouldBundle ? 'Include' : 'Exclude'} asset ${asset.files?.[0]}`);\n return asset.fileHashes.map(\n (hash) => 'asset_' + hash + ('type' in asset && asset.type ? '.' + asset.type : '')\n );\n }\n return [];\n })\n .flat();\n\n // The assets returned by the RN packager has duplicates so make sure we\n // only bundle each once.\n (exp as any).bundledAssets = [...new Set(allBundledAssets)];\n delete exp.assetBundlePatterns;\n\n return exp;\n}\n\nfunction logPatterns(patterns: string[]) {\n // Only log the patterns in debug mode, if they aren't already defined in the app.json, then all files will be targeted.\n Log.log('\\nProcessing asset bundle patterns:');\n patterns.forEach((p) => Log.log('- ' + p));\n}\n\nfunction shouldBundleAsset(asset: Asset, patterns: string[]) {\n const file = asset.files?.[0];\n return !!(\n '__packager_asset' in asset &&\n asset.__packager_asset &&\n file &&\n patterns.some((pattern) => minimatch(file, pattern))\n );\n}\n\nexport async function exportAssetsAsync(\n projectRoot: string,\n {\n exp,\n outputDir,\n bundles,\n }: {\n exp: ExpoConfig;\n bundles: Partial<Record<ModPlatform, BundleOutput>>;\n outputDir: string;\n }\n) {\n const assets: Asset[] = uniqBy(\n Object.values(bundles).flatMap((bundle) => bundle!.assets),\n (asset) => asset.hash\n );\n\n if (assets[0]?.fileHashes) {\n Log.log('Saving assets');\n await saveAssetsAsync(projectRoot, { assets, outputDir });\n }\n\n // Add google services file if it exists\n await resolveGoogleServicesFile(projectRoot, exp);\n\n // Updates the manifest to reflect additional asset bundling + configs\n await resolveAssetBundlePatternsAsync(projectRoot, exp, assets);\n\n return { exp, assets };\n}\n\nexport async function exportCssAssetsAsync({\n outputDir,\n bundles,\n basePath,\n}: {\n bundles: Partial<Record<ModPlatform, BundleOutput>>;\n outputDir: string;\n basePath: string;\n}) {\n const assets = uniqBy(\n Object.values(bundles).flatMap((bundle) => bundle!.css),\n (asset) => asset.filename\n );\n\n const cssDirectory = assets[0]?.filename;\n if (!cssDirectory) return [];\n\n await fs.promises.mkdir(path.join(outputDir, path.dirname(cssDirectory)), { recursive: true });\n\n await Promise.all(\n assets.map((v) => fs.promises.writeFile(path.join(outputDir, v.filename), v.source))\n );\n\n return assets.map((v) => basePath + '/' + v.filename);\n}\n"],"names":["resolveAssetBundlePatternsAsync","exportAssetsAsync","exportCssAssetsAsync","Log","debug","require","projectRoot","exp","assets","assetBundlePatterns","length","fullPatterns","map","p","path","join","logPatterns","allBundledAssets","asset","shouldBundle","shouldBundleAsset","files","fileHashes","hash","type","flat","bundledAssets","Set","patterns","log","forEach","file","__packager_asset","some","pattern","minimatch","outputDir","bundles","uniqBy","Object","values","flatMap","bundle","saveAssetsAsync","resolveGoogleServicesFile","basePath","css","filename","cssDirectory","fs","promises","mkdir","dirname","recursive","Promise","all","v","writeFile","source"],"mappings":"AAAA;;;;QAmBsBA,+BAA+B,GAA/BA,+BAA+B;QAyD/BC,iBAAiB,GAAjBA,iBAAiB;QA+BjBC,oBAAoB,GAApBA,oBAAoB;AAzG3B,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACG,IAAA,UAAW,kCAAX,WAAW,EAAA;AAChB,IAAA,KAAM,kCAAN,MAAM,EAAA;AAGgB,IAAA,WAAc,WAAd,cAAc,CAAA;AACzCC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AAC2B,IAAA,cAA0C,WAA1C,0CAA0C,CAAA;AAC7D,IAAA,MAAgB,WAAhB,gBAAgB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEvC,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,0BAA0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AI,QAAA,CAACC,IAAI,CAACqB,SAAS,EAAEtB,KAAI,QAAA,CAACsC,OAAO,CAACJ,YAAY,CAAC,CAAC,EAAE;QAAEK,SAAS,EAAE,IAAI;KAAE,CAAC,CAAC;IAE/F,MAAMC,OAAO,CAACC,GAAG,CACf/C,MAAM,CAACI,GAAG,CAAC,CAAC4C,CAAC,GAAKP,GAAE,QAAA,CAACC,QAAQ,CAACO,SAAS,CAAC3C,KAAI,QAAA,CAACC,IAAI,CAACqB,SAAS,EAAEoB,CAAC,CAACT,QAAQ,CAAC,EAAES,CAAC,CAACE,MAAM,CAAC;IAAA,CAAC,CACrF,CAAC;IAEF,OAAOlD,MAAM,CAACI,GAAG,CAAC,CAAC4C,CAAC,GAAKX,QAAQ,GAAG,GAAG,GAAGW,CAAC,CAACT,QAAQ;IAAA,CAAC,CAAC;CACvD"}
@@ -0,0 +1,204 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.importHermesCommandFromProject = importHermesCommandFromProject;
6
+ exports.isEnableHermesManaged = isEnableHermesManaged;
7
+ exports.buildHermesBundleAsync = buildHermesBundleAsync;
8
+ exports.createHermesSourcemapAsync = createHermesSourcemapAsync;
9
+ exports.parseGradleProperties = parseGradleProperties;
10
+ exports.maybeThrowFromInconsistentEngineAsync = maybeThrowFromInconsistentEngineAsync;
11
+ exports.maybeInconsistentEngineAndroidAsync = maybeInconsistentEngineAndroidAsync;
12
+ exports.maybeInconsistentEngineIosAsync = maybeInconsistentEngineIosAsync;
13
+ exports.isHermesBytecodeBundleAsync = isHermesBytecodeBundleAsync;
14
+ exports.getHermesBytecodeBundleVersionAsync = getHermesBytecodeBundleVersionAsync;
15
+ var _spawnAsync = _interopRequireDefault(require("@expo/spawn-async"));
16
+ var _fsExtra = _interopRequireDefault(require("fs-extra"));
17
+ var _os = _interopRequireDefault(require("os"));
18
+ var _path = _interopRequireDefault(require("path"));
19
+ var _process = _interopRequireDefault(require("process"));
20
+ var _resolveFromProject = require("../start/server/metro/resolveFromProject");
21
+ function _interopRequireDefault(obj) {
22
+ return obj && obj.__esModule ? obj : {
23
+ default: obj
24
+ };
25
+ }
26
+ function importHermesCommandFromProject(projectRoot) {
27
+ const platformExecutable = getHermesCommandPlatform();
28
+ const hermescLocations = [
29
+ // Override hermesc dir by environment variables
30
+ _process.default.env["REACT_NATIVE_OVERRIDE_HERMES_DIR"] ? `${_process.default.env["REACT_NATIVE_OVERRIDE_HERMES_DIR"]}/build/bin/hermesc` : "",
31
+ // Building hermes from source
32
+ "react-native/ReactAndroid/hermes-engine/build/hermes/bin/hermesc",
33
+ // Prebuilt hermesc in official react-native 0.69+
34
+ `react-native/sdks/hermesc/${platformExecutable}`,
35
+ // Legacy hermes-engine package
36
+ `hermes-engine/${platformExecutable}`,
37
+ ];
38
+ for (const location of hermescLocations){
39
+ try {
40
+ return (0, _resolveFromProject).resolveFromProject(projectRoot, location);
41
+ } catch {}
42
+ }
43
+ throw new Error("Cannot find the hermesc executable.");
44
+ }
45
+ function getHermesCommandPlatform() {
46
+ switch(_os.default.platform()){
47
+ case "darwin":
48
+ return "osx-bin/hermesc";
49
+ case "linux":
50
+ return "linux64-bin/hermesc";
51
+ case "win32":
52
+ return "win64-bin/hermesc.exe";
53
+ default:
54
+ throw new Error(`Unsupported host platform for Hermes compiler: ${_os.default.platform()}`);
55
+ }
56
+ }
57
+ function isEnableHermesManaged(expoConfig, platform) {
58
+ switch(platform){
59
+ case "android":
60
+ {
61
+ var ref;
62
+ var ref1;
63
+ return ((ref1 = (ref = expoConfig.android) == null ? void 0 : ref.jsEngine) != null ? ref1 : expoConfig.jsEngine) !== "jsc";
64
+ }
65
+ case "ios":
66
+ {
67
+ var ref2;
68
+ var ref3;
69
+ return ((ref3 = (ref2 = expoConfig.ios) == null ? void 0 : ref2.jsEngine) != null ? ref3 : expoConfig.jsEngine) !== "jsc";
70
+ }
71
+ default:
72
+ return false;
73
+ }
74
+ }
75
+ async function buildHermesBundleAsync(projectRoot, code, map, optimize = false) {
76
+ const tempDir = _path.default.join(_os.default.tmpdir(), `expo-bundler-${_process.default.pid}`);
77
+ await _fsExtra.default.ensureDir(tempDir);
78
+ try {
79
+ const tempBundleFile = _path.default.join(tempDir, "index.bundle");
80
+ const tempSourcemapFile = _path.default.join(tempDir, "index.bundle.map");
81
+ await _fsExtra.default.writeFile(tempBundleFile, code);
82
+ await _fsExtra.default.writeFile(tempSourcemapFile, map);
83
+ const tempHbcFile = _path.default.join(tempDir, "index.hbc");
84
+ const hermesCommand = importHermesCommandFromProject(projectRoot);
85
+ const args = [
86
+ "-emit-binary",
87
+ "-out",
88
+ tempHbcFile,
89
+ tempBundleFile,
90
+ "-output-source-map"
91
+ ];
92
+ if (optimize) {
93
+ args.push("-O");
94
+ }
95
+ await (0, _spawnAsync).default(hermesCommand, args);
96
+ const [hbc, sourcemap] = await Promise.all([
97
+ _fsExtra.default.readFile(tempHbcFile),
98
+ createHermesSourcemapAsync(projectRoot, map, `${tempHbcFile}.map`),
99
+ ]);
100
+ return {
101
+ hbc,
102
+ sourcemap
103
+ };
104
+ } finally{
105
+ await _fsExtra.default.remove(tempDir);
106
+ }
107
+ }
108
+ async function createHermesSourcemapAsync(projectRoot, sourcemap, hermesMapFile) {
109
+ const composeSourceMaps = (0, _resolveFromProject).importMetroSourceMapComposeSourceMapsFromProject(projectRoot);
110
+ const bundlerSourcemap = JSON.parse(sourcemap);
111
+ const hermesSourcemap = await _fsExtra.default.readJSON(hermesMapFile);
112
+ return JSON.stringify(composeSourceMaps([
113
+ bundlerSourcemap,
114
+ hermesSourcemap
115
+ ]));
116
+ }
117
+ function parseGradleProperties(content) {
118
+ const result = {};
119
+ for (let line of content.split("\n")){
120
+ line = line.trim();
121
+ if (!line || line.startsWith("#")) {
122
+ continue;
123
+ }
124
+ const sepIndex = line.indexOf("=");
125
+ const key = line.substr(0, sepIndex);
126
+ const value = line.substr(sepIndex + 1);
127
+ result[key] = value;
128
+ }
129
+ return result;
130
+ }
131
+ async function maybeThrowFromInconsistentEngineAsync(projectRoot, configFilePath, platform, isHermesManaged) {
132
+ const configFileName = _path.default.basename(configFilePath);
133
+ if (platform === "android" && await maybeInconsistentEngineAndroidAsync(projectRoot, isHermesManaged)) {
134
+ throw new Error(`JavaScript engine configuration is inconsistent between ${configFileName} and Android native project.\n` + `In ${configFileName}: Hermes is ${isHermesManaged ? "enabled" : "not enabled"}\n` + `In Android native project: Hermes is ${isHermesManaged ? "not enabled" : "enabled"}\n` + `Please check the following files for inconsistencies:\n` + ` - ${configFilePath}\n` + ` - ${_path.default.join(projectRoot, "android", "gradle.properties")}\n` + ` - ${_path.default.join(projectRoot, "android", "app", "build.gradle")}\n` + "Learn more: https://expo.fyi/hermes-android-config");
135
+ }
136
+ if (platform === "ios" && await maybeInconsistentEngineIosAsync(projectRoot, isHermesManaged)) {
137
+ throw new Error(`JavaScript engine configuration is inconsistent between ${configFileName} and iOS native project.\n` + `In ${configFileName}: Hermes is ${isHermesManaged ? "enabled" : "not enabled"}\n` + `In iOS native project: Hermes is ${isHermesManaged ? "not enabled" : "enabled"}\n` + `Please check the following files for inconsistencies:\n` + ` - ${configFilePath}\n` + ` - ${_path.default.join(projectRoot, "ios", "Podfile")}\n` + ` - ${_path.default.join(projectRoot, "ios", "Podfile.properties.json")}\n` + "Learn more: https://expo.fyi/hermes-ios-config");
138
+ }
139
+ }
140
+ async function maybeInconsistentEngineAndroidAsync(projectRoot, isHermesManaged) {
141
+ // Trying best to check android native project if by chance to be consistent between app config
142
+ // Check gradle.properties from prebuild template
143
+ const gradlePropertiesPath = _path.default.join(projectRoot, "android", "gradle.properties");
144
+ if (_fsExtra.default.existsSync(gradlePropertiesPath)) {
145
+ const props = parseGradleProperties(await _fsExtra.default.readFile(gradlePropertiesPath, "utf8"));
146
+ const isHermesBare = props["hermesEnabled"] === "true";
147
+ if (isHermesManaged !== isHermesBare) {
148
+ return true;
149
+ }
150
+ }
151
+ return false;
152
+ }
153
+ async function maybeInconsistentEngineIosAsync(projectRoot, isHermesManaged) {
154
+ // Trying best to check ios native project if by chance to be consistent between app config
155
+ // Check ios/Podfile for ":hermes_enabled => true"
156
+ const podfilePath = _path.default.join(projectRoot, "ios", "Podfile");
157
+ if (_fsExtra.default.existsSync(podfilePath)) {
158
+ const content = await _fsExtra.default.readFile(podfilePath, "utf8");
159
+ const isPropsReference = content.search(/^\s*:hermes_enabled\s*=>\s*podfile_properties\['expo.jsEngine'\]\s*==\s*nil\s*\|\|\s*podfile_properties\['expo.jsEngine'\]\s*==\s*'hermes',?/m) >= 0;
160
+ const isHermesBare = content.search(/^\s*:hermes_enabled\s*=>\s*true,?\s+/m) >= 0;
161
+ if (!isPropsReference && isHermesManaged !== isHermesBare) {
162
+ return true;
163
+ }
164
+ }
165
+ // Check Podfile.properties.json from prebuild template
166
+ const podfilePropertiesPath = _path.default.join(projectRoot, "ios", "Podfile.properties.json");
167
+ if (_fsExtra.default.existsSync(podfilePropertiesPath)) {
168
+ const props = await parsePodfilePropertiesAsync(podfilePropertiesPath);
169
+ const isHermesBare = props["expo.jsEngine"] === "hermes";
170
+ if (isHermesManaged !== isHermesBare) {
171
+ return true;
172
+ }
173
+ }
174
+ return false;
175
+ }
176
+ // https://github.com/facebook/hermes/blob/release-v0.5/include/hermes/BCGen/HBC/BytecodeFileFormat.h#L24-L25
177
+ const HERMES_MAGIC_HEADER = "c61fbc03c103191f";
178
+ async function isHermesBytecodeBundleAsync(file) {
179
+ const header = await readHermesHeaderAsync(file);
180
+ return header.slice(0, 8).toString("hex") === HERMES_MAGIC_HEADER;
181
+ }
182
+ async function getHermesBytecodeBundleVersionAsync(file) {
183
+ const header = await readHermesHeaderAsync(file);
184
+ if (header.slice(0, 8).toString("hex") !== HERMES_MAGIC_HEADER) {
185
+ throw new Error("Invalid hermes bundle file");
186
+ }
187
+ return header.readUInt32LE(8);
188
+ }
189
+ async function readHermesHeaderAsync(file) {
190
+ const fd = await _fsExtra.default.open(file, "r");
191
+ const buffer = Buffer.alloc(12);
192
+ await _fsExtra.default.read(fd, buffer, 0, 12, null);
193
+ await _fsExtra.default.close(fd);
194
+ return buffer;
195
+ }
196
+ async function parsePodfilePropertiesAsync(podfilePropertiesPath) {
197
+ try {
198
+ return JSON.parse(await _fsExtra.default.readFile(podfilePropertiesPath, "utf8"));
199
+ } catch {
200
+ return {};
201
+ }
202
+ }
203
+
204
+ //# sourceMappingURL=exportHermes.js.map