@expo/cli 0.11.0 → 0.12.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 (281) hide show
  1. package/build/bin/cli +2 -2
  2. package/build/src/api/getExpoGoIntermediateCertificate.js +1 -1
  3. package/build/src/api/getExpoGoIntermediateCertificate.js.map +1 -1
  4. package/build/src/api/getExpoSchema.js +1 -1
  5. package/build/src/api/getExpoSchema.js.map +1 -1
  6. package/build/src/api/getNativeModuleVersions.js +1 -1
  7. package/build/src/api/getNativeModuleVersions.js.map +1 -1
  8. package/build/src/api/getProjectDevelopmentCertificate.js +1 -1
  9. package/build/src/api/getProjectDevelopmentCertificate.js.map +1 -1
  10. package/build/src/api/getVersions.js +1 -1
  11. package/build/src/api/getVersions.js.map +1 -1
  12. package/build/src/api/rest/cache/wrapFetchWithCache.js.map +1 -1
  13. package/build/src/api/rest/client.js +5 -5
  14. package/build/src/api/rest/client.js.map +1 -1
  15. package/build/src/api/rest/wrapFetchWithOffline.js.map +1 -1
  16. package/build/src/api/rest/wrapFetchWithProgress.js.map +1 -1
  17. package/build/src/api/rest/wrapFetchWithProxy.js.map +1 -1
  18. package/build/src/api/updateDevelopmentSession.js +1 -1
  19. package/build/src/api/updateDevelopmentSession.js.map +1 -1
  20. package/build/src/api/user/actions.js +2 -2
  21. package/build/src/api/user/actions.js.map +1 -1
  22. package/build/src/api/user/otp.js +1 -1
  23. package/build/src/api/user/otp.js.map +1 -1
  24. package/build/src/api/user/user.js +2 -2
  25. package/build/src/api/user/user.js.map +1 -1
  26. package/build/src/config/configAsync.js +17 -1
  27. package/build/src/config/configAsync.js.map +1 -1
  28. package/build/src/customize/customizeAsync.js +1 -1
  29. package/build/src/customize/customizeAsync.js.map +1 -1
  30. package/build/src/customize/generate.js +29 -2
  31. package/build/src/customize/generate.js.map +1 -1
  32. package/build/src/customize/templates.js +8 -0
  33. package/build/src/customize/templates.js.map +1 -1
  34. package/build/src/customize/typescript.js +54 -0
  35. package/build/src/customize/typescript.js.map +1 -0
  36. package/build/src/export/createBundles.js +1 -1
  37. package/build/src/export/createBundles.js.map +1 -1
  38. package/build/src/export/createMetadataJson.js.map +1 -1
  39. package/build/src/export/embed/exportEmbedAsync.js +50 -4
  40. package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
  41. package/build/src/export/embed/index.js +1 -3
  42. package/build/src/export/embed/index.js.map +1 -1
  43. package/build/src/export/embed/resolveOptions.js +6 -10
  44. package/build/src/export/embed/resolveOptions.js.map +1 -1
  45. package/build/src/export/exportApp.js +50 -41
  46. package/build/src/export/exportApp.js.map +1 -1
  47. package/build/src/export/exportAssets.js +2 -2
  48. package/build/src/export/exportAssets.js.map +1 -1
  49. package/build/src/export/exportAsync.js +1 -1
  50. package/build/src/export/exportAsync.js.map +1 -1
  51. package/build/src/export/exportStaticAsync.js +42 -12
  52. package/build/src/export/exportStaticAsync.js.map +1 -1
  53. package/build/src/export/fork-bundleAsync.js +27 -2
  54. package/build/src/export/fork-bundleAsync.js.map +1 -1
  55. package/build/src/export/getPublicExpoManifest.js +1 -1
  56. package/build/src/export/getPublicExpoManifest.js.map +1 -1
  57. package/build/src/export/getResolvedLocales.js.map +1 -1
  58. package/build/src/export/printBundleSizes.js.map +1 -1
  59. package/build/src/export/web/exportWebAsync.js.map +1 -1
  60. package/build/src/export/writeContents.js +5 -1
  61. package/build/src/export/writeContents.js.map +1 -1
  62. package/build/src/install/checkPackages.js +1 -1
  63. package/build/src/install/checkPackages.js.map +1 -1
  64. package/build/src/install/installAsync.js +1 -1
  65. package/build/src/install/installAsync.js.map +1 -1
  66. package/build/src/prebuild/configureProjectAsync.js +5 -9
  67. package/build/src/prebuild/configureProjectAsync.js.map +1 -1
  68. package/build/src/prebuild/prebuildAsync.js +5 -5
  69. package/build/src/prebuild/prebuildAsync.js.map +1 -1
  70. package/build/src/prebuild/updateFromTemplate.js +8 -5
  71. package/build/src/prebuild/updateFromTemplate.js.map +1 -1
  72. package/build/src/register/registerAsync.js +0 -1
  73. package/build/src/register/registerAsync.js.map +1 -1
  74. package/build/src/run/android/resolveInstallApkName.js.map +1 -1
  75. package/build/src/run/android/resolveOptions.js +1 -1
  76. package/build/src/run/android/resolveOptions.js.map +1 -1
  77. package/build/src/run/android/runAndroidAsync.js +2 -2
  78. package/build/src/run/android/runAndroidAsync.js.map +1 -1
  79. package/build/src/run/ios/XcodeBuild.js +2 -2
  80. package/build/src/run/ios/XcodeBuild.js.map +1 -1
  81. package/build/src/run/ios/appleDevice/AppleDevice.js +4 -4
  82. package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -1
  83. package/build/src/run/ios/appleDevice/ClientManager.js +1 -1
  84. package/build/src/run/ios/appleDevice/ClientManager.js.map +1 -1
  85. package/build/src/run/ios/appleDevice/client/AFCClient.js +1 -1
  86. package/build/src/run/ios/appleDevice/client/AFCClient.js.map +1 -1
  87. package/build/src/run/ios/appleDevice/client/DebugserverClient.js +1 -1
  88. package/build/src/run/ios/appleDevice/client/DebugserverClient.js.map +1 -1
  89. package/build/src/run/ios/appleDevice/client/InstallationProxyClient.js +1 -1
  90. package/build/src/run/ios/appleDevice/client/InstallationProxyClient.js.map +1 -1
  91. package/build/src/run/ios/appleDevice/client/LockdowndClient.js +1 -1
  92. package/build/src/run/ios/appleDevice/client/LockdowndClient.js.map +1 -1
  93. package/build/src/run/ios/appleDevice/client/MobileImageMounterClient.js +1 -1
  94. package/build/src/run/ios/appleDevice/client/MobileImageMounterClient.js.map +1 -1
  95. package/build/src/run/ios/appleDevice/client/ServiceClient.js.map +1 -1
  96. package/build/src/run/ios/appleDevice/client/UsbmuxdClient.js +1 -1
  97. package/build/src/run/ios/appleDevice/client/UsbmuxdClient.js.map +1 -1
  98. package/build/src/run/ios/appleDevice/installOnDeviceAsync.js +1 -1
  99. package/build/src/run/ios/appleDevice/installOnDeviceAsync.js.map +1 -1
  100. package/build/src/run/ios/appleDevice/protocol/AFCProtocol.js +1 -1
  101. package/build/src/run/ios/appleDevice/protocol/AFCProtocol.js.map +1 -1
  102. package/build/src/run/ios/appleDevice/protocol/AbstractProtocol.js.map +1 -1
  103. package/build/src/run/ios/appleDevice/protocol/GDBProtocol.js +1 -1
  104. package/build/src/run/ios/appleDevice/protocol/GDBProtocol.js.map +1 -1
  105. package/build/src/run/ios/appleDevice/protocol/LockdownProtocol.js +1 -1
  106. package/build/src/run/ios/appleDevice/protocol/LockdownProtocol.js.map +1 -1
  107. package/build/src/run/ios/codeSigning/configureCodeSigning.js +1 -1
  108. package/build/src/run/ios/codeSigning/configureCodeSigning.js.map +1 -1
  109. package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js +2 -2
  110. package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js.map +1 -1
  111. package/build/src/run/ios/codeSigning/xcodeCodeSigning.js +3 -0
  112. package/build/src/run/ios/codeSigning/xcodeCodeSigning.js.map +1 -1
  113. package/build/src/run/ios/index.js.map +1 -1
  114. package/build/src/run/ios/launchApp.js +2 -2
  115. package/build/src/run/ios/launchApp.js.map +1 -1
  116. package/build/src/run/ios/options/resolveDevice.js +1 -1
  117. package/build/src/run/ios/options/resolveDevice.js.map +1 -1
  118. package/build/src/run/ios/options/resolveOptions.js +2 -2
  119. package/build/src/run/ios/options/resolveOptions.js.map +1 -1
  120. package/build/src/run/ios/runIosAsync.js +3 -3
  121. package/build/src/run/ios/runIosAsync.js.map +1 -1
  122. package/build/src/start/doctor/apple/XcodePrerequisite.js +43 -2
  123. package/build/src/start/doctor/apple/XcodePrerequisite.js.map +1 -1
  124. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +1 -1
  125. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
  126. package/build/src/start/doctor/dependencies/getVersionedPackages.js +5 -3
  127. package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
  128. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +1 -1
  129. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
  130. package/build/src/start/doctor/ngrok/ExternalModule.js.map +1 -1
  131. package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js +7 -7
  132. package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js.map +1 -1
  133. package/build/src/start/doctor/typescript/updateTSConfig.js +11 -10
  134. package/build/src/start/doctor/typescript/updateTSConfig.js.map +1 -1
  135. package/build/src/start/index.js +0 -2
  136. package/build/src/start/index.js.map +1 -1
  137. package/build/src/start/interface/interactiveActions.js +1 -1
  138. package/build/src/start/interface/interactiveActions.js.map +1 -1
  139. package/build/src/start/interface/startInterface.js +3 -3
  140. package/build/src/start/interface/startInterface.js.map +1 -1
  141. package/build/src/start/platforms/ExpoGoInstaller.js.map +1 -1
  142. package/build/src/start/platforms/PlatformManager.js.map +1 -1
  143. package/build/src/start/platforms/android/ADBServer.js +1 -1
  144. package/build/src/start/platforms/android/ADBServer.js.map +1 -1
  145. package/build/src/start/platforms/android/AndroidDeviceManager.js +5 -5
  146. package/build/src/start/platforms/android/AndroidDeviceManager.js.map +1 -1
  147. package/build/src/start/platforms/android/AndroidPlatformManager.js +1 -1
  148. package/build/src/start/platforms/android/AndroidPlatformManager.js.map +1 -1
  149. package/build/src/start/platforms/android/adb.js +1 -1
  150. package/build/src/start/platforms/android/adb.js.map +1 -1
  151. package/build/src/start/platforms/android/adbReverse.js +2 -2
  152. package/build/src/start/platforms/android/adbReverse.js.map +1 -1
  153. package/build/src/start/platforms/android/emulator.js +1 -1
  154. package/build/src/start/platforms/android/emulator.js.map +1 -1
  155. package/build/src/start/platforms/android/getDevices.js +1 -1
  156. package/build/src/start/platforms/android/getDevices.js.map +1 -1
  157. package/build/src/start/platforms/android/promptAndroidDevice.js +1 -1
  158. package/build/src/start/platforms/android/promptAndroidDevice.js.map +1 -1
  159. package/build/src/start/platforms/ios/AppleDeviceManager.js +5 -5
  160. package/build/src/start/platforms/ios/AppleDeviceManager.js.map +1 -1
  161. package/build/src/start/platforms/ios/ApplePlatformManager.js +1 -1
  162. package/build/src/start/platforms/ios/ApplePlatformManager.js.map +1 -1
  163. package/build/src/start/platforms/ios/ensureSimulatorAppRunning.js.map +1 -1
  164. package/build/src/start/platforms/ios/getBestSimulator.js +1 -1
  165. package/build/src/start/platforms/ios/getBestSimulator.js.map +1 -1
  166. package/build/src/start/platforms/ios/promptAppleDevice.js +1 -1
  167. package/build/src/start/platforms/ios/promptAppleDevice.js.map +1 -1
  168. package/build/src/start/platforms/ios/simctl.js +1 -1
  169. package/build/src/start/platforms/ios/simctl.js.map +1 -1
  170. package/build/src/start/platforms/ios/simctlLogging.js +1 -1
  171. package/build/src/start/platforms/ios/simctlLogging.js.map +1 -1
  172. package/build/src/start/resolveOptions.js +0 -5
  173. package/build/src/start/resolveOptions.js.map +1 -1
  174. package/build/src/start/server/AsyncNgrok.js +4 -3
  175. package/build/src/start/server/AsyncNgrok.js.map +1 -1
  176. package/build/src/start/server/BundlerDevServer.js +4 -11
  177. package/build/src/start/server/BundlerDevServer.js.map +1 -1
  178. package/build/src/start/server/DevServerManager.js +3 -2
  179. package/build/src/start/server/DevServerManager.js.map +1 -1
  180. package/build/src/start/server/UrlCreator.js +2 -1
  181. package/build/src/start/server/UrlCreator.js.map +1 -1
  182. package/build/src/start/server/getStaticRenderFunctions.js +2 -2
  183. package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
  184. package/build/src/start/server/metro/MetroBundlerDevServer.js +42 -25
  185. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  186. package/build/src/start/server/metro/MetroTerminalReporter.js +14 -3
  187. package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
  188. package/build/src/start/server/metro/TerminalReporter.js.map +1 -1
  189. package/build/src/start/server/metro/TerminalReporter.types.js.map +1 -1
  190. package/build/src/start/server/metro/inspector-proxy/device.js.map +1 -1
  191. package/build/src/start/server/metro/inspector-proxy/handlers/NetworkResponse.js.map +1 -1
  192. package/build/src/start/server/metro/inspector-proxy/handlers/PageReload.js.map +1 -1
  193. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerGetPossibleBreakpoints.js.map +1 -1
  194. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerScriptParsed.js.map +1 -1
  195. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerSetBreakpointByUrl.js.map +1 -1
  196. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeGetProperties.js.map +1 -1
  197. package/build/src/start/server/metro/inspector-proxy/handlers/types.js.map +1 -1
  198. package/build/src/start/server/metro/inspector-proxy/index.js +1 -1
  199. package/build/src/start/server/metro/inspector-proxy/index.js.map +1 -1
  200. package/build/src/start/server/metro/instantiateMetro.js +49 -8
  201. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  202. package/build/src/start/server/metro/resolveFromProject.js +0 -4
  203. package/build/src/start/server/metro/resolveFromProject.js.map +1 -1
  204. package/build/src/start/server/metro/runServer-fork.js +1 -1
  205. package/build/src/start/server/metro/runServer-fork.js.map +1 -1
  206. package/build/src/start/server/metro/withMetroMultiPlatform.js +59 -9
  207. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  208. package/build/src/start/server/metro/withMetroResolvers.js +6 -5
  209. package/build/src/start/server/metro/withMetroResolvers.js.map +1 -1
  210. package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js +2 -2
  211. package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js.map +1 -1
  212. package/build/src/start/server/middleware/ExpoMiddleware.js.map +1 -1
  213. package/build/src/start/server/middleware/FaviconMiddleware.js +1 -1
  214. package/build/src/start/server/middleware/FaviconMiddleware.js.map +1 -1
  215. package/build/src/start/server/middleware/ManifestMiddleware.js +8 -11
  216. package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
  217. package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js +1 -1
  218. package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js.map +1 -1
  219. package/build/src/start/server/middleware/ServeStaticMiddleware.js +1 -1
  220. package/build/src/start/server/middleware/ServeStaticMiddleware.js.map +1 -1
  221. package/build/src/start/server/middleware/resolvePlatform.js.map +1 -1
  222. package/build/src/start/server/middleware/server.types.js.map +1 -1
  223. package/build/src/start/server/openPlatforms.js.map +1 -1
  224. package/build/src/start/server/type-generation/__typetests__/fixtures/basic.js.map +1 -1
  225. package/build/src/start/server/type-generation/routes.js +6 -6
  226. package/build/src/start/server/type-generation/routes.js.map +1 -1
  227. package/build/src/start/server/type-generation/startTypescriptTypeGeneration.js +3 -3
  228. package/build/src/start/server/type-generation/startTypescriptTypeGeneration.js.map +1 -1
  229. package/build/src/start/server/webpack/WebpackBundlerDevServer.js +10 -5
  230. package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
  231. package/build/src/start/server/webpack/compile.js +1 -1
  232. package/build/src/start/server/webpack/compile.js.map +1 -1
  233. package/build/src/start/startAsync.js +10 -32
  234. package/build/src/start/startAsync.js.map +1 -1
  235. package/build/src/utils/FileNotifier.js +1 -1
  236. package/build/src/utils/FileNotifier.js.map +1 -1
  237. package/build/src/utils/analytics/metroDebuggerMiddleware.js +1 -1
  238. package/build/src/utils/analytics/metroDebuggerMiddleware.js.map +1 -1
  239. package/build/src/utils/analytics/rudderstackClient.js +2 -2
  240. package/build/src/utils/array.js.map +1 -1
  241. package/build/src/utils/cocoapods.js +2 -2
  242. package/build/src/utils/cocoapods.js.map +1 -1
  243. package/build/src/utils/codesigning.js +2 -2
  244. package/build/src/utils/codesigning.js.map +1 -1
  245. package/build/src/utils/downloadAppAsync.js +1 -1
  246. package/build/src/utils/downloadAppAsync.js.map +1 -1
  247. package/build/src/utils/downloadExpoGoAsync.js +2 -2
  248. package/build/src/utils/downloadExpoGoAsync.js.map +1 -1
  249. package/build/src/utils/editor.js +1 -1
  250. package/build/src/utils/editor.js.map +1 -1
  251. package/build/src/utils/env.js +1 -1
  252. package/build/src/utils/env.js.map +1 -1
  253. package/build/src/utils/errors.js.map +1 -1
  254. package/build/src/utils/getOrPromptApplicationId.js +2 -2
  255. package/build/src/utils/getOrPromptApplicationId.js.map +1 -1
  256. package/build/src/utils/git.js +1 -1
  257. package/build/src/utils/git.js.map +1 -1
  258. package/build/src/utils/modifyConfigAsync.js +1 -1
  259. package/build/src/utils/modifyConfigAsync.js.map +1 -1
  260. package/build/src/utils/modifyConfigPlugins.js +1 -1
  261. package/build/src/utils/modifyConfigPlugins.js.map +1 -1
  262. package/build/src/utils/npm.js +1 -1
  263. package/build/src/utils/npm.js.map +1 -1
  264. package/build/src/utils/obj.js.map +1 -1
  265. package/build/src/utils/plist.js +1 -1
  266. package/build/src/utils/plist.js.map +1 -1
  267. package/build/src/utils/port.js +1 -1
  268. package/build/src/utils/port.js.map +1 -1
  269. package/build/src/utils/profile.js +1 -1
  270. package/build/src/utils/profile.js.map +1 -1
  271. package/build/src/utils/scheme.js +1 -1
  272. package/build/src/utils/scheme.js.map +1 -1
  273. package/build/src/utils/tsconfig/loadTsConfigPaths.js +1 -1
  274. package/build/src/utils/tsconfig/loadTsConfigPaths.js.map +1 -1
  275. package/build/src/utils/validateApplicationId.js +85 -5
  276. package/build/src/utils/validateApplicationId.js.map +1 -1
  277. package/package.json +11 -8
  278. package/build/src/api/signManifest.js +0 -26
  279. package/build/src/api/signManifest.js.map +0 -1
  280. package/build/src/start/server/middleware/ClassicManifestMiddleware.js +0 -155
  281. package/build/src/start/server/middleware/ClassicManifestMiddleware.js.map +0 -1
@@ -5,12 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  exports.exportAppAsync = exportAppAsync;
6
6
  var _fs = _interopRequireDefault(require("fs"));
7
7
  var _path = _interopRequireDefault(require("path"));
8
- var Log = _interopRequireWildcard(require("../log"));
9
- var _resolveFromProject = require("../start/server/metro/resolveFromProject");
10
- var _webTemplate = require("../start/server/webTemplate");
11
- var _dir = require("../utils/dir");
12
- var _env = require("../utils/env");
13
- var _nodeEnv = require("../utils/nodeEnv");
14
8
  var _createBundles = require("./createBundles");
15
9
  var _exportAssets = require("./exportAssets");
16
10
  var _exportStaticAsync = require("./exportStaticAsync");
@@ -18,6 +12,12 @@ var _favicon = require("./favicon");
18
12
  var _getPublicExpoManifest = require("./getPublicExpoManifest");
19
13
  var _printBundleSizes = require("./printBundleSizes");
20
14
  var _writeContents = require("./writeContents");
15
+ var Log = _interopRequireWildcard(require("../log"));
16
+ var _resolveFromProject = require("../start/server/metro/resolveFromProject");
17
+ var _webTemplate = require("../start/server/webTemplate");
18
+ var _dir = require("../utils/dir");
19
+ var _env = require("../utils/env");
20
+ var _nodeEnv = require("../utils/nodeEnv");
21
21
  function _interopRequireDefault(obj) {
22
22
  return obj && obj.__esModule ? obj : {
23
23
  default: obj
@@ -93,6 +93,7 @@ async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev
93
93
  // Write the JS bundles to disk, and get the bundle file names (this could change with async chunk loading support).
94
94
  const { hashes , fileNames } = await (0, _writeContents).writeBundlesAsync({
95
95
  bundles,
96
+ useWebSSG,
96
97
  outputDir: bundlesPath
97
98
  });
98
99
  Log.log("Finished saving JS Bundles");
@@ -101,7 +102,8 @@ async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev
101
102
  await (0, _exportStaticAsync).unstable_exportStaticAsync(projectRoot, {
102
103
  outputDir: outputPath,
103
104
  // TODO: Expose
104
- minify
105
+ minify,
106
+ includeMaps: dumpSourcemap
105
107
  });
106
108
  Log.log("Finished saving static files");
107
109
  } else {
@@ -124,47 +126,54 @@ async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev
124
126
  // If web exists, then write the template HTML file.
125
127
  await _fs.default.promises.writeFile(_path.default.join(staticFolder, "index.html"), html);
126
128
  }
127
- // Save assets like a typical bundler, preserving the file paths on web.
128
- const saveAssets = (0, _resolveFromProject).importCliSaveAssetsFromProject(projectRoot);
129
- await Promise.all(Object.entries(bundles).map(([platform, bundle])=>{
130
- return saveAssets(bundle.assets, platform, staticFolder, undefined);
131
- }));
129
+ // TODO: Use a different mechanism for static web.
130
+ if (bundles.web) {
131
+ // 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
+ }));
136
+ }
132
137
  }
133
- const { assets } = await (0, _exportAssets).exportAssetsAsync(projectRoot, {
134
- exp,
135
- outputDir: staticFolder,
136
- bundles
137
- });
138
- if (dumpAssetmap) {
139
- Log.log("Dumping asset map");
140
- await (0, _writeContents).writeAssetMapAsync({
138
+ // Can be empty during web-only SSG.
139
+ // TODO: Use same asset system across platforms again.
140
+ if (Object.keys(fileNames).length) {
141
+ const { assets } = await (0, _exportAssets).exportAssetsAsync(projectRoot, {
142
+ exp,
141
143
  outputDir: staticFolder,
142
- assets
144
+ bundles
143
145
  });
144
- }
145
- // build source maps
146
- if (dumpSourcemap) {
147
- Log.log("Dumping source maps");
148
- await (0, _writeContents).writeSourceMapsAsync({
149
- bundles,
150
- hashes,
151
- outputDir: bundlesPath,
152
- fileNames
153
- });
154
- Log.log("Preparing additional debugging files");
155
- // If we output source maps, then add a debug HTML file which the user can open in
156
- // the web browser to inspect the output like web.
157
- await (0, _writeContents).writeDebugHtmlAsync({
146
+ if (dumpAssetmap) {
147
+ Log.log("Dumping asset map");
148
+ await (0, _writeContents).writeAssetMapAsync({
149
+ outputDir: staticFolder,
150
+ assets
151
+ });
152
+ }
153
+ // build source maps
154
+ if (dumpSourcemap) {
155
+ Log.log("Dumping source maps");
156
+ await (0, _writeContents).writeSourceMapsAsync({
157
+ bundles,
158
+ hashes,
159
+ outputDir: bundlesPath,
160
+ fileNames
161
+ });
162
+ Log.log("Preparing additional debugging files");
163
+ // If we output source maps, then add a debug HTML file which the user can open in
164
+ // the web browser to inspect the output like web.
165
+ await (0, _writeContents).writeDebugHtmlAsync({
166
+ outputDir: staticFolder,
167
+ fileNames
168
+ });
169
+ }
170
+ // Generate a `metadata.json` and the export is complete.
171
+ await (0, _writeContents).writeMetadataJsonAsync({
158
172
  outputDir: staticFolder,
173
+ bundles,
159
174
  fileNames
160
175
  });
161
176
  }
162
- // Generate a `metadata.json` and the export is complete.
163
- await (0, _writeContents).writeMetadataJsonAsync({
164
- outputDir: staticFolder,
165
- bundles,
166
- fileNames
167
- });
168
177
  }
169
178
  /**
170
179
  * Copy the contents of the public folder into the output folder.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/exportApp.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\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';\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';\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({ bundles, outputDir: bundlesPath });\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 });\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 // 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 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\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 * 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","cssLinks","exportCssAssetsAsync","html","createTemplateHtmlFromExpoConfigAsync","scripts","modifyHtml","getVirtualFaviconAssetsAsync","fs","promises","writeFile","saveAssets","importCliSaveAssetsFromProject","platform","bundle","assets","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;AAEXC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACgC,IAAA,mBAA0C,WAA1C,0CAA0C,CAAA;AACnC,IAAA,YAA6B,WAA7B,6BAA6B,CAAA;AACnC,IAAA,IAAc,WAAd,cAAc,CAAA;AAC1C,IAAA,IAAc,WAAd,cAAc,CAAA;AACP,IAAA,QAAkB,WAAlB,kBAAkB,CAAA;AACV,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,WAAzB,yBAAyB,CAAA;AACnC,IAAA,iBAAoB,WAApB,oBAAoB,CAAA;AAQ9C,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcjB,eAAeD,cAAc,CAClCE,WAAmB,EACnB,EACEC,SAAS,CAAA,EACTC,SAAS,CAAA,EACTC,KAAK,CAAA,EACLC,GAAG,CAAA,EACHC,YAAY,CAAA,EACZC,aAAa,CAAA,EACbC,MAAM,CAAA,EAIP,EACc;QAMGC,GAAO;IALzBC,CAAAA,GAAAA,QAAU,AAAoC,CAAA,WAApC,CAACL,GAAG,GAAG,a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AE/D,SAAS,EAAEoB,YAAY;YAAEyC,MAAM;SAAE,CAAC,CAAC;KAC/D;IAED,oBAAoB;IACpB,IAAIzD,aAAa,EAAE;QACjBP,GAAG,CAAC+C,GAAG,CAAC,qBAAqB,CAAC,CAAC;QAC/B,MAAMoB,CAAAA,GAAAA,cAAoB,AAKxB,CAAA,qBALwB,CAAC;YACzBnC,OAAO;YACPY,MAAM;YACNzC,SAAS,EAAEuB,WAAW;YACtBmB,SAAS;SACV,CAAC,CAAC;QAEH7C,GAAG,CAAC+C,GAAG,CAAC,sCAAsC,CAAC,CAAC;QAChD,kFAAkF;QAClF,kDAAkD;QAClD,MAAMqB,CAAAA,GAAAA,cAAmB,AAGvB,CAAA,oBAHuB,CAAC;YACxBjE,SAAS,EAAEoB,YAAY;YACvBsB,SAAS;SACV,CAAC,CAAC;KACJ;IAED,yDAAyD;IACzD,MAAMwB,CAAAA,GAAAA,cAAsB,AAAiD,CAAA,uBAAjD,CAAC;QAAElE,SAAS,EAAEoB,YAAY;QAAES,OAAO;QAAEa,SAAS;KAAE,CAAC,CAAC;CAC/E;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"}
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,iBAAi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zC,SAAS,EAAEuB,WAAW;gBACtBmB,SAAS;aACV,CAAC,CAAC;YAEH7C,GAAG,CAAC+C,GAAG,CAAC,sCAAsC,CAAC,CAAC;YAChD,kFAAkF;YAClF,kDAAkD;YAClD,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"}
@@ -8,10 +8,10 @@ exports.exportCssAssetsAsync = exportCssAssetsAsync;
8
8
  var _fs = _interopRequireDefault(require("fs"));
9
9
  var _minimatch = _interopRequireDefault(require("minimatch"));
10
10
  var _path = _interopRequireDefault(require("path"));
11
+ var _saveAssets = require("./saveAssets");
11
12
  var Log = _interopRequireWildcard(require("../log"));
12
13
  var _resolveAssets = require("../start/server/middleware/resolveAssets");
13
14
  var _array = require("../utils/array");
14
- var _saveAssets = require("./saveAssets");
15
15
  function _interopRequireDefault(obj) {
16
16
  return obj && obj.__esModule ? obj : {
17
17
  default: obj
@@ -64,7 +64,7 @@ async function resolveAssetBundlePatternsAsync(projectRoot, exp, assets) {
64
64
  }).flat();
65
65
  // The assets returned by the RN packager has duplicates so make sure we
66
66
  // only bundle each once.
67
- exp.bundledAssets = [
67
+ (exp).bundledAssets = [
68
68
  ...new Set(allBundledAssets)
69
69
  ];
70
70
  delete exp.assetBundlePatterns;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/exportAssets.ts"],"sourcesContent":["import { ExpoAppManifest } from '@expo/config';\nimport { ModPlatform } from '@expo/config-plugins';\nimport fs from 'fs';\nimport minimatch from 'minimatch';\nimport path from 'path';\n\nimport * as Log from '../log';\nimport { resolveGoogleServicesFile } from '../start/server/middleware/resolveAssets';\nimport { uniqBy } from '../utils/array';\nimport { BundleOutput } from './fork-bundleAsync';\nimport { Asset, saveAssetsAsync } from './saveAssets';\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(\n projectRoot: string,\n exp: Pick<ExpoAppManifest, 'bundledAssets' | 'assetBundlePatterns'>,\n assets: Asset[]\n) {\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.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: ExpoAppManifest;\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;AAEXC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AAC2B,IAAA,cAA0C,WAA1C,0CAA0C,CAAA;AAC7D,IAAA,MAAgB,WAAhB,gBAAgB,CAAA;AAEA,IAAA,WAAc,WAAd,cAAc,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAErD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,0BAA0B,CAAC,AAAsB,AAAC;AAO1E,eAAeL,+BAA+B,CACnDM,WAAmB,EACnBC,GAAmE,EACnEC,MAAe,EACf;QACKD,IAAuB;IAA5B,IAAI,CAACA,CAAAA,CAAAA,IAAuB,GAAvBA,GAAG,CAACE,mBAAmB,SAAQ,GAA/BF,KAAAA,CAA+B,GAA/BA,IAAuB,CAAEG,MAAM,CAAA,IAAI,CAACF,MAAM,CAACE,MAAM,EAAE;QACtD,OAAOH,GAAG,CAACE,mBAAmB,CAAC;QAC/B,OAAOF,GAAG,CAAC;KACZ;IACD,qEAAqE;IACrE,sEAAsE;IACtE,6EAA6E;IAC7E,yEAAyE;IAEzE,MAAMI,YAAY,GAAaJ,GAAG,CAACE,mBAAmB,CAACG,GAAG,CAAC,CAACC,CAAS,GACnEC,KAAI,QAAA,CAACC,IAAI,CAACT,WAAW,EAAEO,CAAC,CAAC;IAAA,CAC1B,AAAC;IAEFG,WAAW,CAACL,YAAY,CAAC,CAAC;IAE1B,MAAMM,gBAAgB,GAAGT,MAAM,CAC5BI,G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S,CAAA,EACTC,OAAO,CAAA,EAIR,EAAE;QAMoB7B,GAAS;IAL9B,MAAMA,MAAM,GAAG8B,CAAAA,GAAAA,MAAM,AAGpB,CAAA,OAHoB,CACnBC,MAAM,CAACC,MAAM,CAACH,OAAO,CAAC,CAACI,OAAO,CAAC,CAACC,MAAM,GAAKA,MAAM,CAAEG,GAAG;IAAA,CAAC,EACvD,CAAC3B,KAAK,GAAKA,KAAK,CAAC4B,QAAQ;IAAA,CAC1B,AAAC;IAEF,MAAMC,YAAY,GAAGvC,CAAAA,GAAS,GAATA,MAAM,CAAC,CAAC,CAAC,SAAU,GAAnBA,KAAAA,CAAmB,GAAnBA,GAAS,CAAEsC,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}: {\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,o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AO,CAAC,CAACC,MAAM,GAAKA,MAAM,CAAEG,GAAG;IAAA,CAAC,EACvD,CAAC3B,KAAK,GAAKA,KAAK,CAAC4B,QAAQ;IAAA,CAC1B,AAAC;IAEF,MAAMC,YAAY,GAAGvC,CAAAA,GAAS,GAATA,MAAM,CAAC,CAAC,CAAC,SAAU,GAAnBA,KAAAA,CAAmB,GAAnBA,GAAS,CAAEsC,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"}
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  exports.exportAsync = exportAsync;
6
6
  var _path = _interopRequireDefault(require("path"));
7
+ var _exportApp = require("./exportApp");
7
8
  var Log = _interopRequireWildcard(require("../log"));
8
9
  var _fileNotifier = require("../utils/FileNotifier");
9
10
  var _dir = require("../utils/dir");
10
- var _exportApp = require("./exportApp");
11
11
  function _interopRequireDefault(obj) {
12
12
  return obj && obj.__esModule ? obj : {
13
13
  default: obj
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/exportAsync.ts"],"sourcesContent":["import path from 'path';\n\nimport * as Log from '../log';\nimport { FileNotifier } from '../utils/FileNotifier';\nimport { ensureDirectoryAsync, removeAsync } from '../utils/dir';\nimport { exportAppAsync } from './exportApp';\nimport { Options } from './resolveOptions';\n\nexport async function exportAsync(projectRoot: string, options: Options) {\n // Ensure the output directory is created\n const outputPath = path.resolve(projectRoot, options.outputDir);\n // Delete the output directory if it exists\n await removeAsync(outputPath);\n // Create the output directory\n await ensureDirectoryAsync(outputPath);\n\n // Export the app\n await exportAppAsync(projectRoot, options);\n\n // Stop any file watchers to prevent the CLI from hanging.\n FileNotifier.stopAll();\n\n // Final notes\n Log.log(`Export was successful. Your exported files can be found in ${options.outputDir}`);\n}\n"],"names":["exportAsync","Log","projectRoot","options","outputPath","path","resolve","outputDir","removeAsync","ensureDirectoryAsync","exportAppAsync","FileNotifier","stopAll","log"],"mappings":"AAAA;;;;QAQsBA,WAAW,GAAXA,WAAW;AARhB,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEXC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACc,IAAA,aAAuB,WAAvB,uBAAuB,CAAA;AACF,IAAA,IAAc,WAAd,cAAc,CAAA;AACjC,IAAA,UAAa,WAAb,aAAa,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGrC,eAAeD,WAAW,CAACE,WAAmB,EAAEC,OAAgB,EAAE;IACvE,yCAAyC;IACzC,MAAMC,UAAU,GAAGC,KAAI,QAAA,CAACC,OAAO,CAACJ,WAAW,EAAEC,OAAO,CAACI,SAAS,CAAC,AAAC;IAChE,2CAA2C;IAC3C,MAAMC,CAAAA,GAAAA,IAAW,AAAY,CAAA,YAAZ,CAACJ,UAAU,CAAC,CAAC;IAC9B,8BAA8B;IAC9B,MAAMK,CAAAA,GAAAA,IAAoB,AAAY,CAAA,qBAAZ,CAACL,UAAU,CAAC,CAAC;IAEvC,iBAAiB;IACjB,MAAMM,CAAAA,GAAAA,UAAc,AAAsB,CAAA,eAAtB,CAACR,WAAW,EAAEC,OAAO,CAAC,CAAC;IAE3C,0DAA0D;IAC1DQ,aAAY,aAAA,CAACC,OAAO,EAAE,CAAC;IAEvB,cAAc;IACdX,GAAG,CAACY,GAAG,CAAC,CAAC,2DAA2D,EAAEV,OAAO,CAACI,SAAS,CAAC,CAAC,CAAC,CAAC;CAC5F"}
1
+ {"version":3,"sources":["../../../src/export/exportAsync.ts"],"sourcesContent":["import path from 'path';\n\nimport { exportAppAsync } from './exportApp';\nimport { Options } from './resolveOptions';\nimport * as Log from '../log';\nimport { FileNotifier } from '../utils/FileNotifier';\nimport { ensureDirectoryAsync, removeAsync } from '../utils/dir';\n\nexport async function exportAsync(projectRoot: string, options: Options) {\n // Ensure the output directory is created\n const outputPath = path.resolve(projectRoot, options.outputDir);\n // Delete the output directory if it exists\n await removeAsync(outputPath);\n // Create the output directory\n await ensureDirectoryAsync(outputPath);\n\n // Export the app\n await exportAppAsync(projectRoot, options);\n\n // Stop any file watchers to prevent the CLI from hanging.\n FileNotifier.stopAll();\n\n // Final notes\n Log.log(`Export was successful. Your exported files can be found in ${options.outputDir}`);\n}\n"],"names":["exportAsync","Log","projectRoot","options","outputPath","path","resolve","outputDir","removeAsync","ensureDirectoryAsync","exportAppAsync","FileNotifier","stopAll","log"],"mappings":"AAAA;;;;QAQsBA,WAAW,GAAXA,WAAW;AARhB,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEQ,IAAA,UAAa,WAAb,aAAa,CAAA;AAEhCC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACc,IAAA,aAAuB,WAAvB,uBAAuB,CAAA;AACF,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzD,eAAeD,WAAW,CAACE,WAAmB,EAAEC,OAAgB,EAAE;IACvE,yCAAyC;IACzC,MAAMC,UAAU,GAAGC,KAAI,QAAA,CAACC,OAAO,CAACJ,WAAW,EAAEC,OAAO,CAACI,SAAS,CAAC,AAAC;IAChE,2CAA2C;IAC3C,MAAMC,CAAAA,GAAAA,IAAW,AAAY,CAAA,YAAZ,CAACJ,UAAU,CAAC,CAAC;IAC9B,8BAA8B;IAC9B,MAAMK,CAAAA,GAAAA,IAAoB,AAAY,CAAA,qBAAZ,CAACL,UAAU,CAAC,CAAC;IAEvC,iBAAiB;IACjB,MAAMM,CAAAA,GAAAA,UAAc,AAAsB,CAAA,eAAtB,CAACR,WAAW,EAAEC,OAAO,CAAC,CAAC;IAE3C,0DAA0D;IAC1DQ,aAAY,aAAA,CAACC,OAAO,EAAE,CAAC;IAEvB,cAAc;IACdX,GAAG,CAACY,GAAG,CAAC,CAAC,2DAA2D,EAAEV,OAAO,CAACI,SAAS,CAAC,CAAC,CAAC,CAAC;CAC5F"}
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  exports.unstable_exportStaticAsync = unstable_exportStaticAsync;
6
6
  exports.getFilesToExportFromServerAsync = getFilesToExportFromServerAsync;
7
7
  exports.exportFromServerAsync = exportFromServerAsync;
8
+ exports.modifyBundlesWithSourceMaps = modifyBundlesWithSourceMaps;
8
9
  exports.getHtmlFiles = getHtmlFiles;
9
10
  exports.getPathVariations = getPathVariations;
10
11
  var _assert = _interopRequireDefault(require("assert"));
@@ -13,11 +14,12 @@ var _fs = _interopRequireDefault(require("fs"));
13
14
  var _path = _interopRequireDefault(require("path"));
14
15
  var _prettyBytes = _interopRequireDefault(require("pretty-bytes"));
15
16
  var _util = require("util");
17
+ var _favicon = require("./favicon");
16
18
  var _log = require("../log");
17
19
  var _devServerManager = require("../start/server/DevServerManager");
18
20
  var _metroBundlerDevServer = require("../start/server/metro/MetroBundlerDevServer");
19
21
  var _metroErrorInterface = require("../start/server/metro/metroErrorInterface");
20
- var _favicon = require("./favicon");
22
+ var _link = require("../utils/link");
21
23
  function _interopRequireDefault(obj) {
22
24
  return obj && obj.__esModule ? obj : {
23
25
  default: obj
@@ -25,8 +27,8 @@ function _interopRequireDefault(obj) {
25
27
  }
26
28
  const debug = require("debug")("expo:export:generateStaticRoutes");
27
29
  async function unstable_exportStaticAsync(projectRoot, options) {
28
- // NOTE(EvanBacon): Please don't use this feature.
29
- _log.Log.warn("Static exporting with Metro is an experimental feature.");
30
+ _log.Log.warn(`Experimental static rendering is enabled. ` + (0, _link).learnMore("https://docs.expo.dev/router/reference/static-rendering/"));
31
+ // TODO: Prevent starting the watcher.
30
32
  const devServerManager = new _devServerManager.DevServerManager(projectRoot, {
31
33
  minify: options.minify,
32
34
  mode: "production",
@@ -34,11 +36,18 @@ async function unstable_exportStaticAsync(projectRoot, options) {
34
36
  });
35
37
  await devServerManager.startAsync([
36
38
  {
37
- type: "metro"
39
+ type: "metro",
40
+ options: {
41
+ location: {},
42
+ isExporting: true
43
+ }
38
44
  },
39
45
  ]);
40
- await exportFromServerAsync(projectRoot, devServerManager, options);
41
- await devServerManager.stopAsync();
46
+ try {
47
+ await exportFromServerAsync(projectRoot, devServerManager, options);
48
+ } finally{
49
+ await devServerManager.stopAsync();
50
+ }
42
51
  }
43
52
  /** Match `(page)` -> `page` */ function matchGroupName(name) {
44
53
  var ref;
@@ -50,7 +59,7 @@ async function getFilesToExportFromServerAsync(projectRoot, { manifest , renderA
50
59
  await Promise.all(getHtmlFiles({
51
60
  manifest
52
61
  }).map(async (outputPath)=>{
53
- const pathname = outputPath.replace(/(index)?\.html$/, "");
62
+ const pathname = outputPath.replace(/(?:index)?\.html$/, "");
54
63
  try {
55
64
  files.set(outputPath, "");
56
65
  const data = await renderAsync(pathname);
@@ -65,15 +74,15 @@ async function getFilesToExportFromServerAsync(projectRoot, { manifest , renderA
65
74
  }));
66
75
  return files;
67
76
  }
68
- async function exportFromServerAsync(projectRoot, devServerManager, { outputDir , minify }) {
77
+ async function exportFromServerAsync(projectRoot, devServerManager, { outputDir , minify , includeMaps }) {
69
78
  const injectFaviconTag = await (0, _favicon).getVirtualFaviconAssetsAsync(projectRoot, outputDir);
70
79
  const devServer = devServerManager.getDefaultDevServer();
71
80
  (0, _assert).default(devServer instanceof _metroBundlerDevServer.MetroBundlerDevServer);
72
- const [manifest, resources, renderAsync] = await Promise.all([
73
- devServer.getRoutesAsync(),
81
+ const [resources, { manifest , renderAsync }] = await Promise.all([
74
82
  devServer.getStaticResourcesAsync({
75
83
  mode: "production",
76
- minify
84
+ minify,
85
+ includeMaps
77
86
  }),
78
87
  devServer.getStaticRenderFunctionAsync({
79
88
  mode: "production",
@@ -100,7 +109,7 @@ async function exportFromServerAsync(projectRoot, devServerManager, { outputDir
100
109
  }
101
110
  });
102
111
  resources.forEach((resource)=>{
103
- files.set(resource.filename, resource.source);
112
+ files.set(resource.filename, modifyBundlesWithSourceMaps(resource.filename, resource.source, includeMaps));
104
113
  });
105
114
  _fs.default.mkdirSync(_path.default.join(outputDir), {
106
115
  recursive: true
@@ -121,6 +130,27 @@ async function exportFromServerAsync(projectRoot, devServerManager, { outputDir
121
130
  }));
122
131
  _log.Log.log("");
123
132
  }
133
+ function modifyBundlesWithSourceMaps(filename, source, includeMaps) {
134
+ if (filename.endsWith(".js")) {
135
+ // If the bundle ends with source map URLs then update them to point to the correct location.
136
+ // TODO: basePath support
137
+ const normalizedFilename = "/" + filename.replace(/^\/+/, "");
138
+ //# sourceMappingURL=//localhost:8085/index.map?platform=web&dev=false&hot=false&lazy=true&minify=true&resolver.environment=client&transform.environment=client&serializer.output=static
139
+ //# 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
140
+ return source.replace(/^\/\/# (sourceMappingURL|sourceURL)=.*$/gm, (...props)=>{
141
+ if (includeMaps) {
142
+ if (props[1] === "sourceURL") {
143
+ return `//# ${props[1]}=` + normalizedFilename;
144
+ } else if (props[1] === "sourceMappingURL") {
145
+ const mapName = normalizedFilename + ".map";
146
+ return `//# ${props[1]}=` + mapName;
147
+ }
148
+ }
149
+ return "";
150
+ });
151
+ }
152
+ return source;
153
+ }
124
154
  function getHtmlFiles({ manifest }) {
125
155
  const htmlFiles = new Set();
126
156
  function traverseScreens(screens, basePath = "") {
@@ -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 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 { Log } from '../log';\nimport { DevServerManager } from '../start/server/DevServerManager';\nimport { MetroBundlerDevServer } from '../start/server/metro/MetroBundlerDevServer';\nimport { logMetroErrorAsync } from '../start/server/metro/metroErrorInterface';\nimport { getVirtualFaviconAssetsAsync } from './favicon';\n\nconst debug = require('debug')('expo:export:generateStaticRoutes') as typeof console.log;\n\ntype Options = { outputDir: string; minify: boolean };\n\n/** @private */\nexport async function unstable_exportStaticAsync(projectRoot: string, options: Options) {\n // NOTE(EvanBacon): Please don't use this feature.\n Log.warn('Static exporting with Metro is an experimental feature.');\n\n const devServerManager = new DevServerManager(projectRoot, {\n minify: options.minify,\n mode: 'production',\n location: {},\n });\n\n await devServerManager.startAsync([\n {\n type: 'metro',\n },\n ]);\n\n await exportFromServerAsync(projectRoot, devServerManager, options);\n\n await devServerManager.stopAsync();\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, minify }: Options\n): Promise<void> {\n const injectFaviconTag = await getVirtualFaviconAssetsAsync(projectRoot, outputDir);\n\n const devServer = devServerManager.getDefaultDevServer();\n assert(devServer instanceof MetroBundlerDevServer);\n\n const [manifest, resources, renderAsync] = await Promise.all([\n devServer.getRoutesAsync(),\n devServer.getStaticResourcesAsync({ mode: 'production', minify }),\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 });\n\n if (injectFaviconTag) {\n html = injectFaviconTag(html);\n }\n\n return html;\n },\n });\n\n resources.forEach((resource) => {\n files.set(resource.filename, resource.source);\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 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"],"names":["unstable_exportStaticAsync","getFilesToExportFromServerAsync","exportFromServerAsync","getHtmlFiles","getPathVariations","debug","require","projectRoot","options","Log","warn","devServerManager","DevServerManager","minify","mode","location","startAsync","type","stopAsync","matchGroupName","name","match","manifest","renderAsync","files","Map","Promise","all","map","outputPath","pathname","replace","set","data","e","logMetroErrorAsync","error","Error","outputDir","injectFaviconTag","getVirtualFaviconAssetsAsync","devServer","getDefaultDevServer","assert","MetroBundlerDevServer","resources","getRoutesAsync","getStaticResourcesAsync","getStaticRenderFunctionAsync","inspect","colors","depth","template","html","composeResourcesWithHtml","forEach","resource","filename","source","fs","mkdirSync","path","join","recursive","log","chalk","bold","size","entries","sort","a","b","localeCompare","file","contents","length","Buffer","byteLength","gray","prettyBytes","promises","mkdir","dirname","writeFile","htmlFiles","Set","traverseScreens","screens","basePath","value","Object","values","filePath","endsWith","slice","addOptionalGroups","newPath","variations","variation","add","Array","from","parts","split","partsWithGroups","part","startsWith","routePath","segments","generateVariations","index","newSegments","splice"],"mappings":"AAMA;;;;QAkBsBA,0BAA0B,GAA1BA,0BAA0B;QA0B1BC,+BAA+B,GAA/BA,+BAA+B;QA+B/BC,qBAAqB,GAArBA,qBAAqB;QA6D3BC,YAAY,GAAZA,YAAY;QAkDZC,iBAAiB,GAAjBA,iBAAiB;AA1Ld,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;AAEV,IAAA,IAAQ,WAAR,QAAQ,CAAA;AACK,IAAA,iBAAkC,WAAlC,kCAAkC,CAAA;AAC7B,IAAA,sBAA6C,WAA7C,6CAA6C,CAAA;AAChD,IAAA,oBAA2C,WAA3C,2CAA2C,CAAA;AACjC,IAAA,QAAW,WAAX,WAAW,CAAA;;;;;;AAExD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,kCAAkC,CAAC,AAAsB,AAAC;AAKlF,eAAeN,0BAA0B,CAACO,WAAmB,EAAEC,OAAgB,EAAE;IACtF,kDAAkD;IAClDC,IAAG,IAAA,CAACC,IAAI,CAAC,yDAAyD,CAAC,CAAC;IAEpE,MAAMC,gBAAgB,GAAG,IAAIC,iBAAgB,iBAAA,CAACL,WAAW,EAAE;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C,CAAC,AAAC;IAChD,MAAMC,SAAQ,GAAGD,SAAS,CAACJ,KAAK,CAAC,GAAG,CAAC,AAAC;IAEtC,SAASM,kBAAkB,CAACD,QAAkB,EAAEE,KAAa,EAAQ;QACnE,IAAIA,KAAK,IAAIF,QAAQ,CAACjC,MAAM,EAAE;YAC5B,OAAO;SACR;QAED,MAAMoC,WAAW,GAAG;eAAIH,QAAQ;SAAC,AAAC;QAClC,MACEE,KAAK,GAAGC,WAAW,CAACpC,MAAM,IAC1BxD,cAAc,CAAC4F,WAAW,CAACD,KAAK,CAAC,CAAC,IAClCC,WAAW,CAACpC,MAAM,GAAG,CAAC,CACtB;YACAoC,WAAW,CAACC,MAAM,CAACF,KAAK,EAAE,CAAC,CAAC,CAAC;YAC7Bb,UAAU,CAACE,GAAG,CAACY,WAAW,CAACjD,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YACtC+C,kBAAkB,CAACE,WAAW,EAAED,KAAK,GAAG,CAAC,CAAC,CAAC;SAC5C;QAEDD,kBAAkB,CAACD,QAAQ,EAAEE,KAAK,GAAG,CAAC,CAAC,CAAC;KACzC;IAEDD,kBAAkB,CAACD,SAAQ,EAAE,CAAC,CAAC,CAAC;IAEhC,OAAOR,KAAK,CAACC,IAAI,CAACJ,UAAU,CAAC,CAAC;CAC/B"}
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 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 { learnMore } from '../utils/link';\n\nconst debug = require('debug')('expo:export:generateStaticRoutes') as typeof console.log;\n\ntype Options = { outputDir: string; minify: boolean; includeMaps: boolean };\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, minify, includeMaps }: Options\n): Promise<void> {\n const injectFaviconTag = await getVirtualFaviconAssetsAsync(projectRoot, outputDir);\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 });\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 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"],"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","includeMaps","injectFaviconTag","getVirtualFaviconAssetsAsync","devServer","getDefaultDevServer","assert","MetroBundlerDevServer","resources","getStaticResourcesAsync","getStaticRenderFunctionAsync","inspect","colors","depth","template","html","composeResourcesWithHtml","forEach","resource","filename","source","fs","mkdirSync","path","join","recursive","log","chalk","bold","size","entries","sort","a","b","localeCompare","file","contents","length","Buffer","byteLength","gray","prettyBytes","promises","mkdir","dirname","writeFile","endsWith","normalizedFilename","props","mapName","htmlFiles","Set","traverseScreens","screens","basePath","value","Object","values","filePath","slice","addOptionalGroups","newPath","variations","variation","add","Array","from","parts","split","partsWithGroups","part","startsWith","routePath","segments","generateVariations","index","newSegments","splice"],"mappings":"AAMA;;;;QAmBsBA,0BAA0B,GAA1BA,0BAA0B;QAkC1BC,+BAA+B,GAA/BA,+BAA+B;QA+B/BC,qBAAqB,GAArBA,qBAAqB;QA+D3BC,2BAA2B,GAA3BA,2BAA2B;QA2B3BC,YAAY,GAAZA,YAAY;QAkDZC,iBAAiB,GAAjBA,iBAAiB;AAhOd,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;AACpC,IAAA,IAAQ,WAAR,QAAQ,CAAA;AACK,IAAA,iBAAkC,WAAlC,kCAAkC,CAAA;AAC7B,IAAA,sBAA6C,WAA7C,6CAA6C,CAAA;AAChD,IAAA,oBAA2C,WAA3C,2CAA2C,C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,CAAC,AAAC;QACH,OAAOD,eAAe,CAAC7C,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC;KAC5C,CAAC,CAAC;CACJ;AAIM,SAAS5D,iBAAiB,CAAC4G,SAAiB,EAAY;IAC7D,MAAMV,UAAU,GAAG,IAAIX,GAAG,CAAS;QAACqB,SAAS;KAAC,CAAC,AAAC;IAChD,MAAMC,SAAQ,GAAGD,SAAS,CAACJ,KAAK,CAAC,GAAG,CAAC,AAAC;IAEtC,SAASM,kBAAkB,CAACD,QAAkB,EAAEE,KAAa,EAAQ;QACnE,IAAIA,KAAK,IAAIF,QAAQ,CAACpC,MAAM,EAAE;YAC5B,OAAO;SACR;QAED,MAAMuC,WAAW,GAAG;eAAIH,QAAQ;SAAC,AAAC;QAClC,MACEE,KAAK,GAAGC,WAAW,CAACvC,MAAM,IAC1BxD,cAAc,CAAC+F,WAAW,CAACD,KAAK,CAAC,CAAC,IAClCC,WAAW,CAACvC,MAAM,GAAG,CAAC,CACtB;YACAuC,WAAW,CAACC,MAAM,CAACF,KAAK,EAAE,CAAC,CAAC,CAAC;YAC7Bb,UAAU,CAACE,GAAG,CAACY,WAAW,CAACpD,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YACtCkD,kBAAkB,CAACE,WAAW,EAAED,KAAK,GAAG,CAAC,CAAC,CAAC;SAC5C;QAEDD,kBAAkB,CAACD,QAAQ,EAAEE,KAAK,GAAG,CAAC,CAAC,CAAC;KACzC;IAEDD,kBAAkB,CAACD,SAAQ,EAAE,CAAC,CAAC,CAAC;IAEhC,OAAOR,KAAK,CAACC,IAAI,CAACJ,UAAU,CAAC,CAAC;CAC/B"}
@@ -3,10 +3,13 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.bundleAsync = bundleAsync;
6
+ exports.getAssets = getAssets;
6
7
  var _config = require("@expo/config");
7
8
  var _hermesBundler = require("@expo/dev-server/build/HermesBundler");
8
9
  var _importMetroFromProject = require("@expo/dev-server/build/metro/importMetroFromProject");
9
10
  var _chalk = _interopRequireDefault(require("chalk"));
11
+ var _getAssets = _interopRequireDefault(require("metro/src/DeltaBundler/Serializers/getAssets"));
12
+ var _splitBundleOptions = _interopRequireDefault(require("metro/src/lib/splitBundleOptions"));
10
13
  var _getCssModulesFromBundler = require("../start/server/metro/getCssModulesFromBundler");
11
14
  var _instantiateMetro = require("../start/server/metro/instantiateMetro");
12
15
  function _interopRequireDefault(obj) {
@@ -31,7 +34,8 @@ async function bundleAsync(projectRoot, expoConfig, options, bundles) {
31
34
  const metro = (0, _importMetroFromProject).importMetroFromProject(projectRoot);
32
35
  const Server = (0, _importMetroFromProject).importMetroServerFromProject(projectRoot);
33
36
  const { config , reporter } = await (0, _instantiateMetro).loadMetroConfigAsync(projectRoot, options, {
34
- exp: expoConfig
37
+ exp: expoConfig,
38
+ isExporting: true
35
39
  });
36
40
  const metroServer = await metro.runMetro(config, {
37
41
  watch: false
@@ -73,7 +77,8 @@ async function bundleAsync(projectRoot, expoConfig, options, bundles) {
73
77
  try {
74
78
  const { code , map } = await metroServer.build(bundleOptions);
75
79
  const [assets, css] = await Promise.all([
76
- metroServer.getAssets(bundleOptions),
80
+ getAssets(metroServer, bundleOptions),
81
+ // metroServer.getAssets(bundleOptions),
77
82
  (0, _getCssModulesFromBundler).getCssModulesFromBundler(config, metroServer.getBundler(), bundleOptions),
78
83
  ]);
79
84
  reporter.update({
@@ -129,5 +134,25 @@ async function bundleAsync(projectRoot, expoConfig, options, bundles) {
129
134
  metroServer.end();
130
135
  }
131
136
  }
137
+ async function getAssets(metro, options) {
138
+ const { entryFile , onProgress , resolverOptions , transformOptions } = (0, _splitBundleOptions).default(options);
139
+ // @ts-expect-error: _bundler isn't exposed on the type.
140
+ const dependencies = await metro._bundler.getDependencies([
141
+ entryFile
142
+ ], transformOptions, resolverOptions, {
143
+ onProgress,
144
+ shallow: false,
145
+ lazy: false
146
+ });
147
+ // @ts-expect-error
148
+ const _config1 = metro._config;
149
+ return await (0, _getAssets).default(dependencies, {
150
+ processModuleFilter: _config1.serializer.processModuleFilter,
151
+ assetPlugins: _config1.transformer.assetPlugins,
152
+ platform: transformOptions.platform,
153
+ projectRoot: _config1.projectRoot,
154
+ publicPath: _config1.transformer.publicPath
155
+ });
156
+ }
132
157
 
133
158
  //# sourceMappingURL=fork-bundleAsync.js.map