@expo/cli 0.1.4 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/build/bin/cli +83 -4
  2. package/build/bin/cli.map +1 -1
  3. package/build/src/api/rest/wrapFetchWithOffline.js +2 -23
  4. package/build/src/api/rest/wrapFetchWithOffline.js.map +1 -1
  5. package/build/src/customize/customizeAsync.js +40 -0
  6. package/build/src/customize/customizeAsync.js.map +1 -0
  7. package/build/src/customize/generate.js +77 -0
  8. package/build/src/customize/generate.js.map +1 -0
  9. package/build/src/customize/index.js +41 -0
  10. package/build/src/customize/index.js.map +1 -0
  11. package/build/src/customize/resolveOptions.js +18 -0
  12. package/build/src/customize/resolveOptions.js.map +1 -0
  13. package/build/src/customize/templates.js +118 -0
  14. package/build/src/customize/templates.js.map +1 -0
  15. package/build/src/export/createMetadataJson.js +10 -7
  16. package/build/src/export/createMetadataJson.js.map +1 -1
  17. package/build/src/export/exportApp.js +32 -0
  18. package/build/src/export/exportApp.js.map +1 -1
  19. package/build/src/export/exportAssets.js +2 -3
  20. package/build/src/export/exportAssets.js.map +1 -1
  21. package/build/src/export/fork-bundleAsync.js +51 -34
  22. package/build/src/export/fork-bundleAsync.js.map +1 -1
  23. package/build/src/export/index.js +14 -10
  24. package/build/src/export/index.js.map +1 -1
  25. package/build/src/export/printBundleSizes.js +27 -48
  26. package/build/src/export/printBundleSizes.js.map +1 -1
  27. package/build/src/export/resolveOptions.js +44 -5
  28. package/build/src/export/resolveOptions.js.map +1 -1
  29. package/build/src/export/saveAssets.js +2 -1
  30. package/build/src/export/saveAssets.js.map +1 -1
  31. package/build/src/export/web/exportWebAsync.js +37 -0
  32. package/build/src/export/web/exportWebAsync.js.map +1 -0
  33. package/build/src/export/web/index.js +66 -0
  34. package/build/src/export/web/index.js.map +1 -0
  35. package/build/src/export/web/resolveOptions.js +13 -0
  36. package/build/src/export/web/resolveOptions.js.map +1 -0
  37. package/build/src/export/writeContents.js.map +1 -1
  38. package/build/src/install/checkPackages.js +2 -1
  39. package/build/src/install/checkPackages.js.map +1 -1
  40. package/build/src/install/index.js +1 -0
  41. package/build/src/install/index.js.map +1 -1
  42. package/build/src/install/installAsync.js +13 -5
  43. package/build/src/install/installAsync.js.map +1 -1
  44. package/build/src/install/resolveOptions.js +12 -65
  45. package/build/src/install/resolveOptions.js.map +1 -1
  46. package/build/src/install/utils/autoAddConfigPlugins.js +5 -26
  47. package/build/src/install/utils/autoAddConfigPlugins.js.map +1 -1
  48. package/build/src/log.js.map +1 -1
  49. package/build/src/prebuild/copyTemplateFiles.js +5 -23
  50. package/build/src/prebuild/copyTemplateFiles.js.map +1 -1
  51. package/build/src/prebuild/index.js +18 -12
  52. package/build/src/prebuild/index.js.map +1 -1
  53. package/build/src/prebuild/prebuildAsync.js +11 -12
  54. package/build/src/prebuild/prebuildAsync.js.map +1 -1
  55. package/build/src/prebuild/resolveOptions.js +17 -0
  56. package/build/src/prebuild/resolveOptions.js.map +1 -1
  57. package/build/src/prebuild/resolveTemplate.js +2 -1
  58. package/build/src/prebuild/resolveTemplate.js.map +1 -1
  59. package/build/src/prebuild/updatePackageJson.js +5 -5
  60. package/build/src/prebuild/updatePackageJson.js.map +1 -1
  61. package/build/src/run/android/resolveInstallApkName.js +5 -26
  62. package/build/src/run/android/resolveInstallApkName.js.map +1 -1
  63. package/build/src/start/doctor/apple/SimulatorAppPrerequisite.js +2 -0
  64. package/build/src/start/doctor/apple/SimulatorAppPrerequisite.js.map +1 -1
  65. package/build/src/start/doctor/apple/XcodePrerequisite.js +2 -0
  66. package/build/src/start/doctor/apple/XcodePrerequisite.js.map +1 -1
  67. package/build/src/start/doctor/dependencies/bundledNativeModules.js +3 -2
  68. package/build/src/start/doctor/dependencies/bundledNativeModules.js.map +1 -1
  69. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +7 -13
  70. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
  71. package/build/src/start/doctor/dependencies/getMissingPackages.js +3 -24
  72. package/build/src/start/doctor/dependencies/getMissingPackages.js.map +1 -1
  73. package/build/src/start/doctor/dependencies/getVersionedPackages.js +2 -23
  74. package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
  75. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +17 -9
  76. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
  77. package/build/src/start/doctor/ngrok/ExternalModule.js +2 -1
  78. package/build/src/start/doctor/ngrok/ExternalModule.js.map +1 -1
  79. package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js +4 -3
  80. package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js.map +1 -1
  81. package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js +29 -31
  82. package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js.map +1 -1
  83. package/build/src/start/interface/KeyPressHandler.js +2 -0
  84. package/build/src/start/interface/KeyPressHandler.js.map +1 -1
  85. package/build/src/start/interface/interactiveActions.js +5 -5
  86. package/build/src/start/interface/interactiveActions.js.map +1 -1
  87. package/build/src/start/interface/startInterface.js +3 -2
  88. package/build/src/start/interface/startInterface.js.map +1 -1
  89. package/build/src/start/platforms/ExpoGoInstaller.js +2 -1
  90. package/build/src/start/platforms/ExpoGoInstaller.js.map +1 -1
  91. package/build/src/start/platforms/PlatformManager.js +4 -24
  92. package/build/src/start/platforms/PlatformManager.js.map +1 -1
  93. package/build/src/start/platforms/android/ADBServer.js +17 -32
  94. package/build/src/start/platforms/android/ADBServer.js.map +1 -1
  95. package/build/src/start/platforms/android/AndroidSdk.js +41 -0
  96. package/build/src/start/platforms/android/AndroidSdk.js.map +1 -0
  97. package/build/src/start/platforms/android/activateWindow.js +4 -4
  98. package/build/src/start/platforms/android/activateWindow.js.map +1 -1
  99. package/build/src/start/platforms/android/adb.js +8 -3
  100. package/build/src/start/platforms/android/adb.js.map +1 -1
  101. package/build/src/start/platforms/android/adbReverse.js +3 -2
  102. package/build/src/start/platforms/android/adbReverse.js.map +1 -1
  103. package/build/src/start/platforms/android/gradle.js +2 -2
  104. package/build/src/start/platforms/android/gradle.js.map +1 -1
  105. package/build/src/start/platforms/ios/getBestSimulator.js +4 -4
  106. package/build/src/start/platforms/ios/getBestSimulator.js.map +1 -1
  107. package/build/src/start/platforms/ios/xcrun.js +2 -23
  108. package/build/src/start/platforms/ios/xcrun.js.map +1 -1
  109. package/build/src/start/project/devices.js +2 -0
  110. package/build/src/start/project/devices.js.map +1 -1
  111. package/build/src/start/server/AsyncNgrok.js +6 -5
  112. package/build/src/start/server/AsyncNgrok.js.map +1 -1
  113. package/build/src/start/server/BundlerDevServer.js +15 -8
  114. package/build/src/start/server/BundlerDevServer.js.map +1 -1
  115. package/build/src/start/server/DevServerManager.js +15 -5
  116. package/build/src/start/server/DevServerManager.js.map +1 -1
  117. package/build/src/start/server/DevelopmentSession.js +4 -0
  118. package/build/src/start/server/DevelopmentSession.js.map +1 -1
  119. package/build/src/start/server/UrlCreator.js +10 -3
  120. package/build/src/start/server/UrlCreator.js.map +1 -1
  121. package/build/src/start/server/metro/MetroBundlerDevServer.js +9 -0
  122. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  123. package/build/src/start/server/metro/TerminalReporter.js +5 -0
  124. package/build/src/start/server/metro/TerminalReporter.js.map +1 -1
  125. package/build/src/start/server/metro/instantiateMetro.js +11 -1
  126. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  127. package/build/src/start/server/metro/resolveFromProject.js +8 -0
  128. package/build/src/start/server/metro/resolveFromProject.js.map +1 -1
  129. package/build/src/start/server/metro/withMetroMultiPlatform.js +115 -0
  130. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -0
  131. package/build/src/start/server/middleware/ClassicManifestMiddleware.js +1 -1
  132. package/build/src/start/server/middleware/ExpoMiddleware.js +9 -4
  133. package/build/src/start/server/middleware/ExpoMiddleware.js.map +1 -1
  134. package/build/src/start/server/middleware/HistoryFallbackMiddleware.js +24 -0
  135. package/build/src/start/server/middleware/HistoryFallbackMiddleware.js.map +1 -0
  136. package/build/src/start/server/middleware/InterstitialPageMiddleware.js +2 -0
  137. package/build/src/start/server/middleware/InterstitialPageMiddleware.js.map +1 -1
  138. package/build/src/start/server/middleware/ManifestMiddleware.js +57 -6
  139. package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
  140. package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js +6 -1
  141. package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js.map +1 -1
  142. package/build/src/start/server/middleware/ServeStaticMiddleware.js +62 -0
  143. package/build/src/start/server/middleware/ServeStaticMiddleware.js.map +1 -0
  144. package/build/src/start/server/platformBundlers.js +18 -0
  145. package/build/src/start/server/platformBundlers.js.map +1 -0
  146. package/build/src/start/server/webTemplate.js +68 -0
  147. package/build/src/start/server/webTemplate.js.map +1 -0
  148. package/build/src/start/server/webpack/WebpackBundlerDevServer.js +59 -19
  149. package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
  150. package/build/src/start/server/webpack/compile.js +64 -0
  151. package/build/src/start/server/webpack/compile.js.map +1 -0
  152. package/build/src/start/startAsync.js +21 -17
  153. package/build/src/start/startAsync.js.map +1 -1
  154. package/build/src/utils/FileNotifier.js +5 -2
  155. package/build/src/utils/FileNotifier.js.map +1 -1
  156. package/build/src/utils/analytics/rudderstackClient.js +2 -2
  157. package/build/src/utils/downloadAppAsync.js +3 -2
  158. package/build/src/utils/downloadAppAsync.js.map +1 -1
  159. package/build/src/utils/downloadExpoGoAsync.js +7 -32
  160. package/build/src/utils/downloadExpoGoAsync.js.map +1 -1
  161. package/build/src/utils/editor.js +3 -2
  162. package/build/src/utils/editor.js.map +1 -1
  163. package/build/src/utils/env.js +3 -0
  164. package/build/src/utils/env.js.map +1 -1
  165. package/build/src/utils/exit.js +4 -25
  166. package/build/src/utils/exit.js.map +1 -1
  167. package/build/src/utils/getRunningProcess.js +6 -2
  168. package/build/src/utils/getRunningProcess.js.map +1 -1
  169. package/build/src/utils/nodeModules.js +13 -102
  170. package/build/src/utils/nodeModules.js.map +1 -1
  171. package/build/src/utils/npm.js +3 -24
  172. package/build/src/utils/npm.js.map +1 -1
  173. package/build/src/utils/ora.js +1 -13
  174. package/build/src/utils/ora.js.map +1 -1
  175. package/build/src/utils/progress.js +46 -0
  176. package/build/src/utils/progress.js.map +1 -1
  177. package/build/src/utils/prompts.js +4 -4
  178. package/build/src/utils/prompts.js.map +1 -1
  179. package/build/src/utils/tar.js +3 -0
  180. package/build/src/utils/tar.js.map +1 -1
  181. package/build/src/utils/validateApplicationId.js +9 -2
  182. package/build/src/utils/validateApplicationId.js.map +1 -1
  183. package/build/src/utils/variadic.js +47 -0
  184. package/build/src/utils/variadic.js.map +1 -0
  185. package/package.json +12 -8
  186. package/static/template/babel.config.js +6 -0
  187. package/static/template/index.html +117 -0
  188. package/static/template/metro.config.js +4 -0
  189. package/static/template/serve.json +13 -0
  190. package/static/template/webpack.config.js +7 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/middleware/ManifestMiddleware.ts"],"sourcesContent":["import { ExpoConfig, ExpoGoConfig, getConfig, ProjectConfig } from '@expo/config';\nimport { resolve } from 'url';\n\nimport * as Log from '../../../log';\nimport { stripExtension } from '../../../utils/url';\nimport * as ProjectDevices from '../../project/devices';\nimport { UrlCreator } from '../UrlCreator';\nimport { ExpoMiddleware } from './ExpoMiddleware';\nimport { resolveGoogleServicesFile, resolveManifestAssets } from './resolveAssets';\nimport { resolveEntryPoint } from './resolveEntryPoint';\nimport { RuntimePlatform } from './resolvePlatform';\nimport { ServerHeaders, ServerNext, ServerRequest, ServerResponse } from './server.types';\n\n/** Info about the computer hosting the dev server. */\nexport interface HostInfo {\n host: string;\n server: 'expo';\n serverVersion: string;\n serverDriver: string | null;\n serverOS: NodeJS.Platform;\n serverOSVersion: string;\n}\n\n/** Parsed values from the supported request headers. */\nexport interface ManifestRequestInfo {\n /** Should return the signed manifest. */\n acceptSignature: boolean;\n /** Platform to serve. */\n platform: RuntimePlatform;\n /** Requested host name. */\n hostname?: string | null;\n}\n\n/** Project related info. */\nexport type ResponseProjectSettings = {\n expoGoConfig: ExpoGoConfig;\n hostUri: string;\n bundleUrl: string;\n exp: ExpoConfig;\n};\n\nexport const DEVELOPER_TOOL = 'expo-cli';\n\nexport type ManifestMiddlewareOptions = {\n /** Should start the dev servers in development mode (minify). */\n mode?: 'development' | 'production';\n /** Should instruct the bundler to create minified bundles. */\n minify?: boolean;\n constructUrl: UrlCreator['constructUrl'];\n isNativeWebpack?: boolean;\n privateKeyPath?: string;\n};\n\n/** Base middleware creator for serving the Expo manifest (like the index.html but for native runtimes). */\nexport abstract class ManifestMiddleware<\n TManifestRequestInfo extends ManifestRequestInfo\n> extends ExpoMiddleware {\n constructor(protected projectRoot: string, protected options: ManifestMiddlewareOptions) {\n super(\n projectRoot,\n /**\n * Only support `/`, `/manifest`, `/index.exp` for the manifest middleware.\n */\n ['/', '/manifest', '/index.exp']\n );\n }\n\n /** Exposed for testing. */\n public async _resolveProjectSettingsAsync({\n platform,\n hostname,\n }: Pick<TManifestRequestInfo, 'hostname' | 'platform'>): Promise<ResponseProjectSettings> {\n // Read the config\n const projectConfig = getConfig(this.projectRoot);\n\n // Read from headers\n const mainModuleName = this.resolveMainModuleName(projectConfig, platform);\n\n // Create the manifest and set fields within it\n const expoGoConfig = this.getExpoGoConfig({\n mainModuleName,\n hostname,\n });\n\n const hostUri = this.options.constructUrl({ scheme: '', hostname });\n\n const bundleUrl = this._getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n });\n\n // Resolve all assets and set them on the manifest as URLs\n await this.mutateManifestWithAssetsAsync(projectConfig.exp, bundleUrl);\n\n return {\n expoGoConfig,\n hostUri,\n bundleUrl,\n exp: projectConfig.exp,\n };\n }\n\n /** Get the main entry module ID (file) relative to the project root. */\n private resolveMainModuleName(projectConfig: ProjectConfig, platform: string): string {\n let entryPoint = resolveEntryPoint(this.projectRoot, platform, projectConfig);\n // NOTE(Bacon): Webpack is currently hardcoded to index.bundle on native\n // in the future (TODO) we should move this logic into a Webpack plugin and use\n // a generated file name like we do on web.\n // const server = getDefaultDevServer();\n // // TODO: Move this into BundlerDevServer and read this info from self.\n // const isNativeWebpack = server instanceof WebpackBundlerDevServer && server.isTargetingNative();\n if (this.options.isNativeWebpack) {\n entryPoint = 'index.js';\n }\n\n return stripExtension(entryPoint, 'js');\n }\n\n /** Parse request headers into options. */\n public abstract getParsedHeaders(req: ServerRequest): TManifestRequestInfo;\n\n /** Store device IDs that were sent in the request headers. */\n private async saveDevicesAsync(req: ServerRequest) {\n const deviceIds = req.headers?.['expo-dev-client-id'];\n if (deviceIds) {\n await ProjectDevices.saveDevicesAsync(this.projectRoot, deviceIds).catch((e) =>\n Log.exception(e)\n );\n }\n }\n\n /** Create the bundle URL (points to the single JS entry file). Exposed for testing. */\n public _getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n }: {\n platform: string;\n hostname?: string | null;\n mainModuleName: string;\n }): string {\n const queryParams = new URLSearchParams({\n platform: encodeURIComponent(platform),\n dev: String(this.options.mode !== 'production'),\n // TODO: Is this still needed?\n hot: String(false),\n });\n\n if (this.options.minify) {\n queryParams.append('minify', String(this.options.minify));\n }\n\n const path = `/${encodeURI(mainModuleName)}.bundle?${queryParams.toString()}`;\n\n return (\n this.options.constructUrl({\n scheme: 'http',\n // hostType: this.options.location.hostType,\n hostname,\n }) + path\n );\n }\n\n /** Log telemetry. */\n protected abstract trackManifest(version?: string): void;\n\n /** Get the manifest response to return to the runtime. This file contains info regarding where the assets can be loaded from. Exposed for testing. */\n public abstract _getManifestResponseAsync(options: TManifestRequestInfo): Promise<{\n body: string;\n version: string;\n headers: ServerHeaders;\n }>;\n\n private getExpoGoConfig({\n mainModuleName,\n hostname,\n }: {\n mainModuleName: string;\n hostname?: string | null;\n }): ExpoGoConfig {\n return {\n // localhost:19000\n debuggerHost: this.options.constructUrl({ scheme: '', hostname }),\n // http://localhost:19000/logs -- used to send logs to the CLI for displaying in the terminal.\n // This is deprecated in favor of the WebSocket connection setup in Metro.\n logUrl: this.options.constructUrl({ scheme: 'http', hostname }) + '/logs',\n // Required for Expo Go to function.\n developer: {\n tool: DEVELOPER_TOOL,\n projectRoot: this.projectRoot,\n },\n packagerOpts: {\n // Required for dev client.\n dev: this.options.mode !== 'production',\n },\n // Indicates the name of the main bundle.\n mainModuleName,\n // Add this string to make Flipper register React Native / Metro as \"running\".\n // Can be tested by running:\n // `METRO_SERVER_PORT=19000 open -a flipper.app`\n // Where 19000 is the port where the Expo project is being hosted.\n __flipperHack: 'React Native packager is running',\n };\n }\n\n /** Resolve all assets and set them on the manifest as URLs */\n private async mutateManifestWithAssetsAsync(manifest: ExpoConfig, bundleUrl: string) {\n await resolveManifestAssets(this.projectRoot, {\n manifest,\n resolver: async (path) => {\n if (this.options.isNativeWebpack) {\n // When using our custom dev server, just do assets normally\n // without the `assets/` subpath redirect.\n return resolve(bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0], path);\n }\n return bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0] + 'assets/' + path;\n },\n });\n // The server normally inserts this but if we're offline we'll do it here\n await resolveGoogleServicesFile(this.projectRoot, manifest);\n }\n\n async handleRequestAsync(\n req: ServerRequest,\n res: ServerResponse,\n next: ServerNext\n ): Promise<void> {\n // Save device IDs for dev client.\n await this.saveDevicesAsync(req);\n\n // Read from headers\n const options = this.getParsedHeaders(req);\n const { body, version, headers } = await this._getManifestResponseAsync(options);\n for (const [headerName, headerValue] of headers) {\n res.setHeader(headerName, headerValue);\n }\n res.end(body);\n\n // Log analytics\n this.trackManifest(version ?? null);\n }\n}\n"],"names":["Log","ProjectDevices","DEVELOPER_TOOL","ManifestMiddleware","ExpoMiddleware","constructor","projectRoot","options","_resolveProjectSettingsAsync","platform","hostname","projectConfig","getConfig","mainModuleName","resolveMainModuleName","expoGoConfig","getExpoGoConfig","hostUri","constructUrl","scheme","bundleUrl","_getBundleUrl","mutateManifestWithAssetsAsync","exp","entryPoint","resolveEntryPoint","isNativeWebpack","stripExtension","saveDevicesAsync","req","deviceIds","headers","catch","e","exception","queryParams","URLSearchParams","encodeURIComponent","dev","String","mode","hot","minify","append","path","encodeURI","toString","debuggerHost","logUrl","developer","tool","packagerOpts","__flipperHack","manifest","resolveManifestAssets","resolver","resolve","match","resolveGoogleServicesFile","handleRequestAsync","res","next","getParsedHeaders","body","version","_getManifestResponseAsync","headerName","headerValue","setHeader","end","trackManifest"],"mappings":"AAAA;;;;;AAAmE,IAAA,OAAc,WAAd,cAAc,CAAA;AACzD,IAAA,IAAK,WAAL,KAAK,CAAA;AAEjBA,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACgB,IAAA,KAAoB,WAApB,oBAAoB,CAAA;AACvCC,IAAAA,cAAc,mCAAM,uBAAuB,EAA7B;AAEK,IAAA,eAAkB,WAAlB,kBAAkB,CAAA;AACgB,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;AAChD,IAAA,kBAAqB,WAArB,qBAAqB,CAAA;;;;;;;;;;;;;;;;;;;;;;AAgChD,MAAMC,cAAc,GAAG,UAAU,AAAC;QAA5BA,cAAc,GAAdA,cAAc;AAapB,MAAeC,kBAAkB,SAE9BC,eAAc,eAAA;IACtBC,YAAsBC,WAAmB,EAAYC,OAAkC,CAAE;QACvF,KAAK,CACHD,WAAW,EACX;;SAEG,CACH;YAAC,GAAG;YAAE,WAAW;YAAE,YAAY;SAAC,CACjC,CAAC;aAPkBA,WAAmB,GAAnBA,WAAmB;aAAYC,OAAkC,GAAlCA,OAAkC;KAQtF;IAED,2BAA2B,CAC3B,MAAaC,4BAA4B,CAAC,EACxCC,QAAQ,CAAA,EACRC,QAAQ,CAAA,EAC4C,EAAoC;QACxF,kBAAkB;QAClB,MAAMC,aAAa,GAAGC,CAAAA,GAAAA,OAAS,AAAkB,CAAA,UAAlB,CAAC,IAAI,CAACN,WAAW,CAAC,AAAC;QA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,CAAA,0BAA5B,CAAC,IAAI,CAACpD,WAAW,EAAE+C,QAAQ,CAAC,CAAC;KAC7D;IAED,MAAMM,kBAAkB,CACtB9B,GAAkB,EAClB+B,GAAmB,EACnBC,IAAgB,EACD;QACf,kCAAkC;QAClC,MAAM,IAAI,CAACjC,gBAAgB,CAACC,GAAG,CAAC,CAAC;QAEjC,oBAAoB;QACpB,MAAMtB,OAAO,GAAG,IAAI,CAACuD,gBAAgB,CAACjC,GAAG,CAAC,AAAC;QAC3C,MAAM,EAAEkC,IAAI,CAAA,EAAEC,OAAO,CAAA,EAAEjC,OAAO,CAAA,EAAE,GAAG,MAAM,IAAI,CAACkC,yBAAyB,CAAC1D,OAAO,CAAC,AAAC;QACjF,KAAK,MAAM,CAAC2D,UAAU,EAAEC,WAAW,CAAC,IAAIpC,OAAO,CAAE;YAC/C6B,GAAG,CAACQ,SAAS,CAACF,UAAU,EAAEC,WAAW,CAAC,CAAC;SACxC;QACDP,GAAG,CAACS,GAAG,CAACN,IAAI,CAAC,CAAC;QAEd,gBAAgB;QAChB,IAAI,CAACO,aAAa,CAACN,OAAO,WAAPA,OAAO,GAAI,IAAI,CAAC,CAAC;KACrC;CACF;QA5LqB7D,kBAAkB,GAAlBA,kBAAkB"}
1
+ {"version":3,"sources":["../../../../../src/start/server/middleware/ManifestMiddleware.ts"],"sourcesContent":["import { ExpoConfig, ExpoGoConfig, getConfig, ProjectConfig } from '@expo/config';\nimport { resolve } from 'url';\n\nimport * as Log from '../../../log';\nimport { stripExtension } from '../../../utils/url';\nimport * as ProjectDevices from '../../project/devices';\nimport { UrlCreator } from '../UrlCreator';\nimport { getPlatformBundlers } from '../platformBundlers';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../webTemplate';\nimport { ExpoMiddleware } from './ExpoMiddleware';\nimport { resolveGoogleServicesFile, resolveManifestAssets } from './resolveAssets';\nimport { resolveEntryPoint } from './resolveEntryPoint';\nimport { parsePlatformHeader, RuntimePlatform } from './resolvePlatform';\nimport { ServerHeaders, ServerNext, ServerRequest, ServerResponse } from './server.types';\n\n/** Info about the computer hosting the dev server. */\nexport interface HostInfo {\n host: string;\n server: 'expo';\n serverVersion: string;\n serverDriver: string | null;\n serverOS: NodeJS.Platform;\n serverOSVersion: string;\n}\n\n/** Parsed values from the supported request headers. */\nexport interface ManifestRequestInfo {\n /** Should return the signed manifest. */\n acceptSignature: boolean;\n /** Platform to serve. */\n platform: RuntimePlatform;\n /** Requested host name. */\n hostname?: string | null;\n}\n\n/** Project related info. */\nexport type ResponseProjectSettings = {\n expoGoConfig: ExpoGoConfig;\n hostUri: string;\n bundleUrl: string;\n exp: ExpoConfig;\n};\n\nexport const DEVELOPER_TOOL = 'expo-cli';\n\nexport type ManifestMiddlewareOptions = {\n /** Should start the dev servers in development mode (minify). */\n mode?: 'development' | 'production';\n /** Should instruct the bundler to create minified bundles. */\n minify?: boolean;\n constructUrl: UrlCreator['constructUrl'];\n isNativeWebpack?: boolean;\n privateKeyPath?: string;\n};\n\n/** Base middleware creator for serving the Expo manifest (like the index.html but for native runtimes). */\nexport abstract class ManifestMiddleware<\n TManifestRequestInfo extends ManifestRequestInfo\n> extends ExpoMiddleware {\n private initialProjectConfig: ProjectConfig;\n\n constructor(protected projectRoot: string, protected options: ManifestMiddlewareOptions) {\n super(\n projectRoot,\n /**\n * Only support `/`, `/manifest`, `/index.exp` for the manifest middleware.\n */\n ['/', '/manifest', '/index.exp']\n );\n this.initialProjectConfig = getConfig(projectRoot);\n }\n\n /** Exposed for testing. */\n public async _resolveProjectSettingsAsync({\n platform,\n hostname,\n }: Pick<TManifestRequestInfo, 'hostname' | 'platform'>): Promise<ResponseProjectSettings> {\n // Read the config\n const projectConfig = getConfig(this.projectRoot);\n\n // Read from headers\n const mainModuleName = this.resolveMainModuleName(projectConfig, platform);\n\n // Create the manifest and set fields within it\n const expoGoConfig = this.getExpoGoConfig({\n mainModuleName,\n hostname,\n });\n\n const hostUri = this.options.constructUrl({ scheme: '', hostname });\n\n const bundleUrl = this._getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n });\n\n // Resolve all assets and set them on the manifest as URLs\n await this.mutateManifestWithAssetsAsync(projectConfig.exp, bundleUrl);\n\n return {\n expoGoConfig,\n hostUri,\n bundleUrl,\n exp: projectConfig.exp,\n };\n }\n\n /** Get the main entry module ID (file) relative to the project root. */\n private resolveMainModuleName(projectConfig: ProjectConfig, platform: string): string {\n let entryPoint = resolveEntryPoint(this.projectRoot, platform, projectConfig);\n // NOTE(Bacon): Webpack is currently hardcoded to index.bundle on native\n // in the future (TODO) we should move this logic into a Webpack plugin and use\n // a generated file name like we do on web.\n // const server = getDefaultDevServer();\n // // TODO: Move this into BundlerDevServer and read this info from self.\n // const isNativeWebpack = server instanceof WebpackBundlerDevServer && server.isTargetingNative();\n if (this.options.isNativeWebpack) {\n entryPoint = 'index.js';\n }\n\n return stripExtension(entryPoint, 'js');\n }\n\n /** Parse request headers into options. */\n public abstract getParsedHeaders(req: ServerRequest): TManifestRequestInfo;\n\n /** Store device IDs that were sent in the request headers. */\n private async saveDevicesAsync(req: ServerRequest) {\n const deviceIds = req.headers?.['expo-dev-client-id'];\n if (deviceIds) {\n await ProjectDevices.saveDevicesAsync(this.projectRoot, deviceIds).catch((e) =>\n Log.exception(e)\n );\n }\n }\n\n /** Create the bundle URL (points to the single JS entry file). Exposed for testing. */\n public _getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n }: {\n platform: string;\n hostname?: string | null;\n mainModuleName: string;\n }): string {\n const path = this._getBundleUrlPath({ platform, mainModuleName });\n\n return (\n this.options.constructUrl({\n scheme: 'http',\n // hostType: this.options.location.hostType,\n hostname,\n }) + path\n );\n }\n\n public _getBundleUrlPath({\n platform,\n mainModuleName,\n }: {\n platform: string;\n mainModuleName: string;\n }): string {\n const queryParams = new URLSearchParams({\n platform: encodeURIComponent(platform),\n dev: String(this.options.mode !== 'production'),\n // TODO: Is this still needed?\n hot: String(false),\n });\n\n if (this.options.minify) {\n queryParams.append('minify', String(this.options.minify));\n }\n\n return `/${encodeURI(mainModuleName)}.bundle?${queryParams.toString()}`;\n }\n\n /** Log telemetry. */\n protected abstract trackManifest(version?: string): void;\n\n /** Get the manifest response to return to the runtime. This file contains info regarding where the assets can be loaded from. Exposed for testing. */\n public abstract _getManifestResponseAsync(options: TManifestRequestInfo): Promise<{\n body: string;\n version: string;\n headers: ServerHeaders;\n }>;\n\n private getExpoGoConfig({\n mainModuleName,\n hostname,\n }: {\n mainModuleName: string;\n hostname?: string | null;\n }): ExpoGoConfig {\n return {\n // localhost:19000\n debuggerHost: this.options.constructUrl({ scheme: '', hostname }),\n // http://localhost:19000/logs -- used to send logs to the CLI for displaying in the terminal.\n // This is deprecated in favor of the WebSocket connection setup in Metro.\n logUrl: this.options.constructUrl({ scheme: 'http', hostname }) + '/logs',\n // Required for Expo Go to function.\n developer: {\n tool: DEVELOPER_TOOL,\n projectRoot: this.projectRoot,\n },\n packagerOpts: {\n // Required for dev client.\n dev: this.options.mode !== 'production',\n },\n // Indicates the name of the main bundle.\n mainModuleName,\n // Add this string to make Flipper register React Native / Metro as \"running\".\n // Can be tested by running:\n // `METRO_SERVER_PORT=19000 open -a flipper.app`\n // Where 19000 is the port where the Expo project is being hosted.\n __flipperHack: 'React Native packager is running',\n };\n }\n\n /** Resolve all assets and set them on the manifest as URLs */\n private async mutateManifestWithAssetsAsync(manifest: ExpoConfig, bundleUrl: string) {\n await resolveManifestAssets(this.projectRoot, {\n manifest,\n resolver: async (path) => {\n if (this.options.isNativeWebpack) {\n // When using our custom dev server, just do assets normally\n // without the `assets/` subpath redirect.\n return resolve(bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0], path);\n }\n return bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0] + 'assets/' + path;\n },\n });\n // The server normally inserts this but if we're offline we'll do it here\n await resolveGoogleServicesFile(this.projectRoot, manifest);\n }\n\n /**\n * Web platforms should create an index.html response using the same script resolution as native.\n *\n * Instead of adding a `bundleUrl` to a `manifest.json` (native) we'll add a `<script src=\"\">`\n * to an `index.html`, this enables the web platform to load JavaScript from the server.\n */\n private async handleWebRequestAsync(req: ServerRequest, res: ServerResponse) {\n const platform = 'web';\n // Read from headers\n const mainModuleName = this.resolveMainModuleName(this.initialProjectConfig, platform);\n const bundleUrl = this._getBundleUrlPath({\n platform,\n mainModuleName,\n });\n\n res.setHeader('Content-Type', 'text/html');\n\n res.end(\n await createTemplateHtmlFromExpoConfigAsync(this.projectRoot, {\n exp: this.initialProjectConfig.exp,\n scripts: [bundleUrl],\n })\n );\n }\n\n /** Exposed for testing. */\n async checkBrowserRequestAsync(req: ServerRequest, res: ServerResponse) {\n // Read the config\n const bundlers = getPlatformBundlers(this.initialProjectConfig.exp);\n if (bundlers.web === 'metro') {\n // NOTE(EvanBacon): This effectively disables the safety check we do on custom runtimes to ensure\n // the `expo-platform` header is included. When `web.bundler=web`, if the user has non-standard Expo\n // code loading then they'll get a web bundle without a clear assertion of platform support.\n const platform = parsePlatformHeader(req);\n // On web, serve the public folder\n if (!platform || platform === 'web') {\n await this.handleWebRequestAsync(req, res);\n return true;\n }\n }\n return false;\n }\n\n async handleRequestAsync(\n req: ServerRequest,\n res: ServerResponse,\n next: ServerNext\n ): Promise<void> {\n // First check for standard JavaScript runtimes (aka legacy browsers like Chrome).\n if (await this.checkBrowserRequestAsync(req, res)) {\n return;\n }\n\n // Save device IDs for dev client.\n await this.saveDevicesAsync(req);\n\n // Read from headers\n const options = this.getParsedHeaders(req);\n const { body, version, headers } = await this._getManifestResponseAsync(options);\n for (const [headerName, headerValue] of headers) {\n res.setHeader(headerName, headerValue);\n }\n res.end(body);\n\n // Log analytics\n this.trackManifest(version ?? null);\n }\n}\n"],"names":["Log","ProjectDevices","DEVELOPER_TOOL","ManifestMiddleware","ExpoMiddleware","constructor","projectRoot","options","initialProjectConfig","getConfig","_resolveProjectSettingsAsync","platform","hostname","projectConfig","mainModuleName","resolveMainModuleName","expoGoConfig","getExpoGoConfig","hostUri","constructUrl","scheme","bundleUrl","_getBundleUrl","mutateManifestWithAssetsAsync","exp","entryPoint","resolveEntryPoint","isNativeWebpack","stripExtension","saveDevicesAsync","req","deviceIds","headers","catch","e","exception","path","_getBundleUrlPath","queryParams","URLSearchParams","encodeURIComponent","dev","String","mode","hot","minify","append","encodeURI","toString","debuggerHost","logUrl","developer","tool","packagerOpts","__flipperHack","manifest","resolveManifestAssets","resolver","resolve","match","resolveGoogleServicesFile","handleWebRequestAsync","res","setHeader","end","createTemplateHtmlFromExpoConfigAsync","scripts","checkBrowserRequestAsync","bundlers","getPlatformBundlers","web","parsePlatformHeader","handleRequestAsync","next","getParsedHeaders","body","version","_getManifestResponseAsync","headerName","headerValue","trackManifest"],"mappings":"AAAA;;;;;AAAmE,IAAA,OAAc,WAAd,cAAc,CAAA;AACzD,IAAA,IAAK,WAAL,KAAK,CAAA;AAEjBA,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACgB,IAAA,KAAoB,WAApB,oBAAoB,CAAA;AACvCC,IAAAA,cAAc,mCAAM,uBAAuB,EAA7B;AAEU,IAAA,iBAAqB,WAArB,qBAAqB,CAAA;AACH,IAAA,YAAgB,WAAhB,gBAAgB,CAAA;AACvC,IAAA,eAAkB,WAAlB,kBAAkB,CAAA;AACgB,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;AAChD,IAAA,kBAAqB,WAArB,qBAAqB,CAAA;AACF,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;;;;;;;;;;;;;;;;;;;;;;AA+BjE,MAAMC,cAAc,GAAG,UAAU,AAAC;QAA5BA,cAAc,GAAdA,cAAc;AAapB,MAAeC,kBAAkB,SAE9BC,eAAc,eAAA;IAGtBC,YAAsBC,WAAmB,EAAYC,OAAkC,CAAE;QACvF,KAAK,CACHD,WAAW,EACX;;SAEG,CACH;YAAC,GAAG;YAAE,WAAW;YAAE,YAAY;SAAC,CACjC,CAAC;aAPkBA,WAAmB,GAAnBA,WAAmB;aAAYC,OAAkC,GAAlCA,OAAkC;Q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W,IAAI,CAAC,CAAC;QAEd,gBAAgB;QAChB,IAAI,CAACK,aAAa,CAACJ,OAAO,WAAPA,OAAO,GAAI,IAAI,CAAC,CAAC;KACrC;CACF;QAzPqBzE,kBAAkB,GAAlBA,kBAAkB"}
@@ -27,6 +27,7 @@ function _interopRequireWildcard(obj) {
27
27
  return newObj;
28
28
  }
29
29
  }
30
+ const debug = require("debug")("expo:start:server:middleware:runtimeRedirect");
30
31
  class RuntimeRedirectMiddleware extends _expoMiddleware.ExpoMiddleware {
31
32
  constructor(projectRoot, options){
32
33
  super(projectRoot, [
@@ -42,6 +43,10 @@ class RuntimeRedirectMiddleware extends _expoMiddleware.ExpoMiddleware {
42
43
  (0, _resolvePlatform).assertMissingRuntimePlatform(platform);
43
44
  (0, _resolvePlatform).assertRuntimePlatform(platform);
44
45
  const runtime = isDevClient ? "custom" : "expo";
46
+ debug(`props:`, {
47
+ platform,
48
+ runtime
49
+ });
45
50
  this.options.onDeepLink({
46
51
  runtime,
47
52
  platform
@@ -55,7 +60,7 @@ class RuntimeRedirectMiddleware extends _expoMiddleware.ExpoMiddleware {
55
60
  res.end();
56
61
  return;
57
62
  }
58
- Log.debug("Redirect ->", redirect);
63
+ debug("Redirect ->", redirect);
59
64
  res.setHeader("Location", redirect);
60
65
  // Disable caching
61
66
  (0, _expoMiddleware).disableResponseCache(res);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/middleware/RuntimeRedirectMiddleware.ts"],"sourcesContent":["import { parse } from 'url';\n\nimport * as Log from '../../../log';\nimport { disableResponseCache, ExpoMiddleware } from './ExpoMiddleware';\nimport {\n assertMissingRuntimePlatform,\n assertRuntimePlatform,\n parsePlatformHeader,\n RuntimePlatform,\n} from './resolvePlatform';\nimport { ServerRequest, ServerResponse } from './server.types';\n\n/** Runtime to target: expo = Expo Go, custom = Dev Client. */\ntype RuntimeTarget = 'expo' | 'custom';\n\nexport class RuntimeRedirectMiddleware extends ExpoMiddleware {\n constructor(\n protected projectRoot: string,\n protected options: {\n onDeepLink: (props: {\n runtime: RuntimeTarget;\n platform: RuntimePlatform;\n }) => void | Promise<void>;\n getLocation: (props: { runtime: RuntimeTarget }) => string | null | undefined;\n }\n ) {\n super(projectRoot, ['/_expo/link']);\n }\n\n async handleRequestAsync(req: ServerRequest, res: ServerResponse): Promise<void> {\n const { query } = parse(req.url!, true);\n const isDevClient = query['choice'] === 'expo-dev-client';\n const platform = parsePlatformHeader(req);\n assertMissingRuntimePlatform(platform);\n assertRuntimePlatform(platform);\n const runtime = isDevClient ? 'custom' : 'expo';\n\n this.options.onDeepLink({ runtime, platform });\n\n const redirect = this.options.getLocation({ runtime });\n if (!redirect) {\n Log.warn(\n `[redirect middleware]: Unable to determine redirect location for runtime '${runtime}' and platform '${platform}'`\n );\n res.statusCode = 404;\n res.end();\n return;\n }\n Log.debug('Redirect ->', redirect);\n res.setHeader('Location', redirect);\n\n // Disable caching\n disableResponseCache(res);\n\n // 'Temporary Redirect'\n res.statusCode = 307;\n res.end();\n }\n}\n"],"names":["Log","RuntimeRedirectMiddleware","ExpoMiddleware","constructor","projectRoot","options","handleRequestAsync","req","res","query","parse","url","isDevClient","platform","parsePlatformHeader","assertMissingRuntimePlatform","assertRuntimePlatform","runtime","onDeepLink","redirect","getLocation","warn","statusCode","end","debug","setHeader","disableResponseCache"],"mappings":"AAAA;;;;AAAsB,IAAA,IAAK,WAAL,KAAK,CAAA;AAEfA,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACsC,IAAA,eAAkB,WAAlB,kBAAkB,CAAA;AAMhE,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;;;;;;;;;;;;;;;;;;;;;;AAMnB,MAAMC,yBAAyB,SAASC,eAAc,eAAA;IAC3DC,YACYC,WAAmB,EACnBC,OAMT,CACD;QACA,KAAK,CAACD,WAAW,EAAE;YAAC,aAAa;SAAC,CAAC,CAAC;aAT1BA,WAAmB,GAAnBA,WAAmB;aACnBC,OAMT,GANSA,OAMT;KAGF;IAED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B;QACvBA,GAAG,CAACc,UAAU,GAAG,GAAG,CAAC;QACrBd,GAAG,CAACe,GAAG,EAAE,CAAC;KACX;CACF;QA3CYtB,yBAAyB,GAAzBA,yBAAyB"}
1
+ {"version":3,"sources":["../../../../../src/start/server/middleware/RuntimeRedirectMiddleware.ts"],"sourcesContent":["import { parse } from 'url';\n\nimport * as Log from '../../../log';\nimport { disableResponseCache, ExpoMiddleware } from './ExpoMiddleware';\nimport {\n assertMissingRuntimePlatform,\n assertRuntimePlatform,\n parsePlatformHeader,\n RuntimePlatform,\n} from './resolvePlatform';\nimport { ServerRequest, ServerResponse } from './server.types';\n\nconst debug = require('debug')(\n 'expo:start:server:middleware:runtimeRedirect'\n) as typeof console.log;\n\n/** Runtime to target: expo = Expo Go, custom = Dev Client. */\ntype RuntimeTarget = 'expo' | 'custom';\n\nexport class RuntimeRedirectMiddleware extends ExpoMiddleware {\n constructor(\n protected projectRoot: string,\n protected options: {\n onDeepLink: (props: {\n runtime: RuntimeTarget;\n platform: RuntimePlatform;\n }) => void | Promise<void>;\n getLocation: (props: { runtime: RuntimeTarget }) => string | null | undefined;\n }\n ) {\n super(projectRoot, ['/_expo/link']);\n }\n\n async handleRequestAsync(req: ServerRequest, res: ServerResponse): Promise<void> {\n const { query } = parse(req.url!, true);\n const isDevClient = query['choice'] === 'expo-dev-client';\n const platform = parsePlatformHeader(req);\n assertMissingRuntimePlatform(platform);\n assertRuntimePlatform(platform);\n const runtime = isDevClient ? 'custom' : 'expo';\n\n debug(`props:`, { platform, runtime });\n\n this.options.onDeepLink({ runtime, platform });\n\n const redirect = this.options.getLocation({ runtime });\n if (!redirect) {\n Log.warn(\n `[redirect middleware]: Unable to determine redirect location for runtime '${runtime}' and platform '${platform}'`\n );\n res.statusCode = 404;\n res.end();\n return;\n }\n debug('Redirect ->', redirect);\n res.setHeader('Location', redirect);\n\n // Disable caching\n disableResponseCache(res);\n\n // 'Temporary Redirect'\n res.statusCode = 307;\n res.end();\n }\n}\n"],"names":["Log","debug","require","RuntimeRedirectMiddleware","ExpoMiddleware","constructor","projectRoot","options","handleRequestAsync","req","res","query","parse","url","isDevClient","platform","parsePlatformHeader","assertMissingRuntimePlatform","assertRuntimePlatform","runtime","onDeepLink","redirect","getLocation","warn","statusCode","end","setHeader","disableResponseCache"],"mappings":"AAAA;;;;AAAsB,IAAA,IAAK,WAAL,KAAK,CAAA;AAEfA,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACsC,IAAA,eAAkB,WAAlB,kBAAkB,CAAA;AAMhE,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;;;;;;;;;;;;;;;;;;;;;;AAG1B,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAC5B,8CAA8C,CAC/C,AAAsB,AAAC;AAKjB,MAAMC,yBAAyB,SAASC,eAAc,eAAA;IAC3DC,YACYC,WAAmB,EACnBC,OAMT,CACD;QACA,KAAK,CAACD,WAAW,EAAE;YAAC,aAAa;SAAC,CAAC,CAAC;aAT1BA,WAAmB,GAAnBA,WAAmB;aACnBC,OAMT,GANSA,OAMT;KAGF;IAED,MAAMC,kBAAkB,CAACC,GAAkB,EAAEC,GAAmB,EAAiB;QAC/E,MAAM,EAAEC,KAAK,CAAA,EAAE,GAAGC,CAAAA,GAAAA,IAAK,AAAgB,CAAA,MAAhB,CAACH,GAAG,CAACI,GAAG,EAAG,IAAI,CAAC,AAAC;QACxC,MAAMC,WAAW,GAAGH,KAAK,CAAC,QAAQ,CAAC,KAAK,iBAAiB,AAAC;QAC1D,MAAMI,QAAQ,GAAGC,CAAAA,GAAAA,gBAAmB,AAAK,CAAA,oBAAL,CAACP,GAAG,CAAC,AAAC;QAC1CQ,CAAAA,GAAAA,gBAA4B,AAAU,CAAA,6BAAV,CAACF,QAAQ,CAAC,CAAC;QACvCG,CAAAA,GAAAA,gBAAqB,AAAU,CAAA,sBAAV,CAACH,QAAQ,CAAC,CAAC;QAChC,MAAMI,OAAO,GAAGL,WAAW,GAAG,QAAQ,GAAG,MAAM,AAAC;QAEhDb,KAAK,CAAC,CAAC,MAAM,CAAC,EAAE;YAAEc,QAAQ;YAAEI,OAAO;SAAE,CAAC,CAAC;QAEvC,IAAI,CAACZ,OAAO,CAACa,UAAU,CAAC;YAAED,OAAO;YAAEJ,QAAQ;SAAE,CAAC,CAAC;QAE/C,MAAMM,QAAQ,GAAG,IAAI,CAACd,OAAO,CAACe,WAAW,CAAC;YAAEH,OAAO;SAAE,CAAC,AAAC;QACvD,IAAI,CAACE,QAAQ,EAAE;YACbrB,GAAG,CAACuB,IAAI,CACN,CAAC,0EAA0E,EAAEJ,OAAO,CAAC,gBAAgB,EAAEJ,QAAQ,CAAC,CAAC,CAAC,CACnH,CAAC;YACFL,GAAG,CAACc,UAAU,GAAG,GAAG,CAAC;YACrBd,GAAG,CAACe,GAAG,EAAE,CAAC;YACV,OAAO;SACR;QACDxB,KAAK,CAAC,aAAa,EAAEoB,QAAQ,CAAC,CAAC;QAC/BX,GAAG,CAACgB,SAAS,CAAC,UAAU,EAAEL,QAAQ,CAAC,CAAC;QAEpC,kBAAkB;QAClBM,CAAAA,GAAAA,eAAoB,AAAK,CAAA,qBAAL,CAACjB,GAAG,CAAC,CAAC;QAE1B,uBAAuB;QACvBA,GAAG,CAACc,UAAU,GAAG,GAAG,CAAC;QACrBd,GAAG,CAACe,GAAG,EAAE,CAAC;KACX;CACF;QA7CYtB,yBAAyB,GAAzBA,yBAAyB"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ var _path = _interopRequireDefault(require("path"));
6
+ var _send = _interopRequireDefault(require("send"));
7
+ var _url = require("url");
8
+ var _env = require("../../../utils/env");
9
+ var _resolvePlatform = require("./resolvePlatform");
10
+ function _interopRequireDefault(obj) {
11
+ return obj && obj.__esModule ? obj : {
12
+ default: obj
13
+ };
14
+ }
15
+ const debug = require("debug")("expo:start:server:middleware:serveStatic");
16
+ class ServeStaticMiddleware {
17
+ constructor(projectRoot){
18
+ this.projectRoot = projectRoot;
19
+ }
20
+ getHandler() {
21
+ const publicPath = _path.default.join(this.projectRoot, _env.env.EXPO_PUBLIC_FOLDER);
22
+ debug(`Serving static files from:`, publicPath);
23
+ const opts = {
24
+ root: publicPath
25
+ };
26
+ return (req, res, next)=>{
27
+ if (!(req == null ? void 0 : req.url) || req.method !== "GET" && req.method !== "HEAD") {
28
+ return next();
29
+ }
30
+ const platform = (0, _resolvePlatform).parsePlatformHeader(req);
31
+ // Currently this is web-only
32
+ if (platform && platform !== "web") {
33
+ return next();
34
+ }
35
+ const pathname = (0, _url).parse(req.url).pathname;
36
+ if (!pathname) {
37
+ return next();
38
+ }
39
+ debug(`Maybe serve static:`, pathname);
40
+ const stream = (0, _send).default(req, pathname, opts);
41
+ // add file listener for fallthrough
42
+ let forwardError = false;
43
+ stream.on("file", function onFile() {
44
+ // once file is determined, always forward error
45
+ forwardError = true;
46
+ });
47
+ // forward errors
48
+ stream.on("error", function error(err) {
49
+ if (forwardError || !(err.statusCode < 500)) {
50
+ next(err);
51
+ return;
52
+ }
53
+ next();
54
+ });
55
+ // pipe
56
+ stream.pipe(res);
57
+ };
58
+ }
59
+ }
60
+ exports.ServeStaticMiddleware = ServeStaticMiddleware;
61
+
62
+ //# sourceMappingURL=ServeStaticMiddleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/start/server/middleware/ServeStaticMiddleware.ts"],"sourcesContent":["import path from 'path';\nimport send from 'send';\nimport { parse } from 'url';\n\nimport { env } from '../../../utils/env';\nimport { parsePlatformHeader } from './resolvePlatform';\nimport { ServerRequest, ServerResponse } from './server.types';\n\nconst debug = require('debug')('expo:start:server:middleware:serveStatic') as typeof console.log;\n\n/**\n * Adds support for serving the files in the static `public/` folder to web apps.\n */\nexport class ServeStaticMiddleware {\n constructor(private projectRoot: string) {}\n getHandler() {\n const publicPath = path.join(this.projectRoot, env.EXPO_PUBLIC_FOLDER);\n\n debug(`Serving static files from:`, publicPath);\n const opts = {\n root: publicPath,\n };\n return (req: ServerRequest, res: ServerResponse, next: any) => {\n if (!req?.url || (req.method !== 'GET' && req.method !== 'HEAD')) {\n return next();\n }\n\n const platform = parsePlatformHeader(req);\n // Currently this is web-only\n if (platform && platform !== 'web') {\n return next();\n }\n\n const pathname = parse(req.url).pathname;\n if (!pathname) {\n return next();\n }\n\n debug(`Maybe serve static:`, pathname);\n const stream = send(req, pathname, opts);\n\n // add file listener for fallthrough\n let forwardError = false;\n stream.on('file', function onFile() {\n // once file is determined, always forward error\n forwardError = true;\n });\n\n // forward errors\n stream.on('error', function error(err: any) {\n if (forwardError || !(err.statusCode < 500)) {\n next(err);\n return;\n }\n\n next();\n });\n\n // pipe\n stream.pipe(res);\n };\n }\n}\n"],"names":["debug","require","ServeStaticMiddleware","constructor","projectRoot","getHandler","publicPath","path","join","env","EXPO_PUBLIC_FOLDER","opts","root","req","res","next","url","method","platform","parsePlatformHeader","pathname","parse","stream","send","forwardError","on","onFile","error","err","statusCode","pipe"],"mappings":"AAAA;;;;AAAiB,IAAA,KAAM,kCAAN,MAAM,EAAA;AACN,IAAA,KAAM,kCAAN,MAAM,EAAA;AACD,IAAA,IAAK,WAAL,KAAK,CAAA;AAEP,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACJ,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;;;;;;AAGvD,MAAMA,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,0CAA0C,CAAC,AAAsB,AAAC;AAK1F,MAAMC,qBAAqB;IAChCC,YAAoBC,WAAmB,CAAE;aAArBA,WAAmB,GAAnBA,WAAmB;KAAI;IAC3CC,UAAU,GAAG;QACX,MAAMC,UAAU,GAAGC,KAAI,QAAA,CAACC,IAAI,CAAC,IAAI,CAACJ,WAAW,EAAEK,IAAG,IAAA,CAACC,kBAAkB,CAAC,AAAC;QAEvEV,KAAK,CAAC,CAAC,0BAA0B,CAAC,EAAEM,UAAU,CAAC,CAAC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AG,GAAG,CAAC,EAAE;oBAC3Cd,IAAI,CAACa,GAAG,CAAC,CAAC;oBACV,OAAO;iBACR;gBAEDb,IAAI,EAAE,CAAC;aACR,CAAC,CAAC;YAEH,OAAO;YACPO,MAAM,CAACQ,IAAI,CAAChB,GAAG,CAAC,CAAC;SAClB,CAAC;KACH;CACF;QAjDYZ,qBAAqB,GAArBA,qBAAqB"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.getPlatformBundlers = getPlatformBundlers;
6
+ function getPlatformBundlers(exp) {
7
+ var ref, ref1, ref2;
8
+ var ref3, ref4, ref5;
9
+ return {
10
+ // @ts-expect-error: not on type yet
11
+ ios: (ref3 = (ref = exp.ios) == null ? void 0 : ref.bundler) != null ? ref3 : "metro",
12
+ // @ts-expect-error: not on type yet
13
+ android: (ref4 = (ref1 = exp.android) == null ? void 0 : ref1.bundler) != null ? ref4 : "metro",
14
+ web: (ref5 = (ref2 = exp.web) == null ? void 0 : ref2.bundler) != null ? ref5 : "webpack"
15
+ };
16
+ }
17
+
18
+ //# sourceMappingURL=platformBundlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/start/server/platformBundlers.ts"],"sourcesContent":["import { ExpoConfig, Platform } from '@expo/config';\n\n/** Which bundler each platform should use. */\nexport type PlatformBundlers = Record<Platform, 'metro' | 'webpack'>;\n\n/** Get the platform bundlers mapping. */\nexport function getPlatformBundlers(exp: Partial<ExpoConfig>): PlatformBundlers {\n return {\n // @ts-expect-error: not on type yet\n ios: exp.ios?.bundler ?? 'metro',\n // @ts-expect-error: not on type yet\n android: exp.android?.bundler ?? 'metro',\n web: exp.web?.bundler ?? 'webpack',\n };\n}\n"],"names":["getPlatformBundlers","exp","ios","bundler","android","web"],"mappings":"AAAA;;;;QAMgBA,mBAAmB,GAAnBA,mBAAmB;AAA5B,SAASA,mBAAmB,CAACC,GAAwB,EAAoB;QAGvEA,GAAO,EAEHA,IAAW,EACfA,IAAO;QAHPA,IAAgB,EAEZA,IAAoB,EACxBA,IAAgB;IALvB,OAAO;QACL,oCAAoC;QACpCC,GAAG,EAAED,CAAAA,IAAgB,GAAhBA,CAAAA,GAAO,GAAPA,GAAG,CAACC,GAAG,SAAS,GAAhBD,KAAAA,CAAgB,GAAhBA,GAAO,CAAEE,OAAO,YAAhBF,IAAgB,GAAI,OAAO;QAChC,oCAAoC;QACpCG,OAAO,EAAEH,CAAAA,IAAoB,GAApBA,CAAAA,IAAW,GAAXA,GAAG,CAACG,OAAO,SAAS,GAApBH,KAAAA,CAAoB,GAApBA,IAAW,CAAEE,OAAO,YAApBF,IAAoB,GAAI,OAAO;QACxCI,GAAG,EAAEJ,CAAAA,IAAgB,GAAhBA,CAAAA,IAAO,GAAPA,GAAG,CAACI,GAAG,SAAS,GAAhBJ,KAAAA,CAAgB,GAAhBA,IAAO,CAAEE,OAAO,YAAhBF,IAAgB,GAAI,SAAS;KACnC,CAAC;CACH"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.createTemplateHtmlFromExpoConfigAsync = createTemplateHtmlFromExpoConfigAsync;
6
+ exports.createTemplateHtmlAsync = createTemplateHtmlAsync;
7
+ var _config = require("@expo/config");
8
+ var _fs = _interopRequireDefault(require("fs"));
9
+ var _path = _interopRequireDefault(require("path"));
10
+ var _templates = require("../../customize/templates");
11
+ var _env = require("../../utils/env");
12
+ function _interopRequireDefault(obj) {
13
+ return obj && obj.__esModule ? obj : {
14
+ default: obj
15
+ };
16
+ }
17
+ async function createTemplateHtmlFromExpoConfigAsync(projectRoot, { scripts , exp =(0, _config).getConfig(projectRoot, {
18
+ skipSDKVersionRequirement: true
19
+ }).exp }) {
20
+ var ref, ref1, ref2;
21
+ var ref3, _webName;
22
+ return createTemplateHtmlAsync(projectRoot, {
23
+ langIsoCode: (ref3 = (ref = exp.web) == null ? void 0 : ref.lang) != null ? ref3 : "en",
24
+ scripts,
25
+ title: (_webName = (0, _config).getNameFromConfig(exp).webName) != null ? _webName : "Expo App",
26
+ description: (ref1 = exp.web) == null ? void 0 : ref1.description,
27
+ themeColor: (ref2 = exp.web) == null ? void 0 : ref2.themeColor
28
+ });
29
+ }
30
+ function getFileFromLocalPublicFolder(projectRoot, { publicFolder , filePath }) {
31
+ const localFilePath = _path.default.resolve(projectRoot, publicFolder, filePath);
32
+ if (!_fs.default.existsSync(localFilePath)) {
33
+ return null;
34
+ }
35
+ return localFilePath;
36
+ }
37
+ /** Attempt to read the `index.html` from the local project before falling back on the template `index.html`. */ async function getTemplateIndexHtmlAsync(projectRoot) {
38
+ let filePath = getFileFromLocalPublicFolder(projectRoot, {
39
+ // TODO: Maybe use the app.json override.
40
+ publicFolder: _env.env.EXPO_PUBLIC_FOLDER,
41
+ filePath: "index.html"
42
+ });
43
+ if (!filePath) {
44
+ filePath = _templates.TEMPLATES.find((value)=>value.id === "index.html"
45
+ ).file(projectRoot);
46
+ }
47
+ return _fs.default.promises.readFile(filePath, "utf8");
48
+ }
49
+ async function createTemplateHtmlAsync(projectRoot, { scripts , description , langIsoCode , title , themeColor }) {
50
+ // Resolve the best possible index.html template file.
51
+ let contents = await getTemplateIndexHtmlAsync(projectRoot);
52
+ contents = contents.replace("%LANG_ISO_CODE%", langIsoCode);
53
+ contents = contents.replace("%WEB_TITLE%", title);
54
+ contents = contents.replace("</body>", scripts.map((url)=>`<script src="${url}"></script>`
55
+ ).join("") + "</body>");
56
+ if (themeColor) {
57
+ contents = addMeta(contents, `name="theme-color" content="${themeColor}"`);
58
+ }
59
+ if (description) {
60
+ contents = addMeta(contents, `name="description" content="${description}"`);
61
+ }
62
+ return contents;
63
+ }
64
+ /** Add a `<meta />` tag to the `<head />` element. */ function addMeta(contents, meta) {
65
+ return contents.replace("</head>", `<meta ${meta}>\n</head>`);
66
+ }
67
+
68
+ //# sourceMappingURL=webTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/start/server/webTemplate.ts"],"sourcesContent":["import { ExpoConfig, getConfig, getNameFromConfig } from '@expo/config';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { TEMPLATES } from '../../customize/templates';\nimport { env } from '../../utils/env';\n\n/**\n * Create a static HTML for SPA styled websites.\n * This method attempts to reuse the same patterns as `@expo/webpack-config`.\n */\nexport async function createTemplateHtmlFromExpoConfigAsync(\n projectRoot: string,\n {\n scripts,\n exp = getConfig(projectRoot, { skipSDKVersionRequirement: true }).exp,\n }: {\n scripts: string[];\n exp?: ExpoConfig;\n }\n) {\n return createTemplateHtmlAsync(projectRoot, {\n langIsoCode: exp.web?.lang ?? 'en',\n scripts,\n title: getNameFromConfig(exp).webName ?? 'Expo App',\n description: exp.web?.description,\n themeColor: exp.web?.themeColor,\n });\n}\n\nfunction getFileFromLocalPublicFolder(\n projectRoot: string,\n { publicFolder, filePath }: { publicFolder: string; filePath: string }\n): string | null {\n const localFilePath = path.resolve(projectRoot, publicFolder, filePath);\n if (!fs.existsSync(localFilePath)) {\n return null;\n }\n return localFilePath;\n}\n\n/** Attempt to read the `index.html` from the local project before falling back on the template `index.html`. */\nasync function getTemplateIndexHtmlAsync(projectRoot: string): Promise<string> {\n let filePath = getFileFromLocalPublicFolder(projectRoot, {\n // TODO: Maybe use the app.json override.\n publicFolder: env.EXPO_PUBLIC_FOLDER,\n filePath: 'index.html',\n });\n if (!filePath) {\n filePath = TEMPLATES.find((value) => value.id === 'index.html')!.file(projectRoot);\n }\n return fs.promises.readFile(filePath, 'utf8');\n}\n\n/** Return an `index.html` string with template values added. */\nexport async function createTemplateHtmlAsync(\n projectRoot: string,\n {\n scripts,\n description,\n langIsoCode,\n title,\n themeColor,\n }: {\n scripts: string[];\n description?: string;\n langIsoCode: string;\n title: string;\n themeColor?: string;\n }\n): Promise<string> {\n // Resolve the best possible index.html template file.\n let contents = await getTemplateIndexHtmlAsync(projectRoot);\n\n contents = contents.replace('%LANG_ISO_CODE%', langIsoCode);\n contents = contents.replace('%WEB_TITLE%', title);\n contents = contents.replace(\n '</body>',\n scripts.map((url) => `<script src=\"${url}\"></script>`).join('') + '</body>'\n );\n\n if (themeColor) {\n contents = addMeta(contents, `name=\"theme-color\" content=\"${themeColor}\"`);\n }\n\n if (description) {\n contents = addMeta(contents, `name=\"description\" content=\"${description}\"`);\n }\n\n return contents;\n}\n\n/** Add a `<meta />` tag to the `<head />` element. */\nfunction addMeta(contents: string, meta: string): string {\n return contents.replace('</head>', `<meta ${meta}>\\n</head>`);\n}\n"],"names":["createTemplateHtmlFromExpoConfigAsync","createTemplateHtmlAsync","projectRoot","scripts","exp","getConfig","skipSDKVersionRequirement","getNameFromConfig","langIsoCode","web","lang","title","webName","description","themeColor","getFileFromLocalPublicFolder","publicFolder","filePath","localFilePath","path","resolve","fs","existsSync","getTemplateIndexHtmlAsync","env","EXPO_PUBLIC_FOLDER","TEMPLATES","find","value","id","file","promises","readFile","contents","replace","map","url","join","addMeta","meta"],"mappings":"AAAA;;;;QAWsBA,qCAAqC,GAArCA,qCAAqC;QA4CrCC,uBAAuB,GAAvBA,uBAAuB;AAvDY,IAAA,OAAc,WAAd,cAAc,CAAA;AACxD,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEG,IAAA,UAA2B,WAA3B,2BAA2B,CAAA;AACjC,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;;;;;;AAM9B,eAAeD,qCAAqC,CACzDE,WAAmB,EACnB,EACEC,OAAO,CAAA,EACPC,GAAG,EAAGC,CAAAA,GAAAA,OAAS,AAAkD,CAAA,UAAlD,CAACH,WAAW,EAAE;IAAEI,yBAAyB,EAAE,IAAI;CAAE,CAAC,CAACF,GAAG,CAAA,EAItE,EACD;QAEeA,GAAO,EAGPA,IAAO,EACRA,IAAO;QAJNA,IAAa,EAEnBG,QAA8B;IAHvC,OAAON,uBAAuB,CAACC,WAAW,EAAE;QAC1CM,WAAW,EA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/D"}
@@ -13,8 +13,10 @@ var _env = require("../../../utils/env");
13
13
  var _errors = require("../../../utils/errors");
14
14
  var _ip = require("../../../utils/ip");
15
15
  var _port = require("../../../utils/port");
16
+ var _progress = require("../../../utils/progress");
16
17
  var _dotExpo = require("../../project/dotExpo");
17
18
  var _bundlerDevServer = require("../BundlerDevServer");
19
+ var _compile = require("./compile");
18
20
  var _resolveFromProject = require("./resolveFromProject");
19
21
  var _tls = require("./tls");
20
22
  function _interopRequireDefault(obj) {
@@ -43,6 +45,7 @@ function _interopRequireWildcard(obj) {
43
45
  return newObj;
44
46
  }
45
47
  }
48
+ const debug = require("debug")("expo:start:server:webpack:devServer");
46
49
  function assertIsWebpackDevServer(value) {
47
50
  if (!(value == null ? void 0 : value.sockWrite)) {
48
51
  var ref;
@@ -99,9 +102,6 @@ class WebpackBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
99
102
  "android"
100
103
  ].includes(process.env.EXPO_WEBPACK_PLATFORM || "");
101
104
  }
102
- isTargetingWeb() {
103
- return true;
104
- }
105
105
  async createNativeDevServerMiddleware({ port , compiler , options }) {
106
106
  if (!this.isTargetingNative()) {
107
107
  return null;
@@ -141,6 +141,46 @@ class WebpackBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
141
141
  throw new _errors.CommandError("NO_PORT_FOUND", error.message);
142
142
  }
143
143
  }
144
+ async bundleAsync({ mode , clear }) {
145
+ // Do this first to fail faster.
146
+ const webpack = (0, _resolveFromProject).importWebpackFromProject(this.projectRoot);
147
+ if (clear) {
148
+ await this.clearWebProjectCacheAsync(this.projectRoot, mode);
149
+ }
150
+ const config = await this.loadConfigAsync({
151
+ isImageEditingEnabled: true,
152
+ mode
153
+ });
154
+ if (!config.plugins) {
155
+ config.plugins = [];
156
+ }
157
+ const bar = (0, _progress).createProgressBar(_chalk.default`{bold Web} Bundling Javascript [:bar] :percent`, {
158
+ width: 64,
159
+ total: 100,
160
+ clear: true,
161
+ complete: "=",
162
+ incomplete: " "
163
+ });
164
+ // NOTE(EvanBacon): Add a progress bar to the webpack logger if defined (e.g. not in CI).
165
+ if (bar != null) {
166
+ config.plugins.push(new webpack.ProgressPlugin((percent)=>{
167
+ bar == null ? void 0 : bar.update(percent);
168
+ if (percent === 1) {
169
+ bar == null ? void 0 : bar.terminate();
170
+ }
171
+ }));
172
+ }
173
+ // Create a webpack compiler that is configured with custom messages.
174
+ const compiler = webpack(config);
175
+ try {
176
+ await (0, _compile).compileAsync(compiler);
177
+ } catch (error) {
178
+ Log.error(_chalk.default.red("Failed to compile"));
179
+ throw error;
180
+ } finally{
181
+ bar == null ? void 0 : bar.terminate();
182
+ }
183
+ }
144
184
  async startImplementationAsync(options) {
145
185
  var ref;
146
186
  // Do this first to fail faster.
@@ -157,12 +197,12 @@ class WebpackBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
157
197
  scheme: https ? "https" : "http"
158
198
  }
159
199
  });
160
- Log.debug("Starting webpack on port: " + port);
200
+ debug("Starting webpack on port: " + port);
161
201
  if (resetDevServer) {
162
- await clearWebProjectCacheAsync(this.projectRoot, mode);
202
+ await this.clearWebProjectCacheAsync(this.projectRoot, mode);
163
203
  }
164
204
  if (https) {
165
- Log.debug("Configuring TLS to enable HTTPS support");
205
+ debug("Configuring TLS to enable HTTPS support");
166
206
  await (0, _tls).ensureEnvironmentSupportsTLSAsync(this.projectRoot).catch((error)=>{
167
207
  Log.error(`Error creating TLS certificates: ${error}`);
168
208
  });
@@ -273,6 +313,19 @@ class WebpackBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
273
313
  "./webpack.config.js"
274
314
  ];
275
315
  }
316
+ async clearWebProjectCacheAsync(projectRoot, mode = "development") {
317
+ Log.log(_chalk.default.dim(`Clearing Webpack ${mode} cache directory...`));
318
+ const dir = await (0, _dotExpo).ensureDotExpoProjectDirectoryInitialized(projectRoot);
319
+ const cacheFolder = path.join(dir, "web/cache", mode);
320
+ try {
321
+ await _fs.default.promises.rm(cacheFolder, {
322
+ recursive: true,
323
+ force: true
324
+ });
325
+ } catch (error) {
326
+ Log.error(`Could not clear ${mode} web cache directory: ${error.message}`);
327
+ }
328
+ }
276
329
  }
277
330
  exports.WebpackBundlerDevServer = WebpackBundlerDevServer;
278
331
  function setMode(mode) {
@@ -282,18 +335,5 @@ function setMode(mode) {
282
335
  function getProjectWebpackConfigFilePath(projectRoot) {
283
336
  return _resolveFrom.default.silent(projectRoot, "./webpack.config.js");
284
337
  }
285
- async function clearWebProjectCacheAsync(projectRoot, mode = "development") {
286
- Log.log(_chalk.default.dim(`Clearing Webpack ${mode} cache directory...`));
287
- const dir = await (0, _dotExpo).ensureDotExpoProjectDirectoryInitialized(projectRoot);
288
- const cacheFolder = path.join(dir, "web/cache", mode);
289
- try {
290
- await _fs.default.promises.rm(cacheFolder, {
291
- recursive: true,
292
- force: true
293
- });
294
- } catch (error) {
295
- Log.error(`Could not clear ${mode} web cache directory: ${error.message}`);
296
- }
297
- }
298
338
 
299
339
  //# sourceMappingURL=WebpackBundlerDevServer.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/webpack/WebpackBundlerDevServer.ts"],"sourcesContent":["import { createSymbolicateMiddleware } from '@expo/dev-server/build/webpack/symbolicateMiddleware';\nimport chalk from 'chalk';\nimport type { Application } from 'express';\nimport fs from 'fs';\nimport http from 'http';\nimport * as path from 'path';\nimport resolveFrom from 'resolve-from';\nimport type webpack from 'webpack';\nimport type WebpackDevServer from 'webpack-dev-server';\n\nimport * as Log from '../../../log';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { getIpAddress } from '../../../utils/ip';\nimport { choosePortAsync } from '../../../utils/port';\nimport { ensureDotExpoProjectDirectoryInitialized } from '../../project/dotExpo';\nimport { BundlerDevServer, BundlerStartOptions, DevServerInstance } from '../BundlerDevServer';\nimport {\n importExpoWebpackConfigFromProject,\n importWebpackDevServerFromProject,\n importWebpackFromProject,\n} from './resolveFromProject';\nimport { ensureEnvironmentSupportsTLSAsync } from './tls';\n\ntype AnyCompiler = webpack.Compiler | webpack.MultiCompiler;\n\nexport type WebpackConfiguration = webpack.Configuration & {\n devServer?: {\n before?: (app: Application, server: WebpackDevServer, compiler: webpack.Compiler) => void;\n };\n};\n\nfunction assertIsWebpackDevServer(value: any): asserts value is WebpackDevServer {\n if (!value?.sockWrite) {\n throw new CommandError(\n 'WEBPACK',\n value\n ? 'Expected Webpack dev server, found: ' + (value.constructor?.name ?? value)\n : 'Webpack dev server not started yet.'\n );\n }\n}\n\nexport class WebpackBundlerDevServer extends BundlerDevServer {\n get name(): string {\n return 'webpack';\n }\n\n // A custom message websocket broadcaster used to send messages to a React Native runtime.\n private customMessageSocketBroadcaster:\n | undefined\n | ((message: string, data?: Record<string, any>) => void);\n\n public broadcastMessage(\n method: string | 'reload' | 'devMenu' | 'sendDevCommand',\n params?: Record<string, any>\n ): void {\n if (!this.instance) {\n return;\n }\n\n assertIsWebpackDevServer(this.instance?.server);\n\n // Allow any message on native\n if (this.customMessageSocketBroadcaster) {\n this.customMessageSocketBroadcaster(method, params);\n return;\n }\n\n // TODO(EvanBacon): Custom Webpack overlay.\n // Default webpack-dev-server sockets use \"content-changed\" instead of \"reload\" (what we use on native).\n // For now, just manually convert the value so our CLI interface can be unified.\n const hackyConvertedMessage = method === 'reload' ? 'content-changed' : method;\n\n this.instance.server.sockWrite(this.instance.server.sockets, hackyConvertedMessage, params);\n }\n\n private async attachNativeDevServerMiddlewareToDevServer({\n server,\n middleware,\n attachToServer,\n logger,\n }: { server: http.Server } & Awaited<ReturnType<typeof this.createNativeDevServerMiddleware>>) {\n const { attachInspectorProxy, LogReporter } = await import('@expo/dev-server');\n\n // Hook up the React Native WebSockets to the Webpack dev server.\n const { messageSocket, debuggerProxy, eventsSocket } = attachToServer(server);\n\n this.customMessageSocketBroadcaster = messageSocket.broadcast;\n\n const logReporter = new LogReporter(logger);\n logReporter.reportEvent = eventsSocket.reportEvent;\n\n const { inspectorProxy } = attachInspectorProxy(this.projectRoot, {\n middleware,\n server,\n });\n\n return {\n messageSocket,\n eventsSocket,\n debuggerProxy,\n logReporter,\n inspectorProxy,\n };\n }\n\n isTargetingNative(): boolean {\n // Temporary hack while we implement multi-bundler dev server proxy.\n return ['ios', 'android'].includes(process.env.EXPO_WEBPACK_PLATFORM || '');\n }\n\n isTargetingWeb(): boolean {\n return true;\n }\n\n private async createNativeDevServerMiddleware({\n port,\n compiler,\n options,\n }: {\n port: number;\n compiler: AnyCompiler;\n options: BundlerStartOptions;\n }) {\n if (!this.isTargetingNative()) {\n return null;\n }\n\n const { createDevServerMiddleware } = await import('../middleware/createDevServerMiddleware');\n\n const nativeMiddleware = createDevServerMiddleware(this.projectRoot, {\n port,\n watchFolders: [this.projectRoot],\n });\n // Add manifest middleware to the other middleware.\n // TODO: Move this in to expo/dev-server.\n\n const middleware = await this.getManifestMiddlewareAsync(options);\n\n nativeMiddleware.middleware.use(middleware).use(\n '/symbolicate',\n createSymbolicateMiddleware({\n projectRoot: this.projectRoot,\n compiler,\n logger: nativeMiddleware.logger,\n })\n );\n return nativeMiddleware;\n }\n\n private async getAvailablePortAsync(options: { defaultPort?: number }): Promise<number> {\n try {\n const defaultPort = options?.defaultPort ?? 19006;\n const port = await choosePortAsync(this.projectRoot, {\n defaultPort,\n host: env.WEB_HOST,\n });\n if (!port) {\n throw new CommandError('NO_PORT_FOUND', `Port ${defaultPort} not available.`);\n }\n return port;\n } catch (error: any) {\n throw new CommandError('NO_PORT_FOUND', error.message);\n }\n }\n\n protected async startImplementationAsync(\n options: BundlerStartOptions\n ): Promise<DevServerInstance> {\n // Do this first to fail faster.\n const webpack = importWebpackFromProject(this.projectRoot);\n const WebpackDevServer = importWebpackDevServerFromProject(this.projectRoot);\n\n await this.stopAsync();\n\n options.port = await this.getAvailablePortAsync({\n defaultPort: options.port,\n });\n const { resetDevServer, https, port, mode } = options;\n\n this.urlCreator = this.getUrlCreator({\n port,\n location: {\n scheme: https ? 'https' : 'http',\n },\n });\n\n Log.debug('Starting webpack on port: ' + port);\n\n if (resetDevServer) {\n await clearWebProjectCacheAsync(this.projectRoot, mode);\n }\n\n if (https) {\n Log.debug('Configuring TLS to enable HTTPS support');\n await ensureEnvironmentSupportsTLSAsync(this.projectRoot).catch((error) => {\n Log.error(`Error creating TLS certificates: ${error}`);\n });\n }\n\n const config = await this.loadConfigAsync(options);\n\n Log.log(chalk`Starting Webpack on port ${port} in {underline ${mode}} mode.`);\n\n // Create a webpack compiler that is configured with custom messages.\n const compiler = webpack(config);\n\n let nativeMiddleware: Awaited<ReturnType<typeof this.createNativeDevServerMiddleware>> | null =\n null;\n if (config.devServer?.before) {\n // Create the middleware required for interacting with a native runtime (Expo Go, or a development build).\n nativeMiddleware = await this.createNativeDevServerMiddleware({\n port,\n compiler,\n options,\n });\n // Inject the native manifest middleware.\n const originalBefore = config.devServer.before.bind(config.devServer.before);\n config.devServer.before = (\n app: Application,\n server: WebpackDevServer,\n compiler: webpack.Compiler\n ) => {\n originalBefore(app, server, compiler);\n\n if (nativeMiddleware?.middleware) {\n app.use(nativeMiddleware.middleware);\n }\n };\n }\n const { attachNativeDevServerMiddlewareToDevServer } = this;\n\n const server = new WebpackDevServer(\n // @ts-expect-error: type mismatch -- Webpack types aren't great.\n compiler,\n config.devServer\n );\n // Launch WebpackDevServer.\n server.listen(port, env.WEB_HOST, function (this: http.Server, error) {\n if (nativeMiddleware) {\n attachNativeDevServerMiddlewareToDevServer({\n server: this,\n ...nativeMiddleware,\n });\n }\n if (error) {\n Log.error(error.message);\n }\n });\n\n // Extend the close method to ensure that we clean up the local info.\n const originalClose = server.close.bind(server);\n\n server.close = (callback?: (err?: Error) => void) => {\n return originalClose((err?: Error) => {\n this.instance = null;\n callback?.(err);\n });\n };\n\n const _host = getIpAddress();\n const protocol = https ? 'https' : 'http';\n\n return {\n // Server instance\n server,\n // URL Info\n location: {\n url: `${protocol}://${_host}:${port}`,\n port,\n protocol,\n host: _host,\n },\n middleware: nativeMiddleware?.middleware,\n // Match the native protocol.\n messageSocket: {\n broadcast: this.broadcastMessage,\n },\n };\n }\n\n /** Load the Webpack config. Exposed for testing. */\n getProjectConfigFilePath(): string | null {\n // Check if the project has a webpack.config.js in the root.\n return (\n this.getConfigModuleIds().reduce<string | null | undefined>(\n (prev, moduleId) => prev || resolveFrom.silent(this.projectRoot, moduleId),\n null\n ) ?? null\n );\n }\n\n async loadConfigAsync(\n options: BundlerStartOptions,\n argv?: string[]\n ): Promise<WebpackConfiguration> {\n // let bar: ProgressBar | null = null;\n\n const env = {\n projectRoot: this.projectRoot,\n pwa: !!options.isImageEditingEnabled,\n // TODO: Use a new loader in Webpack config...\n logger: {\n info() {},\n },\n mode: options.mode,\n https: options.https,\n };\n setMode(env.mode ?? 'development');\n // Check if the project has a webpack.config.js in the root.\n const projectWebpackConfig = this.getProjectConfigFilePath();\n let config: WebpackConfiguration;\n if (projectWebpackConfig) {\n const webpackConfig = require(projectWebpackConfig);\n if (typeof webpackConfig === 'function') {\n config = await webpackConfig(env, argv);\n } else {\n config = webpackConfig;\n }\n } else {\n // Fallback to the default expo webpack config.\n const loadDefaultConfigAsync = importExpoWebpackConfigFromProject(this.projectRoot);\n // @ts-expect-error: types appear to be broken\n config = await loadDefaultConfigAsync(env, argv);\n }\n return config;\n }\n\n protected getConfigModuleIds(): string[] {\n return ['./webpack.config.js'];\n }\n}\n\nfunction setMode(mode: 'development' | 'production' | 'test' | 'none'): void {\n process.env.BABEL_ENV = mode;\n process.env.NODE_ENV = mode;\n}\n\nexport function getProjectWebpackConfigFilePath(projectRoot: string) {\n return resolveFrom.silent(projectRoot, './webpack.config.js');\n}\n\nasync function clearWebProjectCacheAsync(\n projectRoot: string,\n mode: string = 'development'\n): Promise<void> {\n Log.log(chalk.dim(`Clearing Webpack ${mode} cache directory...`));\n\n const dir = await ensureDotExpoProjectDirectoryInitialized(projectRoot);\n const cacheFolder = path.join(dir, 'web/cache', mode);\n try {\n await fs.promises.rm(cacheFolder, { recursive: true, force: true });\n } catch (error: any) {\n Log.error(`Could not clear ${mode} web cache directory: ${error.message}`);\n }\n}\n"],"names":["getProjectWebpackConfigFilePath","path","Log","assertIsWebpackDevServer","value","sockWrite","CommandError","constructor","name","WebpackBundlerDevServer","BundlerDevServer","broadcastMessage","method","params","instance","server","customMessageSocketBroadcaster","hackyConvertedMessage","sockets","attachNativeDevServerMiddlewareToDevServer","middleware","attachToServer","logger","attachInspectorProxy","LogReporter","messageSocket","debuggerProxy","eventsSocket","broadcast","logReporter","reportEvent","inspectorProxy","projectRoot","isTargetingNative","includes","process","env","EXPO_WEBPACK_PLATFORM","isTargetingWeb","createNativeDevServerMiddleware","port","compiler","options","createDevServerMiddleware","nativeMiddleware","watchFolders","getManifestMiddlewareAsync","use","createSymbolicateMiddleware","getAvailablePortAsync","defaultPort","choosePortAsync","host","WEB_HOST","error","message","startImplementationAsync","config","webpack","importWebpackFromProject","WebpackDevServer","importWebpackDevServerFromProject","stopAsync","resetDevServer","https","mode","urlCreator","getUrlCreator","location","scheme","debug","clearWebProjectCacheAsync","ensureEnvironmentSupportsTLSAsync","catch","loadConfigAsync","log","chalk","devServer","before","originalBefore","bind","app","listen","originalClose","close","callback","err","_host","getIpAddress","protocol","url","getProjectConfigFilePath","getConfigModuleIds","reduce","prev","moduleId","resolveFrom","silent","argv","pwa","isImageEditingEnabled","info","setMode","projectWebpackConfig","webpackConfig","require","loadDefaultConfigAsync","importExpoWebpackConfigFromProject","BABEL_ENV","NODE_ENV","dim","dir","ensureDotExpoProjectDirectoryInitialized","cacheFolder","join","fs","promises","rm","recursive","force"],"mappings":"AAAA;;;;QAmVgBA,+BAA+B,GAA/BA,+BAA+B;AAnVH,IAAA,sBAAsD,WAAtD,sDAAsD,CAAA;AAChF,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAEPC,IAAAA,IAAI,mCAAM,MAAM,EAAZ;AACQ,IAAA,YAAc,kCAAd,cAAc,EAAA;AAI1BC,IAAAA,GAAG,mCAA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AC,CAAC;IAElE,MAAM8C,GAAG,GAAG,MAAMC,CAAAA,GAAAA,QAAwC,AAAa,CAAA,yCAAb,CAAChF,WAAW,CAAC,AAAC;IACxE,MAAMiF,WAAW,GAAGhH,IAAI,CAACiH,IAAI,CAACH,GAAG,EAAE,WAAW,EAAE9C,IAAI,CAAC,AAAC;IACtD,IAAI;QACF,MAAMkD,GAAE,QAAA,CAACC,QAAQ,CAACC,EAAE,CAACJ,WAAW,EAAE;YAAEK,SAAS,EAAE,IAAI;YAAEC,KAAK,EAAE,IAAI;SAAE,CAAC,CAAC;KACrE,CAAC,OAAOjE,KAAK,EAAO;QACnBpD,GAAG,CAACoD,KAAK,CAAC,CAAC,gBAAgB,EAAEW,IAAI,CAAC,sBAAsB,EAAEX,KAAK,CAACC,OAAO,CAAC,CAAC,CAAC,CAAC;KAC5E;CACF"}
1
+ {"version":3,"sources":["../../../../../src/start/server/webpack/WebpackBundlerDevServer.ts"],"sourcesContent":["import { createSymbolicateMiddleware } from '@expo/dev-server/build/webpack/symbolicateMiddleware';\nimport chalk from 'chalk';\nimport type { Application } from 'express';\nimport fs from 'fs';\nimport http from 'http';\nimport * as path from 'path';\nimport resolveFrom from 'resolve-from';\nimport type webpack from 'webpack';\nimport type WebpackDevServer from 'webpack-dev-server';\n\nimport * as Log from '../../../log';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { getIpAddress } from '../../../utils/ip';\nimport { choosePortAsync } from '../../../utils/port';\nimport { createProgressBar } from '../../../utils/progress';\nimport { ensureDotExpoProjectDirectoryInitialized } from '../../project/dotExpo';\nimport { BundlerDevServer, BundlerStartOptions, DevServerInstance } from '../BundlerDevServer';\nimport { compileAsync } from './compile';\nimport {\n importExpoWebpackConfigFromProject,\n importWebpackDevServerFromProject,\n importWebpackFromProject,\n} from './resolveFromProject';\nimport { ensureEnvironmentSupportsTLSAsync } from './tls';\n\nconst debug = require('debug')('expo:start:server:webpack:devServer') as typeof console.log;\n\ntype AnyCompiler = webpack.Compiler | webpack.MultiCompiler;\n\nexport type WebpackConfiguration = webpack.Configuration & {\n devServer?: {\n before?: (app: Application, server: WebpackDevServer, compiler: webpack.Compiler) => void;\n };\n};\n\nfunction assertIsWebpackDevServer(value: any): asserts value is WebpackDevServer {\n if (!value?.sockWrite) {\n throw new CommandError(\n 'WEBPACK',\n value\n ? 'Expected Webpack dev server, found: ' + (value.constructor?.name ?? value)\n : 'Webpack dev server not started yet.'\n );\n }\n}\n\nexport class WebpackBundlerDevServer extends BundlerDevServer {\n get name(): string {\n return 'webpack';\n }\n\n // A custom message websocket broadcaster used to send messages to a React Native runtime.\n private customMessageSocketBroadcaster:\n | undefined\n | ((message: string, data?: Record<string, any>) => void);\n\n public broadcastMessage(\n method: string | 'reload' | 'devMenu' | 'sendDevCommand',\n params?: Record<string, any>\n ): void {\n if (!this.instance) {\n return;\n }\n\n assertIsWebpackDevServer(this.instance?.server);\n\n // Allow any message on native\n if (this.customMessageSocketBroadcaster) {\n this.customMessageSocketBroadcaster(method, params);\n return;\n }\n\n // TODO(EvanBacon): Custom Webpack overlay.\n // Default webpack-dev-server sockets use \"content-changed\" instead of \"reload\" (what we use on native).\n // For now, just manually convert the value so our CLI interface can be unified.\n const hackyConvertedMessage = method === 'reload' ? 'content-changed' : method;\n\n this.instance.server.sockWrite(this.instance.server.sockets, hackyConvertedMessage, params);\n }\n\n private async attachNativeDevServerMiddlewareToDevServer({\n server,\n middleware,\n attachToServer,\n logger,\n }: { server: http.Server } & Awaited<ReturnType<typeof this.createNativeDevServerMiddleware>>) {\n const { attachInspectorProxy, LogReporter } = await import('@expo/dev-server');\n\n // Hook up the React Native WebSockets to the Webpack dev server.\n const { messageSocket, debuggerProxy, eventsSocket } = attachToServer(server);\n\n this.customMessageSocketBroadcaster = messageSocket.broadcast;\n\n const logReporter = new LogReporter(logger);\n logReporter.reportEvent = eventsSocket.reportEvent;\n\n const { inspectorProxy } = attachInspectorProxy(this.projectRoot, {\n middleware,\n server,\n });\n\n return {\n messageSocket,\n eventsSocket,\n debuggerProxy,\n logReporter,\n inspectorProxy,\n };\n }\n\n isTargetingNative(): boolean {\n // Temporary hack while we implement multi-bundler dev server proxy.\n return ['ios', 'android'].includes(process.env.EXPO_WEBPACK_PLATFORM || '');\n }\n\n private async createNativeDevServerMiddleware({\n port,\n compiler,\n options,\n }: {\n port: number;\n compiler: AnyCompiler;\n options: BundlerStartOptions;\n }) {\n if (!this.isTargetingNative()) {\n return null;\n }\n\n const { createDevServerMiddleware } = await import('../middleware/createDevServerMiddleware');\n\n const nativeMiddleware = createDevServerMiddleware(this.projectRoot, {\n port,\n watchFolders: [this.projectRoot],\n });\n // Add manifest middleware to the other middleware.\n // TODO: Move this in to expo/dev-server.\n\n const middleware = await this.getManifestMiddlewareAsync(options);\n\n nativeMiddleware.middleware.use(middleware).use(\n '/symbolicate',\n createSymbolicateMiddleware({\n projectRoot: this.projectRoot,\n compiler,\n logger: nativeMiddleware.logger,\n })\n );\n return nativeMiddleware;\n }\n\n private async getAvailablePortAsync(options: { defaultPort?: number }): Promise<number> {\n try {\n const defaultPort = options?.defaultPort ?? 19006;\n const port = await choosePortAsync(this.projectRoot, {\n defaultPort,\n host: env.WEB_HOST,\n });\n if (!port) {\n throw new CommandError('NO_PORT_FOUND', `Port ${defaultPort} not available.`);\n }\n return port;\n } catch (error: any) {\n throw new CommandError('NO_PORT_FOUND', error.message);\n }\n }\n\n async bundleAsync({ mode, clear }: { mode: 'development' | 'production'; clear: boolean }) {\n // Do this first to fail faster.\n const webpack = importWebpackFromProject(this.projectRoot);\n\n if (clear) {\n await this.clearWebProjectCacheAsync(this.projectRoot, mode);\n }\n\n const config = await this.loadConfigAsync({\n isImageEditingEnabled: true,\n mode,\n });\n\n if (!config.plugins) {\n config.plugins = [];\n }\n\n const bar = createProgressBar(chalk`{bold Web} Bundling Javascript [:bar] :percent`, {\n width: 64,\n total: 100,\n clear: true,\n complete: '=',\n incomplete: ' ',\n });\n\n // NOTE(EvanBacon): Add a progress bar to the webpack logger if defined (e.g. not in CI).\n if (bar != null) {\n config.plugins.push(\n new webpack.ProgressPlugin((percent: number) => {\n bar?.update(percent);\n if (percent === 1) {\n bar?.terminate();\n }\n })\n );\n }\n\n // Create a webpack compiler that is configured with custom messages.\n const compiler = webpack(config);\n\n try {\n await compileAsync(compiler);\n } catch (error: any) {\n Log.error(chalk.red('Failed to compile'));\n throw error;\n } finally {\n bar?.terminate();\n }\n }\n\n protected async startImplementationAsync(\n options: BundlerStartOptions\n ): Promise<DevServerInstance> {\n // Do this first to fail faster.\n const webpack = importWebpackFromProject(this.projectRoot);\n const WebpackDevServer = importWebpackDevServerFromProject(this.projectRoot);\n\n await this.stopAsync();\n\n options.port = await this.getAvailablePortAsync({\n defaultPort: options.port,\n });\n const { resetDevServer, https, port, mode } = options;\n\n this.urlCreator = this.getUrlCreator({\n port,\n location: {\n scheme: https ? 'https' : 'http',\n },\n });\n\n debug('Starting webpack on port: ' + port);\n\n if (resetDevServer) {\n await this.clearWebProjectCacheAsync(this.projectRoot, mode);\n }\n\n if (https) {\n debug('Configuring TLS to enable HTTPS support');\n await ensureEnvironmentSupportsTLSAsync(this.projectRoot).catch((error) => {\n Log.error(`Error creating TLS certificates: ${error}`);\n });\n }\n\n const config = await this.loadConfigAsync(options);\n\n Log.log(chalk`Starting Webpack on port ${port} in {underline ${mode}} mode.`);\n\n // Create a webpack compiler that is configured with custom messages.\n const compiler = webpack(config);\n\n let nativeMiddleware: Awaited<ReturnType<typeof this.createNativeDevServerMiddleware>> | null =\n null;\n if (config.devServer?.before) {\n // Create the middleware required for interacting with a native runtime (Expo Go, or a development build).\n nativeMiddleware = await this.createNativeDevServerMiddleware({\n port,\n compiler,\n options,\n });\n // Inject the native manifest middleware.\n const originalBefore = config.devServer.before.bind(config.devServer.before);\n config.devServer.before = (\n app: Application,\n server: WebpackDevServer,\n compiler: webpack.Compiler\n ) => {\n originalBefore(app, server, compiler);\n\n if (nativeMiddleware?.middleware) {\n app.use(nativeMiddleware.middleware);\n }\n };\n }\n const { attachNativeDevServerMiddlewareToDevServer } = this;\n\n const server = new WebpackDevServer(\n // @ts-expect-error: type mismatch -- Webpack types aren't great.\n compiler,\n config.devServer\n );\n // Launch WebpackDevServer.\n server.listen(port, env.WEB_HOST, function (this: http.Server, error) {\n if (nativeMiddleware) {\n attachNativeDevServerMiddlewareToDevServer({\n server: this,\n ...nativeMiddleware,\n });\n }\n if (error) {\n Log.error(error.message);\n }\n });\n\n // Extend the close method to ensure that we clean up the local info.\n const originalClose = server.close.bind(server);\n\n server.close = (callback?: (err?: Error) => void) => {\n return originalClose((err?: Error) => {\n this.instance = null;\n callback?.(err);\n });\n };\n\n const _host = getIpAddress();\n const protocol = https ? 'https' : 'http';\n\n return {\n // Server instance\n server,\n // URL Info\n location: {\n url: `${protocol}://${_host}:${port}`,\n port,\n protocol,\n host: _host,\n },\n middleware: nativeMiddleware?.middleware,\n // Match the native protocol.\n messageSocket: {\n broadcast: this.broadcastMessage,\n },\n };\n }\n\n /** Load the Webpack config. Exposed for testing. */\n getProjectConfigFilePath(): string | null {\n // Check if the project has a webpack.config.js in the root.\n return (\n this.getConfigModuleIds().reduce<string | null | undefined>(\n (prev, moduleId) => prev || resolveFrom.silent(this.projectRoot, moduleId),\n null\n ) ?? null\n );\n }\n\n async loadConfigAsync(\n options: Pick<BundlerStartOptions, 'mode' | 'isImageEditingEnabled' | 'https'>,\n argv?: string[]\n ): Promise<WebpackConfiguration> {\n // let bar: ProgressBar | null = null;\n\n const env = {\n projectRoot: this.projectRoot,\n pwa: !!options.isImageEditingEnabled,\n // TODO: Use a new loader in Webpack config...\n logger: {\n info() {},\n },\n mode: options.mode,\n https: options.https,\n };\n setMode(env.mode ?? 'development');\n // Check if the project has a webpack.config.js in the root.\n const projectWebpackConfig = this.getProjectConfigFilePath();\n let config: WebpackConfiguration;\n if (projectWebpackConfig) {\n const webpackConfig = require(projectWebpackConfig);\n if (typeof webpackConfig === 'function') {\n config = await webpackConfig(env, argv);\n } else {\n config = webpackConfig;\n }\n } else {\n // Fallback to the default expo webpack config.\n const loadDefaultConfigAsync = importExpoWebpackConfigFromProject(this.projectRoot);\n // @ts-expect-error: types appear to be broken\n config = await loadDefaultConfigAsync(env, argv);\n }\n return config;\n }\n\n protected getConfigModuleIds(): string[] {\n return ['./webpack.config.js'];\n }\n\n protected async clearWebProjectCacheAsync(\n projectRoot: string,\n mode: string = 'development'\n ): Promise<void> {\n Log.log(chalk.dim(`Clearing Webpack ${mode} cache directory...`));\n\n const dir = await ensureDotExpoProjectDirectoryInitialized(projectRoot);\n const cacheFolder = path.join(dir, 'web/cache', mode);\n try {\n await fs.promises.rm(cacheFolder, { recursive: true, force: true });\n } catch (error: any) {\n Log.error(`Could not clear ${mode} web cache directory: ${error.message}`);\n }\n }\n}\n\nfunction setMode(mode: 'development' | 'production' | 'test' | 'none'): void {\n process.env.BABEL_ENV = mode;\n process.env.NODE_ENV = mode;\n}\n\nexport function getProjectWebpackConfigFilePath(projectRoot: string) {\n return resolveFrom.silent(projectRoot, './webpack.config.js');\n}\n"],"names":["getProjectWebpackConfigFilePath","path","Log","debug","require","assertIsWebpackDevServer","value","sockWrite","CommandError","constructor","name","WebpackBundlerDevServer","BundlerDevServer","broadcastMessage","method","params","instance","server","customMessageSocketBroadcaster","hackyConvertedMessage","sockets","attachNativeDevServerMiddlewareToDevServer","middleware","attachToServer","logger","attachInspectorProxy","LogReporter","messageSocket","debuggerProxy","eventsSocket","broadcast","logReporter","reportEvent","inspectorProxy","projectRoot","isTargetingNative","includes","process","env","EXPO_WEBPACK_PLATFORM","createNativeDevServerMiddleware","port","compiler","options","createDevServerMiddleware","nativeMiddleware","watchFolders","getManifestMiddlewareAsync","use","createSymbolicateMiddleware","getAvailablePortAsync","defaultPort","choosePortAsync","host","WEB_HOST","error","message","bundleAsync","mode","clear","webpack","importWebpackFromProject","clearWebProjectCacheAsync","config","loadConfigAsync","isImageEditingEnabled","plugins","bar","createProgressBar","chalk","width","total","complete","incomplete","push","ProgressPlugin","percent","update","terminate","compileAsync","red","startImplementationAsync","WebpackDevServer","importWebpackDevServerFromProject","stopAsync","resetDevServer","https","urlCreator","getUrlCreator","location","scheme","ensureEnvironmentSupportsTLSAsync","catch","log","devServer","before","originalBefore","bind","app","listen","originalClose","close","callback","err","_host","getIpAddress","protocol","url","getProjectConfigFilePath","getConfigModuleIds","reduce","prev","moduleId","resolveFrom","silent","argv","pwa","info","setMode","projectWebpackConfig","webpackConfig","loadDefaultConfigAsync","importExpoWebpackConfigFromProject","dim","dir","ensureDotExpoProjectDirectoryInitialized","cacheFolder","join","fs","promises","rm","recursive","force","BABEL_ENV","NODE_ENV"],"mappings":"AAAA;;;;QAoZgBA,+BAA+B,GAA/BA,+BAA+B;AApZH,IAAA,sBAAsD,WAAtD,sDAAsD,CAAA;AAChF,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAEPC,IAAAA,IAAI,mCAAM,MAAM,EAAZ;AACQ,IAAA,YAAc,kCAAd,cAAc,EAAA;AAI1BC,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACK,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACX,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACvB,IAAA,GAAmB,WAAnB,mBAAmB,CAAA;AAChB,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AACnB,IAAA,SAAyB,WAAzB,yBAAyB,CAAA;AACF,IAAA,QAAuB,WAAvB,uBAAuB,CAAA;AACP,IAAA,iBAAqB,WAArB,qBAAqB,CAAA;AACjE,IAAA,QAAW,WAAX,WAAW,CAAA;AAKjC,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AACqB,IAAA,IAAO,WAAP,OAAO,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,qCAAqC,CAAC,AAAsB,AAAC;AAU5F,SAASC,wBAAwB,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