@expo/cli 55.0.7 → 55.0.9
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.
- package/build/bin/cli +13 -1
- package/build/bin/cli.map +1 -1
- package/build/src/config/configAsync.js +1 -1
- package/build/src/config/configAsync.js.map +1 -1
- package/build/src/customize/customizeAsync.js +1 -1
- package/build/src/customize/customizeAsync.js.map +1 -1
- package/build/src/export/embed/exportEmbedAsync.js +1 -1
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/export/exportApp.js +1 -1
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportStaticAsync.js +7 -11
- package/build/src/export/exportStaticAsync.js.map +1 -1
- package/build/src/export/web/exportWebAsync.js +1 -1
- package/build/src/export/web/exportWebAsync.js.map +1 -1
- package/build/src/install/installAsync.js +1 -1
- package/build/src/install/installAsync.js.map +1 -1
- package/build/src/lint/lintAsync.js +1 -1
- package/build/src/lint/lintAsync.js.map +1 -1
- package/build/src/prebuild/prebuildAsync.js +1 -1
- package/build/src/prebuild/prebuildAsync.js.map +1 -1
- package/build/src/run/android/runAndroidAsync.js +1 -1
- package/build/src/run/android/runAndroidAsync.js.map +1 -1
- package/build/src/run/ios/runIosAsync.js +1 -1
- package/build/src/run/ios/runIosAsync.js.map +1 -1
- package/build/src/serve/serveAsync.js +1 -1
- package/build/src/serve/serveAsync.js.map +1 -1
- package/build/src/start/interface/commandsTable.js +89 -69
- package/build/src/start/interface/commandsTable.js.map +1 -1
- package/build/src/start/interface/interactiveActions.js +29 -14
- package/build/src/start/interface/interactiveActions.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +16 -9
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +5 -1
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/UrlCreator.js +17 -7
- package/build/src/start/server/UrlCreator.js.map +1 -1
- package/build/src/start/server/getStaticRenderFunctions.js +8 -8
- package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +20 -20
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/MetroTerminalReporter.js +1 -1
- package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
- package/build/src/start/server/metro/createServerComponentsMiddleware.js +1 -1
- package/build/src/start/server/metro/createServerComponentsMiddleware.js.map +1 -1
- package/build/src/start/server/metro/dev-server/createMetroMiddleware.js +18 -18
- package/build/src/start/server/metro/dev-server/createMetroMiddleware.js.map +1 -1
- package/build/src/start/server/metro/log-box/LogBoxSymbolication.js +5 -1
- package/build/src/start/server/metro/log-box/LogBoxSymbolication.js.map +1 -1
- package/build/src/start/server/metro/resolveLoader.js +2 -0
- package/build/src/start/server/metro/resolveLoader.js.map +1 -1
- package/build/src/start/server/metro/runServer-fork.js +6 -5
- package/build/src/start/server/metro/runServer-fork.js.map +1 -1
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js +4 -4
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
- package/build/src/utils/editor.js +404 -31
- package/build/src/utils/editor.js.map +1 -1
- package/build/src/utils/getRunningProcess.js +80 -41
- package/build/src/utils/getRunningProcess.js.map +1 -1
- package/build/src/utils/ip.js +44 -8
- package/build/src/utils/ip.js.map +1 -1
- package/build/src/utils/nodeEnv.js +66 -1
- package/build/src/utils/nodeEnv.js.map +1 -1
- package/build/src/utils/port.js +2 -2
- package/build/src/utils/port.js.map +1 -1
- package/build/src/utils/qr.js +186 -0
- package/build/src/utils/qr.js.map +1 -0
- package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
- package/build/src/utils/telemetry/utils/context.js +1 -1
- package/package.json +16 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/runServer-fork.ts"],"sourcesContent":["// Copyright © 2023 650 Industries.\n// Copyright (c) Meta Platforms, Inc. and affiliates.\n//\n// Forks https://github.com/facebook/metro/blob/b80d9a0f638ee9fb82ff69cd3c8d9f4309ca1da2/packages/metro/src/index.flow.js#L57\n// and adds the ability to access the bundler instance.\nimport { createConnectMiddleware } from '@expo/metro/metro';\nimport type { RunServerOptions } from '@expo/metro/metro';\nimport MetroHmrServer, { type Client as MetroHmrClient } from '@expo/metro/metro/HmrServer';\nimport Server from '@expo/metro/metro/Server';\nimport createWebsocketServer from '@expo/metro/metro/lib/createWebsocketServer';\nimport type { ConfigT } from '@expo/metro/metro-config';\nimport assert from 'assert';\nimport http from 'http';\nimport https from 'https';\nimport { parse } from 'url';\nimport type { WebSocketServer } from 'ws';\n\nimport { MetroBundlerDevServer } from './MetroBundlerDevServer';\nimport { Log } from '../../../log';\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/runServer-fork.ts"],"sourcesContent":["// Copyright © 2023 650 Industries.\n// Copyright (c) Meta Platforms, Inc. and affiliates.\n//\n// Forks https://github.com/facebook/metro/blob/b80d9a0f638ee9fb82ff69cd3c8d9f4309ca1da2/packages/metro/src/index.flow.js#L57\n// and adds the ability to access the bundler instance.\nimport { createConnectMiddleware } from '@expo/metro/metro';\nimport type { RunServerOptions } from '@expo/metro/metro';\nimport MetroHmrServer, { type Client as MetroHmrClient } from '@expo/metro/metro/HmrServer';\nimport Server from '@expo/metro/metro/Server';\nimport createWebsocketServer from '@expo/metro/metro/lib/createWebsocketServer';\nimport type { ConfigT } from '@expo/metro/metro-config';\nimport assert from 'assert';\nimport http from 'http';\nimport https from 'https';\nimport { parse } from 'url';\nimport type { WebSocketServer } from 'ws';\n\nimport { MetroBundlerDevServer } from './MetroBundlerDevServer';\nimport { Log } from '../../../log';\nimport type { ConnectAppType } from '../middleware/server.types';\n\nexport const runServer = async (\n metroBundler: MetroBundlerDevServer,\n config: ConfigT,\n {\n hasReducedPerformance = false,\n host,\n onError,\n onReady,\n secureServerOptions,\n waitForBundler = false,\n websocketEndpoints = {},\n watch,\n }: RunServerOptions,\n {\n mockServer,\n }: {\n // Use a mock server object instead of creating a real server, this is used in export cases where we want to reuse codepaths but not actually start a server.\n mockServer: boolean;\n }\n): Promise<{\n server: http.Server | https.Server;\n hmrServer: MetroHmrServer<MetroHmrClient> | null;\n metro: Server;\n}> => {\n // await earlyPortCheck(host, config.server.port);\n\n // if (secure != null || secureCert != null || secureKey != null) {\n // // eslint-disable-next-line no-console\n // console.warn(\n // chalk.inverse.yellow.bold(' DEPRECATED '),\n // 'The `secure`, `secureCert`, and `secureKey` options are now deprecated. ' +\n // 'Use the `secureServerOptions` object instead to pass options to ' +\n // \"Metro's https development server.\",\n // );\n // }\n\n const { middleware, end, metroServer } = await createConnectMiddleware(config, {\n hasReducedPerformance,\n waitForBundler,\n watch,\n });\n\n if (!mockServer) {\n assert(typeof (middleware as any).use === 'function');\n }\n const serverApp = middleware as ConnectAppType;\n\n let httpServer: http.Server | https.Server;\n\n if (secureServerOptions != null) {\n httpServer = https.createServer(secureServerOptions, serverApp);\n } else {\n httpServer = http.createServer(serverApp);\n }\n\n httpServer.on('error', (error) => {\n if ('code' in error && error.code === 'EADDRINUSE') {\n // If `Error: listen EADDRINUSE: address already in use :::8081` then print additional info\n // about the process before throwing.\n const { getRunningProcess } =\n require('../../../utils/getRunningProcess') as typeof import('../../../utils/getRunningProcess');\n getRunningProcess(config.server.port).then((info) => {\n if (info) {\n Log.error(\n `Port ${config.server.port} is busy running ${info.command} in: ${info.directory}`\n );\n }\n });\n }\n\n if (onError) {\n onError(error);\n }\n end();\n });\n\n // Disable any kind of automatic timeout behavior for incoming\n // requests in case it takes the packager more than the default\n // timeout of 120 seconds to respond to a request.\n httpServer.timeout = 0;\n\n // Extend the close method to ensure all websocket servers are closed, and connections are terminated\n const originalClose = httpServer.close.bind(httpServer);\n\n httpServer.close = function closeHttpServer(callback) {\n originalClose((err?: Error) => {\n // Always call end() to clean up Metro workers, even if the server wasn't started.\n // The 'close' event doesn't fire for servers that were never started (mockServer case),\n // so we need to call end() explicitly here.\n end();\n callback?.(err);\n });\n\n // Close all websocket servers, including possible client connections (see: https://github.com/websockets/ws/issues/2137#issuecomment-1507469375)\n for (const endpoint of Object.values(websocketEndpoints) as WebSocketServer[]) {\n endpoint.close();\n endpoint.clients.forEach((client) => client.terminate());\n }\n\n // Forcibly close active connections\n this.closeAllConnections();\n return this;\n };\n\n if (mockServer) {\n return { server: httpServer, hmrServer: null, metro: metroServer };\n }\n\n return new Promise<{\n server: http.Server | https.Server;\n hmrServer: MetroHmrServer<MetroHmrClient>;\n metro: Server;\n }>((resolve, reject) => {\n httpServer.on('error', (error) => {\n reject(error);\n });\n\n httpServer.listen(config.server.port, host, () => {\n if (onReady) {\n onReady(httpServer);\n }\n\n const hmrServer = new MetroHmrServer(\n metroServer.getBundler(),\n metroServer.getCreateModuleId(),\n config\n );\n\n Object.assign(websocketEndpoints, {\n '/hot': createWebsocketServer({\n websocketServer: hmrServer,\n }),\n });\n\n httpServer.on('upgrade', (request, socket, head) => {\n const { pathname } = parse(request.url!);\n if (pathname != null && websocketEndpoints[pathname]) {\n websocketEndpoints[pathname].handleUpgrade(request, socket, head, (ws) => {\n websocketEndpoints[pathname].emit('connection', ws, request);\n });\n } else {\n socket.destroy();\n }\n });\n\n resolve({ server: httpServer, hmrServer, metro: metroServer });\n });\n });\n};\n"],"names":["runServer","metroBundler","config","hasReducedPerformance","host","onError","onReady","secureServerOptions","waitForBundler","websocketEndpoints","watch","mockServer","middleware","end","metroServer","createConnectMiddleware","assert","use","serverApp","httpServer","https","createServer","http","on","error","code","getRunningProcess","require","server","port","then","info","Log","command","directory","timeout","originalClose","close","bind","closeHttpServer","callback","err","endpoint","Object","values","clients","forEach","client","terminate","closeAllConnections","hmrServer","metro","Promise","resolve","reject","listen","MetroHmrServer","getBundler","getCreateModuleId","assign","createWebsocketServer","websocketServer","request","socket","head","pathname","parse","url","handleUpgrade","ws","emit","destroy"],"mappings":"AAAA,mCAAmC;AACnC,qDAAqD;AACrD,EAAE;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gBACzC,MAAM,EAAEC,QAAQ,EAAE,GAAGC,IAAAA,YAAK,EAACJ,QAAQK,GAAG;gBACtC,IAAIF,YAAY,QAAQxD,kBAAkB,CAACwD,SAAS,EAAE;oBACpDxD,kBAAkB,CAACwD,SAAS,CAACG,aAAa,CAACN,SAASC,QAAQC,MAAM,CAACK;wBACjE5D,kBAAkB,CAACwD,SAAS,CAACK,IAAI,CAAC,cAAcD,IAAIP;oBACtD;gBACF,OAAO;oBACLC,OAAOQ,OAAO;gBAChB;YACF;YAEAlB,QAAQ;gBAAEzB,QAAQT;gBAAY+B;gBAAWC,OAAOrC;YAAY;QAC9D;IACF;AACF"}
|
|
@@ -50,7 +50,6 @@ const _tls = require("./tls");
|
|
|
50
50
|
const _log = /*#__PURE__*/ _interop_require_wildcard(require("../../../log"));
|
|
51
51
|
const _env = require("../../../utils/env");
|
|
52
52
|
const _errors = require("../../../utils/errors");
|
|
53
|
-
const _ip = require("../../../utils/ip");
|
|
54
53
|
const _nodeEnv = require("../../../utils/nodeEnv");
|
|
55
54
|
const _port = require("../../../utils/port");
|
|
56
55
|
const _progress = require("../../../utils/progress");
|
|
@@ -200,7 +199,7 @@ class WebpackBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
|
|
|
200
199
|
defaultPort: options.port
|
|
201
200
|
});
|
|
202
201
|
const { resetDevServer, https, port, mode } = options;
|
|
203
|
-
|
|
202
|
+
const urlCreator = await this.initUrlCreator({
|
|
204
203
|
port,
|
|
205
204
|
location: {
|
|
206
205
|
scheme: https ? 'https' : 'http'
|
|
@@ -236,12 +235,13 @@ class WebpackBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
|
|
|
236
235
|
callback == null ? void 0 : callback(err);
|
|
237
236
|
});
|
|
238
237
|
};
|
|
239
|
-
const _host =
|
|
238
|
+
const _host = urlCreator.getDefaultRouteAddress();
|
|
240
239
|
const protocol = https ? 'https' : 'http';
|
|
241
240
|
return {
|
|
242
241
|
// Server instance
|
|
243
242
|
server,
|
|
244
243
|
// URL Info
|
|
244
|
+
// TODO(@kitten): Why is this not using the URL creator?
|
|
245
245
|
location: {
|
|
246
246
|
url: `${protocol}://${_host}:${port}`,
|
|
247
247
|
port,
|
|
@@ -272,7 +272,7 @@ class WebpackBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
|
|
|
272
272
|
https: options.https
|
|
273
273
|
};
|
|
274
274
|
(0, _nodeEnv.setNodeEnv)(env.mode ?? 'development');
|
|
275
|
-
|
|
275
|
+
(0, _nodeEnv.loadEnvFiles)(env.projectRoot);
|
|
276
276
|
// Check if the project has a webpack.config.js in the root.
|
|
277
277
|
const projectWebpackConfig = this.getProjectConfigFilePath();
|
|
278
278
|
let config;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/webpack/WebpackBundlerDevServer.ts"],"sourcesContent":["import chalk from 'chalk';\nimport type { Application } from 'express';\nimport fs from 'node:fs';\nimport http from 'node:http';\nimport path from 'node:path';\nimport resolveFrom from 'resolve-from';\nimport type webpack from 'webpack';\nimport type WebpackDevServer from 'webpack-dev-server';\n\nimport { compileAsync } from './compile';\nimport {\n importExpoWebpackConfigFromProject,\n importWebpackDevServerFromProject,\n importWebpackFromProject,\n} from './resolveFromProject';\nimport { ensureEnvironmentSupportsTLSAsync } from './tls';\nimport * as Log from '../../../log';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { getIpAddress } from '../../../utils/ip';\nimport { setNodeEnv } from '../../../utils/nodeEnv';\nimport { choosePortAsync } from '../../../utils/port';\nimport { createProgressBar } from '../../../utils/progress';\nimport { ensureDotExpoProjectDirectoryInitialized } from '../../project/dotExpo';\nimport { BundlerDevServer, BundlerStartOptions, DevServerInstance } from '../BundlerDevServer';\n\nconst debug = require('debug')('expo:start:server:webpack:devServer') as typeof console.log;\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 && !value?.sendMessage) {\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 public async startTypeScriptServices(): Promise<void> {\n // noop -- this feature is Metro-only.\n }\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 // 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 if (\n 'sendMessage' in this.instance.server &&\n typeof this.instance.server.sendMessage === 'function'\n ) {\n // NOTE: https://github.com/expo/expo/issues/21994#issuecomment-1517122501\n this.instance.server.sendMessage(this.instance.server.sockets, hackyConvertedMessage, params);\n } else {\n this.instance.server.sockWrite(this.instance.server.sockets, hackyConvertedMessage, params);\n }\n }\n\n isTargetingNative(): boolean {\n return false;\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 const server = new WebpackDevServer(compiler, config.devServer);\n const host =\n env.WEB_HOST ?? (options.location.hostType === 'localhost' ? 'localhost' : undefined);\n\n // Launch WebpackDevServer.\n server.listen(port, host, function (this: http.Server, error) {\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: null,\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 setNodeEnv(env.mode ?? 'development');\n require('@expo/env').load(env.projectRoot);\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 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\nexport function getProjectWebpackConfigFilePath(projectRoot: string) {\n return resolveFrom.silent(projectRoot, './webpack.config.js');\n}\n"],"names":["WebpackBundlerDevServer","getProjectWebpackConfigFilePath","debug","require","assertIsWebpackDevServer","value","sockWrite","sendMessage","CommandError","constructor","name","BundlerDevServer","startTypeScriptServices","broadcastMessage","method","params","instance","server","hackyConvertedMessage","sockets","isTargetingNative","getAvailablePortAsync","options","defaultPort","port","choosePortAsync","projectRoot","host","env","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","compiler","compileAsync","Log","red","startImplementationAsync","WebpackDevServer","importWebpackDevServerFromProject","stopAsync","resetDevServer","https","urlCreator","getUrlCreator","location","scheme","ensureEnvironmentSupportsTLSAsync","catch","log","devServer","hostType","undefined","listen","originalClose","close","bind","callback","err","_host","getIpAddress","protocol","url","middleware","messageSocket","broadcast","getProjectConfigFilePath","getConfigModuleIds","reduce","prev","moduleId","resolveFrom","silent","argv","pwa","logger","info","setNodeEnv","load","projectWebpackConfig","webpackConfig","loadDefaultConfigAsync","importExpoWebpackConfigFromProject","dim","dir","ensureDotExpoProjectDirectoryInitialized","cacheFolder","path","join","fs","promises","rm","recursive","force"],"mappings":";;;;;;;;;;;IA6CaA,uBAAuB;eAAvBA;;IA+PGC,+BAA+B;eAA/BA;;;;gEA5SE;;;;;;;gEAEH;;;;;;;gEAEE;;;;;;;gEACO;;;;;;yBAIK;oCAKtB;qBAC2C;6DAC7B;qBACD;wBACS;oB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QyC,KAAK;QACtB;QACAmC,IAAAA,mBAAU,EAACtE,IAAIK,IAAI,IAAI;QACvB9B,QAAQ,aAAagG,IAAI,CAACvE,IAAIF,WAAW;QACzC,4DAA4D;QAC5D,MAAM0E,uBAAuB,IAAI,CAACb,wBAAwB;QAC1D,IAAIjD;QACJ,IAAI8D,sBAAsB;YACxB,MAAMC,gBAAgBlG,QAAQiG;YAC9B,IAAI,OAAOC,kBAAkB,YAAY;gBACvC/D,SAAS,MAAM+D,cAAczE,KAAKkE;YACpC,OAAO;gBACLxD,SAAS+D;YACX;QACF,OAAO;YACL,+CAA+C;YAC/C,MAAMC,yBAAyBC,IAAAA,sDAAkC,EAAC,IAAI,CAAC7E,WAAW;YAClFY,SAAS,MAAMgE,uBAAuB1E,KAAKkE;QAC7C;QACA,OAAOxD;IACT;IAEUkD,qBAA+B;QACvC,OAAO;YAAC;SAAsB;IAChC;IAEA,MAAgBnD,0BACdX,WAAmB,EACnBO,OAAe,aAAa,EACb;QACfuB,KAAIc,GAAG,CAAC1B,gBAAK,CAAC4D,GAAG,CAAC,CAAC,iBAAiB,EAAEvE,KAAK,mBAAmB,CAAC;QAE/D,MAAMwE,MAAM,MAAMC,IAAAA,iDAAwC,EAAChF;QAC3D,MAAMiF,cAAcC,mBAAI,CAACC,IAAI,CAACJ,KAAK,aAAaxE;QAChD,IAAI;YACF,MAAM6E,iBAAE,CAACC,QAAQ,CAACC,EAAE,CAACL,aAAa;gBAAEM,WAAW;gBAAMC,OAAO;YAAK;QACnE,EAAE,OAAOpF,OAAY;YACnB0B,KAAI1B,KAAK,CAAC,CAAC,gBAAgB,EAAEG,KAAK,sBAAsB,EAAEH,MAAMC,OAAO,EAAE;QAC3E;IACF;AACF;AAEO,SAAS9B,gCAAgCyB,WAAmB;IACjE,OAAOkE,sBAAW,CAACC,MAAM,CAACnE,aAAa;AACzC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/webpack/WebpackBundlerDevServer.ts"],"sourcesContent":["import chalk from 'chalk';\nimport type { Application } from 'express';\nimport fs from 'node:fs';\nimport http from 'node:http';\nimport path from 'node:path';\nimport resolveFrom from 'resolve-from';\nimport type webpack from 'webpack';\nimport type WebpackDevServer from 'webpack-dev-server';\n\nimport { compileAsync } from './compile';\nimport {\n importExpoWebpackConfigFromProject,\n importWebpackDevServerFromProject,\n importWebpackFromProject,\n} from './resolveFromProject';\nimport { ensureEnvironmentSupportsTLSAsync } from './tls';\nimport * as Log from '../../../log';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { setNodeEnv, loadEnvFiles } from '../../../utils/nodeEnv';\nimport { choosePortAsync } from '../../../utils/port';\nimport { createProgressBar } from '../../../utils/progress';\nimport { ensureDotExpoProjectDirectoryInitialized } from '../../project/dotExpo';\nimport { BundlerDevServer, BundlerStartOptions, DevServerInstance } from '../BundlerDevServer';\n\nconst debug = require('debug')('expo:start:server:webpack:devServer') as typeof console.log;\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 && !value?.sendMessage) {\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 public async startTypeScriptServices(): Promise<void> {\n // noop -- this feature is Metro-only.\n }\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 // 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 if (\n 'sendMessage' in this.instance.server &&\n typeof this.instance.server.sendMessage === 'function'\n ) {\n // NOTE: https://github.com/expo/expo/issues/21994#issuecomment-1517122501\n this.instance.server.sendMessage(this.instance.server.sockets, hackyConvertedMessage, params);\n } else {\n this.instance.server.sockWrite(this.instance.server.sockets, hackyConvertedMessage, params);\n }\n }\n\n isTargetingNative(): boolean {\n return false;\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\n const { resetDevServer, https, port, mode } = options;\n\n const urlCreator = await this.initUrlCreator({\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 const server = new WebpackDevServer(compiler, config.devServer);\n const host =\n env.WEB_HOST ?? (options.location.hostType === 'localhost' ? 'localhost' : undefined);\n\n // Launch WebpackDevServer.\n server.listen(port, host, function (this: http.Server, error) {\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 = urlCreator.getDefaultRouteAddress();\n const protocol = https ? 'https' : 'http';\n\n return {\n // Server instance\n server,\n // URL Info\n // TODO(@kitten): Why is this not using the URL creator?\n location: {\n url: `${protocol}://${_host}:${port}`,\n port,\n protocol,\n host: _host,\n },\n middleware: null,\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\n setNodeEnv(env.mode ?? 'development');\n loadEnvFiles(env.projectRoot);\n\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 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\nexport function getProjectWebpackConfigFilePath(projectRoot: string) {\n return resolveFrom.silent(projectRoot, './webpack.config.js');\n}\n"],"names":["WebpackBundlerDevServer","getProjectWebpackConfigFilePath","debug","require","assertIsWebpackDevServer","value","sockWrite","sendMessage","CommandError","constructor","name","BundlerDevServer","startTypeScriptServices","broadcastMessage","method","params","instance","server","hackyConvertedMessage","sockets","isTargetingNative","getAvailablePortAsync","options","defaultPort","port","choosePortAsync","projectRoot","host","env","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","compiler","compileAsync","Log","red","startImplementationAsync","WebpackDevServer","importWebpackDevServerFromProject","stopAsync","resetDevServer","https","urlCreator","initUrlCreator","location","scheme","ensureEnvironmentSupportsTLSAsync","catch","log","devServer","hostType","undefined","listen","originalClose","close","bind","callback","err","_host","getDefaultRouteAddress","protocol","url","middleware","messageSocket","broadcast","getProjectConfigFilePath","getConfigModuleIds","reduce","prev","moduleId","resolveFrom","silent","argv","pwa","logger","info","setNodeEnv","loadEnvFiles","projectWebpackConfig","webpackConfig","loadDefaultConfigAsync","importExpoWebpackConfigFromProject","dim","dir","ensureDotExpoProjectDirectoryInitialized","cacheFolder","path","join","fs","promises","rm","recursive","force"],"mappings":";;;;;;;;;;;IA4CaA,uBAAuB;eAAvBA;;IAmQGC,+BAA+B;eAA/BA;;;;gEA/SE;;;;;;;gEAEH;;;;;;;gEAEE;;;;;;;gEACO;;;;;;yBAIK;oCAKtB;qBAC2C;6DAC7B;qBACD;wBACS;yBACY;sBACT;0BACE;yBACuB;kCACgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzE,MAAMC,QAAQC,QAAQ,SAAS;AAQ/B,SAASC,yBAAyBC,KAAU;IAC1C,IAAI,EAACA,yBAAAA,MAAOC,SAAS,KAAI,EAACD,yBAAAA,MAAOE,WAAW,GAAE;YAIIF;QAHhD,MAAM,IAAIG,oBAAY,CACpB,WACAH,QACI,yCAA0CA,CAAAA,EAAAA,qBAAAA,MAAMI,WAAW,qBAAjBJ,mBAAmBK,IAAI,KAAIL,KAAI,IACzE;IAER;AACF;AAEO,MAAML,gCAAgCW,kCAAgB;IAC3D,IAAID,OAAe;QACjB,OAAO;IACT;IAEA,MAAaE,0BAAyC;IACpD,uCAAuC;I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