@expo/cli 0.13.2 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/build/bin/cli +30 -27
  2. package/build/bin/cli.map +1 -1
  3. package/build/src/api/getVersions.js.map +1 -1
  4. package/build/src/api/rest/cache/response.js.map +1 -1
  5. package/build/src/api/rest/client.js +2 -2
  6. package/build/src/api/rest/client.js.map +1 -1
  7. package/build/src/config/configAsync.js +1 -1
  8. package/build/src/config/configAsync.js.map +1 -1
  9. package/build/src/config/index.js +2 -2
  10. package/build/src/config/index.js.map +1 -1
  11. package/build/src/customize/generate.js +1 -1
  12. package/build/src/customize/generate.js.map +1 -1
  13. package/build/src/customize/typescript.js +6 -4
  14. package/build/src/customize/typescript.js.map +1 -1
  15. package/build/src/export/createMetadataJson.js +3 -2
  16. package/build/src/export/createMetadataJson.js.map +1 -1
  17. package/build/src/export/embed/exportEmbedAsync.js +44 -17
  18. package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
  19. package/build/src/export/embed/index.js +4 -4
  20. package/build/src/export/embed/index.js.map +1 -1
  21. package/build/src/export/embed/resolveOptions.js +3 -3
  22. package/build/src/export/embed/resolveOptions.js.map +1 -1
  23. package/build/src/export/exportApp.js +74 -83
  24. package/build/src/export/exportApp.js.map +1 -1
  25. package/build/src/export/exportAssets.js +81 -21
  26. package/build/src/export/exportAssets.js.map +1 -1
  27. package/build/src/export/exportHermes.js +24 -14
  28. package/build/src/export/exportHermes.js.map +1 -1
  29. package/build/src/export/exportStaticAsync.js +109 -58
  30. package/build/src/export/exportStaticAsync.js.map +1 -1
  31. package/build/src/export/favicon.js +2 -2
  32. package/build/src/export/favicon.js.map +1 -1
  33. package/build/src/export/fork-bundleAsync.js +56 -23
  34. package/build/src/export/fork-bundleAsync.js.map +1 -1
  35. package/build/src/export/index.js +11 -9
  36. package/build/src/export/index.js.map +1 -1
  37. package/build/src/export/metroAssetLocalPath.js +101 -0
  38. package/build/src/export/metroAssetLocalPath.js.map +1 -0
  39. package/build/src/export/persistMetroAssets.js +94 -21
  40. package/build/src/export/persistMetroAssets.js.map +1 -1
  41. package/build/src/export/resolveOptions.js +1 -1
  42. package/build/src/export/resolveOptions.js.map +1 -1
  43. package/build/src/export/saveAssets.js +9 -48
  44. package/build/src/export/saveAssets.js.map +1 -1
  45. package/build/src/export/web/exportWebAsync.js +1 -1
  46. package/build/src/export/web/exportWebAsync.js.map +1 -1
  47. package/build/src/export/web/index.js +2 -2
  48. package/build/src/export/web/index.js.map +1 -1
  49. package/build/src/export/writeContents.js +6 -3
  50. package/build/src/export/writeContents.js.map +1 -1
  51. package/build/src/install/applyPlugins.js +52 -0
  52. package/build/src/install/applyPlugins.js.map +1 -0
  53. package/build/src/install/checkPackages.js +2 -2
  54. package/build/src/install/checkPackages.js.map +1 -1
  55. package/build/src/install/fixPackages.js +84 -0
  56. package/build/src/install/fixPackages.js.map +1 -0
  57. package/build/src/install/installAsync.js +32 -61
  58. package/build/src/install/installAsync.js.map +1 -1
  59. package/build/src/install/installExpoPackage.js +79 -0
  60. package/build/src/install/installExpoPackage.js.map +1 -0
  61. package/build/src/login/index.js +1 -1
  62. package/build/src/login/index.js.map +1 -1
  63. package/build/src/logout/index.js +1 -1
  64. package/build/src/logout/index.js.map +1 -1
  65. package/build/src/prebuild/clearNativeFolder.js +1 -1
  66. package/build/src/prebuild/clearNativeFolder.js.map +1 -1
  67. package/build/src/prebuild/configureProjectAsync.js +3 -3
  68. package/build/src/prebuild/configureProjectAsync.js.map +1 -1
  69. package/build/src/prebuild/copyTemplateFiles.js +21 -30
  70. package/build/src/prebuild/copyTemplateFiles.js.map +1 -1
  71. package/build/src/prebuild/index.js +3 -3
  72. package/build/src/prebuild/index.js.map +1 -1
  73. package/build/src/prebuild/prebuildAsync.js +39 -17
  74. package/build/src/prebuild/prebuildAsync.js.map +1 -1
  75. package/build/src/prebuild/resolveOptions.js +2 -2
  76. package/build/src/prebuild/resolveOptions.js.map +1 -1
  77. package/build/src/prebuild/updateFromTemplate.js +6 -6
  78. package/build/src/prebuild/updateFromTemplate.js.map +1 -1
  79. package/build/src/prebuild/updatePackageJson.js +49 -36
  80. package/build/src/prebuild/updatePackageJson.js.map +1 -1
  81. package/build/src/prebuild/validateTemplatePlatforms.js +2 -2
  82. package/build/src/prebuild/validateTemplatePlatforms.js.map +1 -1
  83. package/build/src/register/index.js +1 -1
  84. package/build/src/register/index.js.map +1 -1
  85. package/build/src/run/android/index.js +2 -2
  86. package/build/src/run/android/index.js.map +1 -1
  87. package/build/src/run/ios/appleDevice/AppleDevice.js +35 -2
  88. package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -1
  89. package/build/src/run/ios/index.js +2 -2
  90. package/build/src/run/ios/index.js.map +1 -1
  91. package/build/src/start/doctor/dependencies/getVersionedPackages.js +12 -4
  92. package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
  93. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +20 -3
  94. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
  95. package/build/src/start/index.js +3 -3
  96. package/build/src/start/index.js.map +1 -1
  97. package/build/src/start/interface/interactiveActions.js +30 -11
  98. package/build/src/start/interface/interactiveActions.js.map +1 -1
  99. package/build/src/start/server/BundlerDevServer.js +14 -10
  100. package/build/src/start/server/BundlerDevServer.js.map +1 -1
  101. package/build/src/start/server/DevServerManager.js +6 -1
  102. package/build/src/start/server/DevServerManager.js.map +1 -1
  103. package/build/src/start/server/DevToolsPluginManager.js +63 -0
  104. package/build/src/start/server/DevToolsPluginManager.js.map +1 -0
  105. package/build/src/start/server/getStaticRenderFunctions.js +21 -20
  106. package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
  107. package/build/src/start/server/metro/MetroBundlerDevServer.js +67 -64
  108. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  109. package/build/src/start/server/metro/bundleApiRoutes.js +4 -19
  110. package/build/src/start/server/metro/bundleApiRoutes.js.map +1 -1
  111. package/build/src/start/server/metro/createExpoMetroResolver.js +187 -0
  112. package/build/src/start/server/metro/createExpoMetroResolver.js.map +1 -0
  113. package/build/src/start/server/metro/createJResolver.js +149 -0
  114. package/build/src/start/server/metro/createJResolver.js.map +1 -0
  115. package/build/src/start/server/metro/createServerRouteMiddleware.js +13 -1
  116. package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
  117. package/build/src/start/server/metro/externals.js +25 -3
  118. package/build/src/start/server/metro/externals.js.map +1 -1
  119. package/build/src/start/server/metro/fetchRouterManifest.js.map +1 -1
  120. package/build/src/start/server/metro/formatFileCandidates.js +72 -0
  121. package/build/src/start/server/metro/formatFileCandidates.js.map +1 -0
  122. package/build/src/start/server/metro/inspector-proxy/device.js +3 -1
  123. package/build/src/start/server/metro/inspector-proxy/device.js.map +1 -1
  124. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerGetPossibleBreakpoints.js +3 -4
  125. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerGetPossibleBreakpoints.js.map +1 -1
  126. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeCallFunctionOn.js +24 -0
  127. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeCallFunctionOn.js.map +1 -0
  128. package/build/src/start/server/metro/inspector-proxy/handlers/utils.js +11 -0
  129. package/build/src/start/server/metro/inspector-proxy/handlers/utils.js.map +1 -0
  130. package/build/src/start/server/metro/inspector-proxy/index.js +10 -7
  131. package/build/src/start/server/metro/inspector-proxy/index.js.map +1 -1
  132. package/build/src/start/server/metro/instantiateMetro.js +37 -16
  133. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  134. package/build/src/start/server/metro/metroErrorInterface.js +3 -2
  135. package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
  136. package/build/src/start/server/metro/router.js +6 -3
  137. package/build/src/start/server/metro/router.js.map +1 -1
  138. package/build/src/start/server/metro/runServer-fork.js +19 -10
  139. package/build/src/start/server/metro/runServer-fork.js.map +1 -1
  140. package/build/src/start/server/metro/serializeHtml.js +43 -0
  141. package/build/src/start/server/metro/serializeHtml.js.map +1 -0
  142. package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js +1 -2
  143. package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js.map +1 -1
  144. package/build/src/start/server/metro/withMetroMultiPlatform.js +268 -191
  145. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  146. package/build/src/start/server/metro/withMetroResolvers.js +114 -40
  147. package/build/src/start/server/metro/withMetroResolvers.js.map +1 -1
  148. package/build/src/start/server/middleware/DevToolsPluginMiddleware.js +61 -0
  149. package/build/src/start/server/middleware/DevToolsPluginMiddleware.js.map +1 -0
  150. package/build/src/start/server/middleware/ExpoMiddleware.js +2 -2
  151. package/build/src/start/server/middleware/ExpoMiddleware.js.map +1 -1
  152. package/build/src/start/server/middleware/ManifestMiddleware.js +45 -68
  153. package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
  154. package/build/src/start/server/middleware/inspector/JsInspector.js +1 -1
  155. package/build/src/start/server/middleware/inspector/JsInspector.js.map +1 -1
  156. package/build/src/start/server/middleware/inspector/LaunchBrowser.js +30 -26
  157. package/build/src/start/server/middleware/inspector/LaunchBrowser.js.map +1 -1
  158. package/build/src/start/server/middleware/inspector/LaunchBrowser.types.js +7 -7
  159. package/build/src/start/server/middleware/inspector/LaunchBrowser.types.js.map +1 -1
  160. package/build/src/start/server/middleware/inspector/LaunchBrowserImplLinux.js +5 -2
  161. package/build/src/start/server/middleware/inspector/LaunchBrowserImplLinux.js.map +1 -1
  162. package/build/src/start/server/middleware/inspector/LaunchBrowserImplMacOS.js +3 -2
  163. package/build/src/start/server/middleware/inspector/LaunchBrowserImplMacOS.js.map +1 -1
  164. package/build/src/start/server/middleware/inspector/LaunchBrowserImplWindows.js +8 -7
  165. package/build/src/start/server/middleware/inspector/LaunchBrowserImplWindows.js.map +1 -1
  166. package/build/src/start/server/middleware/metroOptions.js +123 -0
  167. package/build/src/start/server/middleware/metroOptions.js.map +1 -0
  168. package/build/src/start/server/middleware/resolveAssets.js.map +1 -1
  169. package/build/src/start/server/type-generation/__typetests__/fixtures/basic.js.map +1 -1
  170. package/build/src/start/server/type-generation/expo-env.js +1 -1
  171. package/build/src/start/server/type-generation/expo-env.js.map +1 -1
  172. package/build/src/start/server/type-generation/routes.js +1 -0
  173. package/build/src/start/server/type-generation/routes.js.map +1 -1
  174. package/build/src/utils/analytics/getMetroDebugProperties.js +1 -2
  175. package/build/src/utils/analytics/getMetroDebugProperties.js.map +1 -1
  176. package/build/src/utils/analytics/getMetroProperties.js +1 -2
  177. package/build/src/utils/analytics/getMetroProperties.js.map +1 -1
  178. package/build/src/utils/analytics/rudderstackClient.js +2 -2
  179. package/build/src/utils/args.js +4 -2
  180. package/build/src/utils/args.js.map +1 -1
  181. package/build/src/utils/cocoapods.js +2 -1
  182. package/build/src/utils/cocoapods.js.map +1 -1
  183. package/build/src/utils/dir.js +18 -8
  184. package/build/src/utils/dir.js.map +1 -1
  185. package/build/src/utils/env.js +6 -0
  186. package/build/src/utils/env.js.map +1 -1
  187. package/build/src/utils/getOrPromptApplicationId.js +2 -4
  188. package/build/src/utils/getOrPromptApplicationId.js.map +1 -1
  189. package/build/src/utils/prompts.js +1 -28
  190. package/build/src/utils/prompts.js.map +1 -1
  191. package/build/src/whoami/index.js +1 -1
  192. package/build/src/whoami/index.js.map +1 -1
  193. package/package.json +16 -16
  194. package/static/shims/react-native-web/dist/cjs/exports/AppRegistry/AppContainer.js +13 -0
  195. package/static/shims/react-native-web/dist/cjs/exports/BackHandler/index.js +10 -0
  196. package/static/shims/react-native-web/dist/exports/AppRegistry/AppContainer.js +12 -0
  197. package/static/shims/react-native-web/dist/exports/BackHandler/index.js +7 -0
  198. package/build/src/export/createBundles.js +0 -37
  199. package/build/src/export/createBundles.js.map +0 -1
  200. package/build/src/start/server/metro/resolveFromProject.js +0 -90
  201. package/build/src/start/server/metro/resolveFromProject.js.map +0 -1
  202. package/build/src/start/server/middleware/resolveEntryPoint.js +0 -42
  203. package/build/src/start/server/middleware/resolveEntryPoint.js.map +0 -1
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  exports.unstable_exportStaticAsync = unstable_exportStaticAsync;
6
6
  exports.getFilesToExportFromServerAsync = getFilesToExportFromServerAsync;
7
7
  exports.exportFromServerAsync = exportFromServerAsync;
8
+ exports.getFilesFromSerialAssets = getFilesFromSerialAssets;
9
+ exports.persistMetroFilesAsync = persistMetroFilesAsync;
8
10
  exports.modifyBundlesWithSourceMaps = modifyBundlesWithSourceMaps;
9
11
  exports.getHtmlFiles = getHtmlFiles;
10
12
  exports.getPathVariations = getPathVariations;
@@ -16,12 +18,15 @@ var _path = _interopRequireDefault(require("path"));
16
18
  var _prettyBytes = _interopRequireDefault(require("pretty-bytes"));
17
19
  var _util = require("util");
18
20
  var _favicon = require("./favicon");
21
+ var _persistMetroAssets = require("./persistMetroAssets");
19
22
  var _log = require("../log");
20
23
  var _devServerManager = require("../start/server/DevServerManager");
21
24
  var _metroBundlerDevServer = require("../start/server/metro/MetroBundlerDevServer");
22
25
  var _metroErrorInterface = require("../start/server/metro/metroErrorInterface");
23
26
  var _router = require("../start/server/metro/router");
27
+ var _serializeHtml = require("../start/server/metro/serializeHtml");
24
28
  var _link = require("../utils/link");
29
+ var _port = require("../utils/port");
25
30
  function _interopRequireDefault(obj) {
26
31
  return obj && obj.__esModule ? obj : {
27
32
  default: obj
@@ -30,18 +35,24 @@ function _interopRequireDefault(obj) {
30
35
  const debug = require("debug")("expo:export:generateStaticRoutes");
31
36
  async function unstable_exportStaticAsync(projectRoot, options) {
32
37
  _log.Log.warn(`Experimental static rendering is enabled. ` + (0, _link).learnMore("https://docs.expo.dev/router/reference/static-rendering/"));
38
+ // Useful for running parallel e2e tests in CI.
39
+ const port = await (0, _port).getFreePortAsync(8082);
33
40
  // TODO: Prevent starting the watcher.
34
41
  const devServerManager = new _devServerManager.DevServerManager(projectRoot, {
35
42
  minify: options.minify,
36
43
  mode: "production",
37
- location: {}
44
+ port,
45
+ location: {},
46
+ resetDevServer: options.clear
38
47
  });
39
48
  await devServerManager.startAsync([
40
49
  {
41
50
  type: "metro",
42
51
  options: {
52
+ port,
43
53
  location: {},
44
- isExporting: true
54
+ isExporting: true,
55
+ resetDevServer: options.clear
45
56
  }
46
57
  },
47
58
  ]);
@@ -55,11 +66,12 @@ async function unstable_exportStaticAsync(projectRoot, options) {
55
66
  var ref;
56
67
  return (ref = name.match(/^\(([^/]+?)\)$/)) == null ? void 0 : ref[1];
57
68
  }
58
- async function getFilesToExportFromServerAsync(projectRoot, { manifest , renderAsync }) {
69
+ async function getFilesToExportFromServerAsync(projectRoot, { manifest , renderAsync , includeGroupVariations }) {
59
70
  // name : contents
60
71
  const files = new Map();
61
72
  await Promise.all(getHtmlFiles({
62
- manifest
73
+ manifest,
74
+ includeGroupVariations
63
75
  }).map(async (outputPath)=>{
64
76
  const pathname = outputPath.replace(/(?:index)?\.html$/, "");
65
77
  try {
@@ -76,26 +88,28 @@ async function getFilesToExportFromServerAsync(projectRoot, { manifest , renderA
76
88
  }));
77
89
  return files;
78
90
  }
79
- async function exportFromServerAsync(projectRoot, devServerManager, { outputDir , basePath , exportServer , minify , includeMaps }) {
91
+ async function exportFromServerAsync(projectRoot, devServerManager, { outputDir , baseUrl , exportServer , minify , includeMaps }) {
80
92
  const { exp } = (0, _config).getConfig(projectRoot, {
81
93
  skipSDKVersionRequirement: true
82
94
  });
83
95
  const appDir = (0, _router).getRouterDirectoryWithManifest(projectRoot, exp);
84
96
  const injectFaviconTag = await (0, _favicon).getVirtualFaviconAssetsAsync(projectRoot, {
85
97
  outputDir,
86
- basePath
98
+ baseUrl
87
99
  });
88
100
  const devServer = devServerManager.getDefaultDevServer();
89
101
  (0, _assert).default(devServer instanceof _metroBundlerDevServer.MetroBundlerDevServer);
90
- const [resources, { manifest , renderAsync }] = await Promise.all([
102
+ const [resources, { manifest , serverManifest , renderAsync }] = await Promise.all([
91
103
  devServer.getStaticResourcesAsync({
92
104
  mode: "production",
93
105
  minify,
94
- includeMaps
106
+ includeMaps,
107
+ baseUrl
95
108
  }),
96
109
  devServer.getStaticRenderFunctionAsync({
97
110
  mode: "production",
98
- minify
111
+ minify,
112
+ baseUrl
99
113
  }),
100
114
  ]);
101
115
  debug("Routes:\n", (0, _util).inspect(manifest, {
@@ -104,13 +118,17 @@ async function exportFromServerAsync(projectRoot, devServerManager, { outputDir
104
118
  }));
105
119
  const files = await getFilesToExportFromServerAsync(projectRoot, {
106
120
  manifest,
121
+ // Servers can handle group routes automatically and therefore
122
+ // don't require the build-time generation of every possible group
123
+ // variation.
124
+ includeGroupVariations: !exportServer,
107
125
  async renderAsync (pathname) {
108
126
  const template = await renderAsync(pathname);
109
- let html = await devServer.composeResourcesWithHtml({
127
+ let html = await (0, _serializeHtml).serializeHtmlWithAssets({
110
128
  mode: "production",
111
- resources,
129
+ resources: resources.artifacts,
112
130
  template,
113
- basePath
131
+ baseUrl
114
132
  });
115
133
  if (injectFaviconTag) {
116
134
  html = injectFaviconTag(html);
@@ -118,14 +136,24 @@ async function exportFromServerAsync(projectRoot, devServerManager, { outputDir
118
136
  return html;
119
137
  }
120
138
  });
121
- resources.forEach((resource)=>{
122
- files.set(resource.filename, modifyBundlesWithSourceMaps(resource.filename, resource.source, includeMaps));
139
+ getFilesFromSerialAssets(resources.artifacts, {
140
+ includeMaps,
141
+ files
123
142
  });
143
+ if (resources.assets) {
144
+ await (0, _persistMetroAssets).persistMetroAssetsAsync(resources.assets, {
145
+ platform: "web",
146
+ outputDirectory: outputDir,
147
+ baseUrl
148
+ });
149
+ }
124
150
  if (exportServer) {
125
151
  const apiRoutes = await exportApiRoutesAsync({
126
152
  outputDir,
127
153
  server: devServer,
128
- appDir
154
+ appDir,
155
+ manifest: serverManifest,
156
+ baseUrl
129
157
  });
130
158
  // Add the api routes to the files to export.
131
159
  for (const [route, contents] of apiRoutes){
@@ -134,6 +162,15 @@ async function exportFromServerAsync(projectRoot, devServerManager, { outputDir
134
162
  } else {
135
163
  warnPossibleInvalidExportType(appDir);
136
164
  }
165
+ await persistMetroFilesAsync(files, outputDir);
166
+ }
167
+ function getFilesFromSerialAssets(resources, { includeMaps , files =new Map() }) {
168
+ resources.forEach((resource)=>{
169
+ files.set(resource.filename, modifyBundlesWithSourceMaps(resource.filename, resource.source, includeMaps));
170
+ });
171
+ return files;
172
+ }
173
+ async function persistMetroFilesAsync(files, outputDir) {
137
174
  _fs.default.mkdirSync(_path.default.join(outputDir), {
138
175
  recursive: true
139
176
  });
@@ -156,8 +193,9 @@ async function exportFromServerAsync(projectRoot, devServerManager, { outputDir
156
193
  function modifyBundlesWithSourceMaps(filename, source, includeMaps) {
157
194
  if (filename.endsWith(".js")) {
158
195
  // If the bundle ends with source map URLs then update them to point to the correct location.
159
- // TODO: basePath support
196
+ // TODO: baseUrl support
160
197
  const normalizedFilename = "/" + filename.replace(/^\/+/, "");
198
+ // Ref: https://developer.chrome.com/blog/sourcemaps/#sourceurl-and-displayname-in-action-eval-and-anonymous-functions
161
199
  //# sourceMappingURL=//localhost:8085/index.map?platform=web&dev=false&hot=false&lazy=true&minify=true&resolver.environment=client&transform.environment=client&serializer.output=static
162
200
  //# sourceURL=http://localhost:8085/index.bundle//&platform=web&dev=false&hot=false&lazy=true&minify=true&resolver.environment=client&transform.environment=client&serializer.output=static
163
201
  return source.replace(/^\/\/# (sourceMappingURL|sourceURL)=.*$/gm, (...props)=>{
@@ -174,19 +212,23 @@ function modifyBundlesWithSourceMaps(filename, source, includeMaps) {
174
212
  }
175
213
  return source;
176
214
  }
177
- function getHtmlFiles({ manifest }) {
215
+ function getHtmlFiles({ manifest , includeGroupVariations }) {
178
216
  const htmlFiles = new Set();
179
- function traverseScreens(screens, basePath = "") {
217
+ function traverseScreens(screens, baseUrl = "") {
180
218
  for (const value of Object.values(screens)){
181
219
  if (typeof value === "string") {
182
- let filePath = basePath + value;
220
+ let filePath = baseUrl + value;
183
221
  if (value === "") {
184
- filePath = basePath === "" ? "index" : basePath.endsWith("/") ? basePath + "index" : basePath.slice(0, -1);
222
+ filePath = baseUrl === "" ? "index" : baseUrl.endsWith("/") ? baseUrl + "index" : baseUrl.slice(0, -1);
223
+ }
224
+ if (includeGroupVariations) {
225
+ // TODO: Dedupe requests for alias routes.
226
+ addOptionalGroups(filePath);
227
+ } else {
228
+ htmlFiles.add(filePath);
185
229
  }
186
- // TODO: Dedupe requests for alias routes.
187
- addOptionalGroups(filePath);
188
230
  } else if (typeof value === "object" && (value == null ? void 0 : value.screens)) {
189
- const newPath = basePath + value.path + "/";
231
+ const newPath = baseUrl + value.path + "/";
190
232
  traverseScreens(value.screens, newPath);
191
233
  }
192
234
  }
@@ -202,7 +244,9 @@ function getHtmlFiles({ manifest }) {
202
244
  const parts = value.split("/");
203
245
  // Replace `:foo` with `[foo]` and `*foo` with `[...foo]`
204
246
  const partsWithGroups = parts.map((part)=>{
205
- if (part.startsWith(":")) {
247
+ if (part === "*not-found") {
248
+ return `+not-found`;
249
+ } else if (part.startsWith(":")) {
206
250
  return `[${part.slice(1)}]`;
207
251
  } else if (part.startsWith("*")) {
208
252
  return `[...${part.slice(1)}]`;
@@ -213,50 +257,57 @@ function getHtmlFiles({ manifest }) {
213
257
  });
214
258
  }
215
259
  function getPathVariations(routePath) {
216
- const variations = new Set([
217
- routePath
218
- ]);
260
+ const variations = new Set();
219
261
  const segments1 = routePath.split("/");
220
- function generateVariations(segments, index) {
221
- if (index >= segments.length) {
262
+ function generateVariations(segments, current = "") {
263
+ if (segments.length === 0) {
264
+ if (current) variations.add(current);
222
265
  return;
223
266
  }
224
- const newSegments = [
225
- ...segments
226
- ];
227
- while(index < newSegments.length && matchGroupName(newSegments[index]) && newSegments.length > 1){
228
- newSegments.splice(index, 1);
229
- variations.add(newSegments.join("/"));
230
- generateVariations(newSegments, index + 1);
267
+ const [head, ...rest] = segments;
268
+ if (head.startsWith("(foo,foo")) {}
269
+ if (matchGroupName(head)) {
270
+ const groups = head.slice(1, -1).split(",");
271
+ if (groups.length > 1) {
272
+ for (const group of groups){
273
+ // If there are multiple groups, recurse on each group.
274
+ generateVariations([
275
+ `(${group.trim()})`,
276
+ ...rest
277
+ ], current);
278
+ }
279
+ return;
280
+ } else {
281
+ // Start a fork where this group is included
282
+ generateVariations(rest, current ? `${current}/(${groups[0]})` : `(${groups[0]})`);
283
+ // This code will continue and add paths without this group included`
284
+ }
285
+ } else if (current) {
286
+ current = `${current}/${head}`;
287
+ } else {
288
+ current = head;
231
289
  }
232
- generateVariations(segments, index + 1);
290
+ generateVariations(rest, current);
233
291
  }
234
- generateVariations(segments1, 0);
292
+ generateVariations(segments1);
235
293
  return Array.from(variations);
236
294
  }
237
- async function exportApiRoutesAsync({ outputDir , server , appDir }) {
238
- const funcDir = _path.default.join(outputDir, "_expo/functions");
295
+ async function exportApiRoutesAsync({ outputDir , server , appDir , baseUrl , ...props }) {
296
+ const functionsDir = "_expo/functions";
297
+ const funcDir = _path.default.join(outputDir, functionsDir);
239
298
  _fs.default.mkdirSync(_path.default.join(funcDir), {
240
299
  recursive: true
241
300
  });
242
- const [manifest, files1] = await Promise.all([
243
- server.getExpoRouterRoutesManifestAsync({
244
- appDir
245
- }),
246
- server.exportExpoRouterApiRoutesAsync({
247
- mode: "production",
248
- appDir
249
- }).then((routes)=>{
250
- const files = new Map();
251
- for (const [route, contents] of routes){
252
- files.set(_path.default.join("_expo/functions", route), contents);
253
- }
254
- return files;
255
- }),
256
- ]);
257
- _log.Log.log(_chalk.default.bold`Exporting ${files1.size} API Routes.`);
258
- files1.set("_expo/routes.json", JSON.stringify(manifest, null, 2));
259
- return files1;
301
+ const { manifest , files } = await server.exportExpoRouterApiRoutesAsync({
302
+ mode: "production",
303
+ appDir,
304
+ outputDir: functionsDir,
305
+ prerenderManifest: props.manifest,
306
+ baseUrl
307
+ });
308
+ _log.Log.log(_chalk.default.bold`Exporting ${files.size} API Routes.`);
309
+ files.set("_expo/routes.json", JSON.stringify(manifest, null, 2));
310
+ return files;
260
311
  }
261
312
  function warnPossibleInvalidExportType(appDir) {
262
313
  const apiRoutes = (0, _router).getApiRoutesForDirectory(appDir);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/exportStaticAsync.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { getConfig } from '@expo/config';\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\nimport prettyBytes from 'pretty-bytes';\nimport { inspect } from 'util';\n\nimport { getVirtualFaviconAssetsAsync } from './favicon';\nimport { Log } from '../log';\nimport { DevServerManager } from '../start/server/DevServerManager';\nimport { MetroBundlerDevServer } from '../start/server/metro/MetroBundlerDevServer';\nimport { logMetroErrorAsync } from '../start/server/metro/metroErrorInterface';\nimport {\n getApiRoutesForDirectory,\n getRouterDirectoryWithManifest,\n} from '../start/server/metro/router';\nimport { learnMore } from '../utils/link';\n\nconst debug = require('debug')('expo:export:generateStaticRoutes') as typeof console.log;\n\ntype Options = {\n outputDir: string;\n minify: boolean;\n exportServer: boolean;\n basePath: string;\n includeMaps: boolean;\n};\n\n/** @private */\nexport async function unstable_exportStaticAsync(projectRoot: string, options: Options) {\n Log.warn(\n `Experimental static rendering is enabled. ` +\n learnMore('https://docs.expo.dev/router/reference/static-rendering/')\n );\n\n // TODO: Prevent starting the watcher.\n const devServerManager = new DevServerManager(projectRoot, {\n minify: options.minify,\n mode: 'production',\n location: {},\n });\n await devServerManager.startAsync([\n {\n type: 'metro',\n options: {\n location: {},\n isExporting: true,\n },\n },\n ]);\n\n try {\n await exportFromServerAsync(projectRoot, devServerManager, options);\n } finally {\n await devServerManager.stopAsync();\n }\n}\n\n/** Match `(page)` -> `page` */\nfunction matchGroupName(name: string): string | undefined {\n return name.match(/^\\(([^/]+?)\\)$/)?.[1];\n}\n\nexport async function getFilesToExportFromServerAsync(\n projectRoot: string,\n {\n manifest,\n renderAsync,\n }: {\n manifest: any;\n renderAsync: (pathname: string) => Promise<string>;\n }\n): Promise<Map<string, string>> {\n // name : contents\n const files = new Map<string, string>();\n\n await Promise.all(\n getHtmlFiles({ manifest }).map(async (outputPath) => {\n const pathname = outputPath.replace(/(?:index)?\\.html$/, '');\n try {\n files.set(outputPath, '');\n const data = await renderAsync(pathname);\n files.set(outputPath, data);\n } catch (e: any) {\n await logMetroErrorAsync({ error: e, projectRoot });\n throw new Error('Failed to statically export route: ' + pathname);\n }\n })\n );\n\n return files;\n}\n\n/** Perform all fs commits */\nexport async function exportFromServerAsync(\n projectRoot: string,\n devServerManager: DevServerManager,\n { outputDir, basePath, exportServer, minify, includeMaps }: Options\n): Promise<void> {\n const { exp } = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n const appDir = getRouterDirectoryWithManifest(projectRoot, exp);\n\n const injectFaviconTag = await getVirtualFaviconAssetsAsync(projectRoot, { outputDir, basePath });\n\n const devServer = devServerManager.getDefaultDevServer();\n assert(devServer instanceof MetroBundlerDevServer);\n\n const [resources, { manifest, renderAsync }] = await Promise.all([\n devServer.getStaticResourcesAsync({ mode: 'production', minify, includeMaps }),\n devServer.getStaticRenderFunctionAsync({\n mode: 'production',\n minify,\n }),\n ]);\n\n debug('Routes:\\n', inspect(manifest, { colors: true, depth: null }));\n\n const files = await getFilesToExportFromServerAsync(projectRoot, {\n manifest,\n async renderAsync(pathname: string) {\n const template = await renderAsync(pathname);\n let html = await devServer.composeResourcesWithHtml({\n mode: 'production',\n resources,\n template,\n basePath,\n });\n\n if (injectFaviconTag) {\n html = injectFaviconTag(html);\n }\n\n return html;\n },\n });\n\n resources.forEach((resource) => {\n files.set(\n resource.filename,\n modifyBundlesWithSourceMaps(resource.filename, resource.source, includeMaps)\n );\n });\n\n if (exportServer) {\n const apiRoutes = await exportApiRoutesAsync({ outputDir, server: devServer, appDir });\n\n // Add the api routes to the files to export.\n for (const [route, contents] of apiRoutes) {\n files.set(route, contents);\n }\n } else {\n warnPossibleInvalidExportType(appDir);\n }\n\n fs.mkdirSync(path.join(outputDir), { recursive: true });\n\n Log.log('');\n Log.log(chalk.bold`Exporting ${files.size} files:`);\n await Promise.all(\n [...files.entries()]\n .sort(([a], [b]) => a.localeCompare(b))\n .map(async ([file, contents]) => {\n const length = Buffer.byteLength(contents, 'utf8');\n Log.log(file, chalk.gray`(${prettyBytes(length)})`);\n const outputPath = path.join(outputDir, file);\n await fs.promises.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.promises.writeFile(outputPath, contents);\n })\n );\n Log.log('');\n}\n\nexport function modifyBundlesWithSourceMaps(\n filename: string,\n source: string,\n includeMaps: boolean\n): string {\n if (filename.endsWith('.js')) {\n // If the bundle ends with source map URLs then update them to point to the correct location.\n\n // TODO: basePath support\n const normalizedFilename = '/' + filename.replace(/^\\/+/, '');\n //# sourceMappingURL=//localhost:8085/index.map?platform=web&dev=false&hot=false&lazy=true&minify=true&resolver.environment=client&transform.environment=client&serializer.output=static\n //# sourceURL=http://localhost:8085/index.bundle//&platform=web&dev=false&hot=false&lazy=true&minify=true&resolver.environment=client&transform.environment=client&serializer.output=static\n return source.replace(/^\\/\\/# (sourceMappingURL|sourceURL)=.*$/gm, (...props) => {\n if (includeMaps) {\n if (props[1] === 'sourceURL') {\n return `//# ${props[1]}=` + normalizedFilename;\n } else if (props[1] === 'sourceMappingURL') {\n const mapName = normalizedFilename + '.map';\n return `//# ${props[1]}=` + mapName;\n }\n }\n return '';\n });\n }\n return source;\n}\n\nexport function getHtmlFiles({ manifest }: { manifest: any }): string[] {\n const htmlFiles = new Set<string>();\n\n function traverseScreens(screens: string | { screens: any; path: string }, basePath = '') {\n for (const value of Object.values(screens)) {\n if (typeof value === 'string') {\n let filePath = basePath + value;\n if (value === '') {\n filePath =\n basePath === ''\n ? 'index'\n : basePath.endsWith('/')\n ? basePath + 'index'\n : basePath.slice(0, -1);\n }\n // TODO: Dedupe requests for alias routes.\n addOptionalGroups(filePath);\n } else if (typeof value === 'object' && value?.screens) {\n const newPath = basePath + value.path + '/';\n traverseScreens(value.screens, newPath);\n }\n }\n }\n\n function addOptionalGroups(path: string) {\n const variations = getPathVariations(path);\n for (const variation of variations) {\n htmlFiles.add(variation);\n }\n }\n\n traverseScreens(manifest.screens);\n\n return Array.from(htmlFiles).map((value) => {\n const parts = value.split('/');\n // Replace `:foo` with `[foo]` and `*foo` with `[...foo]`\n const partsWithGroups = parts.map((part) => {\n if (part.startsWith(':')) {\n return `[${part.slice(1)}]`;\n } else if (part.startsWith('*')) {\n return `[...${part.slice(1)}]`;\n }\n return part;\n });\n return partsWithGroups.join('/') + '.html';\n });\n}\n\n// Given a route like `(foo)/bar/(baz)`, return all possible variations of the route.\n// e.g. `(foo)/bar/(baz)`, `(foo)/bar/baz`, `foo/bar/(baz)`, `foo/bar/baz`,\nexport function getPathVariations(routePath: string): string[] {\n const variations = new Set<string>([routePath]);\n const segments = routePath.split('/');\n\n function generateVariations(segments: string[], index: number): void {\n if (index >= segments.length) {\n return;\n }\n\n const newSegments = [...segments];\n while (\n index < newSegments.length &&\n matchGroupName(newSegments[index]) &&\n newSegments.length > 1\n ) {\n newSegments.splice(index, 1);\n variations.add(newSegments.join('/'));\n generateVariations(newSegments, index + 1);\n }\n\n generateVariations(segments, index + 1);\n }\n\n generateVariations(segments, 0);\n\n return Array.from(variations);\n}\n\nasync function exportApiRoutesAsync({\n outputDir,\n server,\n appDir,\n}: {\n outputDir: string;\n server: MetroBundlerDevServer;\n appDir: string;\n}): Promise<Map<string, string>> {\n const funcDir = path.join(outputDir, '_expo/functions');\n fs.mkdirSync(path.join(funcDir), { recursive: true });\n\n const [manifest, files] = await Promise.all([\n server.getExpoRouterRoutesManifestAsync({\n appDir,\n }),\n server\n .exportExpoRouterApiRoutesAsync({\n mode: 'production',\n appDir,\n })\n .then((routes) => {\n const files = new Map<string, string>();\n for (const [route, contents] of routes) {\n files.set(path.join('_expo/functions', route), contents);\n }\n return files;\n }),\n ]);\n\n Log.log(chalk.bold`Exporting ${files.size} API Routes.`);\n\n files.set('_expo/routes.json', JSON.stringify(manifest, null, 2));\n\n return files;\n}\n\nfunction warnPossibleInvalidExportType(appDir: string) {\n const apiRoutes = getApiRoutesForDirectory(appDir);\n if (apiRoutes.length) {\n // TODO: Allow API Routes for native-only.\n Log.warn(\n chalk.yellow`Skipping export for API routes because \\`web.output\\` is not \"server\". You may want to remove the routes: ${apiRoutes\n .map((v) => path.relative(appDir, v))\n .join(', ')}`\n );\n }\n}\n"],"names":["unstable_exportStaticAsync","getFilesToExportFromServerAsync","exportFromServerAsync","modifyBundlesWithSourceMaps","getHtmlFiles","getPathVariations","debug","require","projectRoot","options","Log","warn","learnMore","devServerManager","DevServerManager","minify","mode","location","startAsync","type","isExporting","stopAsync","matchGroupName","name","match","manifest","renderAsync","files","Map","Promise","all","map","outputPath","pathname","replace","set","data","e","logMetroErrorAsync","error","Error","outputDir","basePath","exportServer","includeMaps","exp","getConfig","skipSDKVersionRequirement","appDir","getRouterDirectoryWithManifest","injectFaviconTag","getVirtualFaviconAssetsAsync","devServer","getDefaultDevServer","assert","MetroBundlerDevServer","resources","getStaticResourcesAsync","getStaticRenderFunctionAsync","inspect","colors","depth","template","html","composeResourcesWithHtml","forEach","resource","filename","source","apiRoutes","exportApiRoutesAsync","server","route","contents","warnPossibleInvalidExportType","fs","mkdirSync","path","join","recursive","log","chalk","bold","size","entries","sort","a","b","localeCompare","file","length","Buffer","byteLength","gray","prettyBytes","promises","mkdir","dirname","writeFile","endsWith","normalizedFilename","props","mapName","htmlFiles","Set","traverseScreens","screens","value","Object","values","filePath","slice","addOptionalGroups","newPath","variations","variation","add","Array","from","parts","split","partsWithGroups","part","startsWith","routePath","segments","generateVariations","index","newSegments","splice","funcDir","getExpoRouterRoutesManifestAsync","exportExpoRouterApiRoutesAsync","then","routes","JSON","stringify","getApiRoutesForDirectory","yellow","v","relative"],"mappings":"AAMA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AAS,GAAGoE,CAAAA,GAAAA,OAAwB,AAAQ,CAAA,yBAAR,CAACzF,MAAM,CAAC,AAAC;IACnD,IAAIqB,SAAS,CAACqB,MAAM,EAAE;QACpB,0CAA0C;QAC1ChF,IAAG,IAAA,CAACC,IAAI,CACNsE,MAAK,QAAA,CAACyD,MAAM,CAAC,0GAA0G,EAAErE,SAAS,CAC/HtC,GAAG,CAAC,CAAC4G,CAAC,GAAK9D,KAAI,QAAA,CAAC+D,QAAQ,CAAC5F,MAAM,EAAE2F,CAAC,CAAC;QAAA,CAAC,CACpC7D,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAChB,CAAC;KACH;CACF"}
1
+ {"version":3,"sources":["../../../src/export/exportStaticAsync.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { getConfig } from '@expo/config';\nimport { SerialAsset } from '@expo/metro-config/build/serializer/serializerAssets';\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\nimport prettyBytes from 'pretty-bytes';\nimport { inspect } from 'util';\n\nimport { getVirtualFaviconAssetsAsync } from './favicon';\nimport { persistMetroAssetsAsync } from './persistMetroAssets';\nimport { Log } from '../log';\nimport { DevServerManager } from '../start/server/DevServerManager';\nimport { MetroBundlerDevServer } from '../start/server/metro/MetroBundlerDevServer';\nimport { ExpoRouterServerManifestV1 } from '../start/server/metro/fetchRouterManifest';\nimport { logMetroErrorAsync } from '../start/server/metro/metroErrorInterface';\nimport {\n getApiRoutesForDirectory,\n getRouterDirectoryWithManifest,\n} from '../start/server/metro/router';\nimport { serializeHtmlWithAssets } from '../start/server/metro/serializeHtml';\nimport { learnMore } from '../utils/link';\nimport { getFreePortAsync } from '../utils/port';\n\nconst debug = require('debug')('expo:export:generateStaticRoutes') as typeof console.log;\n\ntype Options = {\n outputDir: string;\n minify: boolean;\n exportServer: boolean;\n baseUrl: string;\n includeMaps: boolean;\n entryPoint?: string;\n clear: boolean;\n};\n\n/** @private */\nexport async function unstable_exportStaticAsync(projectRoot: string, options: Options) {\n Log.warn(\n `Experimental static rendering is enabled. ` +\n learnMore('https://docs.expo.dev/router/reference/static-rendering/')\n );\n\n // Useful for running parallel e2e tests in CI.\n const port = await getFreePortAsync(8082);\n\n // TODO: Prevent starting the watcher.\n const devServerManager = new DevServerManager(projectRoot, {\n minify: options.minify,\n mode: 'production',\n port,\n location: {},\n resetDevServer: options.clear,\n });\n await devServerManager.startAsync([\n {\n type: 'metro',\n options: {\n port,\n location: {},\n isExporting: true,\n resetDevServer: options.clear,\n },\n },\n ]);\n\n try {\n await exportFromServerAsync(projectRoot, devServerManager, options);\n } finally {\n await devServerManager.stopAsync();\n }\n}\n\n/** Match `(page)` -> `page` */\nfunction matchGroupName(name: string): string | undefined {\n return name.match(/^\\(([^/]+?)\\)$/)?.[1];\n}\n\nexport async function getFilesToExportFromServerAsync(\n projectRoot: string,\n {\n manifest,\n renderAsync,\n includeGroupVariations,\n }: {\n manifest: any;\n renderAsync: (pathname: string) => Promise<string>;\n includeGroupVariations?: boolean;\n }\n): Promise<Map<string, string>> {\n // name : contents\n const files = new Map<string, string>();\n\n await Promise.all(\n getHtmlFiles({ manifest, includeGroupVariations }).map(async (outputPath) => {\n const pathname = outputPath.replace(/(?:index)?\\.html$/, '');\n try {\n files.set(outputPath, '');\n const data = await renderAsync(pathname);\n files.set(outputPath, data);\n } catch (e: any) {\n await logMetroErrorAsync({ error: e, projectRoot });\n throw new Error('Failed to statically export route: ' + pathname);\n }\n })\n );\n\n return files;\n}\n\n/** Perform all fs commits */\nexport async function exportFromServerAsync(\n projectRoot: string,\n devServerManager: DevServerManager,\n { outputDir, baseUrl, exportServer, minify, includeMaps }: Options\n): Promise<void> {\n const { exp } = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n const appDir = getRouterDirectoryWithManifest(projectRoot, exp);\n\n const injectFaviconTag = await getVirtualFaviconAssetsAsync(projectRoot, { outputDir, baseUrl });\n\n const devServer = devServerManager.getDefaultDevServer();\n assert(devServer instanceof MetroBundlerDevServer);\n\n const [resources, { manifest, serverManifest, renderAsync }] = await Promise.all([\n devServer.getStaticResourcesAsync({ mode: 'production', minify, includeMaps, baseUrl }),\n devServer.getStaticRenderFunctionAsync({\n mode: 'production',\n minify,\n baseUrl,\n }),\n ]);\n\n debug('Routes:\\n', inspect(manifest, { colors: true, depth: null }));\n\n const files = await getFilesToExportFromServerAsync(projectRoot, {\n manifest,\n // Servers can handle group routes automatically and therefore\n // don't require the build-time generation of every possible group\n // variation.\n includeGroupVariations: !exportServer,\n async renderAsync(pathname: string) {\n const template = await renderAsync(pathname);\n let html = await serializeHtmlWithAssets({\n mode: 'production',\n resources: resources.artifacts,\n template,\n baseUrl,\n });\n\n if (injectFaviconTag) {\n html = injectFaviconTag(html);\n }\n\n return html;\n },\n });\n\n getFilesFromSerialAssets(resources.artifacts, {\n includeMaps,\n files,\n });\n\n if (resources.assets) {\n await persistMetroAssetsAsync(resources.assets, {\n platform: 'web',\n outputDirectory: outputDir,\n baseUrl,\n });\n }\n\n if (exportServer) {\n const apiRoutes = await exportApiRoutesAsync({\n outputDir,\n server: devServer,\n appDir,\n manifest: serverManifest,\n baseUrl,\n });\n\n // Add the api routes to the files to export.\n for (const [route, contents] of apiRoutes) {\n files.set(route, contents);\n }\n } else {\n warnPossibleInvalidExportType(appDir);\n }\n\n await persistMetroFilesAsync(files, outputDir);\n}\n\n// TODO: Move source map modification to the serializer\nexport function getFilesFromSerialAssets(\n resources: SerialAsset[],\n {\n includeMaps,\n files = new Map<string, string>(),\n }: {\n includeMaps: boolean;\n files?: Map<string, string>;\n }\n) {\n resources.forEach((resource) => {\n files.set(\n resource.filename,\n modifyBundlesWithSourceMaps(resource.filename, resource.source, includeMaps)\n );\n });\n\n return files;\n}\n\nexport async function persistMetroFilesAsync(files: Map<string, string>, outputDir: string) {\n fs.mkdirSync(path.join(outputDir), { recursive: true });\n\n Log.log('');\n\n Log.log(chalk.bold`Exporting ${files.size} files:`);\n await Promise.all(\n [...files.entries()]\n .sort(([a], [b]) => a.localeCompare(b))\n .map(async ([file, contents]) => {\n const length = Buffer.byteLength(contents, 'utf8');\n Log.log(file, chalk.gray`(${prettyBytes(length)})`);\n const outputPath = path.join(outputDir, file);\n await fs.promises.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.promises.writeFile(outputPath, contents);\n })\n );\n Log.log('');\n}\n\nexport function modifyBundlesWithSourceMaps(\n filename: string,\n source: string,\n includeMaps: boolean\n): string {\n if (filename.endsWith('.js')) {\n // If the bundle ends with source map URLs then update them to point to the correct location.\n\n // TODO: baseUrl support\n const normalizedFilename = '/' + filename.replace(/^\\/+/, '');\n // Ref: https://developer.chrome.com/blog/sourcemaps/#sourceurl-and-displayname-in-action-eval-and-anonymous-functions\n //# sourceMappingURL=//localhost:8085/index.map?platform=web&dev=false&hot=false&lazy=true&minify=true&resolver.environment=client&transform.environment=client&serializer.output=static\n //# sourceURL=http://localhost:8085/index.bundle//&platform=web&dev=false&hot=false&lazy=true&minify=true&resolver.environment=client&transform.environment=client&serializer.output=static\n return source.replace(/^\\/\\/# (sourceMappingURL|sourceURL)=.*$/gm, (...props) => {\n if (includeMaps) {\n if (props[1] === 'sourceURL') {\n return `//# ${props[1]}=` + normalizedFilename;\n } else if (props[1] === 'sourceMappingURL') {\n const mapName = normalizedFilename + '.map';\n return `//# ${props[1]}=` + mapName;\n }\n }\n return '';\n });\n }\n return source;\n}\n\nexport function getHtmlFiles({\n manifest,\n includeGroupVariations,\n}: {\n manifest: any;\n includeGroupVariations?: boolean;\n}): string[] {\n const htmlFiles = new Set<string>();\n\n function traverseScreens(screens: string | { screens: any; path: string }, baseUrl = '') {\n for (const value of Object.values(screens)) {\n if (typeof value === 'string') {\n let filePath = baseUrl + value;\n if (value === '') {\n filePath =\n baseUrl === ''\n ? 'index'\n : baseUrl.endsWith('/')\n ? baseUrl + 'index'\n : baseUrl.slice(0, -1);\n }\n if (includeGroupVariations) {\n // TODO: Dedupe requests for alias routes.\n addOptionalGroups(filePath);\n } else {\n htmlFiles.add(filePath);\n }\n } else if (typeof value === 'object' && value?.screens) {\n const newPath = baseUrl + value.path + '/';\n traverseScreens(value.screens, newPath);\n }\n }\n }\n\n function addOptionalGroups(path: string) {\n const variations = getPathVariations(path);\n for (const variation of variations) {\n htmlFiles.add(variation);\n }\n }\n\n traverseScreens(manifest.screens);\n\n return Array.from(htmlFiles).map((value) => {\n const parts = value.split('/');\n // Replace `:foo` with `[foo]` and `*foo` with `[...foo]`\n const partsWithGroups = parts.map((part) => {\n if (part === '*not-found') {\n return `+not-found`;\n } else if (part.startsWith(':')) {\n return `[${part.slice(1)}]`;\n } else if (part.startsWith('*')) {\n return `[...${part.slice(1)}]`;\n }\n return part;\n });\n return partsWithGroups.join('/') + '.html';\n });\n}\n\n// Given a route like `(foo)/bar/(baz)`, return all possible variations of the route.\n// e.g. `(foo)/bar/(baz)`, `(foo)/bar/baz`, `foo/bar/(baz)`, `foo/bar/baz`,\nexport function getPathVariations(routePath: string): string[] {\n const variations = new Set<string>();\n const segments = routePath.split('/');\n\n function generateVariations(segments: string[], current = ''): void {\n if (segments.length === 0) {\n if (current) variations.add(current);\n return;\n }\n\n const [head, ...rest] = segments;\n\n if (head.startsWith('(foo,foo')) {\n }\n\n if (matchGroupName(head)) {\n const groups = head.slice(1, -1).split(',');\n\n if (groups.length > 1) {\n for (const group of groups) {\n // If there are multiple groups, recurse on each group.\n generateVariations([`(${group.trim()})`, ...rest], current);\n }\n return;\n } else {\n // Start a fork where this group is included\n generateVariations(rest, current ? `${current}/(${groups[0]})` : `(${groups[0]})`);\n // This code will continue and add paths without this group included`\n }\n } else if (current) {\n current = `${current}/${head}`;\n } else {\n current = head;\n }\n\n generateVariations(rest, current);\n }\n\n generateVariations(segments);\n\n return Array.from(variations);\n}\n\nasync function exportApiRoutesAsync({\n outputDir,\n server,\n appDir,\n baseUrl,\n ...props\n}: {\n outputDir: string;\n server: MetroBundlerDevServer;\n appDir: string;\n manifest: ExpoRouterServerManifestV1;\n baseUrl: string;\n}): Promise<Map<string, string>> {\n const functionsDir = '_expo/functions';\n const funcDir = path.join(outputDir, functionsDir);\n fs.mkdirSync(path.join(funcDir), { recursive: true });\n\n const { manifest, files } = await server.exportExpoRouterApiRoutesAsync({\n mode: 'production',\n appDir,\n outputDir: functionsDir,\n prerenderManifest: props.manifest,\n baseUrl,\n });\n\n Log.log(chalk.bold`Exporting ${files.size} API Routes.`);\n\n files.set('_expo/routes.json', JSON.stringify(manifest, null, 2));\n\n return files;\n}\n\nfunction warnPossibleInvalidExportType(appDir: string) {\n const apiRoutes = getApiRoutesForDirectory(appDir);\n if (apiRoutes.length) {\n // TODO: Allow API Routes for native-only.\n Log.warn(\n chalk.yellow`Skipping export for API routes because \\`web.output\\` is not \"server\". You may want to remove the routes: ${apiRoutes\n .map((v) => path.relative(appDir, v))\n .join(', ')}`\n );\n }\n}\n"],"names":["unstable_exportStaticAsync","getFilesToExportFromServerAsync","exportFromServerAsync","getFilesFromSerialAssets","persistMetroFilesAsync","modifyBundlesWithSourceMaps","getHtmlFiles","getPathVariations","debug","require","projectRoot","options","Log","warn","learnMore","port","getFreePortAsync","devServerManager","DevServerManager","minify","mode","location","resetDevServer","clear","startAsync","type","isExporting","stopAsync","matchGroupName","name","match","manifest","renderAsync","includeGroupVariations","files","Map","Promise","all","map","outputPath","pathname","replace","set","data","e","logMetroErrorAsync","error","Error","outputDir","baseUrl","exportServer","includeMaps","exp","getConfig","skipSDKVersionRequirement","appDir","getRouterDirectoryWithManifest","injectFaviconTag","getVirtualFaviconAssetsAsync","devServer","getDefaultDevServer","assert","MetroBundlerDevServer","resources","serverManifest","getStaticResourcesAsync","getStaticRenderFunctionAsync","inspect","colors","depth","template","html","serializeHtmlWithAssets","artifacts","assets","persistMetroAssetsAsync","platform","outputDirectory","apiRoutes","exportApiRoutesAsync","server","route","contents","warnPossibleInvalidExportType","forEach","resource","filename","source","fs","mkdirSync","path","join","recursive","log","chalk","bold","size","entries","sort","a","b","localeCompare","file","length","Buffer","byteLength","gray","prettyBytes","promises","mkdir","dirname","writeFile","endsWith","normalizedFilename","props","mapName","htmlFiles","Set","traverseScreens","screens","value","Object","values","filePath","slice","addOptionalGroups","add","newPath","variations","variation","Array","from","parts","split","partsWithGroups","part","startsWith","routePath","segments","generateVariations","current","head","rest","groups","group","trim","functionsDir","funcDir","exportExpoRouterApiRoutesAsync","prerenderManifest","JSON","stringify","getApiRoutesForDirectory","yellow","v","relative"],"mappings":"AAMA;;;;QAqCsBA,0BAA0B,GAA1BA,0BAA0B;QAyC1BC,+BAA+B,GAA/BA,+BAA+B;QAiC/BC,qBAAqB,GAArBA,qBAAqB;QAiF3BC,wBAAwB,GAAxBA,wBAAwB;QAoBlBC,sBAAsB,GAAtBA,sBAAsB;QAoB5BC,2BAA2B,GAA3BA,2BAA2B;QA4B3BC,YAAY,GAAZA,YAAY;QA8DZC,iBAAiB,GAAjBA,iBAAiB;AAlUP,IAAA,OAAc,WAAd,cAAc,CAAA;AAErB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACT,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AACC,IAAA,YAAc,kCAAd,cAAc,EAAA;AACd,IAAA,KAAM,WAAN,MAAM,CAAA;AAEe,IAAA,QAAW,WAAX,WAAW,CAAA;AAChB,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AAC1C,IAAA,IAAQ,WAAR,QAAQ,CAAA;AACK,IAAA,iBAAkC,WAAlC,kCAAkC,CAAA;AAC7B,IAAA,sBAA6C,WAA7C,6CAA6C,CAAA;AAEhD,IAAA,oBAA2C,WAA3C,2CAA2C,CAAA;AAIvE,IAAA,OAA8B,WAA9B,8BAA8B,CAAA;AACG,IAAA,cAAqC,WAArC,qCAAqC,CAAA;AACnD,IAAA,KAAe,WAAf,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E,QAAQ,CAACpG,MAAM,EAAEmG,CAAC,CAAC;QAAA,CAAC,CACpC/D,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAChB,CAAC;KACH;CACF"}
@@ -21,7 +21,7 @@ function getUserDefinedFaviconFile(projectRoot) {
21
21
  "./favicon.ico"
22
22
  ]);
23
23
  }
24
- async function getVirtualFaviconAssetsAsync(projectRoot, { basePath , outputDir }) {
24
+ async function getVirtualFaviconAssetsAsync(projectRoot, { baseUrl , outputDir }) {
25
25
  const existing = getUserDefinedFaviconFile(projectRoot);
26
26
  if (existing) {
27
27
  debug("Using user-defined favicon.ico file.");
@@ -42,7 +42,7 @@ async function getVirtualFaviconAssetsAsync(projectRoot, { basePath , outputDir
42
42
  if (!html.includes("</head>")) {
43
43
  return html;
44
44
  }
45
- return html.replace("</head>", `<link rel="shortcut icon" href="${basePath}/favicon.ico" /></head>`);
45
+ return html.replace("</head>", `<link rel="shortcut icon" href="${baseUrl}/favicon.ico" /></head>`);
46
46
  }
47
47
  return injectFaviconTag;
48
48
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/favicon.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport { generateFaviconAsync, generateImageAsync } from '@expo/image-utils';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { getUserDefinedFile } from './publicFolder';\n\nconst debug = require('debug')('expo:favicon') as typeof console.log;\n\n/** @returns the file system path for a user-defined favicon.ico file in the public folder. */\nexport function getUserDefinedFaviconFile(projectRoot: string): string | null {\n return getUserDefinedFile(projectRoot, ['./favicon.ico']);\n}\n\nexport async function getVirtualFaviconAssetsAsync(\n projectRoot: string,\n { basePath, outputDir }: { outputDir: string; basePath: string }\n): Promise<((html: string) => string) | null> {\n const existing = getUserDefinedFaviconFile(projectRoot);\n if (existing) {\n debug('Using user-defined favicon.ico file.');\n return null;\n }\n\n const data = await getFaviconFromExpoConfigAsync(projectRoot);\n\n if (!data) {\n return null;\n }\n\n await Promise.all(\n [data].map((asset) => {\n const assetPath = path.join(outputDir, asset.path);\n debug('Writing asset to disk: ' + assetPath);\n return fs.promises.writeFile(assetPath, asset.source);\n })\n );\n\n function injectFaviconTag(html: string): string {\n if (!html.includes('</head>')) {\n return html;\n }\n return html.replace(\n '</head>',\n `<link rel=\"shortcut icon\" href=\"${basePath}/favicon.ico\" /></head>`\n );\n }\n\n return injectFaviconTag;\n}\n\nexport async function getFaviconFromExpoConfigAsync(projectRoot: string) {\n const { exp } = getConfig(projectRoot);\n\n const src = exp.web?.favicon ?? null;\n if (!src) {\n return null;\n }\n\n const dims = [16, 32, 48];\n const cacheType = 'favicon';\n\n const size = dims[dims.length - 1];\n const { source } = await generateImageAsync(\n { projectRoot, cacheType },\n {\n resizeMode: 'contain',\n src,\n backgroundColor: 'transparent',\n width: size,\n height: size,\n name: `favicon-${size}.png`,\n }\n );\n\n const faviconBuffer = await generateFaviconAsync(source, dims);\n\n return { source: faviconBuffer, path: 'favicon.ico' };\n}\n"],"names":["getUserDefinedFaviconFile","getVirtualFaviconAssetsAsync","getFaviconFromExpoConfigAsync","debug","require","projectRoot","getUserDefinedFile","basePath","outputDir","existing","data","Promise","all","map","asset","assetPath","path","join","fs","promises","writeFile","source","injectFaviconTag","html","includes","replace","exp","getConfig","src","web","favicon","dims","cacheType","size","length","generateImageAsync","resizeMode","backgroundColor","width","height","name","faviconBuffer","generateFaviconAsync"],"mappings":"AAAA;;;;QAUgBA,yBAAyB,GAAzBA,yBAAyB;QAInBC,4BAA4B,GAA5BA,4BAA4B;QAqC5BC,6BAA6B,GAA7BA,6BAA6B;AAnDzB,IAAA,OAAc,WAAd,cAAc,CAAA;AACiB,IAAA,WAAmB,WAAnB,mBAAmB,CAAA;AAC7D,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEY,IAAA,aAAgB,WAAhB,gBAAgB,CAAA;;;;;;AAEnD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,C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AAmB,EAAE;QAG3DqB,GAAO;IAFnB,MAAM,EAAEA,GAAG,CAAA,EAAE,GAAGC,CAAAA,GAAAA,OAAS,AAAa,CAAA,UAAb,CAACtB,WAAW,CAAC,AAAC;QAE3BqB,IAAgB;IAA5B,MAAME,GAAG,GAAGF,CAAAA,IAAgB,GAAhBA,CAAAA,GAAO,GAAPA,GAAG,CAACG,GAAG,SAAS,GAAhBH,KAAAA,CAAgB,GAAhBA,GAAO,CAAEI,OAAO,YAAhBJ,IAAgB,GAAI,IAAI,AAAC;IACrC,IAAI,CAACE,GAAG,EAAE;QACR,OAAO,IAAI,CAAC;KACb;IAED,MAAMG,IAAI,GAAG;AAAC,UAAE;AAAE,UAAE;AAAE,UAAE;KAAC,AAAC;IAC1B,MAAMC,SAAS,GAAG,SAAS,AAAC;IAE5B,MAAMC,IAAI,GAAGF,IAAI,CAACA,IAAI,CAACG,MAAM,GAAG,CAAC,CAAC,AAAC;IACnC,MAAM,EAAEb,MAAM,CAAA,EAAE,GAAG,MAAMc,CAAAA,GAAAA,WAAkB,AAU1C,CAAA,mBAV0C,CACzC;QAAE9B,WAAW;QAAE2B,SAAS;KAAE,EAC1B;QACEI,UAAU,EAAE,SAAS;QACrBR,GAAG;QACHS,eAAe,EAAE,aAAa;QAC9BC,KAAK,EAAEL,IAAI;QACXM,MAAM,EAAEN,IAAI;QACZO,IAAI,EAAE,CAAC,QAAQ,EAAEP,IAAI,CAAC,IAAI,CAAC;KAC5B,CACF,AAAC;IAEF,MAAMQ,aAAa,GAAG,MAAMC,CAAAA,GAAAA,WAAoB,AAAc,CAAA,qBAAd,CAACrB,MAAM,EAAEU,IAAI,CAAC,AAAC;IAE/D,OAAO;QAAEV,MAAM,EAAEoB,aAAa;QAAEzB,IAAI,EAAE,aAAa;KAAE,CAAC;CACvD"}
1
+ {"version":3,"sources":["../../../src/export/favicon.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport { generateFaviconAsync, generateImageAsync } from '@expo/image-utils';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { getUserDefinedFile } from './publicFolder';\n\nconst debug = require('debug')('expo:favicon') as typeof console.log;\n\n/** @returns the file system path for a user-defined favicon.ico file in the public folder. */\nexport function getUserDefinedFaviconFile(projectRoot: string): string | null {\n return getUserDefinedFile(projectRoot, ['./favicon.ico']);\n}\n\nexport async function getVirtualFaviconAssetsAsync(\n projectRoot: string,\n { baseUrl, outputDir }: { outputDir: string; baseUrl: string }\n): Promise<((html: string) => string) | null> {\n const existing = getUserDefinedFaviconFile(projectRoot);\n if (existing) {\n debug('Using user-defined favicon.ico file.');\n return null;\n }\n\n const data = await getFaviconFromExpoConfigAsync(projectRoot);\n\n if (!data) {\n return null;\n }\n\n await Promise.all(\n [data].map((asset) => {\n const assetPath = path.join(outputDir, asset.path);\n debug('Writing asset to disk: ' + assetPath);\n return fs.promises.writeFile(assetPath, asset.source);\n })\n );\n\n function injectFaviconTag(html: string): string {\n if (!html.includes('</head>')) {\n return html;\n }\n return html.replace(\n '</head>',\n `<link rel=\"shortcut icon\" href=\"${baseUrl}/favicon.ico\" /></head>`\n );\n }\n\n return injectFaviconTag;\n}\n\nexport async function getFaviconFromExpoConfigAsync(projectRoot: string) {\n const { exp } = getConfig(projectRoot);\n\n const src = exp.web?.favicon ?? null;\n if (!src) {\n return null;\n }\n\n const dims = [16, 32, 48];\n const cacheType = 'favicon';\n\n const size = dims[dims.length - 1];\n const { source } = await generateImageAsync(\n { projectRoot, cacheType },\n {\n resizeMode: 'contain',\n src,\n backgroundColor: 'transparent',\n width: size,\n height: size,\n name: `favicon-${size}.png`,\n }\n );\n\n const faviconBuffer = await generateFaviconAsync(source, dims);\n\n return { source: faviconBuffer, path: 'favicon.ico' };\n}\n"],"names":["getUserDefinedFaviconFile","getVirtualFaviconAssetsAsync","getFaviconFromExpoConfigAsync","debug","require","projectRoot","getUserDefinedFile","baseUrl","outputDir","existing","data","Promise","all","map","asset","assetPath","path","join","fs","promises","writeFile","source","injectFaviconTag","html","includes","replace","exp","getConfig","src","web","favicon","dims","cacheType","size","length","generateImageAsync","resizeMode","backgroundColor","width","height","name","faviconBuffer","generateFaviconAsync"],"mappings":"AAAA;;;;QAUgBA,yBAAyB,GAAzBA,yBAAyB;QAInBC,4BAA4B,GAA5BA,4BAA4B;QAqC5BC,6BAA6B,GAA7BA,6BAA6B;AAnDzB,IAAA,OAAc,WAAd,cAAc,CAAA;AACiB,IAAA,WAAmB,WAAnB,mBAAmB,CAAA;AAC7D,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEY,IAAA,aAAgB,WAAhB,gBAAgB,CAAA;;;;;;AAEnD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,AAAsB,AAAC;AAG9D,SAASJ,yBAAyB,CAACK,WAAmB,EAAiB;IAC5E,OAAOC,CAAAA,GAAAA,aAAkB,AAAgC,CAAA,mBAAhC,CAACD,WAAW,EAAE;QAAC,eAAe;KAAC,CAAC,CAAC;CAC3D;AAEM,eAAeJ,4BAA4B,CAChDI,WAAmB,EACnB,EAAEE,OAAO,CAAA,EAAEC,SAAS,CAAA,EAA0C,EAClB;IAC5C,MAAMC,QAAQ,GAAGT,yBAAyB,CAACK,WAAW,CAAC,AAAC;IACxD,IAAII,QAAQ,EAAE;QACZN,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC;KACb;IAED,MAAMO,IAAI,GAAG,MAAMR,6BAA6B,CAACG,WAAW,CAAC,AAAC;IAE9D,IAAI,CAACK,IAAI,EAAE;QACT,OAAO,IAAI,CAAC;KACb;IAED,MAAMC,OAAO,CAACC,GAAG,CACf;QAACF,IAAI;KAAC,CAACG,GAAG,CAAC,CAACC,KAAK,GAAK;QACpB,MAAMC,SAAS,GAAGC,KAAI,QAAA,CAACC,IAAI,CAACT,SAAS,EAAEM,KAAK,CAACE,IAAI,CAAC,AAAC;QACnDb,KAAK,CA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S,eAAe,EAAE,aAAa;QAC9BC,KAAK,EAAEL,IAAI;QACXM,MAAM,EAAEN,IAAI;QACZO,IAAI,EAAE,CAAC,QAAQ,EAAEP,IAAI,CAAC,IAAI,CAAC;KAC5B,CACF,AAAC;IAEF,MAAMQ,aAAa,GAAG,MAAMC,CAAAA,GAAAA,WAAoB,AAAc,CAAA,qBAAd,CAACrB,MAAM,EAAEU,IAAI,CAAC,AAAC;IAE/D,OAAO;QAAEV,MAAM,EAAEoB,aAAa;QAAEzB,IAAI,EAAE,aAAa;KAAE,CAAC;CACvD"}
@@ -2,16 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.bundleAsync = bundleAsync;
5
+ exports.createBundlesAsync = createBundlesAsync;
6
6
  exports.getAssets = getAssets;
7
7
  var _config = require("@expo/config");
8
8
  var _chalk = _interopRequireDefault(require("chalk"));
9
+ var _metro = _interopRequireDefault(require("metro"));
9
10
  var _getAssets = _interopRequireDefault(require("metro/src/DeltaBundler/Serializers/getAssets"));
11
+ var _server = _interopRequireDefault(require("metro/src/Server"));
10
12
  var _splitBundleOptions = _interopRequireDefault(require("metro/src/lib/splitBundleOptions"));
11
13
  var _exportHermes = require("./exportHermes");
12
14
  var _getCssModulesFromBundler = require("../start/server/metro/getCssModulesFromBundler");
13
15
  var _instantiateMetro = require("../start/server/metro/instantiateMetro");
14
- var _resolveFromProject = require("../start/server/metro/resolveFromProject");
16
+ var _manifestMiddleware = require("../start/server/middleware/ManifestMiddleware");
17
+ var _metroOptions = require("../start/server/middleware/metroOptions");
15
18
  function _interopRequireDefault(obj) {
16
19
  return obj && obj.__esModule ? obj : {
17
20
  default: obj
@@ -25,43 +28,68 @@ async function assertEngineMismatchAsync(projectRoot, exp, platform) {
25
28
  const configFilePath = (ref = (_dynamicConfigPath = paths.dynamicConfigPath) != null ? _dynamicConfigPath : paths.staticConfigPath) != null ? ref : "app.json";
26
29
  await (0, _exportHermes).maybeThrowFromInconsistentEngineAsync(projectRoot, configFilePath, platform, isHermesManaged);
27
30
  }
28
- async function bundleAsync(projectRoot, expoConfig, options, bundles) {
31
+ async function createBundlesAsync(projectRoot, projectConfig, bundleOptions) {
32
+ if (!bundleOptions.platforms.length) {
33
+ return {};
34
+ }
35
+ const { exp , pkg } = projectConfig;
36
+ const bundles = await bundleProductionMetroClientAsync(projectRoot, exp, {
37
+ // If not legacy, ignore the target option to prevent warnings from being thrown.
38
+ resetCache: bundleOptions.clear,
39
+ maxWorkers: bundleOptions.maxWorkers
40
+ }, bundleOptions.platforms.map((platform)=>({
41
+ platform,
42
+ entryPoint: (0, _manifestMiddleware).getEntryWithServerRoot(projectRoot, {
43
+ platform,
44
+ pkg
45
+ }),
46
+ sourcemaps: bundleOptions.sourcemaps,
47
+ minify: bundleOptions.minify,
48
+ dev: bundleOptions.dev
49
+ })
50
+ ));
51
+ // { ios: bundle, android: bundle }
52
+ return bundleOptions.platforms.reduce((prev, platform, index)=>({
53
+ ...prev,
54
+ [platform]: bundles[index]
55
+ })
56
+ , {});
57
+ }
58
+ async function bundleProductionMetroClientAsync(projectRoot, expoConfig, metroOptions, bundles) {
29
59
  // Assert early so the user doesn't have to wait until bundling is complete to find out that
30
60
  // Hermes won't be available.
31
61
  await Promise.all(bundles.map(({ platform })=>assertEngineMismatchAsync(projectRoot, expoConfig, platform)
32
62
  ));
33
- const metro = (0, _resolveFromProject).importMetroFromProject(projectRoot);
34
- const Server = (0, _resolveFromProject).importMetroServerFromProject(projectRoot);
35
- const { config , reporter } = await (0, _instantiateMetro).loadMetroConfigAsync(projectRoot, options, {
63
+ const { config , reporter } = await (0, _instantiateMetro).loadMetroConfigAsync(projectRoot, metroOptions, {
36
64
  exp: expoConfig,
37
65
  isExporting: true
38
66
  });
39
- const metroServer = await metro.runMetro(config, {
67
+ const metroServer = await _metro.default.runMetro(config, {
40
68
  watch: false
41
69
  });
42
70
  const buildAsync = async (bundle)=>{
43
71
  const buildID = `bundle_${nextBuildID++}_${bundle.platform}`;
44
72
  const isHermes = (0, _exportHermes).isEnableHermesManaged(expoConfig, bundle.platform);
45
- var _dev, _minify;
46
73
  const bundleOptions = {
47
- ...Server.DEFAULT_BUNDLE_OPTIONS,
74
+ ..._server.default.DEFAULT_BUNDLE_OPTIONS,
75
+ ...(0, _metroOptions).getMetroDirectBundleOptions({
76
+ mainModuleName: bundle.entryPoint,
77
+ platform: bundle.platform,
78
+ mode: bundle.dev ? "development" : "production",
79
+ engine: isHermes ? "hermes" : undefined,
80
+ baseUrl: (0, _metroOptions).getBaseUrlFromExpoConfig(expoConfig)
81
+ }),
48
82
  bundleType: "bundle",
49
- platform: bundle.platform,
50
- entryFile: bundle.entryPoint,
51
- dev: (_dev = bundle.dev) != null ? _dev : false,
52
- minify: !isHermes && ((_minify = bundle.minify) != null ? _minify : !bundle.dev),
53
83
  inlineSourceMap: false,
54
84
  sourceMapUrl: bundle.sourceMapUrl,
55
85
  createModuleIdFactory: config.serializer.createModuleIdFactory,
56
86
  onProgress: (transformedFileCount, totalFileCount)=>{
57
- if (!options.quiet) {
58
- reporter.update({
59
- buildID,
60
- type: "bundle_transform_progressed",
61
- transformedFileCount,
62
- totalFileCount
63
- });
64
- }
87
+ reporter.update({
88
+ buildID,
89
+ type: "bundle_transform_progressed",
90
+ transformedFileCount,
91
+ totalFileCount
92
+ });
65
93
  }
66
94
  };
67
95
  const bundleDetails = {
@@ -108,9 +136,14 @@ async function bundleAsync(projectRoot, expoConfig, options, bundles) {
108
136
  }[platform] || platform);
109
137
  reporter.terminal.log(`${platformTag} Building Hermes bytecode for the bundle`);
110
138
  var _minify;
111
- const hermesBundleOutput = await (0, _exportHermes).buildHermesBundleAsync(projectRoot, bundleOutput.code, bundleOutput.map, (_minify = bundle.minify) != null ? _minify : !bundle.dev);
139
+ const hermesBundleOutput = await (0, _exportHermes).buildHermesBundleAsync(projectRoot, {
140
+ code: bundleOutput.code,
141
+ map: bundle.sourcemaps ? bundleOutput.map : null,
142
+ minify: (_minify = bundle.minify) != null ? _minify : !bundle.dev
143
+ });
112
144
  bundleOutput.hermesBytecodeBundle = hermesBundleOutput.hbc;
113
- bundleOutput.hermesSourcemap = hermesBundleOutput.sourcemap;
145
+ var _sourcemap;
146
+ bundleOutput.hermesSourcemap = (_sourcemap = hermesBundleOutput.sourcemap) != null ? _sourcemap : undefined;
114
147
  }
115
148
  return bundleOutput;
116
149
  };