@expo/cli 0.18.5 → 0.18.6
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 +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +9 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/TerminalReporter.js +7 -0
- package/build/src/start/server/metro/TerminalReporter.js.map +1 -1
- package/build/src/start/server/metro/TerminalReporter.types.js.map +1 -1
- package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
- package/build/src/start/server/metro/fetchRouterManifest.js +1 -1
- package/build/src/start/server/metro/fetchRouterManifest.js.map +1 -1
- package/build/src/utils/fn.js +4 -4
- package/build/src/utils/fn.js.map +1 -1
- package/build/src/utils/telemetry/getContext.js +1 -1
- package/package.json +2 -2
package/build/bin/cli
CHANGED
|
@@ -206,8 +206,11 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
|
|
|
206
206
|
};
|
|
207
207
|
}
|
|
208
208
|
async getExpoRouterRoutesManifestAsync({ appDir }) {
|
|
209
|
+
var ref, ref1;
|
|
209
210
|
// getBuiltTimeServerManifest
|
|
211
|
+
const { exp } = (0, _config().getConfig)(this.projectRoot);
|
|
210
212
|
const manifest = await (0, _fetchRouterManifest.fetchManifest)(this.projectRoot, {
|
|
213
|
+
...(ref = exp.extra) == null ? void 0 : (ref1 = ref.router) == null ? void 0 : ref1.platformRoutes,
|
|
211
214
|
asJson: true,
|
|
212
215
|
appDir
|
|
213
216
|
});
|
|
@@ -217,6 +220,7 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
|
|
|
217
220
|
return manifest;
|
|
218
221
|
}
|
|
219
222
|
async getStaticRenderFunctionAsync() {
|
|
223
|
+
var ref;
|
|
220
224
|
const { mode , minify , isExporting } = this.instanceMetroOptions;
|
|
221
225
|
(0, _assert().default)(mode != null && isExporting != null, "The server must be started before calling ssrLoadModule.");
|
|
222
226
|
const url = this.getDevServerUrl();
|
|
@@ -225,11 +229,13 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
|
|
|
225
229
|
mode,
|
|
226
230
|
isExporting
|
|
227
231
|
});
|
|
232
|
+
const { exp } = (0, _config().getConfig)(this.projectRoot);
|
|
228
233
|
return {
|
|
229
234
|
serverManifest: await getBuildTimeServerManifestAsync(),
|
|
230
235
|
// Get routes from Expo Router.
|
|
231
236
|
manifest: await getManifest({
|
|
232
|
-
preserveApiRoutes: false
|
|
237
|
+
preserveApiRoutes: false,
|
|
238
|
+
...(ref = exp.extra) == null ? void 0 : ref.router
|
|
233
239
|
}),
|
|
234
240
|
// Get route generating function
|
|
235
241
|
async renderAsync (path) {
|
|
@@ -484,10 +490,12 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
|
|
|
484
490
|
// This should come after the static middleware so it doesn't serve the favicon from `public/favicon.ico`.
|
|
485
491
|
middleware.use(new _faviconMiddleware.FaviconMiddleware(this.projectRoot).getHandler());
|
|
486
492
|
if (useServerRendering) {
|
|
493
|
+
var ref2;
|
|
487
494
|
middleware.use((0, _createServerRouteMiddleware.createRouteHandlerMiddleware)(this.projectRoot, {
|
|
488
495
|
appDir,
|
|
489
496
|
routerRoot,
|
|
490
497
|
config,
|
|
498
|
+
...(ref2 = config.exp.extra) == null ? void 0 : ref2.router,
|
|
491
499
|
bundleApiRoute: (functionFilePath)=>this.ssrImportApiRoute(functionFilePath),
|
|
492
500
|
getStaticPageAsync: (pathname)=>{
|
|
493
501
|
return this.getStaticPageAsync(pathname);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/MetroBundlerDevServer.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { getConfig } from '@expo/config';\nimport * as runtimeEnv from '@expo/env';\nimport { SerialAsset } from '@expo/metro-config/build/serializer/serializerAssets';\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport { AssetData } from 'metro';\nimport fetch from 'node-fetch';\nimport path from 'path';\n\nimport { createRouteHandlerMiddleware } from './createServerRouteMiddleware';\nimport { ExpoRouterServerManifestV1, fetchManifest } from './fetchRouterManifest';\nimport { instantiateMetroAsync } from './instantiateMetro';\nimport { getErrorOverlayHtmlAsync, logMetroErrorAsync } from './metroErrorInterface';\nimport { metroWatchTypeScriptFiles } from './metroWatchTypeScriptFiles';\nimport {\n getRouterDirectoryModuleIdWithManifest,\n hasWarnedAboutApiRoutes,\n isApiRouteConvention,\n warnInvalidWebOutput,\n} from './router';\nimport { serializeHtmlWithAssets } from './serializeHtml';\nimport { observeAnyFileChanges, observeFileChanges } from './waitForMetroToObserveTypeScriptFile';\nimport { ExportAssetMap } from '../../../export/saveAssets';\nimport { Log } from '../../../log';\nimport getDevClientProperties from '../../../utils/analytics/getDevClientProperties';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { getFreePortAsync } from '../../../utils/port';\nimport { logEventAsync } from '../../../utils/telemetry';\nimport { BundlerDevServer, BundlerStartOptions, DevServerInstance } from '../BundlerDevServer';\nimport {\n evalMetroNoHandling,\n getStaticRenderFunctionsForEntry,\n requireFileContentsWithMetro,\n} from '../getStaticRenderFunctions';\nimport { ContextModuleSourceMapsMiddleware } from '../middleware/ContextModuleSourceMapsMiddleware';\nimport { CreateFileMiddleware } from '../middleware/CreateFileMiddleware';\nimport { DevToolsPluginMiddleware } from '../middleware/DevToolsPluginMiddleware';\nimport { FaviconMiddleware } from '../middleware/FaviconMiddleware';\nimport { HistoryFallbackMiddleware } from '../middleware/HistoryFallbackMiddleware';\nimport { InterstitialPageMiddleware } from '../middleware/InterstitialPageMiddleware';\nimport { resolveMainModuleName } from '../middleware/ManifestMiddleware';\nimport { ReactDevToolsPageMiddleware } from '../middleware/ReactDevToolsPageMiddleware';\nimport {\n DeepLinkHandler,\n RuntimeRedirectMiddleware,\n} from '../middleware/RuntimeRedirectMiddleware';\nimport { ServeStaticMiddleware } from '../middleware/ServeStaticMiddleware';\nimport {\n ExpoMetroOptions,\n createBundleUrlPath,\n getAsyncRoutesFromExpoConfig,\n getBaseUrlFromExpoConfig,\n shouldEnableAsyncImports,\n} from '../middleware/metroOptions';\nimport { prependMiddleware } from '../middleware/mutations';\nimport { startTypescriptTypeGenerationAsync } from '../type-generation/startTypescriptTypeGeneration';\n\nexport type ExpoRouterRuntimeManifest = Awaited<\n ReturnType<typeof import('expo-router/build/static/renderStaticContent').getManifest>\n>;\n\nexport class ForwardHtmlError extends CommandError {\n constructor(\n message: string,\n public html: string,\n public statusCode: number\n ) {\n super(message);\n }\n}\n\nconst debug = require('debug')('expo:start:server:metro') as typeof console.log;\n\n/** Default port to use for apps running in Expo Go. */\nconst EXPO_GO_METRO_PORT = 8081;\n\n/** Default port to use for apps that run in standard React Native projects or Expo Dev Clients. */\nconst DEV_CLIENT_METRO_PORT = 8081;\n\nexport class MetroBundlerDevServer extends BundlerDevServer {\n private metro: import('metro').Server | null = null;\n\n get name(): string {\n return 'metro';\n }\n\n async resolvePortAsync(options: Partial<BundlerStartOptions> = {}): Promise<number> {\n const port =\n // If the manually defined port is busy then an error should be thrown...\n options.port ??\n // Otherwise use the default port based on the runtime target.\n (options.devClient\n ? // Don't check if the port is busy if we're using the dev client since most clients are hardcoded to 8081.\n Number(process.env.RCT_METRO_PORT) || DEV_CLIENT_METRO_PORT\n : // Otherwise (running in Expo Go) use a free port that falls back on the classic 8081 port.\n await getFreePortAsync(EXPO_GO_METRO_PORT));\n\n return port;\n }\n\n async exportExpoRouterApiRoutesAsync({\n includeSourceMaps,\n outputDir,\n prerenderManifest,\n }: {\n includeSourceMaps?: boolean;\n outputDir: string;\n // This does not contain the API routes info.\n prerenderManifest: ExpoRouterServerManifestV1;\n }): Promise<{ files: ExportAssetMap; manifest: ExpoRouterServerManifestV1<string> }> {\n const { routerRoot } = this.instanceMetroOptions;\n assert(\n routerRoot != null,\n 'The server must be started before calling exportExpoRouterApiRoutesAsync.'\n );\n\n const appDir = path.join(this.projectRoot, routerRoot);\n const manifest = await this.getExpoRouterRoutesManifestAsync({ appDir });\n\n const files: ExportAssetMap = new Map();\n\n for (const route of manifest.apiRoutes) {\n const filepath = path.join(appDir, route.file);\n const contents = await this.bundleApiRoute(filepath);\n const artifactFilename = path.join(\n outputDir,\n path.relative(appDir, filepath.replace(/\\.[tj]sx?$/, '.js'))\n );\n if (contents) {\n let src = contents.src;\n if (includeSourceMaps && contents.map) {\n // TODO(kitten): Merge the source map transformer in the future\n // https://github.com/expo/expo/blob/0dffdb15/packages/%40expo/metro-config/src/serializer/serializeChunks.ts#L422-L439\n // Alternatively, check whether `sourcesRoot` helps here\n const artifactBasename = encodeURIComponent(path.basename(artifactFilename) + '.map');\n src = src.replace(\n /\\/\\/# sourceMappingURL=.*/g,\n `//# sourceMappingURL=${artifactBasename}`\n );\n files.set(artifactFilename + '.map', {\n contents: JSON.stringify({\n version: contents.map.version,\n sources: contents.map.sources.map((source: string) => {\n source =\n typeof source === 'string' && source.startsWith(this.projectRoot)\n ? path.relative(this.projectRoot, source)\n : source;\n return source.split(path.sep).join('/');\n }),\n sourcesContent: new Array(contents.map.sources.length).fill(null),\n names: contents.map.names,\n mappings: contents.map.mappings,\n }),\n targetDomain: 'server',\n });\n }\n files.set(artifactFilename, {\n contents: src,\n targetDomain: 'server',\n });\n }\n // Remap the manifest files to represent the output files.\n route.file = artifactFilename;\n }\n\n return {\n manifest: {\n ...manifest,\n htmlRoutes: prerenderManifest.htmlRoutes,\n },\n files,\n };\n }\n\n async getExpoRouterRoutesManifestAsync({ appDir }: { appDir: string }) {\n // getBuiltTimeServerManifest\n const manifest = await fetchManifest(this.projectRoot, {\n asJson: true,\n appDir,\n });\n\n if (!manifest) {\n throw new CommandError(\n 'EXPO_ROUTER_SERVER_MANIFEST',\n 'Unexpected error: server manifest could not be fetched.'\n );\n }\n\n return manifest;\n }\n\n async getStaticRenderFunctionAsync(): Promise<{\n serverManifest: ExpoRouterServerManifestV1;\n manifest: ExpoRouterRuntimeManifest;\n renderAsync: (path: string) => Promise<string>;\n }> {\n const { mode, minify, isExporting } = this.instanceMetroOptions;\n assert(\n mode != null && isExporting != null,\n 'The server must be started before calling ssrLoadModule.'\n );\n\n const url = this.getDevServerUrl()!;\n\n const { getStaticContent, getManifest, getBuildTimeServerManifestAsync } =\n await this.ssrLoadModule<typeof import('expo-router/build/static/renderStaticContent')>(\n 'expo-router/node/render.js',\n {\n minify,\n mode,\n isExporting,\n }\n );\n\n return {\n serverManifest: await getBuildTimeServerManifestAsync(),\n // Get routes from Expo Router.\n manifest: await getManifest({ preserveApiRoutes: false }),\n // Get route generating function\n async renderAsync(path: string) {\n return await getStaticContent(new URL(path, url));\n },\n };\n }\n\n async getStaticResourcesAsync({\n includeSourceMaps,\n mainModuleName,\n }: {\n includeSourceMaps?: boolean;\n mainModuleName?: string;\n } = {}): Promise<{ artifacts: SerialAsset[]; assets?: AssetData[] }> {\n const { mode, minify, isExporting, baseUrl, routerRoot, asyncRoutes } =\n this.instanceMetroOptions;\n assert(\n mode != null &&\n isExporting != null &&\n baseUrl != null &&\n routerRoot != null &&\n asyncRoutes != null,\n 'The server must be started before calling getStaticPageAsync.'\n );\n\n const platform = 'web';\n\n const devBundleUrlPathname = createBundleUrlPath({\n splitChunks: isExporting && !env.EXPO_NO_BUNDLE_SPLITTING,\n platform,\n mode,\n minify,\n environment: 'client',\n serializerOutput: 'static',\n serializerIncludeMaps: includeSourceMaps,\n mainModuleName: mainModuleName ?? resolveMainModuleName(this.projectRoot, { platform }),\n lazy: shouldEnableAsyncImports(this.projectRoot),\n asyncRoutes,\n baseUrl,\n isExporting,\n routerRoot,\n bytecode: false,\n });\n\n const bundleUrl = new URL(devBundleUrlPathname, this.getDevServerUrl()!);\n\n // Fetch the generated HTML from our custom Metro serializer\n const results = await fetch(bundleUrl.toString());\n\n const txt = await results.text();\n\n let data: any;\n try {\n data = JSON.parse(txt);\n } catch (error: any) {\n debug(txt);\n\n // Metro can throw this error when the initial module id cannot be resolved.\n if (!results.ok && txt.startsWith('<!DOCTYPE html>')) {\n throw new ForwardHtmlError(\n `Metro failed to bundle the project. Check the console for more information.`,\n txt,\n results.status\n );\n }\n\n Log.error(\n 'Failed to generate resources with Metro, the Metro config may not be using the correct serializer. Ensure the metro.config.js is extending the expo/metro-config and is not overriding the serializer.'\n );\n throw error;\n }\n\n // NOTE: This could potentially need more validation in the future.\n if ('artifacts' in data && Array.isArray(data.artifacts)) {\n return data;\n }\n\n if (data != null && (data.errors || data.type?.match(/.*Error$/))) {\n // {\n // type: 'InternalError',\n // errors: [],\n // message: 'Metro has encountered an error: While trying to resolve module `stylis` from file `/Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/@emotion/cache/dist/emotion-cache.browser.esm.js`, the package `/Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/stylis/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/stylis/dist/stylis.mjs`. Indeed, none of these files exist:\\n' +\n // '\\n' +\n // ' * /Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/stylis/dist/stylis.mjs(.web.ts|.ts|.web.tsx|.tsx|.web.js|.js|.web.jsx|.jsx|.web.json|.json|.web.cjs|.cjs|.web.scss|.scss|.web.sass|.sass|.web.css|.css)\\n' +\n // ' * /Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/stylis/dist/stylis.mjs/index(.web.ts|.ts|.web.tsx|.tsx|.web.js|.js|.web.jsx|.jsx|.web.json|.json|.web.cjs|.cjs|.web.scss|.scss|.web.sass|.sass|.web.css|.css): /Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/metro/src/node-haste/DependencyGraph.js (289:17)\\n' +\n // '\\n' +\n // '\\x1B[0m \\x1B[90m 287 |\\x1B[39m }\\x1B[0m\\n' +\n // '\\x1B[0m \\x1B[90m 288 |\\x1B[39m \\x1B[36mif\\x1B[39m (error \\x1B[36minstanceof\\x1B[39m \\x1B[33mInvalidPackageError\\x1B[39m) {\\x1B[0m\\n' +\n // '\\x1B[0m\\x1B[31m\\x1B[1m>\\x1B[22m\\x1B[39m\\x1B[90m 289 |\\x1B[39m \\x1B[36mthrow\\x1B[39m \\x1B[36mnew\\x1B[39m \\x1B[33mPackageResolutionError\\x1B[39m({\\x1B[0m\\n' +\n // '\\x1B[0m \\x1B[90m |\\x1B[39m \\x1B[31m\\x1B[1m^\\x1B[22m\\x1B[39m\\x1B[0m\\n' +\n // '\\x1B[0m \\x1B[90m 290 |\\x1B[39m packageError\\x1B[33m:\\x1B[39m error\\x1B[33m,\\x1B[39m\\x1B[0m\\n' +\n // '\\x1B[0m \\x1B[90m 291 |\\x1B[39m originModulePath\\x1B[33m:\\x1B[39m \\x1B[36mfrom\\x1B[39m\\x1B[33m,\\x1B[39m\\x1B[0m\\n' +\n // '\\x1B[0m \\x1B[90m 292 |\\x1B[39m targetModuleName\\x1B[33m:\\x1B[39m to\\x1B[33m,\\x1B[39m\\x1B[0m'\n // }\n // The Metro logger already showed this error.\n throw new Error(data.message);\n }\n\n throw new Error(\n 'Invalid resources returned from the Metro serializer. Expected array, found: ' + data\n );\n }\n\n private async getStaticPageAsync(pathname: string) {\n const { mode, isExporting, baseUrl, routerRoot, asyncRoutes } = this.instanceMetroOptions;\n assert(\n mode != null &&\n isExporting != null &&\n baseUrl != null &&\n routerRoot != null &&\n asyncRoutes != null,\n 'The server must be started before calling getStaticPageAsync.'\n );\n const platform = 'web';\n\n const devBundleUrlPathname = createBundleUrlPath({\n splitChunks: isExporting && !env.EXPO_NO_BUNDLE_SPLITTING,\n platform,\n mode,\n environment: 'client',\n mainModuleName: resolveMainModuleName(this.projectRoot, { platform }),\n lazy: shouldEnableAsyncImports(this.projectRoot),\n baseUrl,\n isExporting,\n asyncRoutes,\n routerRoot,\n bytecode: false,\n });\n\n const bundleStaticHtml = async (): Promise<string> => {\n const { getStaticContent } = await this.ssrLoadModule<\n typeof import('expo-router/build/static/renderStaticContent')\n >('expo-router/node/render.js', {\n minify: false,\n mode,\n isExporting,\n platform,\n });\n\n const location = new URL(pathname, this.getDevServerUrl()!);\n return await getStaticContent(location);\n };\n\n const [{ artifacts: resources }, staticHtml] = await Promise.all([\n this.getStaticResourcesAsync(),\n bundleStaticHtml(),\n ]);\n const content = serializeHtmlWithAssets({\n isExporting,\n resources,\n template: staticHtml,\n devBundleUrl: devBundleUrlPathname,\n baseUrl,\n });\n return {\n content,\n resources,\n };\n }\n\n // Set when the server is started.\n private instanceMetroOptions: Partial<ExpoMetroOptions> = {};\n\n async ssrLoadModule<T extends Record<string, any>>(\n filePath: string,\n specificOptions: Partial<ExpoMetroOptions> = {}\n ): Promise<T> {\n const { baseUrl, routerRoot, isExporting } = this.instanceMetroOptions;\n assert(\n baseUrl != null && routerRoot != null && isExporting != null,\n 'The server must be started before calling ssrLoadModule.'\n );\n\n return (\n await getStaticRenderFunctionsForEntry<T>(\n this.projectRoot,\n this.getDevServerUrl()!,\n {\n // Bundle in Node.js mode for SSR.\n environment: 'node',\n platform: 'web',\n mode: 'development',\n bytecode: false,\n\n ...this.instanceMetroOptions,\n baseUrl,\n routerRoot,\n isExporting,\n ...specificOptions,\n },\n filePath\n )\n ).fn;\n }\n\n async ssrLoadModuleContents(\n filePath: string,\n specificOptions: Partial<ExpoMetroOptions> = {}\n ): Promise<{ src: string; filename: string }> {\n const { baseUrl, routerRoot, isExporting } = this.instanceMetroOptions;\n assert(\n baseUrl != null && routerRoot != null && isExporting != null,\n 'The server must be started before calling ssrLoadModule.'\n );\n\n return await requireFileContentsWithMetro(this.projectRoot, this.getDevServerUrl()!, filePath, {\n // Bundle in Node.js mode for SSR.\n environment: 'node',\n platform: 'web',\n mode: 'development',\n bytecode: false,\n\n ...this.instanceMetroOptions,\n baseUrl,\n routerRoot,\n isExporting,\n ...specificOptions,\n });\n }\n\n async watchEnvironmentVariables() {\n if (!this.instance) {\n throw new Error(\n 'Cannot observe environment variable changes without a running Metro instance.'\n );\n }\n if (!this.metro) {\n // This can happen when the run command is used and the server is already running in another\n // process.\n debug('Skipping Environment Variable observation because Metro is not running (headless).');\n return;\n }\n\n const envFiles = runtimeEnv\n .getFiles(process.env.NODE_ENV)\n .map((fileName) => path.join(this.projectRoot, fileName));\n\n observeFileChanges(\n {\n metro: this.metro,\n server: this.instance.server,\n },\n envFiles,\n () => {\n debug('Reloading environment variables...');\n // Force reload the environment variables.\n runtimeEnv.load(this.projectRoot, { force: true });\n }\n );\n }\n\n getExpoLineOptions() {\n return this.instanceMetroOptions;\n }\n\n protected async startImplementationAsync(\n options: BundlerStartOptions\n ): Promise<DevServerInstance> {\n options.port = await this.resolvePortAsync(options);\n this.urlCreator = this.getUrlCreator(options);\n\n const config = getConfig(this.projectRoot, { skipSDKVersionRequirement: true });\n const { exp } = config;\n const useServerRendering = ['static', 'server'].includes(exp.web?.output ?? '');\n const baseUrl = getBaseUrlFromExpoConfig(exp);\n const asyncRoutes = getAsyncRoutesFromExpoConfig(exp, options.mode ?? 'development', 'web');\n const routerRoot = getRouterDirectoryModuleIdWithManifest(this.projectRoot, exp);\n const appDir = path.join(this.projectRoot, routerRoot);\n const mode = options.mode ?? 'development';\n\n this.instanceMetroOptions = {\n isExporting: !!options.isExporting,\n baseUrl,\n mode,\n routerRoot,\n minify: options.minify,\n asyncRoutes,\n // Options that are changing between platforms like engine, platform, and environment aren't set here.\n };\n\n const parsedOptions = {\n port: options.port,\n maxWorkers: options.maxWorkers,\n resetCache: options.resetDevServer,\n };\n\n // Required for symbolication:\n process.env.EXPO_DEV_SERVER_ORIGIN = `http://localhost:${options.port}`;\n\n const { metro, server, middleware, messageSocket } = await instantiateMetroAsync(\n this,\n parsedOptions,\n {\n isExporting: !!options.isExporting,\n }\n );\n\n const manifestMiddleware = await this.getManifestMiddlewareAsync(options);\n\n // Important that we noop source maps for context modules as soon as possible.\n prependMiddleware(middleware, new ContextModuleSourceMapsMiddleware().getHandler());\n\n // We need the manifest handler to be the first middleware to run so our\n // routes take precedence over static files. For example, the manifest is\n // served from '/' and if the user has an index.html file in their project\n // then the manifest handler will never run, the static middleware will run\n // and serve index.html instead of the manifest.\n // https://github.com/expo/expo/issues/13114\n prependMiddleware(middleware, manifestMiddleware.getHandler());\n\n middleware.use(\n new InterstitialPageMiddleware(this.projectRoot, {\n // TODO: Prevent this from becoming stale.\n scheme: options.location.scheme ?? null,\n }).getHandler()\n );\n middleware.use(new ReactDevToolsPageMiddleware(this.projectRoot).getHandler());\n middleware.use(\n new DevToolsPluginMiddleware(this.projectRoot, this.devToolsPluginManager).getHandler()\n );\n\n const deepLinkMiddleware = new RuntimeRedirectMiddleware(this.projectRoot, {\n onDeepLink: getDeepLinkHandler(this.projectRoot),\n getLocation: ({ runtime }) => {\n if (runtime === 'custom') {\n return this.urlCreator?.constructDevClientUrl();\n } else {\n return this.urlCreator?.constructUrl({\n scheme: 'exp',\n });\n }\n },\n });\n middleware.use(deepLinkMiddleware.getHandler());\n\n middleware.use(new CreateFileMiddleware(this.projectRoot).getHandler());\n\n // Append support for redirecting unhandled requests to the index.html page on web.\n if (this.isTargetingWeb()) {\n // This MUST be after the manifest middleware so it doesn't have a chance to serve the template `public/index.html`.\n middleware.use(new ServeStaticMiddleware(this.projectRoot).getHandler());\n\n // This should come after the static middleware so it doesn't serve the favicon from `public/favicon.ico`.\n middleware.use(new FaviconMiddleware(this.projectRoot).getHandler());\n\n if (useServerRendering) {\n middleware.use(\n createRouteHandlerMiddleware(this.projectRoot, {\n appDir,\n routerRoot,\n config,\n bundleApiRoute: (functionFilePath) => this.ssrImportApiRoute(functionFilePath),\n getStaticPageAsync: (pathname) => {\n return this.getStaticPageAsync(pathname);\n },\n })\n );\n\n observeAnyFileChanges(\n {\n metro,\n server,\n },\n (events) => {\n if (exp.web?.output === 'server') {\n // NOTE(EvanBacon): We aren't sure what files the API routes are using so we'll just invalidate\n // aggressively to ensure we always have the latest. The only caching we really get here is for\n // cases where the user is making subsequent requests to the same API route without changing anything.\n // This is useful for testing but pretty suboptimal. Luckily our caching is pretty aggressive so it makes\n // up for a lot of the overhead.\n this.invalidateApiRouteCache();\n } else if (!hasWarnedAboutApiRoutes()) {\n for (const event of events) {\n if (\n // If the user did not delete a file that matches the Expo Router API Route convention, then we should warn that\n // API Routes are not enabled in the project.\n event.metadata?.type !== 'd' &&\n // Ensure the file is in the project's routes directory to prevent false positives in monorepos.\n event.filePath.startsWith(appDir) &&\n isApiRouteConvention(event.filePath)\n ) {\n warnInvalidWebOutput();\n }\n }\n }\n }\n );\n } else {\n // This MUST run last since it's the fallback.\n middleware.use(\n new HistoryFallbackMiddleware(manifestMiddleware.getHandler().internal).getHandler()\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 this.metro = null;\n callback?.(err);\n });\n };\n\n this.metro = metro;\n return {\n server,\n location: {\n // The port is the main thing we want to send back.\n port: options.port,\n // localhost isn't always correct.\n host: 'localhost',\n // http is the only supported protocol on native.\n url: `http://localhost:${options.port}`,\n protocol: 'http',\n },\n middleware,\n messageSocket,\n };\n }\n\n public async waitForTypeScriptAsync(): Promise<boolean> {\n if (!this.instance) {\n throw new Error('Cannot wait for TypeScript without a running server.');\n }\n\n return new Promise<boolean>((resolve) => {\n if (!this.metro) {\n // This can happen when the run command is used and the server is already running in another\n // process. In this case we can't wait for the TypeScript check to complete because we don't\n // have access to the Metro server.\n debug('Skipping TypeScript check because Metro is not running (headless).');\n return resolve(false);\n }\n\n const off = metroWatchTypeScriptFiles({\n projectRoot: this.projectRoot,\n server: this.instance!.server,\n metro: this.metro,\n tsconfig: true,\n throttle: true,\n eventTypes: ['change', 'add'],\n callback: async () => {\n // Run once, this prevents the TypeScript project prerequisite from running on every file change.\n off();\n const { TypeScriptProjectPrerequisite } = await import(\n '../../doctor/typescript/TypeScriptProjectPrerequisite.js'\n );\n\n try {\n const req = new TypeScriptProjectPrerequisite(this.projectRoot);\n await req.bootstrapAsync();\n resolve(true);\n } catch (error: any) {\n // Ensure the process doesn't fail if the TypeScript check fails.\n // This could happen during the install.\n Log.log();\n Log.error(\n chalk.red`Failed to automatically setup TypeScript for your project. Try restarting the dev server to fix.`\n );\n Log.exception(error);\n resolve(false);\n }\n },\n });\n });\n }\n\n public async startTypeScriptServices() {\n return startTypescriptTypeGenerationAsync({\n server: this.instance?.server,\n metro: this.metro,\n projectRoot: this.projectRoot,\n });\n }\n\n protected getConfigModuleIds(): string[] {\n return ['./metro.config.js', './metro.config.json', './rn-cli.config.js'];\n }\n\n private pendingRouteOperations = new Map<\n string,\n Promise<{ src: string; filename: string; map?: any } | null>\n >();\n\n // API Routes\n\n // Bundle the API Route with Metro and return the string contents to be evaluated in the server.\n private async bundleApiRoute(\n filePath: string\n ): Promise<{ src: string; filename: string; map?: any } | null | undefined> {\n if (this.pendingRouteOperations.has(filePath)) {\n return this.pendingRouteOperations.get(filePath);\n }\n const bundleAsync = async () => {\n try {\n debug('Bundle API route:', this.instanceMetroOptions.routerRoot, filePath);\n return await this.ssrLoadModuleContents(filePath);\n } catch (error: any) {\n if (error instanceof Error) {\n await logMetroErrorAsync({ error, projectRoot: this.projectRoot });\n }\n throw error;\n } finally {\n // pendingRouteOperations.delete(filepath);\n }\n };\n const route = bundleAsync();\n\n this.pendingRouteOperations.set(filePath, route);\n return route;\n }\n\n private async ssrImportApiRoute(\n filePath: string\n ): Promise<null | Record<string, Function> | Response> {\n // TODO: Cache the evaluated function.\n try {\n const apiRoute = await this.bundleApiRoute(filePath);\n\n if (!apiRoute?.src) {\n return null;\n }\n return evalMetroNoHandling(this.projectRoot, apiRoute.src, apiRoute.filename);\n } catch (error) {\n // Format any errors that were thrown in the global scope of the evaluation.\n if (error instanceof Error) {\n try {\n const htmlServerError = await getErrorOverlayHtmlAsync({\n error,\n projectRoot: this.projectRoot,\n routerRoot: this.getExpoLineOptions().routerRoot!,\n });\n\n return new Response(htmlServerError, {\n status: 500,\n headers: {\n 'Content-Type': 'text/html',\n },\n });\n } catch (internalError) {\n debug('Failed to generate Metro server error UI for API Route error:', internalError);\n throw error;\n }\n } else {\n throw error;\n }\n }\n }\n\n private invalidateApiRouteCache() {\n this.pendingRouteOperations.clear();\n }\n}\n\nexport function getDeepLinkHandler(projectRoot: string): DeepLinkHandler {\n return async ({ runtime }) => {\n if (runtime === 'expo') return;\n const { exp } = getConfig(projectRoot);\n await logEventAsync('dev client start command', {\n status: 'started',\n ...getDevClientProperties(projectRoot, exp),\n });\n };\n}\n"],"names":["ForwardHtmlError","MetroBundlerDevServer","getDeepLinkHandler","CommandError","constructor","message","html","statusCode","debug","require","EXPO_GO_METRO_PORT","DEV_CLIENT_METRO_PORT","BundlerDevServer","metro","name","resolvePortAsync","options","port","devClient","Number","process","env","RCT_METRO_PORT","getFreePortAsync","exportExpoRouterApiRoutesAsync","includeSourceMaps","outputDir","prerenderManifest","routerRoot","instanceMetroOptions","assert","appDir","path","join","projectRoot","manifest","getExpoRouterRoutesManifestAsync","files","Map","route","apiRoutes","filepath","file","contents","bundleApiRoute","artifactFilename","relative","replace","src","map","artifactBasename","encodeURIComponent","basename","set","JSON","stringify","version","sources","source","startsWith","split","sep","sourcesContent","Array","length","fill","names","mappings","targetDomain","htmlRoutes","fetchManifest","asJson","getStaticRenderFunctionAsync","mode","minify","isExporting","url","getDevServerUrl","getStaticContent","getManifest","getBuildTimeServerManifestAsync","ssrLoadModule","serverManifest","preserveApiRoutes","renderAsync","URL","getStaticResourcesAsync","mainModuleName","data","baseUrl","asyncRoutes","platform","devBundleUrlPathname","createBundleUrlPath","splitChunks","EXPO_NO_BUNDLE_SPLITTING","environment","serializerOutput","serializerIncludeMaps","resolveMainModuleName","lazy","shouldEnableAsyncImports","bytecode","bundleUrl","results","fetch","toString","txt","text","parse","error","ok","status","Log","isArray","artifacts","errors","type","match","Error","getStaticPageAsync","pathname","bundleStaticHtml","location","resources","staticHtml","Promise","all","content","serializeHtmlWithAssets","template","devBundleUrl","filePath","specificOptions","getStaticRenderFunctionsForEntry","fn","ssrLoadModuleContents","requireFileContentsWithMetro","watchEnvironmentVariables","instance","envFiles","runtimeEnv","getFiles","NODE_ENV","fileName","observeFileChanges","server","load","force","getExpoLineOptions","startImplementationAsync","exp","urlCreator","getUrlCreator","config","getConfig","skipSDKVersionRequirement","useServerRendering","includes","web","output","getBaseUrlFromExpoConfig","getAsyncRoutesFromExpoConfig","getRouterDirectoryModuleIdWithManifest","parsedOptions","maxWorkers","resetCache","resetDevServer","EXPO_DEV_SERVER_ORIGIN","middleware","messageSocket","instantiateMetroAsync","manifestMiddleware","getManifestMiddlewareAsync","prependMiddleware","ContextModuleSourceMapsMiddleware","getHandler","use","InterstitialPageMiddleware","scheme","ReactDevToolsPageMiddleware","DevToolsPluginMiddleware","devToolsPluginManager","deepLinkMiddleware","RuntimeRedirectMiddleware","onDeepLink","getLocation","runtime","constructDevClientUrl","constructUrl","CreateFileMiddleware","isTargetingWeb","ServeStaticMiddleware","FaviconMiddleware","createRouteHandlerMiddleware","functionFilePath","ssrImportApiRoute","observeAnyFileChanges","events","invalidateApiRouteCache","hasWarnedAboutApiRoutes","event","metadata","isApiRouteConvention","warnInvalidWebOutput","HistoryFallbackMiddleware","internal","originalClose","close","bind","callback","err","host","protocol","waitForTypeScriptAsync","resolve","off","metroWatchTypeScriptFiles","tsconfig","throttle","eventTypes","TypeScriptProjectPrerequisite","req","bootstrapAsync","log","chalk","red","exception","startTypeScriptServices","startTypescriptTypeGenerationAsync","getConfigModuleIds","pendingRouteOperations","has","get","bundleAsync","logMetroErrorAsync","apiRoute","evalMetroNoHandling","filename","htmlServerError","getErrorOverlayHtmlAsync","Response","headers","internalError","clear","logEventAsync","getDevClientProperties"],"mappings":"AAAA;;;;;CAKC,GACD;;;;;;;;;;;IA8DaA,gBAAgB,MAAhBA,gBAAgB;IAkBhBC,qB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IA,OAAO,KAAK,MAAM,EAAE,OAAO;QAC/B,MAAM,EAAEpC,GAAG,CAAA,EAAE,GAAGI,IAAAA,OAAS,EAAA,UAAA,EAACzH,WAAW,CAAC,AAAC;QACvC,MAAMmN,IAAAA,UAAa,cAAA,EAAC,0BAA0B,EAAE;YAC9CrI,MAAM,EAAE,SAAS;YACjB,GAAGsI,IAAAA,uBAAsB,QAAA,EAACpN,WAAW,EAAEqH,GAAG,CAAC;SAC5C,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/MetroBundlerDevServer.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { getConfig } from '@expo/config';\nimport * as runtimeEnv from '@expo/env';\nimport { SerialAsset } from '@expo/metro-config/build/serializer/serializerAssets';\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport { AssetData } from 'metro';\nimport fetch from 'node-fetch';\nimport path from 'path';\n\nimport { createRouteHandlerMiddleware } from './createServerRouteMiddleware';\nimport { ExpoRouterServerManifestV1, fetchManifest } from './fetchRouterManifest';\nimport { instantiateMetroAsync } from './instantiateMetro';\nimport { getErrorOverlayHtmlAsync, logMetroErrorAsync } from './metroErrorInterface';\nimport { metroWatchTypeScriptFiles } from './metroWatchTypeScriptFiles';\nimport {\n getRouterDirectoryModuleIdWithManifest,\n hasWarnedAboutApiRoutes,\n isApiRouteConvention,\n warnInvalidWebOutput,\n} from './router';\nimport { serializeHtmlWithAssets } from './serializeHtml';\nimport { observeAnyFileChanges, observeFileChanges } from './waitForMetroToObserveTypeScriptFile';\nimport { ExportAssetMap } from '../../../export/saveAssets';\nimport { Log } from '../../../log';\nimport getDevClientProperties from '../../../utils/analytics/getDevClientProperties';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { getFreePortAsync } from '../../../utils/port';\nimport { logEventAsync } from '../../../utils/telemetry';\nimport { BundlerDevServer, BundlerStartOptions, DevServerInstance } from '../BundlerDevServer';\nimport {\n evalMetroNoHandling,\n getStaticRenderFunctionsForEntry,\n requireFileContentsWithMetro,\n} from '../getStaticRenderFunctions';\nimport { ContextModuleSourceMapsMiddleware } from '../middleware/ContextModuleSourceMapsMiddleware';\nimport { CreateFileMiddleware } from '../middleware/CreateFileMiddleware';\nimport { DevToolsPluginMiddleware } from '../middleware/DevToolsPluginMiddleware';\nimport { FaviconMiddleware } from '../middleware/FaviconMiddleware';\nimport { HistoryFallbackMiddleware } from '../middleware/HistoryFallbackMiddleware';\nimport { InterstitialPageMiddleware } from '../middleware/InterstitialPageMiddleware';\nimport { resolveMainModuleName } from '../middleware/ManifestMiddleware';\nimport { ReactDevToolsPageMiddleware } from '../middleware/ReactDevToolsPageMiddleware';\nimport {\n DeepLinkHandler,\n RuntimeRedirectMiddleware,\n} from '../middleware/RuntimeRedirectMiddleware';\nimport { ServeStaticMiddleware } from '../middleware/ServeStaticMiddleware';\nimport {\n ExpoMetroOptions,\n createBundleUrlPath,\n getAsyncRoutesFromExpoConfig,\n getBaseUrlFromExpoConfig,\n shouldEnableAsyncImports,\n} from '../middleware/metroOptions';\nimport { prependMiddleware } from '../middleware/mutations';\nimport { startTypescriptTypeGenerationAsync } from '../type-generation/startTypescriptTypeGeneration';\n\nexport type ExpoRouterRuntimeManifest = Awaited<\n ReturnType<typeof import('expo-router/build/static/renderStaticContent').getManifest>\n>;\n\nexport class ForwardHtmlError extends CommandError {\n constructor(\n message: string,\n public html: string,\n public statusCode: number\n ) {\n super(message);\n }\n}\n\nconst debug = require('debug')('expo:start:server:metro') as typeof console.log;\n\n/** Default port to use for apps running in Expo Go. */\nconst EXPO_GO_METRO_PORT = 8081;\n\n/** Default port to use for apps that run in standard React Native projects or Expo Dev Clients. */\nconst DEV_CLIENT_METRO_PORT = 8081;\n\nexport class MetroBundlerDevServer extends BundlerDevServer {\n private metro: import('metro').Server | null = null;\n\n get name(): string {\n return 'metro';\n }\n\n async resolvePortAsync(options: Partial<BundlerStartOptions> = {}): Promise<number> {\n const port =\n // If the manually defined port is busy then an error should be thrown...\n options.port ??\n // Otherwise use the default port based on the runtime target.\n (options.devClient\n ? // Don't check if the port is busy if we're using the dev client since most clients are hardcoded to 8081.\n Number(process.env.RCT_METRO_PORT) || DEV_CLIENT_METRO_PORT\n : // Otherwise (running in Expo Go) use a free port that falls back on the classic 8081 port.\n await getFreePortAsync(EXPO_GO_METRO_PORT));\n\n return port;\n }\n\n async exportExpoRouterApiRoutesAsync({\n includeSourceMaps,\n outputDir,\n prerenderManifest,\n }: {\n includeSourceMaps?: boolean;\n outputDir: string;\n // This does not contain the API routes info.\n prerenderManifest: ExpoRouterServerManifestV1;\n }): Promise<{ files: ExportAssetMap; manifest: ExpoRouterServerManifestV1<string> }> {\n const { routerRoot } = this.instanceMetroOptions;\n assert(\n routerRoot != null,\n 'The server must be started before calling exportExpoRouterApiRoutesAsync.'\n );\n\n const appDir = path.join(this.projectRoot, routerRoot);\n const manifest = await this.getExpoRouterRoutesManifestAsync({ appDir });\n\n const files: ExportAssetMap = new Map();\n\n for (const route of manifest.apiRoutes) {\n const filepath = path.join(appDir, route.file);\n const contents = await this.bundleApiRoute(filepath);\n const artifactFilename = path.join(\n outputDir,\n path.relative(appDir, filepath.replace(/\\.[tj]sx?$/, '.js'))\n );\n if (contents) {\n let src = contents.src;\n if (includeSourceMaps && contents.map) {\n // TODO(kitten): Merge the source map transformer in the future\n // https://github.com/expo/expo/blob/0dffdb15/packages/%40expo/metro-config/src/serializer/serializeChunks.ts#L422-L439\n // Alternatively, check whether `sourcesRoot` helps here\n const artifactBasename = encodeURIComponent(path.basename(artifactFilename) + '.map');\n src = src.replace(\n /\\/\\/# sourceMappingURL=.*/g,\n `//# sourceMappingURL=${artifactBasename}`\n );\n files.set(artifactFilename + '.map', {\n contents: JSON.stringify({\n version: contents.map.version,\n sources: contents.map.sources.map((source: string) => {\n source =\n typeof source === 'string' && source.startsWith(this.projectRoot)\n ? path.relative(this.projectRoot, source)\n : source;\n return source.split(path.sep).join('/');\n }),\n sourcesContent: new Array(contents.map.sources.length).fill(null),\n names: contents.map.names,\n mappings: contents.map.mappings,\n }),\n targetDomain: 'server',\n });\n }\n files.set(artifactFilename, {\n contents: src,\n targetDomain: 'server',\n });\n }\n // Remap the manifest files to represent the output files.\n route.file = artifactFilename;\n }\n\n return {\n manifest: {\n ...manifest,\n htmlRoutes: prerenderManifest.htmlRoutes,\n },\n files,\n };\n }\n\n async getExpoRouterRoutesManifestAsync({ appDir }: { appDir: string }) {\n // getBuiltTimeServerManifest\n const { exp } = getConfig(this.projectRoot);\n const manifest = await fetchManifest(this.projectRoot, {\n ...exp.extra?.router?.platformRoutes,\n asJson: true,\n appDir,\n });\n\n if (!manifest) {\n throw new CommandError(\n 'EXPO_ROUTER_SERVER_MANIFEST',\n 'Unexpected error: server manifest could not be fetched.'\n );\n }\n\n return manifest;\n }\n\n async getStaticRenderFunctionAsync(): Promise<{\n serverManifest: ExpoRouterServerManifestV1;\n manifest: ExpoRouterRuntimeManifest;\n renderAsync: (path: string) => Promise<string>;\n }> {\n const { mode, minify, isExporting } = this.instanceMetroOptions;\n assert(\n mode != null && isExporting != null,\n 'The server must be started before calling ssrLoadModule.'\n );\n\n const url = this.getDevServerUrl()!;\n\n const { getStaticContent, getManifest, getBuildTimeServerManifestAsync } =\n await this.ssrLoadModule<typeof import('expo-router/build/static/renderStaticContent')>(\n 'expo-router/node/render.js',\n {\n minify,\n mode,\n isExporting,\n }\n );\n\n const { exp } = getConfig(this.projectRoot);\n\n return {\n serverManifest: await getBuildTimeServerManifestAsync(),\n // Get routes from Expo Router.\n manifest: await getManifest({ preserveApiRoutes: false, ...exp.extra?.router }),\n // Get route generating function\n async renderAsync(path: string) {\n return await getStaticContent(new URL(path, url));\n },\n };\n }\n\n async getStaticResourcesAsync({\n includeSourceMaps,\n mainModuleName,\n }: {\n includeSourceMaps?: boolean;\n mainModuleName?: string;\n } = {}): Promise<{ artifacts: SerialAsset[]; assets?: AssetData[] }> {\n const { mode, minify, isExporting, baseUrl, routerRoot, asyncRoutes } =\n this.instanceMetroOptions;\n assert(\n mode != null &&\n isExporting != null &&\n baseUrl != null &&\n routerRoot != null &&\n asyncRoutes != null,\n 'The server must be started before calling getStaticPageAsync.'\n );\n\n const platform = 'web';\n\n const devBundleUrlPathname = createBundleUrlPath({\n splitChunks: isExporting && !env.EXPO_NO_BUNDLE_SPLITTING,\n platform,\n mode,\n minify,\n environment: 'client',\n serializerOutput: 'static',\n serializerIncludeMaps: includeSourceMaps,\n mainModuleName: mainModuleName ?? resolveMainModuleName(this.projectRoot, { platform }),\n lazy: shouldEnableAsyncImports(this.projectRoot),\n asyncRoutes,\n baseUrl,\n isExporting,\n routerRoot,\n bytecode: false,\n });\n\n const bundleUrl = new URL(devBundleUrlPathname, this.getDevServerUrl()!);\n\n // Fetch the generated HTML from our custom Metro serializer\n const results = await fetch(bundleUrl.toString());\n\n const txt = await results.text();\n\n let data: any;\n try {\n data = JSON.parse(txt);\n } catch (error: any) {\n debug(txt);\n\n // Metro can throw this error when the initial module id cannot be resolved.\n if (!results.ok && txt.startsWith('<!DOCTYPE html>')) {\n throw new ForwardHtmlError(\n `Metro failed to bundle the project. Check the console for more information.`,\n txt,\n results.status\n );\n }\n\n Log.error(\n 'Failed to generate resources with Metro, the Metro config may not be using the correct serializer. Ensure the metro.config.js is extending the expo/metro-config and is not overriding the serializer.'\n );\n throw error;\n }\n\n // NOTE: This could potentially need more validation in the future.\n if ('artifacts' in data && Array.isArray(data.artifacts)) {\n return data;\n }\n\n if (data != null && (data.errors || data.type?.match(/.*Error$/))) {\n // {\n // type: 'InternalError',\n // errors: [],\n // message: 'Metro has encountered an error: While trying to resolve module `stylis` from file `/Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/@emotion/cache/dist/emotion-cache.browser.esm.js`, the package `/Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/stylis/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/stylis/dist/stylis.mjs`. Indeed, none of these files exist:\\n' +\n // '\\n' +\n // ' * /Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/stylis/dist/stylis.mjs(.web.ts|.ts|.web.tsx|.tsx|.web.js|.js|.web.jsx|.jsx|.web.json|.json|.web.cjs|.cjs|.web.scss|.scss|.web.sass|.sass|.web.css|.css)\\n' +\n // ' * /Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/stylis/dist/stylis.mjs/index(.web.ts|.ts|.web.tsx|.tsx|.web.js|.js|.web.jsx|.jsx|.web.json|.json|.web.cjs|.cjs|.web.scss|.scss|.web.sass|.sass|.web.css|.css): /Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/metro/src/node-haste/DependencyGraph.js (289:17)\\n' +\n // '\\n' +\n // '\\x1B[0m \\x1B[90m 287 |\\x1B[39m }\\x1B[0m\\n' +\n // '\\x1B[0m \\x1B[90m 288 |\\x1B[39m \\x1B[36mif\\x1B[39m (error \\x1B[36minstanceof\\x1B[39m \\x1B[33mInvalidPackageError\\x1B[39m) {\\x1B[0m\\n' +\n // '\\x1B[0m\\x1B[31m\\x1B[1m>\\x1B[22m\\x1B[39m\\x1B[90m 289 |\\x1B[39m \\x1B[36mthrow\\x1B[39m \\x1B[36mnew\\x1B[39m \\x1B[33mPackageResolutionError\\x1B[39m({\\x1B[0m\\n' +\n // '\\x1B[0m \\x1B[90m |\\x1B[39m \\x1B[31m\\x1B[1m^\\x1B[22m\\x1B[39m\\x1B[0m\\n' +\n // '\\x1B[0m \\x1B[90m 290 |\\x1B[39m packageError\\x1B[33m:\\x1B[39m error\\x1B[33m,\\x1B[39m\\x1B[0m\\n' +\n // '\\x1B[0m \\x1B[90m 291 |\\x1B[39m originModulePath\\x1B[33m:\\x1B[39m \\x1B[36mfrom\\x1B[39m\\x1B[33m,\\x1B[39m\\x1B[0m\\n' +\n // '\\x1B[0m \\x1B[90m 292 |\\x1B[39m targetModuleName\\x1B[33m:\\x1B[39m to\\x1B[33m,\\x1B[39m\\x1B[0m'\n // }\n // The Metro logger already showed this error.\n throw new Error(data.message);\n }\n\n throw new Error(\n 'Invalid resources returned from the Metro serializer. Expected array, found: ' + data\n );\n }\n\n private async getStaticPageAsync(pathname: string) {\n const { mode, isExporting, baseUrl, routerRoot, asyncRoutes } = this.instanceMetroOptions;\n assert(\n mode != null &&\n isExporting != null &&\n baseUrl != null &&\n routerRoot != null &&\n asyncRoutes != null,\n 'The server must be started before calling getStaticPageAsync.'\n );\n const platform = 'web';\n\n const devBundleUrlPathname = createBundleUrlPath({\n splitChunks: isExporting && !env.EXPO_NO_BUNDLE_SPLITTING,\n platform,\n mode,\n environment: 'client',\n mainModuleName: resolveMainModuleName(this.projectRoot, { platform }),\n lazy: shouldEnableAsyncImports(this.projectRoot),\n baseUrl,\n isExporting,\n asyncRoutes,\n routerRoot,\n bytecode: false,\n });\n\n const bundleStaticHtml = async (): Promise<string> => {\n const { getStaticContent } = await this.ssrLoadModule<\n typeof import('expo-router/build/static/renderStaticContent')\n >('expo-router/node/render.js', {\n minify: false,\n mode,\n isExporting,\n platform,\n });\n\n const location = new URL(pathname, this.getDevServerUrl()!);\n return await getStaticContent(location);\n };\n\n const [{ artifacts: resources }, staticHtml] = await Promise.all([\n this.getStaticResourcesAsync(),\n bundleStaticHtml(),\n ]);\n const content = serializeHtmlWithAssets({\n isExporting,\n resources,\n template: staticHtml,\n devBundleUrl: devBundleUrlPathname,\n baseUrl,\n });\n return {\n content,\n resources,\n };\n }\n\n // Set when the server is started.\n private instanceMetroOptions: Partial<ExpoMetroOptions> = {};\n\n async ssrLoadModule<T extends Record<string, any>>(\n filePath: string,\n specificOptions: Partial<ExpoMetroOptions> = {}\n ): Promise<T> {\n const { baseUrl, routerRoot, isExporting } = this.instanceMetroOptions;\n assert(\n baseUrl != null && routerRoot != null && isExporting != null,\n 'The server must be started before calling ssrLoadModule.'\n );\n\n return (\n await getStaticRenderFunctionsForEntry<T>(\n this.projectRoot,\n this.getDevServerUrl()!,\n {\n // Bundle in Node.js mode for SSR.\n environment: 'node',\n platform: 'web',\n mode: 'development',\n bytecode: false,\n\n ...this.instanceMetroOptions,\n baseUrl,\n routerRoot,\n isExporting,\n ...specificOptions,\n },\n filePath\n )\n ).fn;\n }\n\n async ssrLoadModuleContents(\n filePath: string,\n specificOptions: Partial<ExpoMetroOptions> = {}\n ): Promise<{ src: string; filename: string }> {\n const { baseUrl, routerRoot, isExporting } = this.instanceMetroOptions;\n assert(\n baseUrl != null && routerRoot != null && isExporting != null,\n 'The server must be started before calling ssrLoadModule.'\n );\n\n return await requireFileContentsWithMetro(this.projectRoot, this.getDevServerUrl()!, filePath, {\n // Bundle in Node.js mode for SSR.\n environment: 'node',\n platform: 'web',\n mode: 'development',\n bytecode: false,\n\n ...this.instanceMetroOptions,\n baseUrl,\n routerRoot,\n isExporting,\n ...specificOptions,\n });\n }\n\n async watchEnvironmentVariables() {\n if (!this.instance) {\n throw new Error(\n 'Cannot observe environment variable changes without a running Metro instance.'\n );\n }\n if (!this.metro) {\n // This can happen when the run command is used and the server is already running in another\n // process.\n debug('Skipping Environment Variable observation because Metro is not running (headless).');\n return;\n }\n\n const envFiles = runtimeEnv\n .getFiles(process.env.NODE_ENV)\n .map((fileName) => path.join(this.projectRoot, fileName));\n\n observeFileChanges(\n {\n metro: this.metro,\n server: this.instance.server,\n },\n envFiles,\n () => {\n debug('Reloading environment variables...');\n // Force reload the environment variables.\n runtimeEnv.load(this.projectRoot, { force: true });\n }\n );\n }\n\n getExpoLineOptions() {\n return this.instanceMetroOptions;\n }\n\n protected async startImplementationAsync(\n options: BundlerStartOptions\n ): Promise<DevServerInstance> {\n options.port = await this.resolvePortAsync(options);\n this.urlCreator = this.getUrlCreator(options);\n\n const config = getConfig(this.projectRoot, { skipSDKVersionRequirement: true });\n const { exp } = config;\n const useServerRendering = ['static', 'server'].includes(exp.web?.output ?? '');\n const baseUrl = getBaseUrlFromExpoConfig(exp);\n const asyncRoutes = getAsyncRoutesFromExpoConfig(exp, options.mode ?? 'development', 'web');\n const routerRoot = getRouterDirectoryModuleIdWithManifest(this.projectRoot, exp);\n const appDir = path.join(this.projectRoot, routerRoot);\n const mode = options.mode ?? 'development';\n\n this.instanceMetroOptions = {\n isExporting: !!options.isExporting,\n baseUrl,\n mode,\n routerRoot,\n minify: options.minify,\n asyncRoutes,\n // Options that are changing between platforms like engine, platform, and environment aren't set here.\n };\n\n const parsedOptions = {\n port: options.port,\n maxWorkers: options.maxWorkers,\n resetCache: options.resetDevServer,\n };\n\n // Required for symbolication:\n process.env.EXPO_DEV_SERVER_ORIGIN = `http://localhost:${options.port}`;\n\n const { metro, server, middleware, messageSocket } = await instantiateMetroAsync(\n this,\n parsedOptions,\n {\n isExporting: !!options.isExporting,\n }\n );\n\n const manifestMiddleware = await this.getManifestMiddlewareAsync(options);\n\n // Important that we noop source maps for context modules as soon as possible.\n prependMiddleware(middleware, new ContextModuleSourceMapsMiddleware().getHandler());\n\n // We need the manifest handler to be the first middleware to run so our\n // routes take precedence over static files. For example, the manifest is\n // served from '/' and if the user has an index.html file in their project\n // then the manifest handler will never run, the static middleware will run\n // and serve index.html instead of the manifest.\n // https://github.com/expo/expo/issues/13114\n prependMiddleware(middleware, manifestMiddleware.getHandler());\n\n middleware.use(\n new InterstitialPageMiddleware(this.projectRoot, {\n // TODO: Prevent this from becoming stale.\n scheme: options.location.scheme ?? null,\n }).getHandler()\n );\n middleware.use(new ReactDevToolsPageMiddleware(this.projectRoot).getHandler());\n middleware.use(\n new DevToolsPluginMiddleware(this.projectRoot, this.devToolsPluginManager).getHandler()\n );\n\n const deepLinkMiddleware = new RuntimeRedirectMiddleware(this.projectRoot, {\n onDeepLink: getDeepLinkHandler(this.projectRoot),\n getLocation: ({ runtime }) => {\n if (runtime === 'custom') {\n return this.urlCreator?.constructDevClientUrl();\n } else {\n return this.urlCreator?.constructUrl({\n scheme: 'exp',\n });\n }\n },\n });\n middleware.use(deepLinkMiddleware.getHandler());\n\n middleware.use(new CreateFileMiddleware(this.projectRoot).getHandler());\n\n // Append support for redirecting unhandled requests to the index.html page on web.\n if (this.isTargetingWeb()) {\n // This MUST be after the manifest middleware so it doesn't have a chance to serve the template `public/index.html`.\n middleware.use(new ServeStaticMiddleware(this.projectRoot).getHandler());\n\n // This should come after the static middleware so it doesn't serve the favicon from `public/favicon.ico`.\n middleware.use(new FaviconMiddleware(this.projectRoot).getHandler());\n\n if (useServerRendering) {\n middleware.use(\n createRouteHandlerMiddleware(this.projectRoot, {\n appDir,\n routerRoot,\n config,\n ...config.exp.extra?.router,\n bundleApiRoute: (functionFilePath) => this.ssrImportApiRoute(functionFilePath),\n getStaticPageAsync: (pathname) => {\n return this.getStaticPageAsync(pathname);\n },\n })\n );\n\n observeAnyFileChanges(\n {\n metro,\n server,\n },\n (events) => {\n if (exp.web?.output === 'server') {\n // NOTE(EvanBacon): We aren't sure what files the API routes are using so we'll just invalidate\n // aggressively to ensure we always have the latest. The only caching we really get here is for\n // cases where the user is making subsequent requests to the same API route without changing anything.\n // This is useful for testing but pretty suboptimal. Luckily our caching is pretty aggressive so it makes\n // up for a lot of the overhead.\n this.invalidateApiRouteCache();\n } else if (!hasWarnedAboutApiRoutes()) {\n for (const event of events) {\n if (\n // If the user did not delete a file that matches the Expo Router API Route convention, then we should warn that\n // API Routes are not enabled in the project.\n event.metadata?.type !== 'd' &&\n // Ensure the file is in the project's routes directory to prevent false positives in monorepos.\n event.filePath.startsWith(appDir) &&\n isApiRouteConvention(event.filePath)\n ) {\n warnInvalidWebOutput();\n }\n }\n }\n }\n );\n } else {\n // This MUST run last since it's the fallback.\n middleware.use(\n new HistoryFallbackMiddleware(manifestMiddleware.getHandler().internal).getHandler()\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 this.metro = null;\n callback?.(err);\n });\n };\n\n this.metro = metro;\n return {\n server,\n location: {\n // The port is the main thing we want to send back.\n port: options.port,\n // localhost isn't always correct.\n host: 'localhost',\n // http is the only supported protocol on native.\n url: `http://localhost:${options.port}`,\n protocol: 'http',\n },\n middleware,\n messageSocket,\n };\n }\n\n public async waitForTypeScriptAsync(): Promise<boolean> {\n if (!this.instance) {\n throw new Error('Cannot wait for TypeScript without a running server.');\n }\n\n return new Promise<boolean>((resolve) => {\n if (!this.metro) {\n // This can happen when the run command is used and the server is already running in another\n // process. In this case we can't wait for the TypeScript check to complete because we don't\n // have access to the Metro server.\n debug('Skipping TypeScript check because Metro is not running (headless).');\n return resolve(false);\n }\n\n const off = metroWatchTypeScriptFiles({\n projectRoot: this.projectRoot,\n server: this.instance!.server,\n metro: this.metro,\n tsconfig: true,\n throttle: true,\n eventTypes: ['change', 'add'],\n callback: async () => {\n // Run once, this prevents the TypeScript project prerequisite from running on every file change.\n off();\n const { TypeScriptProjectPrerequisite } = await import(\n '../../doctor/typescript/TypeScriptProjectPrerequisite.js'\n );\n\n try {\n const req = new TypeScriptProjectPrerequisite(this.projectRoot);\n await req.bootstrapAsync();\n resolve(true);\n } catch (error: any) {\n // Ensure the process doesn't fail if the TypeScript check fails.\n // This could happen during the install.\n Log.log();\n Log.error(\n chalk.red`Failed to automatically setup TypeScript for your project. Try restarting the dev server to fix.`\n );\n Log.exception(error);\n resolve(false);\n }\n },\n });\n });\n }\n\n public async startTypeScriptServices() {\n return startTypescriptTypeGenerationAsync({\n server: this.instance?.server,\n metro: this.metro,\n projectRoot: this.projectRoot,\n });\n }\n\n protected getConfigModuleIds(): string[] {\n return ['./metro.config.js', './metro.config.json', './rn-cli.config.js'];\n }\n\n private pendingRouteOperations = new Map<\n string,\n Promise<{ src: string; filename: string; map?: any } | null>\n >();\n\n // API Routes\n\n // Bundle the API Route with Metro and return the string contents to be evaluated in the server.\n private async bundleApiRoute(\n filePath: string\n ): Promise<{ src: string; filename: string; map?: any } | null | undefined> {\n if (this.pendingRouteOperations.has(filePath)) {\n return this.pendingRouteOperations.get(filePath);\n }\n const bundleAsync = async () => {\n try {\n debug('Bundle API route:', this.instanceMetroOptions.routerRoot, filePath);\n return await this.ssrLoadModuleContents(filePath);\n } catch (error: any) {\n if (error instanceof Error) {\n await logMetroErrorAsync({ error, projectRoot: this.projectRoot });\n }\n throw error;\n } finally {\n // pendingRouteOperations.delete(filepath);\n }\n };\n const route = bundleAsync();\n\n this.pendingRouteOperations.set(filePath, route);\n return route;\n }\n\n private async ssrImportApiRoute(\n filePath: string\n ): Promise<null | Record<string, Function> | Response> {\n // TODO: Cache the evaluated function.\n try {\n const apiRoute = await this.bundleApiRoute(filePath);\n\n if (!apiRoute?.src) {\n return null;\n }\n return evalMetroNoHandling(this.projectRoot, apiRoute.src, apiRoute.filename);\n } catch (error) {\n // Format any errors that were thrown in the global scope of the evaluation.\n if (error instanceof Error) {\n try {\n const htmlServerError = await getErrorOverlayHtmlAsync({\n error,\n projectRoot: this.projectRoot,\n routerRoot: this.getExpoLineOptions().routerRoot!,\n });\n\n return new Response(htmlServerError, {\n status: 500,\n headers: {\n 'Content-Type': 'text/html',\n },\n });\n } catch (internalError) {\n debug('Failed to generate Metro server error UI for API Route error:', internalError);\n throw error;\n }\n } else {\n throw error;\n }\n }\n }\n\n private invalidateApiRouteCache() {\n this.pendingRouteOperations.clear();\n }\n}\n\nexport function getDeepLinkHandler(projectRoot: string): DeepLinkHandler {\n return async ({ runtime }) => {\n if (runtime === 'expo') return;\n const { exp } = getConfig(projectRoot);\n await logEventAsync('dev client start command', {\n status: 'started',\n ...getDevClientProperties(projectRoot, exp),\n });\n };\n}\n"],"names":["ForwardHtmlError","MetroBundlerDevServer","getDeepLinkHandler","CommandError","constructor","message","html","statusCode","debug","require","EXPO_GO_METRO_PORT","DEV_CLIENT_METRO_PORT","BundlerDevServer","metro","name","resolvePortAsync","options","port","devClient","Number","process","env","RCT_METRO_PORT","getFreePortAsync","exportExpoRouterApiRoutesAsync","includeSourceMaps","outputDir","prerenderManifest","routerRoot","instanceMetroOptions","assert","appDir","path","join","projectRoot","manifest","getExpoRouterRoutesManifestAsync","files","Map","route","apiRoutes","filepath","file","contents","bundleApiRoute","artifactFilename","relative","replace","src","map","artifactBasename","encodeURIComponent","basename","set","JSON","stringify","version","sources","source","startsWith","split","sep","sourcesContent","Array","length","fill","names","mappings","targetDomain","htmlRoutes","exp","getConfig","fetchManifest","extra","router","platformRoutes","asJson","getStaticRenderFunctionAsync","mode","minify","isExporting","url","getDevServerUrl","getStaticContent","getManifest","getBuildTimeServerManifestAsync","ssrLoadModule","serverManifest","preserveApiRoutes","renderAsync","URL","getStaticResourcesAsync","mainModuleName","data","baseUrl","asyncRoutes","platform","devBundleUrlPathname","createBundleUrlPath","splitChunks","EXPO_NO_BUNDLE_SPLITTING","environment","serializerOutput","serializerIncludeMaps","resolveMainModuleName","lazy","shouldEnableAsyncImports","bytecode","bundleUrl","results","fetch","toString","txt","text","parse","error","ok","status","Log","isArray","artifacts","errors","type","match","Error","getStaticPageAsync","pathname","bundleStaticHtml","location","resources","staticHtml","Promise","all","content","serializeHtmlWithAssets","template","devBundleUrl","filePath","specificOptions","getStaticRenderFunctionsForEntry","fn","ssrLoadModuleContents","requireFileContentsWithMetro","watchEnvironmentVariables","instance","envFiles","runtimeEnv","getFiles","NODE_ENV","fileName","observeFileChanges","server","load","force","getExpoLineOptions","startImplementationAsync","urlCreator","getUrlCreator","config","skipSDKVersionRequirement","useServerRendering","includes","web","output","getBaseUrlFromExpoConfig","getAsyncRoutesFromExpoConfig","getRouterDirectoryModuleIdWithManifest","parsedOptions","maxWorkers","resetCache","resetDevServer","EXPO_DEV_SERVER_ORIGIN","middleware","messageSocket","instantiateMetroAsync","manifestMiddleware","getManifestMiddlewareAsync","prependMiddleware","ContextModuleSourceMapsMiddleware","getHandler","use","InterstitialPageMiddleware","scheme","ReactDevToolsPageMiddleware","DevToolsPluginMiddleware","devToolsPluginManager","deepLinkMiddleware","RuntimeRedirectMiddleware","onDeepLink","getLocation","runtime","constructDevClientUrl","constructUrl","CreateFileMiddleware","isTargetingWeb","ServeStaticMiddleware","FaviconMiddleware","createRouteHandlerMiddleware","functionFilePath","ssrImportApiRoute","observeAnyFileChanges","events","invalidateApiRouteCache","hasWarnedAboutApiRoutes","event","metadata","isApiRouteConvention","warnInvalidWebOutput","HistoryFallbackMiddleware","internal","originalClose","close","bind","callback","err","host","protocol","waitForTypeScriptAsync","resolve","off","metroWatchTypeScriptFiles","tsconfig","throttle","eventTypes","TypeScriptProjectPrerequisite","req","bootstrapAsync","log","chalk","red","exception","startTypeScriptServices","startTypescriptTypeGenerationAsync","getConfigModuleIds","pendingRouteOperations","has","get","bundleAsync","logMetroErrorAsync","apiRoute","evalMetroNoHandling","filename","htmlServerError","getErrorOverlayHtmlAsync","Response","headers","internalError","clear","logEventAsync","getDevClientProperties"],"mappings":"AAAA;;;;;CAKC,GACD;;;;;;;;;;;IA8DaA,gBAAgB,MAAhBA,gBAAgB;IAkBhBC,qBAAqB,MAArBA,qBAAqB;IA4rBlBC,kBAAkB,MAAlBA,kBAAkB;;;yBA5wBR,cAAc;;;;;;;+DACZ,WAAW;;;;;;;8DAEpB,QAAQ;;;;;;;8DACT,OAAO;;;;;;;8DAEP,YAAY;;;;;;;8DACb,MAAM;;;;;;6CAEsB,+BAA+B;qCAClB,uBAAuB;kCAC3C,oBAAoB;qCACG,uBAAuB;2CAC1C,6BAA6B;wBAMhE,UAAU;+BACuB,iBAAiB;qDACC,uCAAuC;qBAE7E,cAAc;6EACC,iDAAiD;sBAChE,oBAAoB;wBACX,uBAAuB;sBACnB,qBAAqB;2BACxB,0BAA0B;kCACiB,qBAAqB;0CAKvF,6BAA6B;mDACc,iDAAiD;sCAC9D,oCAAoC;0CAChC,wCAAwC;mCAC/C,iCAAiC;2CACzB,yCAAyC;4CACxC,0CAA0C;oCAC/C,kCAAkC;6CAC5B,2CA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,EAAE,CAAC;IACtC;CACD;AAEM,SAASrP,kBAAkB,CAACgC,WAAmB,EAAmB;IACvE,OAAO,OAAO,EAAE4J,OAAO,CAAA,EAAE,GAAK;QAC5B,IAAIA,OAAO,KAAK,MAAM,EAAE,OAAO;QAC/B,MAAM,EAAExH,GAAG,CAAA,EAAE,GAAGC,IAAAA,OAAS,EAAA,UAAA,EAACrC,WAAW,CAAC,AAAC;QACvC,MAAMsN,IAAAA,UAAa,cAAA,EAAC,0BAA0B,EAAE;YAC9CnI,MAAM,EAAE,SAAS;YACjB,GAAGoI,IAAAA,uBAAsB,QAAA,EAACvN,WAAW,EAAEoC,GAAG,CAAC;SAC5C,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -91,6 +91,13 @@ class TerminalReporter extends XTerminalReporter {
|
|
|
91
91
|
* @param event event object.
|
|
92
92
|
* @param duration duration of the build in milliseconds.
|
|
93
93
|
*/ bundleBuildEnded(event, duration) {}
|
|
94
|
+
_logWatcherStatus(status) {
|
|
95
|
+
// Metro logs this warning twice. This helps reduce the noise.
|
|
96
|
+
if (status.type === "watchman_warning") {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
return super._logWatcherStatus(status);
|
|
100
|
+
}
|
|
94
101
|
/**
|
|
95
102
|
* This function is exclusively concerned with updating the internal state.
|
|
96
103
|
* No logging or status updates should be done at this point.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/TerminalReporter.ts"],"sourcesContent":["// This file represents an abstraction on the metro TerminalReporter.\n// We use this abstraction to safely extend the TerminalReporter for our own custom logging.\nimport chalk from 'chalk';\nimport UpstreamTerminalReporter from 'metro/src/lib/TerminalReporter';\nimport { Terminal } from 'metro-core';\nimport util from 'util';\n\nimport {\n BundleDetails,\n BundleProgressUpdate,\n TerminalReportableEvent,\n TerminalReporterInterface,\n} from './TerminalReporter.types';\nimport { stripAnsi } from '../../../utils/ansi';\n\nconst debug = require('debug')('expo:metro:logger') as typeof console.log;\n\n/**\n * A standard way to log a warning to the terminal. This should not be called\n * from some arbitrary Metro logic, only from the reporters. Instead of\n * calling this, add a new type of ReportableEvent instead, and implement a\n * proper handler in the reporter(s).\n */\nexport function logWarning(terminal: Terminal, format: string, ...args: any[]): void {\n const str = util.format(format, ...args);\n terminal.log('%s: %s', chalk.yellow('warning'), str);\n}\n\n/**\n * Similar to `logWarning`, but for messages that require the user to act.\n */\nexport function logError(terminal: Terminal, format: string, ...args: any[]): void {\n terminal.log(\n '%s: %s',\n chalk.red('error'),\n // Syntax errors may have colors applied for displaying code frames\n // in various places outside of where Metro is currently running.\n // If the current terminal does not support color, we'll strip the colors\n // here.\n util.format(chalk.supportsColor ? format : stripAnsi(format), ...args)\n );\n}\n\nconst XTerminalReporter = UpstreamTerminalReporter as unknown as TerminalReporterInterface;\n\n/** Extended TerminalReporter class but with proper types and extra functionality to avoid using the `_log` method directly in subclasses. */\nexport class TerminalReporter extends XTerminalReporter implements TerminalReporterInterface {\n /**\n * A cache of { [buildID]: BundleDetails } which can be used to\n * add more contextual logs. BundleDetails is currently only sent with `bundle_build_started`\n * so we need to cache the details in order to print the platform info with other event types.\n */\n _bundleDetails: Map<string, BundleDetails> = new Map();\n\n /** Keep track of how long a bundle takes to complete */\n _bundleTimers: Map<string, number> = new Map();\n\n /** Keep track of bundle processes that should not be logged. */\n _hiddenBundleEvents: Set<string> = new Set();\n\n _log(event: TerminalReportableEvent): void {\n switch (event.type) {\n case 'transform_cache_reset':\n return this.transformCacheReset();\n case 'dep_graph_loading':\n return this.dependencyGraphLoading(event.hasReducedPerformance);\n case 'client_log':\n if (this.shouldFilterClientLog(event)) {\n return;\n }\n break;\n }\n return super._log(event);\n }\n\n /** Gives subclasses an easy interface for filtering out logs. Return `true` to skip. */\n shouldFilterClientLog(event: {\n type: 'client_log';\n level: 'trace' | 'info' | 'warn' | 'log' | 'group' | 'groupCollapsed' | 'groupEnd' | 'debug';\n data: unknown[];\n }): boolean {\n return false;\n }\n\n /** Gives subclasses an easy interface for filtering out bundle events, specifically for source maps. Return `true` to skip. */\n shouldFilterBundleEvent(event: TerminalReportableEvent): boolean {\n return false;\n }\n\n /** Cache has been reset. */\n transformCacheReset(): void {}\n\n /** One of the first logs that will be printed. */\n dependencyGraphLoading(hasReducedPerformance: boolean): void {}\n\n /**\n * Custom log event representing the end of the bundling.\n *\n * @param event event object.\n * @param duration duration of the build in milliseconds.\n */\n bundleBuildEnded(event: TerminalReportableEvent, duration: number): void {}\n\n /**\n * This function is exclusively concerned with updating the internal state.\n * No logging or status updates should be done at this point.\n */\n _updateState(\n event: TerminalReportableEvent & { bundleDetails?: BundleDetails; buildID?: string }\n ) {\n // Append the buildID to the bundleDetails.\n if (event.bundleDetails) {\n event.bundleDetails.buildID = event.buildID;\n }\n\n const buildID = event.bundleDetails?.buildID ?? event.buildID;\n\n if (buildID && !this._hiddenBundleEvents.has(buildID)) {\n if (this.shouldFilterBundleEvent(event)) {\n debug('skipping bundle events for', buildID, event);\n this._hiddenBundleEvents.add(buildID);\n } else {\n super._updateState(event);\n }\n } else {\n super._updateState(event);\n }\n\n switch (event.type) {\n case 'bundle_build_done':\n case 'bundle_build_failed': {\n const startTime = this._bundleTimers.get(event.buildID);\n // Observed a bug in Metro where the `bundle_build_done` is invoked twice during a static bundle\n // i.e. `expo export`.\n if (startTime == null) {\n break;\n }\n\n this.bundleBuildEnded(event, startTime ? Date.now() - startTime : 0);\n this._bundleTimers.delete(event.buildID);\n break;\n }\n case 'bundle_build_started':\n this._bundleDetails.set(event.buildID, event.bundleDetails);\n this._bundleTimers.set(event.buildID, Date.now());\n break;\n }\n }\n\n /**\n * We use Math.pow(ratio, 2) to as a conservative measure of progress because\n * we know the `totalCount` is going to progressively increase as well. We\n * also prevent the ratio from going backwards.\n */\n _updateBundleProgress(options: BundleProgressUpdate) {\n super._updateBundleProgress(options);\n\n const currentProgress = this._activeBundles.get(options.buildID);\n if (!currentProgress) {\n return;\n }\n\n // Fix an issue where the transformer is faster than the resolver,\n // locking the progress bar at 100% after transforming the first and only resolved file (1/1).\n if (currentProgress.ratio === 1 && options.totalFileCount === 1) {\n Object.assign(currentProgress, { ...currentProgress, ratio: 0 });\n }\n }\n}\n"],"names":["logWarning","logError","TerminalReporter","debug","require","terminal","format","args","str","util","log","chalk","yellow","red","supportsColor","stripAnsi","XTerminalReporter","UpstreamTerminalReporter","_bundleDetails","Map","_bundleTimers","_hiddenBundleEvents","Set","_log","event","type","transformCacheReset","dependencyGraphLoading","hasReducedPerformance","shouldFilterClientLog","shouldFilterBundleEvent","bundleBuildEnded","duration","_updateState","bundleDetails","buildID","has","add","startTime","get","Date","now","delete","set","_updateBundleProgress","options","currentProgress","_activeBundles","ratio","totalFileCount","Object","assign"],"mappings":"AAAA,qEAAqE;AACrE,4FAA4F;AAC5F;;;;;;;;;;;IAqBgBA,UAAU,MAAVA,UAAU;IAQVC,QAAQ,MAARA,QAAQ;IAeXC,gBAAgB,MAAhBA,gBAAgB;;;8DA5CX,OAAO;;;;;;;8DACY,gCAAgC;;;;;;;8DAEpD,MAAM;;;;;;sBAQG,qBAAqB;;;;;;AAE/C,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC,AAAsB,AAAC;AAQnE,SAASJ,UAAU,CAACK,QAAkB,EAAEC,MAAc,EAAE,GAAGC,IAAI,AAAO,EAAQ;IACnF,MAAMC,GAAG,GAAGC,KAAI,EAAA,QAAA,CAACH,MAAM,CAACA,MAAM,KAAKC,IAAI,CAAC,AAAC;IACzCF,QAAQ,CAACK,GAAG,CAAC,QAAQ,EAAEC,MAAK,EAAA,QAAA,CAACC,MAAM,CAAC,SAAS,CAAC,EAAEJ,GAAG,CAAC,CAAC;AACvD,CAAC;AAKM,SAASP,QAAQ,CAACI,QAAkB,EAAEC,MAAc,EAAE,GAAGC,IAAI,AAAO,EAAQ;IACjFF,QAAQ,CAACK,GAAG,CACV,QAAQ,EACRC,MAAK,EAA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CAACC,GAAG,EAAE,GAAGH,SAAS,GAAG,CAAC,CAAC,CAAC;oBACrE,IAAI,CAAClB,aAAa,CAACsB,MAAM,CAAClB,KAAK,CAACW,OAAO,CAAC,CAAC;oBACzC,MAAM;gBACR,CAAC;YACD,KAAK,sBAAsB;gBACzB,IAAI,CAACjB,cAAc,CAACyB,GAAG,CAACnB,KAAK,CAACW,OAAO,EAAEX,KAAK,CAACU,aAAa,CAAC,CAAC;gBAC5D,IAAI,CAACd,aAAa,CAACuB,GAAG,CAACnB,KAAK,CAACW,OAAO,EAAEK,IAAI,CAACC,GAAG,EAAE,CAAC,CAAC;gBAClD,MAAM;SACT;IACH;IAEA;;;;GAIC,GACDG,qBAAqB,CAACC,OAA6B,EAAE;QACnD,KAAK,CAACD,qBAAqB,CAACC,OAAO,CAAC,CAAC;QAErC,MAAMC,eAAe,GAAG,IAAI,CAACC,cAAc,CAACR,GAAG,CAACM,OAAO,CAACV,OAAO,CAAC,AAAC;QACjE,IAAI,CAACW,eAAe,EAAE;YACpB,OAAO;QACT,CAAC;QAED,kEAAkE;QAClE,8FAA8F;QAC9F,IAAIA,eAAe,CAACE,KAAK,KAAK,CAAC,IAAIH,OAAO,CAACI,cAAc,KAAK,CAAC,EAAE;YAC/DC,MAAM,CAACC,MAAM,CAACL,eAAe,EAAE;gBAAE,GAAGA,eAAe;gBAAEE,KAAK,EAAE,CAAC;aAAE,CAAC,CAAC;QACnE,CAAC;IACH;CACD"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/TerminalReporter.ts"],"sourcesContent":["// This file represents an abstraction on the metro TerminalReporter.\n// We use this abstraction to safely extend the TerminalReporter for our own custom logging.\nimport chalk from 'chalk';\nimport UpstreamTerminalReporter from 'metro/src/lib/TerminalReporter';\nimport { Terminal } from 'metro-core';\nimport type { WatcherStatus } from 'metro-file-map';\nimport util from 'util';\n\nimport {\n BundleDetails,\n BundleProgressUpdate,\n TerminalReportableEvent,\n TerminalReporterInterface,\n} from './TerminalReporter.types';\nimport { stripAnsi } from '../../../utils/ansi';\n\nconst debug = require('debug')('expo:metro:logger') as typeof console.log;\n\n/**\n * A standard way to log a warning to the terminal. This should not be called\n * from some arbitrary Metro logic, only from the reporters. Instead of\n * calling this, add a new type of ReportableEvent instead, and implement a\n * proper handler in the reporter(s).\n */\nexport function logWarning(terminal: Terminal, format: string, ...args: any[]): void {\n const str = util.format(format, ...args);\n terminal.log('%s: %s', chalk.yellow('warning'), str);\n}\n\n/**\n * Similar to `logWarning`, but for messages that require the user to act.\n */\nexport function logError(terminal: Terminal, format: string, ...args: any[]): void {\n terminal.log(\n '%s: %s',\n chalk.red('error'),\n // Syntax errors may have colors applied for displaying code frames\n // in various places outside of where Metro is currently running.\n // If the current terminal does not support color, we'll strip the colors\n // here.\n util.format(chalk.supportsColor ? format : stripAnsi(format), ...args)\n );\n}\n\nconst XTerminalReporter = UpstreamTerminalReporter as unknown as TerminalReporterInterface;\n\n/** Extended TerminalReporter class but with proper types and extra functionality to avoid using the `_log` method directly in subclasses. */\nexport class TerminalReporter extends XTerminalReporter implements TerminalReporterInterface {\n /**\n * A cache of { [buildID]: BundleDetails } which can be used to\n * add more contextual logs. BundleDetails is currently only sent with `bundle_build_started`\n * so we need to cache the details in order to print the platform info with other event types.\n */\n _bundleDetails: Map<string, BundleDetails> = new Map();\n\n /** Keep track of how long a bundle takes to complete */\n _bundleTimers: Map<string, number> = new Map();\n\n /** Keep track of bundle processes that should not be logged. */\n _hiddenBundleEvents: Set<string> = new Set();\n\n _log(event: TerminalReportableEvent): void {\n switch (event.type) {\n case 'transform_cache_reset':\n return this.transformCacheReset();\n case 'dep_graph_loading':\n return this.dependencyGraphLoading(event.hasReducedPerformance);\n case 'client_log':\n if (this.shouldFilterClientLog(event)) {\n return;\n }\n break;\n }\n return super._log(event);\n }\n\n /** Gives subclasses an easy interface for filtering out logs. Return `true` to skip. */\n shouldFilterClientLog(event: {\n type: 'client_log';\n level: 'trace' | 'info' | 'warn' | 'log' | 'group' | 'groupCollapsed' | 'groupEnd' | 'debug';\n data: unknown[];\n }): boolean {\n return false;\n }\n\n /** Gives subclasses an easy interface for filtering out bundle events, specifically for source maps. Return `true` to skip. */\n shouldFilterBundleEvent(event: TerminalReportableEvent): boolean {\n return false;\n }\n\n /** Cache has been reset. */\n transformCacheReset(): void {}\n\n /** One of the first logs that will be printed. */\n dependencyGraphLoading(hasReducedPerformance: boolean): void {}\n\n /**\n * Custom log event representing the end of the bundling.\n *\n * @param event event object.\n * @param duration duration of the build in milliseconds.\n */\n bundleBuildEnded(event: TerminalReportableEvent, duration: number): void {}\n\n _logWatcherStatus(status: WatcherStatus) {\n // Metro logs this warning twice. This helps reduce the noise.\n\n if (status.type === 'watchman_warning') {\n return;\n }\n return super._logWatcherStatus(status);\n }\n\n /**\n * This function is exclusively concerned with updating the internal state.\n * No logging or status updates should be done at this point.\n */\n _updateState(\n event: TerminalReportableEvent & { bundleDetails?: BundleDetails; buildID?: string }\n ) {\n // Append the buildID to the bundleDetails.\n if (event.bundleDetails) {\n event.bundleDetails.buildID = event.buildID;\n }\n\n const buildID = event.bundleDetails?.buildID ?? event.buildID;\n\n if (buildID && !this._hiddenBundleEvents.has(buildID)) {\n if (this.shouldFilterBundleEvent(event)) {\n debug('skipping bundle events for', buildID, event);\n this._hiddenBundleEvents.add(buildID);\n } else {\n super._updateState(event);\n }\n } else {\n super._updateState(event);\n }\n\n switch (event.type) {\n case 'bundle_build_done':\n case 'bundle_build_failed': {\n const startTime = this._bundleTimers.get(event.buildID);\n // Observed a bug in Metro where the `bundle_build_done` is invoked twice during a static bundle\n // i.e. `expo export`.\n if (startTime == null) {\n break;\n }\n\n this.bundleBuildEnded(event, startTime ? Date.now() - startTime : 0);\n this._bundleTimers.delete(event.buildID);\n break;\n }\n case 'bundle_build_started':\n this._bundleDetails.set(event.buildID, event.bundleDetails);\n this._bundleTimers.set(event.buildID, Date.now());\n break;\n }\n }\n\n /**\n * We use Math.pow(ratio, 2) to as a conservative measure of progress because\n * we know the `totalCount` is going to progressively increase as well. We\n * also prevent the ratio from going backwards.\n */\n _updateBundleProgress(options: BundleProgressUpdate) {\n super._updateBundleProgress(options);\n\n const currentProgress = this._activeBundles.get(options.buildID);\n if (!currentProgress) {\n return;\n }\n\n // Fix an issue where the transformer is faster than the resolver,\n // locking the progress bar at 100% after transforming the first and only resolved file (1/1).\n if (currentProgress.ratio === 1 && options.totalFileCount === 1) {\n Object.assign(currentProgress, { ...currentProgress, ratio: 0 });\n }\n }\n}\n"],"names":["logWarning","logError","TerminalReporter","debug","require","terminal","format","args","str","util","log","chalk","yellow","red","supportsColor","stripAnsi","XTerminalReporter","UpstreamTerminalReporter","_bundleDetails","Map","_bundleTimers","_hiddenBundleEvents","Set","_log","event","type","transformCacheReset","dependencyGraphLoading","hasReducedPerformance","shouldFilterClientLog","shouldFilterBundleEvent","bundleBuildEnded","duration","_logWatcherStatus","status","_updateState","bundleDetails","buildID","has","add","startTime","get","Date","now","delete","set","_updateBundleProgress","options","currentProgress","_activeBundles","ratio","totalFileCount","Object","assign"],"mappings":"AAAA,qEAAqE;AACrE,4FAA4F;AAC5F;;;;;;;;;;;IAsBgBA,UAAU,MAAVA,UAAU;IAQVC,QAAQ,MAARA,QAAQ;IAeXC,gBAAgB,MAAhBA,gBAAgB;;;8DA7CX,OAAO;;;;;;;8DACY,gCAAgC;;;;;;;8DAGpD,MAAM;;;;;;sBAQG,qBAAqB;;;;;;AAE/C,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC,AAAsB,AAAC;AAQnE,SAASJ,UAAU,CAACK,QAAkB,EAAEC,MAAc,EAAE,GAAGC,IAAI,AAAO,EAAQ;IACnF,MAAMC,GAAG,GAAGC,KAAI,EAAA,QAAA,CAACH,MAAM,CAACA,MAAM,KAAKC,IAAI,CAAC,AAAC;IACzCF,QAAQ,CAACK,GAAG,CAAC,QAAQ,EAAEC,MAAK,EAAA,QAAA,CAACC,MAAM,CAAC,SAAS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CAAC;aAAE,CAAC,CAAC;QACnE,CAAC;IACH;CACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/TerminalReporter.types.ts"],"sourcesContent":["import type { ReportableEvent } from 'metro';\nimport type { TerminalReportableEvent } from 'metro/src/lib/TerminalReporter';\nimport type { Terminal } from 'metro-core';\n\nimport { MetroEnvironment } from '../middleware/metroOptions';\n\nexport type GlobalCacheDisabledReason = 'too_many_errors' | 'too_many_misses';\n\nexport type BundleDetails = {\n buildID?: string;\n bundleType: string;\n dev: boolean;\n entryFile: string;\n minify: boolean;\n platform: string | null | undefined;\n customTransformOptions?: { environment?: MetroEnvironment };\n runtimeBytecodeVersion: number | null | undefined;\n};\n\nexport type BundleProgress = {\n bundleDetails: BundleDetails;\n transformedFileCount: number;\n totalFileCount: number;\n ratio: number;\n};\n\nexport type BundleProgressUpdate = {\n buildID: string;\n transformedFileCount: number;\n totalFileCount: number;\n};\n\nexport { TerminalReportableEvent };\n\nexport type BuildPhase = 'in_progress' | 'done' | 'failed';\n\n/**\n * Code across the application takes a reporter as an option and calls the\n * update whenever one of the ReportableEvent happens. Code does not directly\n * write to the standard output, because a build would be:\n *\n * 1. ad-hoc, embedded into another tool, in which case we do not want to\n * pollute that tool's own output. The tool is free to present the\n * warnings/progress we generate any way they want, by specifying a custom\n * reporter.\n * 2. run as a background process from another tool, in which case we want\n * to expose updates in a way that is easily machine-readable, for example\n * a JSON-stream. We don't want to pollute it with textual messages.\n *\n * We centralize terminal reporting into a single place because we want the\n * output to be robust and consistent. The most common reporter is\n * TerminalReporter, that should be the only place in the application should\n * access the `terminal` module (nor the `console`).\n */\nexport type Reporter = { update(event: ReportableEvent): void };\n\nexport interface SnippetError extends Error {\n code?: string;\n filename?: string;\n snippet?: string;\n\n /** Module that failed to load ex 'fs' */\n targetModuleName?: string;\n originModulePath?: string;\n\n errors?: any[];\n}\n\nexport interface TerminalReporterInterface {\n new (terminal: Terminal): TerminalReporterInterface;\n\n /**\n * The bundle builds for which we are actively maintaining the status on the\n * terminal, ie. showing a progress bar. There can be several bundles being\n * built at the same time.\n */\n _activeBundles: Map<string, BundleProgress>;\n\n _scheduleUpdateBundleProgress: {\n (data: { buildID: string; transformedFileCount: number; totalFileCount: number }): void;\n cancel(): void;\n };\n\n /** Set in super type */\n terminal: Terminal;\n\n /**\n * Construct a message that represents the progress of a\n * single bundle build, for example:\n *\n * BUNDLE path/to/bundle.js ▓▓▓▓▓░░░░░░░░░░░ 36.6% (4790/7922)\n */\n _getBundleStatusMessage(\n {\n bundleDetails: { entryFile, bundleType, runtimeBytecodeVersion },\n transformedFileCount,\n totalFileCount,\n ratio,\n }: BundleProgress,\n phase: BuildPhase\n ): string;\n\n /**\n * This function is only concerned with logging and should not do state\n * or terminal status updates.\n */\n _log(event: TerminalReportableEvent): void;\n\n _logCacheDisabled(reason: GlobalCacheDisabledReason): void;\n\n _logBundleBuildDone(buildID: string): void;\n\n _logBundleBuildFailed(buildID: string): void;\n\n _logInitializing(port: number, hasReducedPerformance: boolean): void;\n\n _logInitializingFailed(port: number, error: SnippetError): void;\n\n /**\n * We do not want to log the whole stacktrace for bundling error, because\n * these are operational errors, not programming errors, and the stacktrace\n * is not actionable to end users.\n */\n _logBundlingError(error: SnippetError): void;\n\n /**\n * We use Math.pow(ratio, 2) to as a conservative measure of progress because\n * we know the `totalCount` is going to progressively increase as well. We\n * also prevent the ratio from going backwards.\n */\n _updateBundleProgress({\n buildID,\n transformedFileCount,\n totalFileCount,\n }: BundleProgressUpdate): void;\n\n /**\n * This function is exclusively concerned with updating the internal state.\n * No logging or status updates should be done at this point.\n */\n _updateState(event: TerminalReportableEvent): void;\n /**\n * Return a status message that is always consistent with the current state\n * of the application. Having this single function ensures we don't have\n * different call sites overriding each other status messages.\n */\n _getStatusMessage(): string;\n\n _logHmrClientError(e: Error): void;\n\n /**\n * Single entry point for reporting events. That allows us to implement the\n * corresponding JSON reporter easily and have a consistent reporting.\n */\n update(event: TerminalReportableEvent): void;\n}\n"],"names":[],"mappings":"AAAA"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/TerminalReporter.types.ts"],"sourcesContent":["import type { ReportableEvent } from 'metro';\nimport type { TerminalReportableEvent } from 'metro/src/lib/TerminalReporter';\nimport type { Terminal } from 'metro-core';\nimport type { WatcherStatus } from 'metro-file-map';\n\nimport { MetroEnvironment } from '../middleware/metroOptions';\n\nexport type GlobalCacheDisabledReason = 'too_many_errors' | 'too_many_misses';\n\nexport type BundleDetails = {\n buildID?: string;\n bundleType: string;\n dev: boolean;\n entryFile: string;\n minify: boolean;\n platform: string | null | undefined;\n customTransformOptions?: { environment?: MetroEnvironment };\n runtimeBytecodeVersion: number | null | undefined;\n};\n\nexport type BundleProgress = {\n bundleDetails: BundleDetails;\n transformedFileCount: number;\n totalFileCount: number;\n ratio: number;\n};\n\nexport type BundleProgressUpdate = {\n buildID: string;\n transformedFileCount: number;\n totalFileCount: number;\n};\n\nexport { TerminalReportableEvent };\n\nexport type BuildPhase = 'in_progress' | 'done' | 'failed';\n\n/**\n * Code across the application takes a reporter as an option and calls the\n * update whenever one of the ReportableEvent happens. Code does not directly\n * write to the standard output, because a build would be:\n *\n * 1. ad-hoc, embedded into another tool, in which case we do not want to\n * pollute that tool's own output. The tool is free to present the\n * warnings/progress we generate any way they want, by specifying a custom\n * reporter.\n * 2. run as a background process from another tool, in which case we want\n * to expose updates in a way that is easily machine-readable, for example\n * a JSON-stream. We don't want to pollute it with textual messages.\n *\n * We centralize terminal reporting into a single place because we want the\n * output to be robust and consistent. The most common reporter is\n * TerminalReporter, that should be the only place in the application should\n * access the `terminal` module (nor the `console`).\n */\nexport type Reporter = { update(event: ReportableEvent): void };\n\nexport interface SnippetError extends Error {\n code?: string;\n filename?: string;\n snippet?: string;\n\n /** Module that failed to load ex 'fs' */\n targetModuleName?: string;\n originModulePath?: string;\n\n errors?: any[];\n}\n\nexport interface TerminalReporterInterface {\n new (terminal: Terminal): TerminalReporterInterface;\n\n /**\n * The bundle builds for which we are actively maintaining the status on the\n * terminal, ie. showing a progress bar. There can be several bundles being\n * built at the same time.\n */\n _activeBundles: Map<string, BundleProgress>;\n\n _scheduleUpdateBundleProgress: {\n (data: { buildID: string; transformedFileCount: number; totalFileCount: number }): void;\n cancel(): void;\n };\n\n /** Set in super type */\n terminal: Terminal;\n\n /**\n * Construct a message that represents the progress of a\n * single bundle build, for example:\n *\n * BUNDLE path/to/bundle.js ▓▓▓▓▓░░░░░░░░░░░ 36.6% (4790/7922)\n */\n _getBundleStatusMessage(\n {\n bundleDetails: { entryFile, bundleType, runtimeBytecodeVersion },\n transformedFileCount,\n totalFileCount,\n ratio,\n }: BundleProgress,\n phase: BuildPhase\n ): string;\n\n _logWatcherStatus(event: WatcherStatus): void;\n\n /**\n * This function is only concerned with logging and should not do state\n * or terminal status updates.\n */\n _log(event: TerminalReportableEvent): void;\n\n _logCacheDisabled(reason: GlobalCacheDisabledReason): void;\n\n _logBundleBuildDone(buildID: string): void;\n\n _logBundleBuildFailed(buildID: string): void;\n\n _logInitializing(port: number, hasReducedPerformance: boolean): void;\n\n _logInitializingFailed(port: number, error: SnippetError): void;\n\n /**\n * We do not want to log the whole stacktrace for bundling error, because\n * these are operational errors, not programming errors, and the stacktrace\n * is not actionable to end users.\n */\n _logBundlingError(error: SnippetError): void;\n\n /**\n * We use Math.pow(ratio, 2) to as a conservative measure of progress because\n * we know the `totalCount` is going to progressively increase as well. We\n * also prevent the ratio from going backwards.\n */\n _updateBundleProgress({\n buildID,\n transformedFileCount,\n totalFileCount,\n }: BundleProgressUpdate): void;\n\n /**\n * This function is exclusively concerned with updating the internal state.\n * No logging or status updates should be done at this point.\n */\n _updateState(event: TerminalReportableEvent): void;\n /**\n * Return a status message that is always consistent with the current state\n * of the application. Having this single function ensures we don't have\n * different call sites overriding each other status messages.\n */\n _getStatusMessage(): string;\n\n _logHmrClientError(e: Error): void;\n\n /**\n * Single entry point for reporting events. That allows us to implement the\n * corresponding JSON reporter easily and have a consistent reporting.\n */\n update(event: TerminalReportableEvent): void;\n}\n"],"names":[],"mappings":"AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/createServerRouteMiddleware.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { ProjectConfig } from '@expo/config';\nimport resolve from 'resolve';\nimport resolveFrom from 'resolve-from';\nimport { promisify } from 'util';\n\nimport { ForwardHtmlError } from './MetroBundlerDevServer';\nimport { fetchManifest } from './fetchRouterManifest';\nimport { getErrorOverlayHtmlAsync, logMetroError } from './metroErrorInterface';\nimport { warnInvalidWebOutput } from './router';\nimport { CommandError } from '../../../utils/errors';\n\nconst debug = require('debug')('expo:start:server:metro') as typeof console.log;\n\nconst resolveAsync = promisify(resolve) as any as (\n id: string,\n opts: resolve.AsyncOpts\n) => Promise<string | null>;\n\nexport function createRouteHandlerMiddleware(\n projectRoot: string,\n options: {\n appDir: string;\n routerRoot: string;\n getStaticPageAsync: (pathname: string) => Promise<{ content: string }>;\n bundleApiRoute: (\n functionFilePath: string\n ) => Promise<null | Record<string, Function> | Response>;\n config: ProjectConfig;\n }\n) {\n if (!resolveFrom.silent(projectRoot, 'expo-router')) {\n throw new CommandError(\n 'static and server rendering requires the expo-router package to be installed in your project.'\n );\n }\n\n const { createRequestHandler } =\n require('@expo/server/build/vendor/http') as typeof import('@expo/server/build/vendor/http');\n\n return createRequestHandler(\n { build: '' },\n {\n async getRoutesManifest() {\n const manifest = await fetchManifest<RegExp>(projectRoot, options);\n debug('manifest', manifest);\n // NOTE: no app dir if null\n // TODO: Redirect to 404 page\n return (\n manifest ?? {\n // Support the onboarding screen if there's no manifest\n htmlRoutes: [\n {\n file: 'index.js',\n page: '/index',\n routeKeys: {},\n namedRegex: /^\\/(?:index)?\\/?$/i,\n },\n ],\n apiRoutes: [],\n notFoundRoutes: [],\n }\n );\n },\n async getHtml(request) {\n try {\n const { content } = await options.getStaticPageAsync(request.url);\n return content;\n } catch (error: any) {\n // Forward the Metro server response as-is. It won't be pretty, but at least it will be accurate.\n if (error instanceof ForwardHtmlError) {\n return new Response(error.html, {\n status: error.statusCode,\n headers: {\n 'Content-Type': 'text/html',\n },\n });\n }\n\n try {\n return new Response(\n await getErrorOverlayHtmlAsync({\n error,\n projectRoot,\n routerRoot: options.routerRoot,\n }),\n {\n status: 500,\n headers: {\n 'Content-Type': 'text/html',\n },\n }\n );\n } catch (staticError: any) {\n debug('Failed to render static error overlay:', staticError);\n // Fallback error for when Expo Router is misconfigured in the project.\n return new Response(\n '<span><h3>Internal Error:</h3><b>Project is not setup correctly for static rendering (check terminal for more info):</b><br/>' +\n error.message +\n '<br/><br/>' +\n staticError.message +\n '</span>',\n {\n status: 500,\n headers: {\n 'Content-Type': 'text/html',\n },\n }\n );\n }\n }\n },\n logApiRouteExecutionError(error) {\n logMetroError(projectRoot, { error });\n },\n async getApiRoute(route) {\n const { exp } = options.config;\n if (exp.web?.output !== 'server') {\n warnInvalidWebOutput();\n }\n\n const resolvedFunctionPath = await resolveAsync(route.file, {\n extensions: ['.js', '.jsx', '.ts', '.tsx'],\n basedir: options.appDir,\n })!;\n\n try {\n debug(`Bundling middleware at: ${resolvedFunctionPath}`);\n return await options.bundleApiRoute(resolvedFunctionPath!);\n } catch (error: any) {\n return new Response(\n 'Failed to load API Route: ' + resolvedFunctionPath + '\\n\\n' + error.message,\n {\n status: 500,\n headers: {\n 'Content-Type': 'text/html',\n },\n }\n );\n }\n },\n }\n );\n}\n"],"names":["createRouteHandlerMiddleware","debug","require","resolveAsync","promisify","resolve","projectRoot","options","resolveFrom","silent","CommandError","createRequestHandler","build","getRoutesManifest","manifest","fetchManifest","htmlRoutes","file","page","routeKeys","namedRegex","apiRoutes","notFoundRoutes","getHtml","request","content","getStaticPageAsync","url","error","ForwardHtmlError","Response","html","status","statusCode","headers","getErrorOverlayHtmlAsync","routerRoot","staticError","message","logApiRouteExecutionError","logMetroError","getApiRoute","route","exp","config","web","output","warnInvalidWebOutput","resolvedFunctionPath","extensions","basedir","appDir","bundleApiRoute"],"mappings":"AAAA;;;;;CAKC,GAED;;;;+BAkBgBA,8BAA4B;;aAA5BA,4BAA4B;;;8DAjBxB,SAAS;;;;;;;8DACL,cAAc;;;;;;;yBACZ,MAAM;;;;;;uCAEC,yBAAyB;qCAC5B,uBAAuB;qCACG,uBAAuB;wBAC1C,UAAU;wBAClB,uBAAuB;;;;;;AAEpD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,yBAAyB,CAAC,AAAsB,AAAC;AAEhF,MAAMC,YAAY,GAAGC,IAAAA,KAAS,EAAA,UAAA,EAACC,QAAO,EAAA,QAAA,CAAC,AAGZ,AAAC;AAErB,SAASL,4BAA4B,CAC1CM,WAAmB,EACnBC,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/createServerRouteMiddleware.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { ProjectConfig } from '@expo/config';\nimport resolve from 'resolve';\nimport resolveFrom from 'resolve-from';\nimport { promisify } from 'util';\n\nimport { ForwardHtmlError } from './MetroBundlerDevServer';\nimport { fetchManifest } from './fetchRouterManifest';\nimport { getErrorOverlayHtmlAsync, logMetroError } from './metroErrorInterface';\nimport { warnInvalidWebOutput } from './router';\nimport { CommandError } from '../../../utils/errors';\n\nconst debug = require('debug')('expo:start:server:metro') as typeof console.log;\n\nconst resolveAsync = promisify(resolve) as any as (\n id: string,\n opts: resolve.AsyncOpts\n) => Promise<string | null>;\n\nexport function createRouteHandlerMiddleware(\n projectRoot: string,\n options: {\n appDir: string;\n routerRoot: string;\n getStaticPageAsync: (pathname: string) => Promise<{ content: string }>;\n bundleApiRoute: (\n functionFilePath: string\n ) => Promise<null | Record<string, Function> | Response>;\n config: ProjectConfig;\n } & import('expo-router/build/routes-manifest').Options\n) {\n if (!resolveFrom.silent(projectRoot, 'expo-router')) {\n throw new CommandError(\n 'static and server rendering requires the expo-router package to be installed in your project.'\n );\n }\n\n const { createRequestHandler } =\n require('@expo/server/build/vendor/http') as typeof import('@expo/server/build/vendor/http');\n\n return createRequestHandler(\n { build: '' },\n {\n async getRoutesManifest() {\n const manifest = await fetchManifest<RegExp>(projectRoot, options);\n debug('manifest', manifest);\n // NOTE: no app dir if null\n // TODO: Redirect to 404 page\n return (\n manifest ?? {\n // Support the onboarding screen if there's no manifest\n htmlRoutes: [\n {\n file: 'index.js',\n page: '/index',\n routeKeys: {},\n namedRegex: /^\\/(?:index)?\\/?$/i,\n },\n ],\n apiRoutes: [],\n notFoundRoutes: [],\n }\n );\n },\n async getHtml(request) {\n try {\n const { content } = await options.getStaticPageAsync(request.url);\n return content;\n } catch (error: any) {\n // Forward the Metro server response as-is. It won't be pretty, but at least it will be accurate.\n if (error instanceof ForwardHtmlError) {\n return new Response(error.html, {\n status: error.statusCode,\n headers: {\n 'Content-Type': 'text/html',\n },\n });\n }\n\n try {\n return new Response(\n await getErrorOverlayHtmlAsync({\n error,\n projectRoot,\n routerRoot: options.routerRoot,\n }),\n {\n status: 500,\n headers: {\n 'Content-Type': 'text/html',\n },\n }\n );\n } catch (staticError: any) {\n debug('Failed to render static error overlay:', staticError);\n // Fallback error for when Expo Router is misconfigured in the project.\n return new Response(\n '<span><h3>Internal Error:</h3><b>Project is not setup correctly for static rendering (check terminal for more info):</b><br/>' +\n error.message +\n '<br/><br/>' +\n staticError.message +\n '</span>',\n {\n status: 500,\n headers: {\n 'Content-Type': 'text/html',\n },\n }\n );\n }\n }\n },\n logApiRouteExecutionError(error) {\n logMetroError(projectRoot, { error });\n },\n async getApiRoute(route) {\n const { exp } = options.config;\n if (exp.web?.output !== 'server') {\n warnInvalidWebOutput();\n }\n\n const resolvedFunctionPath = await resolveAsync(route.file, {\n extensions: ['.js', '.jsx', '.ts', '.tsx'],\n basedir: options.appDir,\n })!;\n\n try {\n debug(`Bundling middleware at: ${resolvedFunctionPath}`);\n return await options.bundleApiRoute(resolvedFunctionPath!);\n } catch (error: any) {\n return new Response(\n 'Failed to load API Route: ' + resolvedFunctionPath + '\\n\\n' + error.message,\n {\n status: 500,\n headers: {\n 'Content-Type': 'text/html',\n },\n }\n );\n }\n },\n }\n );\n}\n"],"names":["createRouteHandlerMiddleware","debug","require","resolveAsync","promisify","resolve","projectRoot","options","resolveFrom","silent","CommandError","createRequestHandler","build","getRoutesManifest","manifest","fetchManifest","htmlRoutes","file","page","routeKeys","namedRegex","apiRoutes","notFoundRoutes","getHtml","request","content","getStaticPageAsync","url","error","ForwardHtmlError","Response","html","status","statusCode","headers","getErrorOverlayHtmlAsync","routerRoot","staticError","message","logApiRouteExecutionError","logMetroError","getApiRoute","route","exp","config","web","output","warnInvalidWebOutput","resolvedFunctionPath","extensions","basedir","appDir","bundleApiRoute"],"mappings":"AAAA;;;;;CAKC,GAED;;;;+BAkBgBA,8BAA4B;;aAA5BA,4BAA4B;;;8DAjBxB,SAAS;;;;;;;8DACL,cAAc;;;;;;;yBACZ,MAAM;;;;;;uCAEC,yBAAyB;qCAC5B,uBAAuB;qCACG,uBAAuB;wBAC1C,UAAU;wBAClB,uBAAuB;;;;;;AAEpD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,yBAAyB,CAAC,AAAsB,AAAC;AAEhF,MAAMC,YAAY,GAAGC,IAAAA,KAAS,EAAA,UAAA,EAACC,QAAO,EAAA,QAAA,CAAC,AAGZ,AAAC;AAErB,SAASL,4BAA4B,CAC1CM,WAAmB,EACnBC,OAQuD,EACvD;IACA,IAAI,CAACC,YAAW,EAAA,QAAA,CAACC,MAAM,CAACH,WAAW,EAAE,aAAa,CAAC,EAAE;QACnD,MAAM,IAAII,OAAY,aAAA,CACpB,+FAA+F,CAChG,CAAC;IACJ,CAAC;IAED,MAAM,EAAEC,oBAAoB,CAA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6C,cAAc,CAACJ,oBAAoB,CAAE,CAAC;YAC7D,EAAE,OAAOpB,KAAK,EAAO;gBACnB,OAAO,IAAIE,QAAQ,CACjB,4BAA4B,GAAGkB,oBAAoB,GAAG,MAAM,GAAGpB,KAAK,CAACU,OAAO,EAC5E;oBACEN,MAAM,EAAE,GAAG;oBACXE,OAAO,EAAE;wBACP,cAAc,EAAE,WAAW;qBAC5B;iBACF,CACF,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -37,7 +37,7 @@ async function fetchManifest(projectRoot, options) {
|
|
|
37
37
|
const getManifest = getExpoRouteManifestBuilderAsync(projectRoot);
|
|
38
38
|
const paths = (0, _router.getRoutePaths)(options.appDir);
|
|
39
39
|
// Get the serialized manifest
|
|
40
|
-
const jsonManifest = getManifest(paths);
|
|
40
|
+
const jsonManifest = getManifest(paths, options);
|
|
41
41
|
if (!jsonManifest) {
|
|
42
42
|
return null;
|
|
43
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/fetchRouterManifest.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport resolveFrom from 'resolve-from';\n\nimport { getRoutePaths } from './router';\n\nexport type ExpoRouterServerManifestV1Route<TRegex = string> = {\n file: string;\n page: string;\n routeKeys: Record<string, string>;\n namedRegex: TRegex;\n generated?: boolean;\n};\n\nexport type ExpoRouterServerManifestV1<TRegex = string> = {\n apiRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n htmlRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n notFoundRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n};\n\nfunction getExpoRouteManifestBuilderAsync(projectRoot: string) {\n return require(resolveFrom(projectRoot, 'expo-router/build/routes-manifest'))\n .createRoutesManifest as typeof import('expo-router/build/routes-manifest').createRoutesManifest;\n}\n\n// TODO: Simplify this now that we use Node.js directly, no need for the Metro bundler caching layer.\nexport async function fetchManifest<TRegex = string>(\n projectRoot: string,\n options: {
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/fetchRouterManifest.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport resolveFrom from 'resolve-from';\n\nimport { getRoutePaths } from './router';\n\nexport type ExpoRouterServerManifestV1Route<TRegex = string> = {\n file: string;\n page: string;\n routeKeys: Record<string, string>;\n namedRegex: TRegex;\n generated?: boolean;\n};\n\nexport type ExpoRouterServerManifestV1<TRegex = string> = {\n apiRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n htmlRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n notFoundRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n};\n\nfunction getExpoRouteManifestBuilderAsync(projectRoot: string) {\n return require(resolveFrom(projectRoot, 'expo-router/build/routes-manifest'))\n .createRoutesManifest as typeof import('expo-router/build/routes-manifest').createRoutesManifest;\n}\n\n// TODO: Simplify this now that we use Node.js directly, no need for the Metro bundler caching layer.\nexport async function fetchManifest<TRegex = string>(\n projectRoot: string,\n options: {\n asJson?: boolean;\n appDir: string;\n } & import('expo-router/build/routes-manifest').Options\n): Promise<ExpoRouterServerManifestV1<TRegex> | null> {\n const getManifest = getExpoRouteManifestBuilderAsync(projectRoot);\n const paths = getRoutePaths(options.appDir);\n // Get the serialized manifest\n const jsonManifest = getManifest(paths, options);\n\n if (!jsonManifest) {\n return null;\n }\n\n if (!jsonManifest.htmlRoutes || !jsonManifest.apiRoutes) {\n throw new Error('Routes manifest is malformed: ' + JSON.stringify(jsonManifest, null, 2));\n }\n\n if (!options.asJson) {\n // @ts-expect-error\n return inflateManifest(jsonManifest);\n }\n // @ts-expect-error\n return jsonManifest;\n}\n\n// Convert the serialized manifest to a usable format\nexport function inflateManifest(\n json: ExpoRouterServerManifestV1<string>\n): ExpoRouterServerManifestV1<RegExp> {\n return {\n ...json,\n htmlRoutes: json.htmlRoutes?.map((value) => {\n return {\n ...value,\n namedRegex: new RegExp(value.namedRegex),\n };\n }),\n apiRoutes: json.apiRoutes?.map((value) => {\n return {\n ...value,\n namedRegex: new RegExp(value.namedRegex),\n };\n }),\n notFoundRoutes: json.notFoundRoutes?.map((value) => {\n return {\n ...value,\n namedRegex: new RegExp(value.namedRegex),\n };\n }),\n };\n}\n"],"names":["fetchManifest","inflateManifest","getExpoRouteManifestBuilderAsync","projectRoot","require","resolveFrom","createRoutesManifest","options","getManifest","paths","getRoutePaths","appDir","jsonManifest","htmlRoutes","apiRoutes","Error","JSON","stringify","asJson","json","map","value","namedRegex","RegExp","notFoundRoutes"],"mappings":"AAAA;;;;;CAKC,GACD;;;;;;;;;;;IAwBsBA,aAAa,MAAbA,aAAa;IA6BnBC,eAAe,MAAfA,eAAe;;;8DArDP,cAAc;;;;;;wBAER,UAAU;;;;;;AAgBxC,SAASC,gCAAgC,CAACC,WAAmB,EAAE;IAC7D,OAAOC,OAAO,CAACC,IAAAA,YAAW,EAAA,QAAA,EAACF,WAAW,EAAE,mCAAmC,CAAC,CAAC,CAC1EG,oBAAoB,CAA4E;AACrG,CAAC;AAGM,eAAeN,aAAa,CACjCG,WAAmB,EACnBI,OAGuD,EACH;IACpD,MAAMC,WAAW,GAAGN,gCAAgC,CAACC,WAAW,CAAC,AAAC;IAClE,MAAMM,KAAK,GAAGC,IAAAA,OAAa,cAAA,EAACH,OAAO,CAACI,MAAM,CAAC,AAAC;IAC5C,8BAA8B;IAC9B,MAAMC,YAAY,GAAGJ,WAAW,CAACC,KAAK,EAAEF,OAAO,CAAC,AAAC;IAEjD,IAAI,CAACK,YAAY,EAAE;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAACA,YAAY,CAACC,UAAU,IAAI,CAACD,YAAY,CAACE,SAAS,EAAE;QACvD,MAAM,IAAIC,KAAK,CA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,14 +13,14 @@ _export(exports, {
|
|
|
13
13
|
guardAsync: ()=>guardAsync
|
|
14
14
|
});
|
|
15
15
|
function memoize(fn) {
|
|
16
|
-
const cache =
|
|
16
|
+
const cache = new Map();
|
|
17
17
|
return (...args)=>{
|
|
18
18
|
const key = JSON.stringify(args);
|
|
19
|
-
if (cache
|
|
20
|
-
return cache
|
|
19
|
+
if (cache.has(key)) {
|
|
20
|
+
return cache.get(key);
|
|
21
21
|
}
|
|
22
22
|
const result = fn(...args);
|
|
23
|
-
cache
|
|
23
|
+
cache.set(key, result);
|
|
24
24
|
return result;
|
|
25
25
|
};
|
|
26
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/fn.ts"],"sourcesContent":["/** `lodash.memoize` */\nexport function memoize<T extends (...args: any[]) => any>(fn: T): T {\n const cache
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/fn.ts"],"sourcesContent":["/** `lodash.memoize` */\nexport function memoize<T extends (...args: any[]) => any>(fn: T): T {\n const cache = new Map<string, any>();\n return ((...args: any[]) => {\n const key = JSON.stringify(args);\n if (cache.has(key)) {\n return cache.get(key);\n }\n const result = fn(...args);\n cache.set(key, result);\n return result;\n }) as T;\n}\n\n/** memoizes an async function to prevent subsequent calls that might be invoked before the function has finished resolving. */\nexport function guardAsync<V, T extends (...args: any[]) => Promise<V>>(fn: T): T {\n let invoked = false;\n let returnValue: V;\n\n const guard: any = async (...args: any[]): Promise<V> => {\n if (!invoked) {\n invoked = true;\n returnValue = await fn(...args);\n }\n\n return returnValue;\n };\n\n return guard;\n}\n"],"names":["memoize","guardAsync","fn","cache","Map","args","key","JSON","stringify","has","get","result","set","invoked","returnValue","guard"],"mappings":"AAAA,qBAAqB,GACrB;;;;;;;;;;;IAAgBA,OAAO,MAAPA,OAAO;IAcPC,UAAU,MAAVA,UAAU;;AAdnB,SAASD,OAAO,CAAoCE,EAAK,EAAK;IACnE,MAAMC,KAAK,GAAG,IAAIC,GAAG,EAAe,AAAC;IACrC,OAAQ,CAAC,GAAGC,IAAI,AAAO,GAAK;QAC1B,MAAMC,GAAG,GAAGC,IAAI,CAACC,SAAS,CAACH,IAAI,CAAC,AAAC;QACjC,IAAIF,KAAK,CAACM,GAAG,CAACH,GAAG,CAAC,EAAE;YAClB,OAAOH,KAAK,CAACO,GAAG,CAACJ,GAAG,CAAC,CAAC;QACxB,CAAC;QACD,MAAMK,MAAM,GAAGT,EAAE,IAAIG,IAAI,CAAC,AAAC;QAC3BF,KAAK,CAACS,GAAG,CAACN,GAAG,EAAEK,MAAM,CAAC,CAAC;QACvB,OAAOA,MAAM,CAAC;IAChB,CAAC,CAAO;AACV,CAAC;AAGM,SAASV,UAAU,CAA8CC,EAAK,EAAK;IAChF,IAAIW,OAAO,GAAG,KAAK,AAAC;IACpB,IAAIC,WAAW,AAAG,AAAC;IAEnB,MAAMC,KAAK,GAAQ,OAAO,GAAGV,IAAI,AAAO,GAAiB;QACvD,IAAI,CAACQ,OAAO,EAAE;YACZA,OAAO,GAAG,IAAI,CAAC;YACfC,WAAW,GAAG,MAAMZ,EAAE,IAAIG,IAAI,CAAC,CAAC;QAClC,CAAC;QAED,OAAOS,WAAW,CAAC;IACrB,CAAC,AAAC;IAEF,OAAOC,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/cli",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.6",
|
|
4
4
|
"description": "The Expo CLI",
|
|
5
5
|
"main": "build/bin/cli",
|
|
6
6
|
"bin": {
|
|
@@ -168,5 +168,5 @@
|
|
|
168
168
|
"tree-kill": "^1.2.2",
|
|
169
169
|
"tsd": "^0.28.1"
|
|
170
170
|
},
|
|
171
|
-
"gitHead": "
|
|
171
|
+
"gitHead": "20f1765146f63f8fdc2543e8aba8b0e5140d1e05"
|
|
172
172
|
}
|