next 16.0.0-beta.0 → 16.0.0-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/next +1 -1
- package/dist/build/index.js +3 -3
- package/dist/build/swc/generated-native.d.ts +1 -0
- package/dist/build/swc/index.js +2 -3
- package/dist/build/swc/index.js.map +1 -1
- package/dist/build/swc/types.d.ts +1 -0
- package/dist/build/webpack-config.js +2 -2
- package/dist/client/app-bootstrap.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/compiled/next-server/server.runtime.prod.js +8 -8
- package/dist/compiled/next-server/server.runtime.prod.js.map +1 -1
- package/dist/esm/build/index.js +3 -3
- package/dist/esm/build/swc/generated-native.d.ts +1 -0
- package/dist/esm/build/swc/index.js +2 -3
- package/dist/esm/build/swc/index.js.map +1 -1
- package/dist/esm/build/swc/types.js.map +1 -1
- package/dist/esm/build/webpack-config.js +2 -2
- package/dist/esm/client/app-bootstrap.js +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/export/worker.js +2 -0
- package/dist/esm/export/worker.js.map +1 -1
- package/dist/esm/lib/turbopack-warning.js +3 -1
- package/dist/esm/lib/turbopack-warning.js.map +1 -1
- package/dist/esm/server/config-schema.js +2 -1
- package/dist/esm/server/config-schema.js.map +1 -1
- package/dist/esm/server/config-shared.js +2 -1
- package/dist/esm/server/config-shared.js.map +1 -1
- package/dist/esm/server/dev/hot-reloader-turbopack.js +1 -1
- package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/esm/server/dev/on-demand-entry-handler.js +2 -1
- package/dist/esm/server/dev/on-demand-entry-handler.js.map +1 -1
- package/dist/esm/server/dev/turbopack-utils.js +4 -2
- package/dist/esm/server/dev/turbopack-utils.js.map +1 -1
- package/dist/esm/server/lib/app-info-log.js +1 -1
- package/dist/esm/server/lib/start-server.js +1 -1
- package/dist/esm/server/next-server.js +2 -0
- package/dist/esm/server/next-server.js.map +1 -1
- package/dist/esm/server/node-environment-extensions/console-dim.external.js +61 -47
- package/dist/esm/server/node-environment-extensions/console-dim.external.js.map +1 -1
- package/dist/esm/server/node-environment-extensions/global-behaviors.js +23 -0
- package/dist/esm/server/node-environment-extensions/global-behaviors.js.map +1 -0
- package/dist/esm/shared/lib/errors/canary-only-config-error.js +1 -1
- package/dist/export/worker.js +2 -0
- package/dist/export/worker.js.map +1 -1
- package/dist/lib/turbopack-warning.js +3 -1
- package/dist/lib/turbopack-warning.js.map +1 -1
- package/dist/server/config-schema.d.ts +1 -0
- package/dist/server/config-schema.js +2 -1
- package/dist/server/config-schema.js.map +1 -1
- package/dist/server/config-shared.d.ts +8 -0
- package/dist/server/config-shared.js +2 -1
- package/dist/server/config-shared.js.map +1 -1
- package/dist/server/dev/hot-reloader-turbopack.js +1 -1
- package/dist/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/server/dev/on-demand-entry-handler.js +2 -1
- package/dist/server/dev/on-demand-entry-handler.js.map +1 -1
- package/dist/server/dev/turbopack-utils.js +4 -2
- package/dist/server/dev/turbopack-utils.js.map +1 -1
- package/dist/server/lib/app-info-log.js +1 -1
- package/dist/server/lib/start-server.js +1 -1
- package/dist/server/next-server.js +2 -0
- package/dist/server/next-server.js.map +1 -1
- package/dist/server/node-environment-extensions/console-dim.external.d.ts +4 -0
- package/dist/server/node-environment-extensions/console-dim.external.js +76 -50
- package/dist/server/node-environment-extensions/console-dim.external.js.map +1 -1
- package/dist/server/node-environment-extensions/global-behaviors.d.ts +7 -0
- package/dist/server/node-environment-extensions/global-behaviors.js +33 -0
- package/dist/server/node-environment-extensions/global-behaviors.js.map +1 -0
- package/dist/shared/lib/errors/canary-only-config-error.js +1 -1
- package/dist/telemetry/anonymous-meta.js +1 -1
- package/dist/telemetry/events/session-stopped.js +2 -2
- package/dist/telemetry/events/version.js +2 -2
- package/package.json +15 -15
|
@@ -228,7 +228,7 @@ class HotReloaderWebpack {
|
|
|
228
228
|
this.previewProps = previewProps;
|
|
229
229
|
this.rewrites = rewrites;
|
|
230
230
|
this.hotReloaderSpan = (0, _trace.trace)('hot-reloader', undefined, {
|
|
231
|
-
version: "16.0.0-
|
|
231
|
+
version: "16.0.0-canary.1"
|
|
232
232
|
});
|
|
233
233
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
|
234
234
|
// of the current `next dev` invocation.
|
|
@@ -587,7 +587,8 @@ function onDemandEntryHandler({ hotReloader, maxInactiveAge, multiCompiler, next
|
|
|
587
587
|
const hasNewEntry = addedValues.some((entry)=>entry.newEntry);
|
|
588
588
|
if (hasNewEntry) {
|
|
589
589
|
const routePage = isApp ? route.page : (0, _apppaths.normalizeAppPath)(route.page);
|
|
590
|
-
|
|
590
|
+
// If proxy file, remove the leading slash from "/proxy" to "proxy".
|
|
591
|
+
(0, _output.reportTrigger)((0, _utils.isMiddlewareFile)(routePage) ? routePage.slice(1) : routePage, url);
|
|
591
592
|
}
|
|
592
593
|
if (entriesThatShouldBeInvalidated.length > 0) {
|
|
593
594
|
const invalidatePromise = Promise.all(entriesThatShouldBeInvalidated.map(([compilerKey, { entryKey }])=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/dev/on-demand-entry-handler.ts"],"sourcesContent":["import type ws from 'next/dist/compiled/ws'\nimport type { webpack } from 'next/dist/compiled/webpack/webpack'\nimport type { NextConfigComplete } from '../config-shared'\nimport type {\n DynamicParamTypesShort,\n FlightRouterState,\n FlightSegmentPath,\n} from '../../shared/lib/app-router-types'\nimport type { CompilerNameValues } from '../../shared/lib/constants'\nimport type { RouteDefinition } from '../route-definitions/route-definition'\nimport type HotReloaderWebpack from './hot-reloader-webpack'\n\nimport createDebug from 'next/dist/compiled/debug'\nimport { EventEmitter } from 'events'\nimport { findPageFile } from '../lib/find-page-file'\nimport { runDependingOnPageType } from '../../build/entries'\nimport { getStaticInfoIncludingLayouts } from '../../build/get-static-info-including-layouts'\nimport { join, posix } from 'path'\nimport { normalizePathSep } from '../../shared/lib/page-path/normalize-path-sep'\nimport { normalizePagePath } from '../../shared/lib/page-path/normalize-page-path'\nimport { ensureLeadingSlash } from '../../shared/lib/page-path/ensure-leading-slash'\nimport { removePagePathTail } from '../../shared/lib/page-path/remove-page-path-tail'\nimport { reportTrigger } from '../../build/output'\nimport getRouteFromEntrypoint from '../get-route-from-entrypoint'\nimport {\n isInstrumentationHookFile,\n isInstrumentationHookFilename,\n isMiddlewareFile,\n isMiddlewareFilename,\n} from '../../build/utils'\nimport { PageNotFoundError, stringifyError } from '../../shared/lib/utils'\nimport {\n COMPILER_INDEXES,\n COMPILER_NAMES,\n RSC_MODULE_TYPES,\n UNDERSCORE_NOT_FOUND_ROUTE_ENTRY,\n} from '../../shared/lib/constants'\nimport { PAGE_SEGMENT_KEY } from '../../shared/lib/segment'\nimport {\n HMR_MESSAGE_SENT_TO_BROWSER,\n HMR_MESSAGE_SENT_TO_SERVER,\n} from './hot-reloader-types'\nimport { isAppPageRouteDefinition } from '../route-definitions/app-page-route-definition'\nimport { scheduleOnNextTick } from '../../lib/scheduler'\nimport { Batcher } from '../../lib/batcher'\nimport { normalizeAppPath } from '../../shared/lib/router/utils/app-paths'\nimport { PAGE_TYPES } from '../../lib/page-types'\nimport { getNextFlightSegmentPath } from '../../client/flight-data-helpers'\nimport { handleErrorStateResponse } from '../mcp/tools/get-errors'\nimport { handlePageMetadataResponse } from '../mcp/tools/get-page-metadata'\n\nconst debug = createDebug('next:on-demand-entry-handler')\n\n/**\n * Returns object keys with type inferred from the object key\n */\nconst keys = Object.keys as <T>(o: T) => Extract<keyof T, string>[]\n\nconst COMPILER_KEYS = keys(COMPILER_INDEXES)\n\nfunction treePathToEntrypoint(\n segmentPath: FlightSegmentPath,\n parentPath?: string\n): string {\n const [parallelRouteKey, segment] = segmentPath\n\n // TODO-APP: modify this path to cover parallelRouteKey convention\n const path =\n (parentPath ? parentPath + '/' : '') +\n (parallelRouteKey !== 'children' && !segment.startsWith('@')\n ? `@${parallelRouteKey}/`\n : '') +\n (segment === '' ? 'page' : segment)\n\n // Last segment\n if (segmentPath.length === 2) {\n return path\n }\n\n const childSegmentPath = getNextFlightSegmentPath(segmentPath)\n return treePathToEntrypoint(childSegmentPath, path)\n}\n\nfunction convertDynamicParamTypeToSyntax(\n dynamicParamTypeShort: DynamicParamTypesShort,\n param: string\n) {\n switch (dynamicParamTypeShort) {\n case 'c':\n case 'ci':\n return `[...${param}]`\n case 'oc':\n return `[[...${param}]]`\n case 'd':\n case 'di':\n return `[${param}]`\n default:\n throw new Error('Unknown dynamic param type')\n }\n}\n\n/**\n * format: {compiler type}@{page type}@{page path}\n * e.g. client@pages@/index\n * e.g. server@app@app/page\n *\n * This guarantees the uniqueness for each page, to avoid conflicts between app/ and pages/\n */\n\nexport function getEntryKey(\n compilerType: CompilerNameValues,\n pageBundleType: PAGE_TYPES,\n page: string\n) {\n // TODO: handle the /children slot better\n // this is a quick hack to handle when children is provided as children/page instead of /page\n const pageKey = page.replace(/(@[^/]+)\\/children/g, '$1')\n return `${compilerType}@${pageBundleType}@${pageKey}`\n}\n\nfunction getPageBundleType(pageBundlePath: string): PAGE_TYPES {\n // Handle special case for /_error\n if (pageBundlePath === '/_error') return PAGE_TYPES.PAGES\n if (isMiddlewareFilename(pageBundlePath)) return PAGE_TYPES.ROOT\n return pageBundlePath.startsWith('pages/')\n ? PAGE_TYPES.PAGES\n : pageBundlePath.startsWith('app/')\n ? PAGE_TYPES.APP\n : PAGE_TYPES.ROOT\n}\n\nfunction getEntrypointsFromTree(\n tree: FlightRouterState,\n isFirst: boolean,\n parentPath: string[] = []\n) {\n const [segment, parallelRoutes] = tree\n\n const currentSegment = Array.isArray(segment)\n ? convertDynamicParamTypeToSyntax(segment[2], segment[0])\n : segment\n\n const isPageSegment = currentSegment.startsWith(PAGE_SEGMENT_KEY)\n\n const currentPath = [...parentPath, isPageSegment ? '' : currentSegment]\n\n if (!isFirst && isPageSegment) {\n // TODO get rid of '' at the start of tree\n return [treePathToEntrypoint(currentPath.slice(1))]\n }\n\n return Object.keys(parallelRoutes).reduce(\n (paths: string[], key: string): string[] => {\n const childTree = parallelRoutes[key]\n const childPages = getEntrypointsFromTree(childTree, false, [\n ...currentPath,\n key,\n ])\n return [...paths, ...childPages]\n },\n []\n )\n}\n\nexport const ADDED = Symbol('added')\nexport const BUILDING = Symbol('building')\nexport const BUILT = Symbol('built')\n\ninterface EntryType {\n /**\n * Tells if a page is scheduled to be disposed.\n */\n dispose?: boolean\n /**\n * Timestamp with the last time the page was active.\n */\n lastActiveTime?: number\n /**\n * Page build status.\n */\n status?: typeof ADDED | typeof BUILDING | typeof BUILT\n\n /**\n * Path to the page file relative to the dist folder with no extension.\n * For example: `pages/about/index`\n */\n bundlePath: string\n\n /**\n * Webpack request to create a dependency for.\n */\n request: string\n}\n\n// Shadowing check in ESLint does not account for enum\n// eslint-disable-next-line no-shadow\nexport const enum EntryTypes {\n ENTRY,\n CHILD_ENTRY,\n}\ninterface Entry extends EntryType {\n type: EntryTypes.ENTRY\n /**\n * The absolute page to the page file. Used for detecting if the file was removed. For example:\n * `/Users/Rick/project/pages/about/index.js`\n */\n absolutePagePath: string\n /**\n * All parallel pages that match the same entry, for example:\n * ['/parallel/@bar/nested/@a/page', '/parallel/@bar/nested/@b/page', '/parallel/@foo/nested/@a/page', '/parallel/@foo/nested/@b/page']\n */\n appPaths: ReadonlyArray<string> | null\n}\n\ninterface ChildEntry extends EntryType {\n type: EntryTypes.CHILD_ENTRY\n /**\n * Which parent entries use this childEntry.\n */\n parentEntries: Set<string>\n /**\n * The absolute page to the entry file. Used for detecting if the file was removed. For example:\n * `/Users/Rick/project/app/about/layout.js`\n */\n absoluteEntryFilePath?: string\n}\n\nconst entriesMap: Map<\n string,\n {\n /**\n * The key composed of the compiler name and the page. For example:\n * `edge-server/about`\n */\n [entryName: string]: Entry | ChildEntry\n }\n> = new Map()\n\n// remove /server from end of output for server compiler\nconst normalizeOutputPath = (dir: string) => dir.replace(/[/\\\\]server$/, '')\n\nexport const getEntries = (\n dir: string\n): NonNullable<ReturnType<(typeof entriesMap)['get']>> => {\n dir = normalizeOutputPath(dir)\n const entries = entriesMap.get(dir) || {}\n entriesMap.set(dir, entries)\n return entries\n}\n\nconst invalidators: Map<string, Invalidator> = new Map()\n\nexport const getInvalidator = (dir: string) => {\n dir = normalizeOutputPath(dir)\n return invalidators.get(dir)\n}\n\nconst doneCallbacks: EventEmitter = new EventEmitter()\nconst lastClientAccessPages = ['']\nconst lastServerAccessPagesForAppDir = ['']\n\ntype BuildingTracker = Set<CompilerNameValues>\ntype RebuildTracker = Set<CompilerNameValues>\n\n// Make sure only one invalidation happens at a time\n// Otherwise, webpack hash gets changed and it'll force the client to reload.\nclass Invalidator {\n private multiCompiler: webpack.MultiCompiler\n\n private building: BuildingTracker = new Set()\n private rebuildAgain: RebuildTracker = new Set()\n\n constructor(multiCompiler: webpack.MultiCompiler) {\n this.multiCompiler = multiCompiler\n }\n\n public shouldRebuildAll() {\n return this.rebuildAgain.size > 0\n }\n\n invalidate(compilerKeys: typeof COMPILER_KEYS = COMPILER_KEYS): void {\n for (const key of compilerKeys) {\n // If there's a current build is processing, we won't abort it by invalidating.\n // (If aborted, it'll cause a client side hard reload)\n // But let it to invalidate just after the completion.\n // So, it can re-build the queued pages at once.\n\n if (this.building.has(key)) {\n this.rebuildAgain.add(key)\n continue\n }\n\n this.building.add(key)\n this.multiCompiler.compilers[COMPILER_INDEXES[key]].watching?.invalidate()\n }\n }\n\n public startBuilding(compilerKey: keyof typeof COMPILER_INDEXES) {\n this.building.add(compilerKey)\n }\n\n public doneBuilding(compilerKeys: typeof COMPILER_KEYS = []) {\n const rebuild: typeof COMPILER_KEYS = []\n for (const key of compilerKeys) {\n this.building.delete(key)\n\n if (this.rebuildAgain.has(key)) {\n rebuild.push(key)\n this.rebuildAgain.delete(key)\n }\n }\n\n if (rebuild.length > 0) {\n this.invalidate(rebuild)\n }\n }\n\n public willRebuild(compilerKey: keyof typeof COMPILER_INDEXES) {\n return this.rebuildAgain.has(compilerKey)\n }\n}\n\nfunction disposeInactiveEntries(\n entries: NonNullable<ReturnType<(typeof entriesMap)['get']>>,\n maxInactiveAge: number\n) {\n Object.keys(entries).forEach((entryKey) => {\n const entryData = entries[entryKey]\n const { lastActiveTime, status, dispose, bundlePath } = entryData\n\n // TODO-APP: implement disposing of CHILD_ENTRY\n if (entryData.type === EntryTypes.CHILD_ENTRY) {\n return\n }\n\n // For the root middleware and the instrumentation hook files,\n // we don't dispose them periodically as it's needed for every request.\n if (\n isMiddlewareFilename(bundlePath) ||\n isInstrumentationHookFilename(bundlePath)\n ) {\n return\n }\n\n if (dispose)\n // Skip pages already scheduled for disposing\n return\n\n // This means this entry is currently building or just added\n // We don't need to dispose those entries.\n if (status !== BUILT) return\n\n // We should not build the last accessed page even we didn't get any pings\n // Sometimes, it's possible our XHR ping to wait before completing other requests.\n // In that case, we should not dispose the current viewing page\n if (\n lastClientAccessPages.includes(entryKey) ||\n lastServerAccessPagesForAppDir.includes(entryKey)\n )\n return\n\n if (lastActiveTime && Date.now() - lastActiveTime > maxInactiveAge) {\n entries[entryKey].dispose = true\n }\n })\n}\n\n// Normalize both app paths and page paths\nfunction tryToNormalizePagePath(page: string) {\n try {\n return normalizePagePath(page)\n } catch (err) {\n console.error(err)\n throw new PageNotFoundError(page)\n }\n}\n\ninterface PagePathData {\n filename: string\n bundlePath: string\n page: string\n}\n\n/**\n * Attempts to find a page file path from the given pages absolute directory,\n * a page and allowed extensions. If the page can't be found it will throw an\n * error. It defaults the `/_error` page to Next.js internal error page.\n *\n * @param rootDir Absolute path to the project root.\n * @param page The page normalized (it will be denormalized).\n * @param extensions Array of page extensions.\n * @param pagesDir Absolute path to the pages folder with trailing `/pages`.\n * @param appDir Absolute path to the app folder with trailing `/app`.\n */\nexport async function findPagePathData(\n rootDir: string,\n page: string,\n extensions: string[],\n pagesDir: string | undefined,\n appDir: string | undefined,\n isGlobalNotFoundEnabled: boolean\n): Promise<PagePathData> {\n const normalizedPagePath = tryToNormalizePagePath(page)\n let pagePath: string | null = null\n\n const isInstrumentation = isInstrumentationHookFile(normalizedPagePath)\n if (isMiddlewareFile(normalizedPagePath) || isInstrumentation) {\n pagePath = await findPageFile(\n rootDir,\n normalizedPagePath,\n extensions,\n false\n )\n\n if (!pagePath) {\n throw new PageNotFoundError(normalizedPagePath)\n }\n\n const pageUrl = ensureLeadingSlash(\n removePagePathTail(normalizePathSep(pagePath), {\n extensions,\n })\n )\n\n let bundlePath = normalizedPagePath\n let pageKey = posix.normalize(pageUrl)\n\n if (isInstrumentation || isMiddlewareFile(normalizedPagePath)) {\n bundlePath = bundlePath.replace('/src', '')\n pageKey = page.replace('/src', '')\n }\n\n return {\n filename: join(rootDir, pagePath),\n bundlePath: bundlePath.slice(1),\n page: pageKey,\n }\n }\n\n // Check appDir first falling back to pagesDir\n if (appDir) {\n if (page === UNDERSCORE_NOT_FOUND_ROUTE_ENTRY) {\n // Load `global-not-found` when global-not-found is enabled.\n // Prefer to load it when both `global-not-found` and root `not-found` present.\n if (isGlobalNotFoundEnabled) {\n const globalNotFoundPath = await findPageFile(\n appDir,\n 'global-not-found',\n extensions,\n true\n )\n if (globalNotFoundPath) {\n return {\n filename: join(appDir, globalNotFoundPath),\n bundlePath: `app${UNDERSCORE_NOT_FOUND_ROUTE_ENTRY}`,\n page: UNDERSCORE_NOT_FOUND_ROUTE_ENTRY,\n }\n }\n } else {\n // Then if global-not-found.js doesn't exist then load not-found.js\n const notFoundPath = await findPageFile(\n appDir,\n 'not-found',\n extensions,\n true\n )\n if (notFoundPath) {\n return {\n filename: join(appDir, notFoundPath),\n bundlePath: `app${UNDERSCORE_NOT_FOUND_ROUTE_ENTRY}`,\n page: UNDERSCORE_NOT_FOUND_ROUTE_ENTRY,\n }\n }\n }\n\n // If they're not presented, then fallback to global-not-found\n return {\n filename: require.resolve(\n 'next/dist/client/components/builtin/global-not-found'\n ),\n bundlePath: `app${UNDERSCORE_NOT_FOUND_ROUTE_ENTRY}`,\n page: UNDERSCORE_NOT_FOUND_ROUTE_ENTRY,\n }\n }\n pagePath = await findPageFile(appDir, normalizedPagePath, extensions, true)\n if (pagePath) {\n const pageUrl = ensureLeadingSlash(\n removePagePathTail(normalizePathSep(pagePath), {\n keepIndex: true,\n extensions,\n })\n )\n\n return {\n filename: join(appDir, pagePath),\n bundlePath: posix.join('app', pageUrl),\n page: posix.normalize(pageUrl),\n }\n }\n }\n\n if (!pagePath && pagesDir) {\n pagePath = await findPageFile(\n pagesDir,\n normalizedPagePath,\n extensions,\n false\n )\n }\n\n if (pagePath !== null && pagesDir) {\n const pageUrl = ensureLeadingSlash(\n removePagePathTail(normalizePathSep(pagePath), {\n extensions,\n })\n )\n\n return {\n filename: join(pagesDir, pagePath),\n bundlePath: posix.join('pages', normalizePagePath(pageUrl)),\n page: posix.normalize(pageUrl),\n }\n }\n\n if (page === '/_error') {\n return {\n filename: require.resolve('next/dist/pages/_error'),\n bundlePath: page,\n page: normalizePathSep(page),\n }\n } else {\n throw new PageNotFoundError(normalizedPagePath)\n }\n}\n\nexport function onDemandEntryHandler({\n hotReloader,\n maxInactiveAge,\n multiCompiler,\n nextConfig,\n pagesBufferLength,\n pagesDir,\n rootDir,\n appDir,\n}: {\n hotReloader: HotReloaderWebpack\n maxInactiveAge: number\n multiCompiler: webpack.MultiCompiler\n nextConfig: NextConfigComplete\n pagesBufferLength: number\n pagesDir?: string\n rootDir: string\n appDir?: string\n}) {\n const hasAppDir = !!appDir\n let curInvalidator: Invalidator = getInvalidator(\n multiCompiler.outputPath\n ) as any\n const curEntries = getEntries(multiCompiler.outputPath) as any\n\n if (!curInvalidator) {\n curInvalidator = new Invalidator(multiCompiler)\n invalidators.set(multiCompiler.outputPath, curInvalidator)\n }\n\n const startBuilding = (compilation: webpack.Compilation) => {\n const compilationName = compilation.name as any as CompilerNameValues\n curInvalidator.startBuilding(compilationName)\n }\n for (const compiler of multiCompiler.compilers) {\n compiler.hooks.make.tap('NextJsOnDemandEntries', startBuilding)\n }\n\n function getPagePathsFromEntrypoints(\n type: CompilerNameValues,\n entrypoints: Map<string, { name?: string | null }>\n ) {\n const pagePaths: string[] = []\n for (const entrypoint of entrypoints.values()) {\n const page = getRouteFromEntrypoint(entrypoint.name!, hasAppDir)\n\n if (page) {\n const pageBundleType = entrypoint.name?.startsWith('app/')\n ? PAGE_TYPES.APP\n : PAGE_TYPES.PAGES\n pagePaths.push(getEntryKey(type, pageBundleType, page))\n } else if (\n isMiddlewareFilename(entrypoint.name) ||\n isInstrumentationHookFilename(entrypoint.name)\n ) {\n pagePaths.push(\n getEntryKey(type, PAGE_TYPES.ROOT, `/${entrypoint.name}`)\n )\n }\n }\n return pagePaths\n }\n\n for (const compiler of multiCompiler.compilers) {\n compiler.hooks.done.tap('NextJsOnDemandEntries', () =>\n getInvalidator(compiler.outputPath)?.doneBuilding([\n compiler.name as keyof typeof COMPILER_INDEXES,\n ])\n )\n }\n\n multiCompiler.hooks.done.tap('NextJsOnDemandEntries', (multiStats) => {\n const [clientStats, serverStats, edgeServerStats] = multiStats.stats\n const entryNames = [\n ...getPagePathsFromEntrypoints(\n COMPILER_NAMES.client,\n clientStats.compilation.entrypoints\n ),\n ...getPagePathsFromEntrypoints(\n COMPILER_NAMES.server,\n serverStats.compilation.entrypoints\n ),\n ...(edgeServerStats\n ? getPagePathsFromEntrypoints(\n COMPILER_NAMES.edgeServer,\n edgeServerStats.compilation.entrypoints\n )\n : []),\n ]\n\n for (const name of entryNames) {\n const entry = curEntries[name]\n if (!entry) {\n continue\n }\n\n if (entry.status !== BUILDING) {\n continue\n }\n\n entry.status = BUILT\n doneCallbacks.emit(name)\n }\n\n getInvalidator(multiCompiler.outputPath)?.doneBuilding([...COMPILER_KEYS])\n })\n\n const pingIntervalTime = Math.max(1000, Math.min(5000, maxInactiveAge))\n\n setInterval(function () {\n disposeInactiveEntries(curEntries, maxInactiveAge)\n }, pingIntervalTime + 1000).unref()\n\n function handleAppDirPing(tree: FlightRouterState): void {\n const pages = getEntrypointsFromTree(tree, true)\n\n for (const page of pages) {\n for (const compilerType of [\n COMPILER_NAMES.client,\n COMPILER_NAMES.server,\n COMPILER_NAMES.edgeServer,\n ]) {\n const entryKey = getEntryKey(compilerType, PAGE_TYPES.APP, `/${page}`)\n const entryInfo = curEntries[entryKey]\n\n // If there's no entry, it may have been invalidated and needs to be re-built.\n if (!entryInfo) {\n // if (page !== lastEntry) client pings, but there's no entry for page\n continue\n }\n\n // We don't need to maintain active state of anything other than BUILT entries\n if (entryInfo.status !== BUILT) continue\n\n // If there's an entryInfo\n if (!lastServerAccessPagesForAppDir.includes(entryKey)) {\n lastServerAccessPagesForAppDir.unshift(entryKey)\n\n // Maintain the buffer max length\n // TODO: verify that the current pageKey is not at the end of the array as multiple entrypoints can exist\n if (lastServerAccessPagesForAppDir.length > pagesBufferLength) {\n lastServerAccessPagesForAppDir.pop()\n }\n }\n entryInfo.lastActiveTime = Date.now()\n entryInfo.dispose = false\n }\n }\n }\n\n function handlePing(pg: string): void {\n const page = normalizePathSep(pg)\n for (const compilerType of [\n COMPILER_NAMES.client,\n COMPILER_NAMES.server,\n COMPILER_NAMES.edgeServer,\n ]) {\n const entryKey = getEntryKey(compilerType, PAGE_TYPES.PAGES, page)\n const entryInfo = curEntries[entryKey]\n\n // If there's no entry, it may have been invalidated and needs to be re-built.\n if (!entryInfo) {\n // if (page !== lastEntry) client pings, but there's no entry for page\n if (compilerType === COMPILER_NAMES.client) {\n return\n }\n continue\n }\n\n // We don't need to maintain active state of anything other than BUILT entries\n if (entryInfo.status !== BUILT) continue\n\n // If there's an entryInfo\n if (!lastClientAccessPages.includes(entryKey)) {\n lastClientAccessPages.unshift(entryKey)\n\n // Maintain the buffer max length\n if (lastClientAccessPages.length > pagesBufferLength) {\n lastClientAccessPages.pop()\n }\n }\n entryInfo.lastActiveTime = Date.now()\n entryInfo.dispose = false\n }\n return\n }\n\n async function ensurePageImpl({\n page,\n appPaths,\n definition,\n isApp,\n url,\n }: {\n page: string\n appPaths: ReadonlyArray<string> | null\n definition: RouteDefinition | undefined\n isApp: boolean | undefined\n url?: string\n }): Promise<void> {\n const stalledTime = 60\n const stalledEnsureTimeout = setTimeout(() => {\n debug(\n `Ensuring ${page} has taken longer than ${stalledTime}s, if this continues to stall this may be a bug`\n )\n }, stalledTime * 1000)\n\n try {\n let route: Pick<RouteDefinition, 'filename' | 'bundlePath' | 'page'>\n if (definition) {\n route = definition\n } else {\n route = await findPagePathData(\n rootDir,\n page,\n nextConfig.pageExtensions,\n pagesDir,\n appDir,\n !!nextConfig.experimental.globalNotFound\n )\n }\n\n const isInsideAppDir = !!appDir && route.filename.startsWith(appDir)\n\n if (typeof isApp === 'boolean' && isApp !== isInsideAppDir) {\n Error.stackTraceLimit = 15\n throw new Error(\n `Ensure bailed, found path \"${\n route.page\n }\" does not match ensure type (${isApp ? 'app' : 'pages'})`\n )\n }\n\n const pageBundleType = getPageBundleType(route.bundlePath)\n const addEntry = (\n compilerType: CompilerNameValues\n ): {\n entryKey: string\n newEntry: boolean\n shouldInvalidate: boolean\n } => {\n const entryKey = getEntryKey(compilerType, pageBundleType, route.page)\n if (\n curEntries[entryKey] &&\n // there can be an overlap in the entryKey for the instrumentation hook file and a page named the same\n // this is a quick fix to support this scenario by overwriting the instrumentation hook entry, since we only use it one time\n // any changes to the instrumentation hook file will require a restart of the dev server anyway\n !isInstrumentationHookFilename(curEntries[entryKey].bundlePath)\n ) {\n curEntries[entryKey].dispose = false\n curEntries[entryKey].lastActiveTime = Date.now()\n if (curEntries[entryKey].status === BUILT) {\n return {\n entryKey,\n newEntry: false,\n shouldInvalidate: false,\n }\n }\n\n return {\n entryKey,\n newEntry: false,\n shouldInvalidate: true,\n }\n }\n\n curEntries[entryKey] = {\n type: EntryTypes.ENTRY,\n appPaths,\n absolutePagePath: route.filename,\n request: route.filename,\n bundlePath: route.bundlePath,\n dispose: false,\n lastActiveTime: Date.now(),\n status: ADDED,\n }\n return {\n entryKey: entryKey,\n newEntry: true,\n shouldInvalidate: true,\n }\n }\n\n const staticInfo = await getStaticInfoIncludingLayouts({\n page,\n pageFilePath: route.filename,\n isInsideAppDir,\n pageExtensions: nextConfig.pageExtensions,\n isDev: true,\n config: nextConfig,\n appDir,\n })\n\n const added = new Map<CompilerNameValues, ReturnType<typeof addEntry>>()\n const isServerComponent =\n isInsideAppDir && staticInfo.rsc !== RSC_MODULE_TYPES.client\n\n let pageRuntime = staticInfo.runtime\n\n runDependingOnPageType({\n page: route.page,\n pageRuntime,\n pageType: pageBundleType,\n onClient: () => {\n // Skip adding the client entry for app / Server Components.\n if (isServerComponent || isInsideAppDir) {\n return\n }\n added.set(COMPILER_NAMES.client, addEntry(COMPILER_NAMES.client))\n },\n onServer: () => {\n added.set(COMPILER_NAMES.server, addEntry(COMPILER_NAMES.server))\n const edgeServerEntry = getEntryKey(\n COMPILER_NAMES.edgeServer,\n pageBundleType,\n route.page\n )\n if (\n curEntries[edgeServerEntry] &&\n !isInstrumentationHookFile(route.page)\n ) {\n // Runtime switched from edge to server\n delete curEntries[edgeServerEntry]\n }\n },\n onEdgeServer: () => {\n added.set(\n COMPILER_NAMES.edgeServer,\n addEntry(COMPILER_NAMES.edgeServer)\n )\n const serverEntry = getEntryKey(\n COMPILER_NAMES.server,\n pageBundleType,\n route.page\n )\n if (\n curEntries[serverEntry] &&\n !isInstrumentationHookFile(route.page)\n ) {\n // Runtime switched from server to edge\n delete curEntries[serverEntry]\n }\n },\n })\n\n const addedValues = [...added.values()]\n const entriesThatShouldBeInvalidated = [...added.entries()].filter(\n ([, entry]) => entry.shouldInvalidate\n )\n const hasNewEntry = addedValues.some((entry) => entry.newEntry)\n\n if (hasNewEntry) {\n const routePage = isApp ? route.page : normalizeAppPath(route.page)\n reportTrigger(routePage, url)\n }\n\n if (entriesThatShouldBeInvalidated.length > 0) {\n const invalidatePromise = Promise.all(\n entriesThatShouldBeInvalidated.map(([compilerKey, { entryKey }]) => {\n return new Promise<void>((resolve, reject) => {\n doneCallbacks.once(entryKey, (err: Error) => {\n if (err) {\n return reject(err)\n }\n\n // If the invalidation also triggers a rebuild, we need to\n // wait for that additional build to prevent race conditions.\n const needsRebuild = curInvalidator.willRebuild(compilerKey)\n if (needsRebuild) {\n doneCallbacks.once(entryKey, (rebuildErr: Error) => {\n if (rebuildErr) {\n return reject(rebuildErr)\n }\n resolve()\n })\n } else {\n resolve()\n }\n })\n })\n })\n )\n\n curInvalidator.invalidate([...added.keys()])\n await invalidatePromise\n }\n } finally {\n clearTimeout(stalledEnsureTimeout)\n }\n }\n\n type EnsurePageOptions = {\n page: string\n appPaths?: ReadonlyArray<string> | null\n definition?: RouteDefinition\n isApp?: boolean\n url?: string\n }\n\n // Make sure that we won't have multiple invalidations ongoing concurrently.\n const batcher = Batcher.create<EnsurePageOptions, void, string>({\n // The cache key here is composed of the elements that affect the\n // compilation, namely, the page, whether it's client only, and whether\n // it's an app page. This ensures that we don't have multiple compilations\n // for the same page happening concurrently.\n //\n // We don't include the whole match because it contains match specific\n // parameters (like route params) that would just bust this cache. Any\n // details that would possibly bust the cache should be listed here.\n cacheKeyFn: (options) => JSON.stringify(options),\n // Schedule the invocation of the ensurePageImpl function on the next tick.\n schedulerFn: scheduleOnNextTick,\n })\n\n return {\n async ensurePage({\n page,\n appPaths = null,\n definition,\n isApp,\n url,\n }: EnsurePageOptions) {\n // If the route is actually an app page route, then we should have access\n // to the app route definition, and therefore, the appPaths from it.\n if (!appPaths && definition && isAppPageRouteDefinition(definition)) {\n appPaths = definition.appPaths\n }\n\n // Wrap the invocation of the ensurePageImpl function in the pending\n // wrapper, which will ensure that we don't have multiple compilations\n // for the same page happening concurrently.\n return batcher.batch({ page, appPaths, definition, isApp }, async () => {\n await ensurePageImpl({\n page,\n appPaths,\n definition,\n isApp,\n url,\n })\n })\n },\n onHMR(client: ws, getHmrServerError: () => Error | null) {\n let bufferedHmrServerError: Error | null = null\n\n client.addEventListener('close', () => {\n bufferedHmrServerError = null\n })\n client.addEventListener('message', ({ data }) => {\n try {\n const error = getHmrServerError()\n\n // New error occurred: buffered error is flushed and new error occurred\n if (!bufferedHmrServerError && error) {\n hotReloader.send({\n type: HMR_MESSAGE_SENT_TO_BROWSER.SERVER_ERROR,\n errorJSON: stringifyError(error),\n })\n bufferedHmrServerError = null\n }\n\n const parsedData = JSON.parse(\n typeof data !== 'string' ? data.toString() : data\n )\n\n if (parsedData.event === HMR_MESSAGE_SENT_TO_SERVER.PING) {\n if (parsedData.appDirRoute) {\n handleAppDirPing(parsedData.tree)\n } else {\n handlePing(parsedData.page)\n }\n } else if (\n parsedData.event ===\n HMR_MESSAGE_SENT_TO_SERVER.MCP_ERROR_STATE_RESPONSE\n ) {\n handleErrorStateResponse(\n parsedData.requestId,\n parsedData.errorState,\n parsedData.url\n )\n } else if (\n parsedData.event ===\n HMR_MESSAGE_SENT_TO_SERVER.MCP_PAGE_METADATA_RESPONSE\n ) {\n handlePageMetadataResponse(\n parsedData.requestId,\n parsedData.segmentTrieData,\n parsedData.url\n )\n }\n } catch {}\n })\n },\n }\n}\n"],"names":["ADDED","BUILDING","BUILT","EntryTypes","findPagePathData","getEntries","getEntryKey","getInvalidator","onDemandEntryHandler","debug","createDebug","keys","Object","COMPILER_KEYS","COMPILER_INDEXES","treePathToEntrypoint","segmentPath","parentPath","parallelRouteKey","segment","path","startsWith","length","childSegmentPath","getNextFlightSegmentPath","convertDynamicParamTypeToSyntax","dynamicParamTypeShort","param","Error","compilerType","pageBundleType","page","pageKey","replace","getPageBundleType","pageBundlePath","PAGE_TYPES","PAGES","isMiddlewareFilename","ROOT","APP","getEntrypointsFromTree","tree","isFirst","parallelRoutes","currentSegment","Array","isArray","isPageSegment","PAGE_SEGMENT_KEY","currentPath","slice","reduce","paths","key","childTree","childPages","Symbol","entriesMap","Map","normalizeOutputPath","dir","entries","get","set","invalidators","doneCallbacks","EventEmitter","lastClientAccessPages","lastServerAccessPagesForAppDir","Invalidator","constructor","multiCompiler","building","Set","rebuildAgain","shouldRebuildAll","size","invalidate","compilerKeys","has","add","compilers","watching","startBuilding","compilerKey","doneBuilding","rebuild","delete","push","willRebuild","disposeInactiveEntries","maxInactiveAge","forEach","entryKey","entryData","lastActiveTime","status","dispose","bundlePath","type","isInstrumentationHookFilename","includes","Date","now","tryToNormalizePagePath","normalizePagePath","err","console","error","PageNotFoundError","rootDir","extensions","pagesDir","appDir","isGlobalNotFoundEnabled","normalizedPagePath","pagePath","isInstrumentation","isInstrumentationHookFile","isMiddlewareFile","findPageFile","pageUrl","ensureLeadingSlash","removePagePathTail","normalizePathSep","posix","normalize","filename","join","UNDERSCORE_NOT_FOUND_ROUTE_ENTRY","globalNotFoundPath","notFoundPath","require","resolve","keepIndex","hotReloader","nextConfig","pagesBufferLength","hasAppDir","curInvalidator","outputPath","curEntries","compilation","compilationName","name","compiler","hooks","make","tap","getPagePathsFromEntrypoints","entrypoints","pagePaths","entrypoint","values","getRouteFromEntrypoint","done","multiStats","clientStats","serverStats","edgeServerStats","stats","entryNames","COMPILER_NAMES","client","server","edgeServer","entry","emit","pingIntervalTime","Math","max","min","setInterval","unref","handleAppDirPing","pages","entryInfo","unshift","pop","handlePing","pg","ensurePageImpl","appPaths","definition","isApp","url","stalledTime","stalledEnsureTimeout","setTimeout","route","pageExtensions","experimental","globalNotFound","isInsideAppDir","stackTraceLimit","addEntry","newEntry","shouldInvalidate","absolutePagePath","request","staticInfo","getStaticInfoIncludingLayouts","pageFilePath","isDev","config","added","isServerComponent","rsc","RSC_MODULE_TYPES","pageRuntime","runtime","runDependingOnPageType","pageType","onClient","onServer","edgeServerEntry","onEdgeServer","serverEntry","addedValues","entriesThatShouldBeInvalidated","filter","hasNewEntry","some","routePage","normalizeAppPath","reportTrigger","invalidatePromise","Promise","all","map","reject","once","needsRebuild","rebuildErr","clearTimeout","batcher","Batcher","create","cacheKeyFn","options","JSON","stringify","schedulerFn","scheduleOnNextTick","ensurePage","isAppPageRouteDefinition","batch","onHMR","getHmrServerError","bufferedHmrServerError","addEventListener","data","send","HMR_MESSAGE_SENT_TO_BROWSER","SERVER_ERROR","errorJSON","stringifyError","parsedData","parse","toString","event","HMR_MESSAGE_SENT_TO_SERVER","PING","appDirRoute","MCP_ERROR_STATE_RESPONSE","handleErrorStateResponse","requestId","errorState","MCP_PAGE_METADATA_RESPONSE","handlePageMetadataResponse","segmentTrieData"],"mappings":";;;;;;;;;;;;;;;;;;;;;;IAoKaA,KAAK;eAALA;;IACAC,QAAQ;eAARA;;IACAC,KAAK;eAALA;;IA8BKC,UAAU;eAAVA;;IAsMIC,gBAAgB;eAAhBA;;IAzJTC,UAAU;eAAVA;;IApIGC,WAAW;eAAXA;;IA+IHC,cAAc;eAAdA;;IA2RGC,oBAAoB;eAApBA;;;8DA3gBQ;wBACK;8BACA;yBACU;+CACO;sBAClB;kCACK;mCACC;oCACC;oCACA;wBACL;+EACK;uBAM5B;wBAC2C;2BAM3C;yBAC0B;kCAI1B;wCACkC;2BACN;yBACX;0BACS;2BACN;mCACc;2BACA;iCACE;;;;;;AAE3C,MAAMC,QAAQC,IAAAA,cAAW,EAAC;AAE1B;;CAEC,GACD,MAAMC,OAAOC,OAAOD,IAAI;AAExB,MAAME,gBAAgBF,KAAKG,2BAAgB;AAE3C,SAASC,qBACPC,WAA8B,EAC9BC,UAAmB;IAEnB,MAAM,CAACC,kBAAkBC,QAAQ,GAAGH;IAEpC,kEAAkE;IAClE,MAAMI,OACJ,AAACH,CAAAA,aAAaA,aAAa,MAAM,EAAC,IACjCC,CAAAA,qBAAqB,cAAc,CAACC,QAAQE,UAAU,CAAC,OACpD,CAAC,CAAC,EAAEH,iBAAiB,CAAC,CAAC,GACvB,EAAC,IACJC,CAAAA,YAAY,KAAK,SAASA,OAAM;IAEnC,eAAe;IACf,IAAIH,YAAYM,MAAM,KAAK,GAAG;QAC5B,OAAOF;IACT;IAEA,MAAMG,mBAAmBC,IAAAA,2CAAwB,EAACR;IAClD,OAAOD,qBAAqBQ,kBAAkBH;AAChD;AAEA,SAASK,gCACPC,qBAA6C,EAC7CC,KAAa;IAEb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AAKC,4CAA0B,CAACC,IAAI,EAAE;wBACxD,IAAIL,WAAWM,WAAW,EAAE;4BAC1BzF,iBAAiBmF,WAAWxN,IAAI;wBAClC,OAAO;4BACL0I,WAAW8E,WAAWnO,IAAI;wBAC5B;oBACF,OAAO,IACLmO,WAAWG,KAAK,KAChBC,4CAA0B,CAACG,wBAAwB,EACnD;wBACAC,IAAAA,mCAAwB,EACtBR,WAAWS,SAAS,EACpBT,WAAWU,UAAU,EACrBV,WAAWxE,GAAG;oBAElB,OAAO,IACLwE,WAAWG,KAAK,KAChBC,4CAA0B,CAACO,0BAA0B,EACrD;wBACAC,IAAAA,2CAA0B,EACxBZ,WAAWS,SAAS,EACpBT,WAAWa,eAAe,EAC1Bb,WAAWxE,GAAG;oBAElB;gBACF,EAAE,OAAM,CAAC;YACX;QACF;IACF;AACF","ignoreList":[0]}
|
|
1
|
+
{"version":3,"sources":["../../../src/server/dev/on-demand-entry-handler.ts"],"sourcesContent":["import type ws from 'next/dist/compiled/ws'\nimport type { webpack } from 'next/dist/compiled/webpack/webpack'\nimport type { NextConfigComplete } from '../config-shared'\nimport type {\n DynamicParamTypesShort,\n FlightRouterState,\n FlightSegmentPath,\n} from '../../shared/lib/app-router-types'\nimport type { CompilerNameValues } from '../../shared/lib/constants'\nimport type { RouteDefinition } from '../route-definitions/route-definition'\nimport type HotReloaderWebpack from './hot-reloader-webpack'\n\nimport createDebug from 'next/dist/compiled/debug'\nimport { EventEmitter } from 'events'\nimport { findPageFile } from '../lib/find-page-file'\nimport { runDependingOnPageType } from '../../build/entries'\nimport { getStaticInfoIncludingLayouts } from '../../build/get-static-info-including-layouts'\nimport { join, posix } from 'path'\nimport { normalizePathSep } from '../../shared/lib/page-path/normalize-path-sep'\nimport { normalizePagePath } from '../../shared/lib/page-path/normalize-page-path'\nimport { ensureLeadingSlash } from '../../shared/lib/page-path/ensure-leading-slash'\nimport { removePagePathTail } from '../../shared/lib/page-path/remove-page-path-tail'\nimport { reportTrigger } from '../../build/output'\nimport getRouteFromEntrypoint from '../get-route-from-entrypoint'\nimport {\n isInstrumentationHookFile,\n isInstrumentationHookFilename,\n isMiddlewareFile,\n isMiddlewareFilename,\n} from '../../build/utils'\nimport { PageNotFoundError, stringifyError } from '../../shared/lib/utils'\nimport {\n COMPILER_INDEXES,\n COMPILER_NAMES,\n RSC_MODULE_TYPES,\n UNDERSCORE_NOT_FOUND_ROUTE_ENTRY,\n} from '../../shared/lib/constants'\nimport { PAGE_SEGMENT_KEY } from '../../shared/lib/segment'\nimport {\n HMR_MESSAGE_SENT_TO_BROWSER,\n HMR_MESSAGE_SENT_TO_SERVER,\n} from './hot-reloader-types'\nimport { isAppPageRouteDefinition } from '../route-definitions/app-page-route-definition'\nimport { scheduleOnNextTick } from '../../lib/scheduler'\nimport { Batcher } from '../../lib/batcher'\nimport { normalizeAppPath } from '../../shared/lib/router/utils/app-paths'\nimport { PAGE_TYPES } from '../../lib/page-types'\nimport { getNextFlightSegmentPath } from '../../client/flight-data-helpers'\nimport { handleErrorStateResponse } from '../mcp/tools/get-errors'\nimport { handlePageMetadataResponse } from '../mcp/tools/get-page-metadata'\n\nconst debug = createDebug('next:on-demand-entry-handler')\n\n/**\n * Returns object keys with type inferred from the object key\n */\nconst keys = Object.keys as <T>(o: T) => Extract<keyof T, string>[]\n\nconst COMPILER_KEYS = keys(COMPILER_INDEXES)\n\nfunction treePathToEntrypoint(\n segmentPath: FlightSegmentPath,\n parentPath?: string\n): string {\n const [parallelRouteKey, segment] = segmentPath\n\n // TODO-APP: modify this path to cover parallelRouteKey convention\n const path =\n (parentPath ? parentPath + '/' : '') +\n (parallelRouteKey !== 'children' && !segment.startsWith('@')\n ? `@${parallelRouteKey}/`\n : '') +\n (segment === '' ? 'page' : segment)\n\n // Last segment\n if (segmentPath.length === 2) {\n return path\n }\n\n const childSegmentPath = getNextFlightSegmentPath(segmentPath)\n return treePathToEntrypoint(childSegmentPath, path)\n}\n\nfunction convertDynamicParamTypeToSyntax(\n dynamicParamTypeShort: DynamicParamTypesShort,\n param: string\n) {\n switch (dynamicParamTypeShort) {\n case 'c':\n case 'ci':\n return `[...${param}]`\n case 'oc':\n return `[[...${param}]]`\n case 'd':\n case 'di':\n return `[${param}]`\n default:\n throw new Error('Unknown dynamic param type')\n }\n}\n\n/**\n * format: {compiler type}@{page type}@{page path}\n * e.g. client@pages@/index\n * e.g. server@app@app/page\n *\n * This guarantees the uniqueness for each page, to avoid conflicts between app/ and pages/\n */\n\nexport function getEntryKey(\n compilerType: CompilerNameValues,\n pageBundleType: PAGE_TYPES,\n page: string\n) {\n // TODO: handle the /children slot better\n // this is a quick hack to handle when children is provided as children/page instead of /page\n const pageKey = page.replace(/(@[^/]+)\\/children/g, '$1')\n return `${compilerType}@${pageBundleType}@${pageKey}`\n}\n\nfunction getPageBundleType(pageBundlePath: string): PAGE_TYPES {\n // Handle special case for /_error\n if (pageBundlePath === '/_error') return PAGE_TYPES.PAGES\n if (isMiddlewareFilename(pageBundlePath)) return PAGE_TYPES.ROOT\n return pageBundlePath.startsWith('pages/')\n ? PAGE_TYPES.PAGES\n : pageBundlePath.startsWith('app/')\n ? PAGE_TYPES.APP\n : PAGE_TYPES.ROOT\n}\n\nfunction getEntrypointsFromTree(\n tree: FlightRouterState,\n isFirst: boolean,\n parentPath: string[] = []\n) {\n const [segment, parallelRoutes] = tree\n\n const currentSegment = Array.isArray(segment)\n ? convertDynamicParamTypeToSyntax(segment[2], segment[0])\n : segment\n\n const isPageSegment = currentSegment.startsWith(PAGE_SEGMENT_KEY)\n\n const currentPath = [...parentPath, isPageSegment ? '' : currentSegment]\n\n if (!isFirst && isPageSegment) {\n // TODO get rid of '' at the start of tree\n return [treePathToEntrypoint(currentPath.slice(1))]\n }\n\n return Object.keys(parallelRoutes).reduce(\n (paths: string[], key: string): string[] => {\n const childTree = parallelRoutes[key]\n const childPages = getEntrypointsFromTree(childTree, false, [\n ...currentPath,\n key,\n ])\n return [...paths, ...childPages]\n },\n []\n )\n}\n\nexport const ADDED = Symbol('added')\nexport const BUILDING = Symbol('building')\nexport const BUILT = Symbol('built')\n\ninterface EntryType {\n /**\n * Tells if a page is scheduled to be disposed.\n */\n dispose?: boolean\n /**\n * Timestamp with the last time the page was active.\n */\n lastActiveTime?: number\n /**\n * Page build status.\n */\n status?: typeof ADDED | typeof BUILDING | typeof BUILT\n\n /**\n * Path to the page file relative to the dist folder with no extension.\n * For example: `pages/about/index`\n */\n bundlePath: string\n\n /**\n * Webpack request to create a dependency for.\n */\n request: string\n}\n\n// Shadowing check in ESLint does not account for enum\n// eslint-disable-next-line no-shadow\nexport const enum EntryTypes {\n ENTRY,\n CHILD_ENTRY,\n}\ninterface Entry extends EntryType {\n type: EntryTypes.ENTRY\n /**\n * The absolute page to the page file. Used for detecting if the file was removed. For example:\n * `/Users/Rick/project/pages/about/index.js`\n */\n absolutePagePath: string\n /**\n * All parallel pages that match the same entry, for example:\n * ['/parallel/@bar/nested/@a/page', '/parallel/@bar/nested/@b/page', '/parallel/@foo/nested/@a/page', '/parallel/@foo/nested/@b/page']\n */\n appPaths: ReadonlyArray<string> | null\n}\n\ninterface ChildEntry extends EntryType {\n type: EntryTypes.CHILD_ENTRY\n /**\n * Which parent entries use this childEntry.\n */\n parentEntries: Set<string>\n /**\n * The absolute page to the entry file. Used for detecting if the file was removed. For example:\n * `/Users/Rick/project/app/about/layout.js`\n */\n absoluteEntryFilePath?: string\n}\n\nconst entriesMap: Map<\n string,\n {\n /**\n * The key composed of the compiler name and the page. For example:\n * `edge-server/about`\n */\n [entryName: string]: Entry | ChildEntry\n }\n> = new Map()\n\n// remove /server from end of output for server compiler\nconst normalizeOutputPath = (dir: string) => dir.replace(/[/\\\\]server$/, '')\n\nexport const getEntries = (\n dir: string\n): NonNullable<ReturnType<(typeof entriesMap)['get']>> => {\n dir = normalizeOutputPath(dir)\n const entries = entriesMap.get(dir) || {}\n entriesMap.set(dir, entries)\n return entries\n}\n\nconst invalidators: Map<string, Invalidator> = new Map()\n\nexport const getInvalidator = (dir: string) => {\n dir = normalizeOutputPath(dir)\n return invalidators.get(dir)\n}\n\nconst doneCallbacks: EventEmitter = new EventEmitter()\nconst lastClientAccessPages = ['']\nconst lastServerAccessPagesForAppDir = ['']\n\ntype BuildingTracker = Set<CompilerNameValues>\ntype RebuildTracker = Set<CompilerNameValues>\n\n// Make sure only one invalidation happens at a time\n// Otherwise, webpack hash gets changed and it'll force the client to reload.\nclass Invalidator {\n private multiCompiler: webpack.MultiCompiler\n\n private building: BuildingTracker = new Set()\n private rebuildAgain: RebuildTracker = new Set()\n\n constructor(multiCompiler: webpack.MultiCompiler) {\n this.multiCompiler = multiCompiler\n }\n\n public shouldRebuildAll() {\n return this.rebuildAgain.size > 0\n }\n\n invalidate(compilerKeys: typeof COMPILER_KEYS = COMPILER_KEYS): void {\n for (const key of compilerKeys) {\n // If there's a current build is processing, we won't abort it by invalidating.\n // (If aborted, it'll cause a client side hard reload)\n // But let it to invalidate just after the completion.\n // So, it can re-build the queued pages at once.\n\n if (this.building.has(key)) {\n this.rebuildAgain.add(key)\n continue\n }\n\n this.building.add(key)\n this.multiCompiler.compilers[COMPILER_INDEXES[key]].watching?.invalidate()\n }\n }\n\n public startBuilding(compilerKey: keyof typeof COMPILER_INDEXES) {\n this.building.add(compilerKey)\n }\n\n public doneBuilding(compilerKeys: typeof COMPILER_KEYS = []) {\n const rebuild: typeof COMPILER_KEYS = []\n for (const key of compilerKeys) {\n this.building.delete(key)\n\n if (this.rebuildAgain.has(key)) {\n rebuild.push(key)\n this.rebuildAgain.delete(key)\n }\n }\n\n if (rebuild.length > 0) {\n this.invalidate(rebuild)\n }\n }\n\n public willRebuild(compilerKey: keyof typeof COMPILER_INDEXES) {\n return this.rebuildAgain.has(compilerKey)\n }\n}\n\nfunction disposeInactiveEntries(\n entries: NonNullable<ReturnType<(typeof entriesMap)['get']>>,\n maxInactiveAge: number\n) {\n Object.keys(entries).forEach((entryKey) => {\n const entryData = entries[entryKey]\n const { lastActiveTime, status, dispose, bundlePath } = entryData\n\n // TODO-APP: implement disposing of CHILD_ENTRY\n if (entryData.type === EntryTypes.CHILD_ENTRY) {\n return\n }\n\n // For the root middleware and the instrumentation hook files,\n // we don't dispose them periodically as it's needed for every request.\n if (\n isMiddlewareFilename(bundlePath) ||\n isInstrumentationHookFilename(bundlePath)\n ) {\n return\n }\n\n if (dispose)\n // Skip pages already scheduled for disposing\n return\n\n // This means this entry is currently building or just added\n // We don't need to dispose those entries.\n if (status !== BUILT) return\n\n // We should not build the last accessed page even we didn't get any pings\n // Sometimes, it's possible our XHR ping to wait before completing other requests.\n // In that case, we should not dispose the current viewing page\n if (\n lastClientAccessPages.includes(entryKey) ||\n lastServerAccessPagesForAppDir.includes(entryKey)\n )\n return\n\n if (lastActiveTime && Date.now() - lastActiveTime > maxInactiveAge) {\n entries[entryKey].dispose = true\n }\n })\n}\n\n// Normalize both app paths and page paths\nfunction tryToNormalizePagePath(page: string) {\n try {\n return normalizePagePath(page)\n } catch (err) {\n console.error(err)\n throw new PageNotFoundError(page)\n }\n}\n\ninterface PagePathData {\n filename: string\n bundlePath: string\n page: string\n}\n\n/**\n * Attempts to find a page file path from the given pages absolute directory,\n * a page and allowed extensions. If the page can't be found it will throw an\n * error. It defaults the `/_error` page to Next.js internal error page.\n *\n * @param rootDir Absolute path to the project root.\n * @param page The page normalized (it will be denormalized).\n * @param extensions Array of page extensions.\n * @param pagesDir Absolute path to the pages folder with trailing `/pages`.\n * @param appDir Absolute path to the app folder with trailing `/app`.\n */\nexport async function findPagePathData(\n rootDir: string,\n page: string,\n extensions: string[],\n pagesDir: string | undefined,\n appDir: string | undefined,\n isGlobalNotFoundEnabled: boolean\n): Promise<PagePathData> {\n const normalizedPagePath = tryToNormalizePagePath(page)\n let pagePath: string | null = null\n\n const isInstrumentation = isInstrumentationHookFile(normalizedPagePath)\n if (isMiddlewareFile(normalizedPagePath) || isInstrumentation) {\n pagePath = await findPageFile(\n rootDir,\n normalizedPagePath,\n extensions,\n false\n )\n\n if (!pagePath) {\n throw new PageNotFoundError(normalizedPagePath)\n }\n\n const pageUrl = ensureLeadingSlash(\n removePagePathTail(normalizePathSep(pagePath), {\n extensions,\n })\n )\n\n let bundlePath = normalizedPagePath\n let pageKey = posix.normalize(pageUrl)\n\n if (isInstrumentation || isMiddlewareFile(normalizedPagePath)) {\n bundlePath = bundlePath.replace('/src', '')\n pageKey = page.replace('/src', '')\n }\n\n return {\n filename: join(rootDir, pagePath),\n bundlePath: bundlePath.slice(1),\n page: pageKey,\n }\n }\n\n // Check appDir first falling back to pagesDir\n if (appDir) {\n if (page === UNDERSCORE_NOT_FOUND_ROUTE_ENTRY) {\n // Load `global-not-found` when global-not-found is enabled.\n // Prefer to load it when both `global-not-found` and root `not-found` present.\n if (isGlobalNotFoundEnabled) {\n const globalNotFoundPath = await findPageFile(\n appDir,\n 'global-not-found',\n extensions,\n true\n )\n if (globalNotFoundPath) {\n return {\n filename: join(appDir, globalNotFoundPath),\n bundlePath: `app${UNDERSCORE_NOT_FOUND_ROUTE_ENTRY}`,\n page: UNDERSCORE_NOT_FOUND_ROUTE_ENTRY,\n }\n }\n } else {\n // Then if global-not-found.js doesn't exist then load not-found.js\n const notFoundPath = await findPageFile(\n appDir,\n 'not-found',\n extensions,\n true\n )\n if (notFoundPath) {\n return {\n filename: join(appDir, notFoundPath),\n bundlePath: `app${UNDERSCORE_NOT_FOUND_ROUTE_ENTRY}`,\n page: UNDERSCORE_NOT_FOUND_ROUTE_ENTRY,\n }\n }\n }\n\n // If they're not presented, then fallback to global-not-found\n return {\n filename: require.resolve(\n 'next/dist/client/components/builtin/global-not-found'\n ),\n bundlePath: `app${UNDERSCORE_NOT_FOUND_ROUTE_ENTRY}`,\n page: UNDERSCORE_NOT_FOUND_ROUTE_ENTRY,\n }\n }\n pagePath = await findPageFile(appDir, normalizedPagePath, extensions, true)\n if (pagePath) {\n const pageUrl = ensureLeadingSlash(\n removePagePathTail(normalizePathSep(pagePath), {\n keepIndex: true,\n extensions,\n })\n )\n\n return {\n filename: join(appDir, pagePath),\n bundlePath: posix.join('app', pageUrl),\n page: posix.normalize(pageUrl),\n }\n }\n }\n\n if (!pagePath && pagesDir) {\n pagePath = await findPageFile(\n pagesDir,\n normalizedPagePath,\n extensions,\n false\n )\n }\n\n if (pagePath !== null && pagesDir) {\n const pageUrl = ensureLeadingSlash(\n removePagePathTail(normalizePathSep(pagePath), {\n extensions,\n })\n )\n\n return {\n filename: join(pagesDir, pagePath),\n bundlePath: posix.join('pages', normalizePagePath(pageUrl)),\n page: posix.normalize(pageUrl),\n }\n }\n\n if (page === '/_error') {\n return {\n filename: require.resolve('next/dist/pages/_error'),\n bundlePath: page,\n page: normalizePathSep(page),\n }\n } else {\n throw new PageNotFoundError(normalizedPagePath)\n }\n}\n\nexport function onDemandEntryHandler({\n hotReloader,\n maxInactiveAge,\n multiCompiler,\n nextConfig,\n pagesBufferLength,\n pagesDir,\n rootDir,\n appDir,\n}: {\n hotReloader: HotReloaderWebpack\n maxInactiveAge: number\n multiCompiler: webpack.MultiCompiler\n nextConfig: NextConfigComplete\n pagesBufferLength: number\n pagesDir?: string\n rootDir: string\n appDir?: string\n}) {\n const hasAppDir = !!appDir\n let curInvalidator: Invalidator = getInvalidator(\n multiCompiler.outputPath\n ) as any\n const curEntries = getEntries(multiCompiler.outputPath) as any\n\n if (!curInvalidator) {\n curInvalidator = new Invalidator(multiCompiler)\n invalidators.set(multiCompiler.outputPath, curInvalidator)\n }\n\n const startBuilding = (compilation: webpack.Compilation) => {\n const compilationName = compilation.name as any as CompilerNameValues\n curInvalidator.startBuilding(compilationName)\n }\n for (const compiler of multiCompiler.compilers) {\n compiler.hooks.make.tap('NextJsOnDemandEntries', startBuilding)\n }\n\n function getPagePathsFromEntrypoints(\n type: CompilerNameValues,\n entrypoints: Map<string, { name?: string | null }>\n ) {\n const pagePaths: string[] = []\n for (const entrypoint of entrypoints.values()) {\n const page = getRouteFromEntrypoint(entrypoint.name!, hasAppDir)\n\n if (page) {\n const pageBundleType = entrypoint.name?.startsWith('app/')\n ? PAGE_TYPES.APP\n : PAGE_TYPES.PAGES\n pagePaths.push(getEntryKey(type, pageBundleType, page))\n } else if (\n isMiddlewareFilename(entrypoint.name) ||\n isInstrumentationHookFilename(entrypoint.name)\n ) {\n pagePaths.push(\n getEntryKey(type, PAGE_TYPES.ROOT, `/${entrypoint.name}`)\n )\n }\n }\n return pagePaths\n }\n\n for (const compiler of multiCompiler.compilers) {\n compiler.hooks.done.tap('NextJsOnDemandEntries', () =>\n getInvalidator(compiler.outputPath)?.doneBuilding([\n compiler.name as keyof typeof COMPILER_INDEXES,\n ])\n )\n }\n\n multiCompiler.hooks.done.tap('NextJsOnDemandEntries', (multiStats) => {\n const [clientStats, serverStats, edgeServerStats] = multiStats.stats\n const entryNames = [\n ...getPagePathsFromEntrypoints(\n COMPILER_NAMES.client,\n clientStats.compilation.entrypoints\n ),\n ...getPagePathsFromEntrypoints(\n COMPILER_NAMES.server,\n serverStats.compilation.entrypoints\n ),\n ...(edgeServerStats\n ? getPagePathsFromEntrypoints(\n COMPILER_NAMES.edgeServer,\n edgeServerStats.compilation.entrypoints\n )\n : []),\n ]\n\n for (const name of entryNames) {\n const entry = curEntries[name]\n if (!entry) {\n continue\n }\n\n if (entry.status !== BUILDING) {\n continue\n }\n\n entry.status = BUILT\n doneCallbacks.emit(name)\n }\n\n getInvalidator(multiCompiler.outputPath)?.doneBuilding([...COMPILER_KEYS])\n })\n\n const pingIntervalTime = Math.max(1000, Math.min(5000, maxInactiveAge))\n\n setInterval(function () {\n disposeInactiveEntries(curEntries, maxInactiveAge)\n }, pingIntervalTime + 1000).unref()\n\n function handleAppDirPing(tree: FlightRouterState): void {\n const pages = getEntrypointsFromTree(tree, true)\n\n for (const page of pages) {\n for (const compilerType of [\n COMPILER_NAMES.client,\n COMPILER_NAMES.server,\n COMPILER_NAMES.edgeServer,\n ]) {\n const entryKey = getEntryKey(compilerType, PAGE_TYPES.APP, `/${page}`)\n const entryInfo = curEntries[entryKey]\n\n // If there's no entry, it may have been invalidated and needs to be re-built.\n if (!entryInfo) {\n // if (page !== lastEntry) client pings, but there's no entry for page\n continue\n }\n\n // We don't need to maintain active state of anything other than BUILT entries\n if (entryInfo.status !== BUILT) continue\n\n // If there's an entryInfo\n if (!lastServerAccessPagesForAppDir.includes(entryKey)) {\n lastServerAccessPagesForAppDir.unshift(entryKey)\n\n // Maintain the buffer max length\n // TODO: verify that the current pageKey is not at the end of the array as multiple entrypoints can exist\n if (lastServerAccessPagesForAppDir.length > pagesBufferLength) {\n lastServerAccessPagesForAppDir.pop()\n }\n }\n entryInfo.lastActiveTime = Date.now()\n entryInfo.dispose = false\n }\n }\n }\n\n function handlePing(pg: string): void {\n const page = normalizePathSep(pg)\n for (const compilerType of [\n COMPILER_NAMES.client,\n COMPILER_NAMES.server,\n COMPILER_NAMES.edgeServer,\n ]) {\n const entryKey = getEntryKey(compilerType, PAGE_TYPES.PAGES, page)\n const entryInfo = curEntries[entryKey]\n\n // If there's no entry, it may have been invalidated and needs to be re-built.\n if (!entryInfo) {\n // if (page !== lastEntry) client pings, but there's no entry for page\n if (compilerType === COMPILER_NAMES.client) {\n return\n }\n continue\n }\n\n // We don't need to maintain active state of anything other than BUILT entries\n if (entryInfo.status !== BUILT) continue\n\n // If there's an entryInfo\n if (!lastClientAccessPages.includes(entryKey)) {\n lastClientAccessPages.unshift(entryKey)\n\n // Maintain the buffer max length\n if (lastClientAccessPages.length > pagesBufferLength) {\n lastClientAccessPages.pop()\n }\n }\n entryInfo.lastActiveTime = Date.now()\n entryInfo.dispose = false\n }\n return\n }\n\n async function ensurePageImpl({\n page,\n appPaths,\n definition,\n isApp,\n url,\n }: {\n page: string\n appPaths: ReadonlyArray<string> | null\n definition: RouteDefinition | undefined\n isApp: boolean | undefined\n url?: string\n }): Promise<void> {\n const stalledTime = 60\n const stalledEnsureTimeout = setTimeout(() => {\n debug(\n `Ensuring ${page} has taken longer than ${stalledTime}s, if this continues to stall this may be a bug`\n )\n }, stalledTime * 1000)\n\n try {\n let route: Pick<RouteDefinition, 'filename' | 'bundlePath' | 'page'>\n if (definition) {\n route = definition\n } else {\n route = await findPagePathData(\n rootDir,\n page,\n nextConfig.pageExtensions,\n pagesDir,\n appDir,\n !!nextConfig.experimental.globalNotFound\n )\n }\n\n const isInsideAppDir = !!appDir && route.filename.startsWith(appDir)\n\n if (typeof isApp === 'boolean' && isApp !== isInsideAppDir) {\n Error.stackTraceLimit = 15\n throw new Error(\n `Ensure bailed, found path \"${\n route.page\n }\" does not match ensure type (${isApp ? 'app' : 'pages'})`\n )\n }\n\n const pageBundleType = getPageBundleType(route.bundlePath)\n const addEntry = (\n compilerType: CompilerNameValues\n ): {\n entryKey: string\n newEntry: boolean\n shouldInvalidate: boolean\n } => {\n const entryKey = getEntryKey(compilerType, pageBundleType, route.page)\n if (\n curEntries[entryKey] &&\n // there can be an overlap in the entryKey for the instrumentation hook file and a page named the same\n // this is a quick fix to support this scenario by overwriting the instrumentation hook entry, since we only use it one time\n // any changes to the instrumentation hook file will require a restart of the dev server anyway\n !isInstrumentationHookFilename(curEntries[entryKey].bundlePath)\n ) {\n curEntries[entryKey].dispose = false\n curEntries[entryKey].lastActiveTime = Date.now()\n if (curEntries[entryKey].status === BUILT) {\n return {\n entryKey,\n newEntry: false,\n shouldInvalidate: false,\n }\n }\n\n return {\n entryKey,\n newEntry: false,\n shouldInvalidate: true,\n }\n }\n\n curEntries[entryKey] = {\n type: EntryTypes.ENTRY,\n appPaths,\n absolutePagePath: route.filename,\n request: route.filename,\n bundlePath: route.bundlePath,\n dispose: false,\n lastActiveTime: Date.now(),\n status: ADDED,\n }\n return {\n entryKey: entryKey,\n newEntry: true,\n shouldInvalidate: true,\n }\n }\n\n const staticInfo = await getStaticInfoIncludingLayouts({\n page,\n pageFilePath: route.filename,\n isInsideAppDir,\n pageExtensions: nextConfig.pageExtensions,\n isDev: true,\n config: nextConfig,\n appDir,\n })\n\n const added = new Map<CompilerNameValues, ReturnType<typeof addEntry>>()\n const isServerComponent =\n isInsideAppDir && staticInfo.rsc !== RSC_MODULE_TYPES.client\n\n let pageRuntime = staticInfo.runtime\n\n runDependingOnPageType({\n page: route.page,\n pageRuntime,\n pageType: pageBundleType,\n onClient: () => {\n // Skip adding the client entry for app / Server Components.\n if (isServerComponent || isInsideAppDir) {\n return\n }\n added.set(COMPILER_NAMES.client, addEntry(COMPILER_NAMES.client))\n },\n onServer: () => {\n added.set(COMPILER_NAMES.server, addEntry(COMPILER_NAMES.server))\n const edgeServerEntry = getEntryKey(\n COMPILER_NAMES.edgeServer,\n pageBundleType,\n route.page\n )\n if (\n curEntries[edgeServerEntry] &&\n !isInstrumentationHookFile(route.page)\n ) {\n // Runtime switched from edge to server\n delete curEntries[edgeServerEntry]\n }\n },\n onEdgeServer: () => {\n added.set(\n COMPILER_NAMES.edgeServer,\n addEntry(COMPILER_NAMES.edgeServer)\n )\n const serverEntry = getEntryKey(\n COMPILER_NAMES.server,\n pageBundleType,\n route.page\n )\n if (\n curEntries[serverEntry] &&\n !isInstrumentationHookFile(route.page)\n ) {\n // Runtime switched from server to edge\n delete curEntries[serverEntry]\n }\n },\n })\n\n const addedValues = [...added.values()]\n const entriesThatShouldBeInvalidated = [...added.entries()].filter(\n ([, entry]) => entry.shouldInvalidate\n )\n const hasNewEntry = addedValues.some((entry) => entry.newEntry)\n\n if (hasNewEntry) {\n const routePage = isApp ? route.page : normalizeAppPath(route.page)\n // If proxy file, remove the leading slash from \"/proxy\" to \"proxy\".\n reportTrigger(\n isMiddlewareFile(routePage) ? routePage.slice(1) : routePage,\n url\n )\n }\n\n if (entriesThatShouldBeInvalidated.length > 0) {\n const invalidatePromise = Promise.all(\n entriesThatShouldBeInvalidated.map(([compilerKey, { entryKey }]) => {\n return new Promise<void>((resolve, reject) => {\n doneCallbacks.once(entryKey, (err: Error) => {\n if (err) {\n return reject(err)\n }\n\n // If the invalidation also triggers a rebuild, we need to\n // wait for that additional build to prevent race conditions.\n const needsRebuild = curInvalidator.willRebuild(compilerKey)\n if (needsRebuild) {\n doneCallbacks.once(entryKey, (rebuildErr: Error) => {\n if (rebuildErr) {\n return reject(rebuildErr)\n }\n resolve()\n })\n } else {\n resolve()\n }\n })\n })\n })\n )\n\n curInvalidator.invalidate([...added.keys()])\n await invalidatePromise\n }\n } finally {\n clearTimeout(stalledEnsureTimeout)\n }\n }\n\n type EnsurePageOptions = {\n page: string\n appPaths?: ReadonlyArray<string> | null\n definition?: RouteDefinition\n isApp?: boolean\n url?: string\n }\n\n // Make sure that we won't have multiple invalidations ongoing concurrently.\n const batcher = Batcher.create<EnsurePageOptions, void, string>({\n // The cache key here is composed of the elements that affect the\n // compilation, namely, the page, whether it's client only, and whether\n // it's an app page. This ensures that we don't have multiple compilations\n // for the same page happening concurrently.\n //\n // We don't include the whole match because it contains match specific\n // parameters (like route params) that would just bust this cache. Any\n // details that would possibly bust the cache should be listed here.\n cacheKeyFn: (options) => JSON.stringify(options),\n // Schedule the invocation of the ensurePageImpl function on the next tick.\n schedulerFn: scheduleOnNextTick,\n })\n\n return {\n async ensurePage({\n page,\n appPaths = null,\n definition,\n isApp,\n url,\n }: EnsurePageOptions) {\n // If the route is actually an app page route, then we should have access\n // to the app route definition, and therefore, the appPaths from it.\n if (!appPaths && definition && isAppPageRouteDefinition(definition)) {\n appPaths = definition.appPaths\n }\n\n // Wrap the invocation of the ensurePageImpl function in the pending\n // wrapper, which will ensure that we don't have multiple compilations\n // for the same page happening concurrently.\n return batcher.batch({ page, appPaths, definition, isApp }, async () => {\n await ensurePageImpl({\n page,\n appPaths,\n definition,\n isApp,\n url,\n })\n })\n },\n onHMR(client: ws, getHmrServerError: () => Error | null) {\n let bufferedHmrServerError: Error | null = null\n\n client.addEventListener('close', () => {\n bufferedHmrServerError = null\n })\n client.addEventListener('message', ({ data }) => {\n try {\n const error = getHmrServerError()\n\n // New error occurred: buffered error is flushed and new error occurred\n if (!bufferedHmrServerError && error) {\n hotReloader.send({\n type: HMR_MESSAGE_SENT_TO_BROWSER.SERVER_ERROR,\n errorJSON: stringifyError(error),\n })\n bufferedHmrServerError = null\n }\n\n const parsedData = JSON.parse(\n typeof data !== 'string' ? data.toString() : data\n )\n\n if (parsedData.event === HMR_MESSAGE_SENT_TO_SERVER.PING) {\n if (parsedData.appDirRoute) {\n handleAppDirPing(parsedData.tree)\n } else {\n handlePing(parsedData.page)\n }\n } else if (\n parsedData.event ===\n HMR_MESSAGE_SENT_TO_SERVER.MCP_ERROR_STATE_RESPONSE\n ) {\n handleErrorStateResponse(\n parsedData.requestId,\n parsedData.errorState,\n parsedData.url\n )\n } else if (\n parsedData.event ===\n HMR_MESSAGE_SENT_TO_SERVER.MCP_PAGE_METADATA_RESPONSE\n ) {\n handlePageMetadataResponse(\n parsedData.requestId,\n parsedData.segmentTrieData,\n parsedData.url\n )\n }\n } catch {}\n })\n },\n }\n}\n"],"names":["ADDED","BUILDING","BUILT","EntryTypes","findPagePathData","getEntries","getEntryKey","getInvalidator","onDemandEntryHandler","debug","createDebug","keys","Object","COMPILER_KEYS","COMPILER_INDEXES","treePathToEntrypoint","segmentPath","parentPath","parallelRouteKey","segment","path","startsWith","length","childSegmentPath","getNextFlightSegmentPath","convertDynamicParamTypeToSyntax","dynamicParamTypeShort","param","Error","compilerType","pageBundleType","page","pageKey","replace","getPageBundleType","pageBundlePath","PAGE_TYPES","PAGES","isMiddlewareFilename","ROOT","APP","getEntrypointsFromTree","tree","isFirst","parallelRoutes","currentSegment","Array","isArray","isPageSegment","PAGE_SEGMENT_KEY","currentPath","slice","reduce","paths","key","childTree","childPages","Symbol","entriesMap","Map","normalizeOutputPath","dir","entries","get","set","invalidators","doneCallbacks","EventEmitter","lastClientAccessPages","lastServerAccessPagesForAppDir","Invalidator","constructor","multiCompiler","building","Set","rebuildAgain","shouldRebuildAll","size","invalidate","compilerKeys","has","add","compilers","watching","startBuilding","compilerKey","doneBuilding","rebuild","delete","push","willRebuild","disposeInactiveEntries","maxInactiveAge","forEach","entryKey","entryData","lastActiveTime","status","dispose","bundlePath","type","isInstrumentationHookFilename","includes","Date","now","tryToNormalizePagePath","normalizePagePath","err","console","error","PageNotFoundError","rootDir","extensions","pagesDir","appDir","isGlobalNotFoundEnabled","normalizedPagePath","pagePath","isInstrumentation","isInstrumentationHookFile","isMiddlewareFile","findPageFile","pageUrl","ensureLeadingSlash","removePagePathTail","normalizePathSep","posix","normalize","filename","join","UNDERSCORE_NOT_FOUND_ROUTE_ENTRY","globalNotFoundPath","notFoundPath","require","resolve","keepIndex","hotReloader","nextConfig","pagesBufferLength","hasAppDir","curInvalidator","outputPath","curEntries","compilation","compilationName","name","compiler","hooks","make","tap","getPagePathsFromEntrypoints","entrypoints","pagePaths","entrypoint","values","getRouteFromEntrypoint","done","multiStats","clientStats","serverStats","edgeServerStats","stats","entryNames","COMPILER_NAMES","client","server","edgeServer","entry","emit","pingIntervalTime","Math","max","min","setInterval","unref","handleAppDirPing","pages","entryInfo","unshift","pop","handlePing","pg","ensurePageImpl","appPaths","definition","isApp","url","stalledTime","stalledEnsureTimeout","setTimeout","route","pageExtensions","experimental","globalNotFound","isInsideAppDir","stackTraceLimit","addEntry","newEntry","shouldInvalidate","absolutePagePath","request","staticInfo","getStaticInfoIncludingLayouts","pageFilePath","isDev","config","added","isServerComponent","rsc","RSC_MODULE_TYPES","pageRuntime","runtime","runDependingOnPageType","pageType","onClient","onServer","edgeServerEntry","onEdgeServer","serverEntry","addedValues","entriesThatShouldBeInvalidated","filter","hasNewEntry","some","routePage","normalizeAppPath","reportTrigger","invalidatePromise","Promise","all","map","reject","once","needsRebuild","rebuildErr","clearTimeout","batcher","Batcher","create","cacheKeyFn","options","JSON","stringify","schedulerFn","scheduleOnNextTick","ensurePage","isAppPageRouteDefinition","batch","onHMR","getHmrServerError","bufferedHmrServerError","addEventListener","data","send","HMR_MESSAGE_SENT_TO_BROWSER","SERVER_ERROR","errorJSON","stringifyError","parsedData","parse","toString","event","HMR_MESSAGE_SENT_TO_SERVER","PING","appDirRoute","MCP_ERROR_STATE_RESPONSE","handleErrorStateResponse","requestId","errorState","MCP_PAGE_METADATA_RESPONSE","handlePageMetadataResponse","segmentTrieData"],"mappings":";;;;;;;;;;;;;;;;;;;;;;IAoKaA,KAAK;eAALA;;IACAC,QAAQ;eAARA;;IACAC,KAAK;eAALA;;IA8BKC,UAAU;eAAVA;;IAsMIC,gBAAgB;eAAhBA;;IAzJTC,UAAU;eAAVA;;IApIGC,WAAW;eAAXA;;IA+IHC,cAAc;eAAdA;;IA2RGC,oBAAoB;eAApBA;;;8DA3gBQ;wBACK;8BACA;yBACU;+CACO;sBAClB;kCACK;mCACC;oCACC;oCACA;wBACL;+EACK;uBAM5B;wBAC2C;2BAM3C;yBAC0B;kCAI1B;wCACkC;2BACN;yBACX;0BACS;2BACN;mCACc;2BACA;iCACE;;;;;;AAE3C,MAAMC,QAAQC,IAAAA,cAAW,EAAC;AAE1B;;CAEC,GACD,MAAMC,OAAOC,OAAOD,IAAI;AAExB,MAAME,gBAAgBF,KAAKG,2BAAgB;AAE3C,SAASC,qBACPC,WAA8B,EAC9BC,UAAmB;IAEnB,MAAM,CAACC,kBAAkBC,QAAQ,GAAGH;IAEpC,kEAAkE;IAClE,MAAMI,OACJ,AAACH,CAAAA,aAAaA,aAAa,MAAM,EAAC,IACjCC,CAAAA,qBAAqB,cAAc,CAACC,QAAQE,UAAU,CAAC,OACpD,CAAC,CAAC,EAAEH,iBAAiB,CAAC,CAAC,GACvB,EAAC,IACJC,CAAAA,YAAY,KAAK,SAASA,OAAM;IAEnC,eAAe;IACf,IAAIH,YAAYM,MAAM,KAAK,GAAG;QAC5B,OAAOF;IACT;IAEA,MAAMG,mBAAmBC,IAAAA,2CAAwB,EAACR;IAClD,OAAOD,qBAAqBQ,kBAAkBH;AAChD;AAEA,SAASK,gCACPC,qBAA6C,EAC7CC,KAAa;IAEb,OAAQD;QACN,KAAK;QACL,KAAK;YACH,OAAO,CAAC,IAAI,EAAEC,MAAM,CAAC,CAAC;QACxB,KAAK;YACH,OAAO,CAA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AE;wBACxD,IAAIL,WAAWM,WAAW,EAAE;4BAC1BzF,iBAAiBmF,WAAWxN,IAAI;wBAClC,OAAO;4BACL0I,WAAW8E,WAAWnO,IAAI;wBAC5B;oBACF,OAAO,IACLmO,WAAWG,KAAK,KAChBC,4CAA0B,CAACG,wBAAwB,EACnD;wBACAC,IAAAA,mCAAwB,EACtBR,WAAWS,SAAS,EACpBT,WAAWU,UAAU,EACrBV,WAAWxE,GAAG;oBAElB,OAAO,IACLwE,WAAWG,KAAK,KAChBC,4CAA0B,CAACO,0BAA0B,EACrD;wBACAC,IAAAA,2CAA0B,EACxBZ,WAAWS,SAAS,EACpBT,WAAWa,eAAe,EAC1Bb,WAAWxE,GAAG;oBAElB;gBACF,EAAE,OAAM,CAAC;YACX;QACF;IACF;AACF","ignoreList":[0]}
|
|
@@ -65,6 +65,7 @@ const _log = /*#__PURE__*/ _interop_require_wildcard(require("../../build/output
|
|
|
65
65
|
const _entrykey = require("../../shared/lib/turbopack/entry-key");
|
|
66
66
|
const _ismetadataroute = require("../../lib/metadata/is-metadata-route");
|
|
67
67
|
const _utils = require("../../shared/lib/turbopack/utils");
|
|
68
|
+
const _constants = require("../../lib/constants");
|
|
68
69
|
function _getRequireWildcardCache(nodeInterop) {
|
|
69
70
|
if (typeof WeakMap !== "function") return null;
|
|
70
71
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -515,9 +516,10 @@ async function handleEntrypoints({ entrypoints, currentEntrypoints, currentEntry
|
|
|
515
516
|
if (middleware) {
|
|
516
517
|
const key = (0, _entrykey.getEntryKey)('root', 'server', 'middleware');
|
|
517
518
|
const endpoint = middleware.endpoint;
|
|
519
|
+
const triggerName = middleware.isProxy ? _constants.PROXY_FILENAME : _constants.MIDDLEWARE_FILENAME;
|
|
518
520
|
async function processMiddleware() {
|
|
519
521
|
var _manifestLoader_getMiddlewareManifest;
|
|
520
|
-
const finishBuilding = dev.hooks.startBuilding(
|
|
522
|
+
const finishBuilding = dev.hooks.startBuilding(triggerName, undefined, true);
|
|
521
523
|
const writtenEndpoint = await endpoint.writeToDisk();
|
|
522
524
|
dev.hooks.handleWrittenEndpoint(key, writtenEndpoint, false);
|
|
523
525
|
(0, _utils.processIssues)(currentEntryIssues, key, writtenEndpoint, false, logErrors);
|
|
@@ -535,7 +537,7 @@ async function handleEntrypoints({ entrypoints, currentEntrypoints, currentEntry
|
|
|
535
537
|
await processMiddleware();
|
|
536
538
|
if (dev) {
|
|
537
539
|
dev == null ? void 0 : dev.hooks.subscribeToChanges(key, false, endpoint, async ()=>{
|
|
538
|
-
const finishBuilding = dev.hooks.startBuilding(
|
|
540
|
+
const finishBuilding = dev.hooks.startBuilding(triggerName, undefined, true);
|
|
539
541
|
await processMiddleware();
|
|
540
542
|
await dev.hooks.propagateServerField('actualMiddlewareFile', dev.serverFields.actualMiddlewareFile);
|
|
541
543
|
await dev.hooks.propagateServerField('middleware', dev.serverFields.middleware);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/dev/turbopack-utils.ts"],"sourcesContent":["import type {\n ServerFields,\n SetupOpts,\n} from '../lib/router-utils/setup-dev-bundler'\nimport type {\n Issue,\n TurbopackResult,\n Endpoint,\n RawEntrypoints,\n Update as TurbopackUpdate,\n WrittenEndpoint,\n} from '../../build/swc/types'\nimport {\n type HmrMessageSentToBrowser,\n HMR_MESSAGE_SENT_TO_BROWSER,\n} from './hot-reloader-types'\nimport * as Log from '../../build/output/log'\nimport type { PropagateToWorkersField } from '../lib/router-utils/types'\nimport type { TurbopackManifestLoader } from '../../shared/lib/turbopack/manifest-loader'\nimport type { AppRoute, Entrypoints, PageRoute } from '../../build/swc/types'\nimport {\n type EntryKey,\n getEntryKey,\n splitEntryKey,\n} from '../../shared/lib/turbopack/entry-key'\nimport type ws from 'next/dist/compiled/ws'\nimport { isMetadataRoute } from '../../lib/metadata/is-metadata-route'\nimport type { CustomRoutes } from '../../lib/load-custom-routes'\nimport {\n formatIssue,\n getIssueKey,\n isRelevantWarning,\n processIssues,\n renderStyledStringToErrorAnsi,\n type EntryIssuesMap,\n type TopLevelIssuesMap,\n} from '../../shared/lib/turbopack/utils'\n\nconst onceErrorSet = new Set()\n/**\n * Check if given issue is a warning to be display only once.\n * This mimics behavior of get-page-static-info's warnOnce.\n * @param issue\n * @returns\n */\nfunction shouldEmitOnceWarning(issue: Issue): boolean {\n const { severity, title, stage } = issue\n if (severity === 'warning' && title.value === 'Invalid page configuration') {\n if (onceErrorSet.has(issue)) {\n return false\n }\n onceErrorSet.add(issue)\n }\n if (\n severity === 'warning' &&\n stage === 'config' &&\n renderStyledStringToErrorAnsi(issue.title).includes(\"can't be external\")\n ) {\n if (onceErrorSet.has(issue)) {\n return false\n }\n onceErrorSet.add(issue)\n }\n\n return true\n}\n\n/// Print out an issue to the console which should not block\n/// the build by throwing out or blocking error overlay.\nexport function printNonFatalIssue(issue: Issue) {\n if (isRelevantWarning(issue) && shouldEmitOnceWarning(issue)) {\n Log.warn(formatIssue(issue))\n }\n}\n\nexport function processTopLevelIssues(\n currentTopLevelIssues: TopLevelIssuesMap,\n result: TurbopackResult\n) {\n currentTopLevelIssues.clear()\n\n for (const issue of result.issues) {\n const issueKey = getIssueKey(issue)\n currentTopLevelIssues.set(issueKey, issue)\n }\n}\n\nconst MILLISECONDS_IN_NANOSECOND = BigInt(1_000_000)\n\nexport function msToNs(ms: number): bigint {\n return BigInt(Math.floor(ms)) * MILLISECONDS_IN_NANOSECOND\n}\n\nexport type ChangeSubscriptions = Map<\n EntryKey,\n Promise<AsyncIterableIterator<TurbopackResult>>\n>\n\nexport type HandleWrittenEndpoint = (\n key: EntryKey,\n result: TurbopackResult<WrittenEndpoint>,\n forceDeleteCache: boolean\n) => boolean\n\nexport type StartChangeSubscription = (\n key: EntryKey,\n includeIssues: boolean,\n endpoint: Endpoint,\n createMessage: (\n change: TurbopackResult,\n hash: string\n ) => Promise<HmrMessageSentToBrowser> | HmrMessageSentToBrowser | void,\n onError?: (\n e: Error\n ) => Promise<HmrMessageSentToBrowser> | HmrMessageSentToBrowser | void\n) => Promise<void>\n\nexport type StopChangeSubscription = (key: EntryKey) => Promise<void>\n\nexport type SendHmr = (id: string, message: HmrMessageSentToBrowser) => void\n\nexport type StartBuilding = (\n id: string,\n requestUrl: string | undefined,\n forceRebuild: boolean\n) => () => void\n\nexport type ReadyIds = Set<string>\n\nexport type ClientState = {\n clientIssues: EntryIssuesMap\n messages: Map<string, HmrMessageSentToBrowser>\n turbopackUpdates: TurbopackUpdate[]\n subscriptions: Map<string, AsyncIterator<any>>\n}\n\nexport type ClientStateMap = WeakMap<ws, ClientState>\n\n// hooks only used by the dev server.\ntype HandleRouteTypeHooks = {\n handleWrittenEndpoint: HandleWrittenEndpoint\n subscribeToChanges: StartChangeSubscription\n}\n\nexport async function handleRouteType({\n dev,\n page,\n pathname,\n route,\n currentEntryIssues,\n entrypoints,\n manifestLoader,\n readyIds,\n devRewrites,\n productionRewrites,\n hooks,\n logErrors,\n}: {\n dev: boolean\n page: string\n pathname: string\n route: PageRoute | AppRoute\n\n currentEntryIssues: EntryIssuesMap\n entrypoints: Entrypoints\n manifestLoader: TurbopackManifestLoader\n devRewrites: SetupOpts['fsChecker']['rewrites'] | undefined\n productionRewrites: CustomRoutes['rewrites'] | undefined\n logErrors: boolean\n\n readyIds?: ReadyIds // dev\n\n hooks?: HandleRouteTypeHooks // dev\n}) {\n const shouldCreateWebpackStats = process.env.TURBOPACK_STATS != null\n\n switch (route.type) {\n case 'page': {\n const clientKey = getEntryKey('pages', 'client', page)\n const serverKey = getEntryKey('pages', 'server', page)\n\n try {\n // In the best case scenario, Turbopack chunks document, app, page separately in that order,\n // so it can happen that the chunks of document change, but the chunks of app and page\n // don't. We still need to reload the page chunks in that case though, otherwise the version\n // of the document or app component export from the pages template is stale.\n let documentOrAppChanged = false\n if (entrypoints.global.app) {\n const key = getEntryKey('pages', 'server', '_app')\n\n const writtenEndpoint = await entrypoints.global.app.writeToDisk()\n documentOrAppChanged ||=\n hooks?.handleWrittenEndpoint(key, writtenEndpoint, false) ?? false\n processIssues(\n currentEntryIssues,\n key,\n writtenEndpoint,\n false,\n logErrors\n )\n }\n await manifestLoader.loadBuildManifest('_app')\n await manifestLoader.loadPagesManifest('_app')\n\n if (entrypoints.global.document) {\n const key = getEntryKey('pages', 'server', '_document')\n\n const writtenEndpoint =\n await entrypoints.global.document.writeToDisk()\n documentOrAppChanged ||=\n hooks?.handleWrittenEndpoint(key, writtenEndpoint, false) ?? false\n processIssues(\n currentEntryIssues,\n key,\n writtenEndpoint,\n false,\n logErrors\n )\n }\n await manifestLoader.loadPagesManifest('_document')\n\n const writtenEndpoint = await route.htmlEndpoint.writeToDisk()\n hooks?.handleWrittenEndpoint(\n serverKey,\n writtenEndpoint,\n documentOrAppChanged\n )\n\n const type = writtenEndpoint?.type\n\n await manifestLoader.loadClientBuildManifest(page)\n await manifestLoader.loadBuildManifest(page)\n await manifestLoader.loadPagesManifest(page)\n if (type === 'edge') {\n await manifestLoader.loadMiddlewareManifest(page, 'pages')\n } else {\n manifestLoader.deleteMiddlewareManifest(serverKey)\n }\n await manifestLoader.loadFontManifest('/_app', 'pages')\n await manifestLoader.loadFontManifest(page, 'pages')\n\n if (shouldCreateWebpackStats) {\n await manifestLoader.loadWebpackStats(page, 'pages')\n }\n\n manifestLoader.writeManifests({\n devRewrites,\n productionRewrites,\n entrypoints,\n })\n\n processIssues(\n currentEntryIssues,\n serverKey,\n writtenEndpoint,\n false,\n logErrors\n )\n } finally {\n if (dev) {\n // TODO subscriptions should only be caused by the WebSocket connections\n // otherwise we don't known when to unsubscribe and this leaking\n hooks?.subscribeToChanges(\n serverKey,\n false,\n route.dataEndpoint,\n () => {\n // Report the next compilation again\n readyIds?.delete(pathname)\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.SERVER_ONLY_CHANGES,\n pages: [page],\n }\n },\n (e) => {\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.RELOAD_PAGE,\n data: `error in ${page} data subscription: ${e}`,\n }\n }\n )\n hooks?.subscribeToChanges(\n clientKey,\n false,\n route.htmlEndpoint,\n () => {\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.CLIENT_CHANGES,\n }\n },\n (e) => {\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.RELOAD_PAGE,\n data: `error in ${page} html subscription: ${e}`,\n }\n }\n )\n if (entrypoints.global.document) {\n hooks?.subscribeToChanges(\n getEntryKey('pages', 'server', '_document'),\n false,\n entrypoints.global.document,\n () => {\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.RELOAD_PAGE,\n data: '_document has changed (page route)',\n }\n },\n (e) => {\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.RELOAD_PAGE,\n data: `error in _document subscription (page route): ${e}`,\n }\n }\n )\n }\n }\n }\n\n break\n }\n case 'page-api': {\n const key = getEntryKey('pages', 'server', page)\n\n const writtenEndpoint = await route.endpoint.writeToDisk()\n hooks?.handleWrittenEndpoint(key, writtenEndpoint, false)\n\n const type = writtenEndpoint.type\n\n await manifestLoader.loadPagesManifest(page)\n if (type === 'edge') {\n await manifestLoader.loadMiddlewareManifest(page, 'pages')\n } else {\n manifestLoader.deleteMiddlewareManifest(key)\n }\n\n manifestLoader.writeManifests({\n devRewrites,\n productionRewrites,\n entrypoints,\n })\n\n processIssues(currentEntryIssues, key, writtenEndpoint, true, logErrors)\n\n break\n }\n case 'app-page': {\n const key = getEntryKey('app', 'server', page)\n\n const writtenEndpoint = await route.htmlEndpoint.writeToDisk()\n hooks?.handleWrittenEndpoint(key, writtenEndpoint, false)\n\n if (dev) {\n // TODO subscriptions should only be caused by the WebSocket connections\n // otherwise we don't known when to unsubscribe and this leaking\n hooks?.subscribeToChanges(\n key,\n true,\n route.rscEndpoint,\n (change, hash) => {\n if (change.issues.some((issue) => issue.severity === 'error')) {\n // Ignore any updates that has errors\n // There will be another update without errors eventually\n return\n }\n // Report the next compilation again\n readyIds?.delete(pathname)\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.SERVER_COMPONENT_CHANGES,\n hash,\n }\n },\n (e) => {\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.RELOAD_PAGE,\n data: `error in ${page} app-page subscription: ${e}`,\n }\n }\n )\n }\n\n const type = writtenEndpoint.type\n\n if (type === 'edge') {\n manifestLoader.loadMiddlewareManifest(page, 'app')\n } else {\n manifestLoader.deleteMiddlewareManifest(key)\n }\n\n manifestLoader.loadBuildManifest(page, 'app')\n manifestLoader.loadAppPathsManifest(page)\n manifestLoader.loadActionManifest(page)\n manifestLoader.loadFontManifest(page, 'app')\n\n if (shouldCreateWebpackStats) {\n manifestLoader.loadWebpackStats(page, 'app')\n }\n\n manifestLoader.writeManifests({\n devRewrites,\n productionRewrites,\n entrypoints,\n })\n\n processIssues(currentEntryIssues, key, writtenEndpoint, dev, logErrors)\n\n break\n }\n case 'app-route': {\n const key = getEntryKey('app', 'server', page)\n\n const writtenEndpoint = await route.endpoint.writeToDisk()\n hooks?.handleWrittenEndpoint(key, writtenEndpoint, false)\n\n const type = writtenEndpoint.type\n\n manifestLoader.loadAppPathsManifest(page)\n\n if (type === 'edge') {\n manifestLoader.loadMiddlewareManifest(page, 'app')\n } else {\n manifestLoader.deleteMiddlewareManifest(key)\n }\n\n manifestLoader.writeManifests({\n devRewrites,\n productionRewrites,\n entrypoints,\n })\n processIssues(currentEntryIssues, key, writtenEndpoint, true, logErrors)\n\n break\n }\n default: {\n throw new Error(`unknown route type ${(route as any).type} for ${page}`)\n }\n }\n}\n\n/**\n * Maintains a mapping between entrypoins and the corresponding client asset paths.\n */\nexport class AssetMapper {\n private entryMap: Map<EntryKey, Set<string>> = new Map()\n private assetMap: Map<string, Set<EntryKey>> = new Map()\n\n /**\n * Overrides asset paths for a key and updates the mapping from path to key.\n *\n * @param key\n * @param assetPaths asset paths relative to the .next directory\n */\n setPathsForKey(key: EntryKey, assetPaths: string[]): void {\n this.delete(key)\n\n const newAssetPaths = new Set(assetPaths)\n this.entryMap.set(key, newAssetPaths)\n\n for (const assetPath of newAssetPaths) {\n let assetPathKeys = this.assetMap.get(assetPath)\n if (!assetPathKeys) {\n assetPathKeys = new Set()\n this.assetMap.set(assetPath, assetPathKeys)\n }\n\n assetPathKeys!.add(key)\n }\n }\n\n /**\n * Deletes the key and any asset only referenced by this key.\n *\n * @param key\n */\n delete(key: EntryKey) {\n for (const assetPath of this.getAssetPathsByKey(key)) {\n const assetPathKeys = this.assetMap.get(assetPath)\n\n assetPathKeys?.delete(key)\n\n if (!assetPathKeys?.size) {\n this.assetMap.delete(assetPath)\n }\n }\n\n this.entryMap.delete(key)\n }\n\n getAssetPathsByKey(key: EntryKey): string[] {\n return Array.from(this.entryMap.get(key) ?? [])\n }\n\n getKeysByAsset(path: string): EntryKey[] {\n return Array.from(this.assetMap.get(path) ?? [])\n }\n\n keys(): IterableIterator<EntryKey> {\n return this.entryMap.keys()\n }\n}\n\nexport function hasEntrypointForKey(\n entrypoints: Entrypoints,\n key: EntryKey,\n assetMapper: AssetMapper | undefined\n): boolean {\n const { type, page } = splitEntryKey(key)\n\n switch (type) {\n case 'app':\n return entrypoints.app.has(page)\n case 'pages':\n switch (page) {\n case '_app':\n return entrypoints.global.app != null\n case '_document':\n return entrypoints.global.document != null\n case '_error':\n return entrypoints.global.error != null\n default:\n return entrypoints.page.has(page)\n }\n case 'root':\n switch (page) {\n case 'middleware':\n return entrypoints.global.middleware != null\n case 'instrumentation':\n return entrypoints.global.instrumentation != null\n default:\n return false\n }\n case 'assets':\n if (!assetMapper) {\n return false\n }\n\n return assetMapper\n .getKeysByAsset(page)\n .some((pageKey) =>\n hasEntrypointForKey(entrypoints, pageKey, assetMapper)\n )\n default: {\n // validation that we covered all cases, this should never run.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const _: never = type\n return false\n }\n }\n}\n\n// hooks only used by the dev server.\ntype HandleEntrypointsHooks = {\n handleWrittenEndpoint: HandleWrittenEndpoint\n propagateServerField: (\n field: PropagateToWorkersField,\n args: any\n ) => Promise<void>\n sendHmr: SendHmr\n startBuilding: StartBuilding\n subscribeToChanges: StartChangeSubscription\n unsubscribeFromChanges: StopChangeSubscription\n unsubscribeFromHmrEvents: (client: ws, id: string) => void\n}\n\ntype HandleEntrypointsDevOpts = {\n assetMapper: AssetMapper\n changeSubscriptions: ChangeSubscriptions\n clients: Array<ws>\n clientStates: ClientStateMap\n serverFields: ServerFields\n\n hooks: HandleEntrypointsHooks\n}\n\nexport async function handleEntrypoints({\n entrypoints,\n\n currentEntrypoints,\n\n currentEntryIssues,\n manifestLoader,\n devRewrites,\n logErrors,\n dev,\n}: {\n entrypoints: TurbopackResult<RawEntrypoints>\n\n currentEntrypoints: Entrypoints\n\n currentEntryIssues: EntryIssuesMap\n manifestLoader: TurbopackManifestLoader\n devRewrites: SetupOpts['fsChecker']['rewrites'] | undefined\n productionRewrites: CustomRoutes['rewrites'] | undefined\n logErrors: boolean\n\n dev: HandleEntrypointsDevOpts\n}) {\n currentEntrypoints.global.app = entrypoints.pagesAppEndpoint\n currentEntrypoints.global.document = entrypoints.pagesDocumentEndpoint\n currentEntrypoints.global.error = entrypoints.pagesErrorEndpoint\n\n currentEntrypoints.global.instrumentation = entrypoints.instrumentation\n\n currentEntrypoints.page.clear()\n currentEntrypoints.app.clear()\n\n for (const [pathname, route] of entrypoints.routes) {\n switch (route.type) {\n case 'page':\n case 'page-api':\n currentEntrypoints.page.set(pathname, route)\n break\n case 'app-page': {\n route.pages.forEach((page) => {\n currentEntrypoints.app.set(page.originalName, {\n type: 'app-page',\n ...page,\n })\n })\n break\n }\n case 'app-route': {\n currentEntrypoints.app.set(route.originalName, route)\n break\n }\n case 'conflict':\n Log.info(`skipping ${pathname} (${route.type})`)\n break\n default:\n route satisfies never\n }\n }\n\n if (dev) {\n await handleEntrypointsDevCleanup({\n currentEntryIssues,\n currentEntrypoints,\n\n ...dev,\n })\n }\n\n const { middleware, instrumentation } = entrypoints\n\n // We check for explicit true/false, since it's initialized to\n // undefined during the first loop (middlewareChanges event is\n // unnecessary during the first serve)\n if (currentEntrypoints.global.middleware && !middleware) {\n const key = getEntryKey('root', 'server', 'middleware')\n // Went from middleware to no middleware\n await dev?.hooks.unsubscribeFromChanges(key)\n currentEntryIssues.delete(key)\n dev.hooks.sendHmr('middleware', {\n type: HMR_MESSAGE_SENT_TO_BROWSER.MIDDLEWARE_CHANGES,\n })\n } else if (!currentEntrypoints.global.middleware && middleware) {\n // Went from no middleware to middleware\n dev.hooks.sendHmr('middleware', {\n type: HMR_MESSAGE_SENT_TO_BROWSER.MIDDLEWARE_CHANGES,\n })\n }\n\n currentEntrypoints.global.middleware = middleware\n\n if (instrumentation) {\n const processInstrumentation = async (\n name: string,\n prop: 'nodeJs' | 'edge'\n ) => {\n const prettyName = {\n nodeJs: 'Node.js',\n edge: 'Edge',\n }\n const finishBuilding = dev.hooks.startBuilding(\n `instrumentation ${prettyName[prop]}`,\n undefined,\n true\n )\n const key = getEntryKey('root', 'server', name)\n\n const writtenEndpoint = await instrumentation[prop].writeToDisk()\n dev.hooks.handleWrittenEndpoint(key, writtenEndpoint, false)\n processIssues(currentEntryIssues, key, writtenEndpoint, false, logErrors)\n finishBuilding()\n }\n await processInstrumentation('instrumentation.nodeJs', 'nodeJs')\n await processInstrumentation('instrumentation.edge', 'edge')\n await manifestLoader.loadMiddlewareManifest(\n 'instrumentation',\n 'instrumentation'\n )\n manifestLoader.writeManifests({\n devRewrites,\n productionRewrites: undefined,\n entrypoints: currentEntrypoints,\n })\n\n dev.serverFields.actualInstrumentationHookFile = '/instrumentation'\n await dev.hooks.propagateServerField(\n 'actualInstrumentationHookFile',\n dev.serverFields.actualInstrumentationHookFile\n )\n } else {\n dev.serverFields.actualInstrumentationHookFile = undefined\n await dev.hooks.propagateServerField(\n 'actualInstrumentationHookFile',\n dev.serverFields.actualInstrumentationHookFile\n )\n }\n\n if (middleware) {\n const key = getEntryKey('root', 'server', 'middleware')\n\n const endpoint = middleware.endpoint\n\n async function processMiddleware() {\n const finishBuilding = dev.hooks.startBuilding(\n 'middleware',\n undefined,\n true\n )\n const writtenEndpoint = await endpoint.writeToDisk()\n dev.hooks.handleWrittenEndpoint(key, writtenEndpoint, false)\n processIssues(currentEntryIssues, key, writtenEndpoint, false, logErrors)\n await manifestLoader.loadMiddlewareManifest('middleware', 'middleware')\n const middlewareConfig =\n manifestLoader.getMiddlewareManifest(key)?.middleware['/']\n\n if (dev && middlewareConfig) {\n dev.serverFields.middleware = {\n match: null as any,\n page: '/',\n matchers: middlewareConfig.matchers,\n }\n }\n finishBuilding()\n }\n await processMiddleware()\n\n if (dev) {\n dev?.hooks.subscribeToChanges(\n key,\n false,\n endpoint,\n async () => {\n const finishBuilding = dev.hooks.startBuilding(\n 'middleware',\n undefined,\n true\n )\n await processMiddleware()\n await dev.hooks.propagateServerField(\n 'actualMiddlewareFile',\n dev.serverFields.actualMiddlewareFile\n )\n await dev.hooks.propagateServerField(\n 'middleware',\n dev.serverFields.middleware\n )\n manifestLoader.writeManifests({\n devRewrites,\n productionRewrites: undefined,\n entrypoints: currentEntrypoints,\n })\n\n finishBuilding?.()\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.MIDDLEWARE_CHANGES,\n }\n },\n () => {\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.MIDDLEWARE_CHANGES,\n }\n }\n )\n }\n } else {\n manifestLoader.deleteMiddlewareManifest(\n getEntryKey('root', 'server', 'middleware')\n )\n dev.serverFields.actualMiddlewareFile = undefined\n dev.serverFields.middleware = undefined\n }\n\n await dev.hooks.propagateServerField(\n 'actualMiddlewareFile',\n dev.serverFields.actualMiddlewareFile\n )\n await dev.hooks.propagateServerField(\n 'middleware',\n dev.serverFields.middleware\n )\n}\n\nasync function handleEntrypointsDevCleanup({\n currentEntryIssues,\n currentEntrypoints,\n\n assetMapper,\n changeSubscriptions,\n clients,\n clientStates,\n\n hooks,\n}: {\n currentEntrypoints: Entrypoints\n currentEntryIssues: EntryIssuesMap\n} & HandleEntrypointsDevOpts) {\n // this needs to be first as `hasEntrypointForKey` uses the `assetMapper`\n for (const key of assetMapper.keys()) {\n if (!hasEntrypointForKey(currentEntrypoints, key, assetMapper)) {\n assetMapper.delete(key)\n }\n }\n\n for (const key of changeSubscriptions.keys()) {\n // middleware is handled separately\n if (!hasEntrypointForKey(currentEntrypoints, key, assetMapper)) {\n await hooks.unsubscribeFromChanges(key)\n }\n }\n\n for (const [key] of currentEntryIssues) {\n if (!hasEntrypointForKey(currentEntrypoints, key, assetMapper)) {\n currentEntryIssues.delete(key)\n }\n }\n\n for (const client of clients) {\n const state = clientStates.get(client)\n if (!state) {\n continue\n }\n\n for (const key of state.clientIssues.keys()) {\n if (!hasEntrypointForKey(currentEntrypoints, key, assetMapper)) {\n state.clientIssues.delete(key)\n }\n }\n\n for (const id of state.subscriptions.keys()) {\n if (\n !hasEntrypointForKey(\n currentEntrypoints,\n getEntryKey('assets', 'client', id),\n assetMapper\n )\n ) {\n hooks.unsubscribeFromHmrEvents(client, id)\n }\n }\n }\n}\n\nexport async function handlePagesErrorRoute({\n currentEntryIssues,\n entrypoints,\n manifestLoader,\n devRewrites,\n productionRewrites,\n logErrors,\n hooks,\n}: {\n currentEntryIssues: EntryIssuesMap\n entrypoints: Entrypoints\n manifestLoader: TurbopackManifestLoader\n devRewrites: SetupOpts['fsChecker']['rewrites'] | undefined\n productionRewrites: CustomRoutes['rewrites'] | undefined\n logErrors: boolean\n hooks: HandleRouteTypeHooks\n}) {\n if (entrypoints.global.app) {\n const key = getEntryKey('pages', 'server', '_app')\n\n const writtenEndpoint = await entrypoints.global.app.writeToDisk()\n hooks.handleWrittenEndpoint(key, writtenEndpoint, false)\n hooks.subscribeToChanges(\n key,\n false,\n entrypoints.global.app,\n () => {\n // There's a special case for this in `../client/page-bootstrap.ts`.\n // https://github.com/vercel/next.js/blob/08d7a7e5189a835f5dcb82af026174e587575c0e/packages/next/src/client/page-bootstrap.ts#L69-L71\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.CLIENT_CHANGES,\n }\n },\n () => {\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.RELOAD_PAGE,\n data: '_app has changed (error route)',\n }\n }\n )\n processIssues(currentEntryIssues, key, writtenEndpoint, false, logErrors)\n }\n await manifestLoader.loadBuildManifest('_app')\n await manifestLoader.loadPagesManifest('_app')\n await manifestLoader.loadFontManifest('_app')\n\n if (entrypoints.global.document) {\n const key = getEntryKey('pages', 'server', '_document')\n\n const writtenEndpoint = await entrypoints.global.document.writeToDisk()\n hooks.handleWrittenEndpoint(key, writtenEndpoint, false)\n hooks.subscribeToChanges(\n key,\n false,\n entrypoints.global.document,\n () => {\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.RELOAD_PAGE,\n data: '_document has changed (error route)',\n }\n },\n (e) => {\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.RELOAD_PAGE,\n data: `error in _document subscription (error route): ${e}`,\n }\n }\n )\n processIssues(currentEntryIssues, key, writtenEndpoint, false, logErrors)\n }\n await manifestLoader.loadPagesManifest('_document')\n\n if (entrypoints.global.error) {\n const key = getEntryKey('pages', 'server', '_error')\n\n const writtenEndpoint = await entrypoints.global.error.writeToDisk()\n hooks.handleWrittenEndpoint(key, writtenEndpoint, false)\n hooks.subscribeToChanges(\n key,\n false,\n entrypoints.global.error,\n () => {\n // There's a special case for this in `../client/page-bootstrap.ts`.\n // https://github.com/vercel/next.js/blob/08d7a7e5189a835f5dcb82af026174e587575c0e/packages/next/src/client/page-bootstrap.ts#L69-L71\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.CLIENT_CHANGES,\n }\n },\n (e) => {\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.RELOAD_PAGE,\n data: `error in _error subscription: ${e}`,\n }\n }\n )\n processIssues(currentEntryIssues, key, writtenEndpoint, false, logErrors)\n }\n await manifestLoader.loadClientBuildManifest('_error')\n await manifestLoader.loadBuildManifest('_error')\n await manifestLoader.loadPagesManifest('_error')\n await manifestLoader.loadFontManifest('_error')\n\n manifestLoader.writeManifests({\n devRewrites,\n productionRewrites,\n entrypoints,\n })\n}\n\nexport function removeRouteSuffix(route: string): string {\n return route.replace(/\\/route$/, '')\n}\n\nexport function addRouteSuffix(route: string): string {\n return route + '/route'\n}\n\nexport function addMetadataIdToRoute(route: string): string {\n return route + '/[__metadata_id__]'\n}\n\n// Since turbopack will create app pages/route entries based on the structure,\n// which means the entry keys are based on file names.\n// But for special metadata conventions we'll change the page/pathname to a different path.\n// So we need this helper to map the new path back to original turbopack entry key.\nexport function normalizedPageToTurbopackStructureRoute(\n route: string,\n ext: string | false\n): string {\n let entrypointKey = route\n if (isMetadataRoute(entrypointKey)) {\n entrypointKey = entrypointKey.endsWith('/route')\n ? entrypointKey.slice(0, -'/route'.length)\n : entrypointKey\n\n if (ext) {\n if (entrypointKey.endsWith('/[__metadata_id__]')) {\n entrypointKey = entrypointKey.slice(0, -'/[__metadata_id__]'.length)\n }\n if (entrypointKey.endsWith('/sitemap.xml') && ext !== '.xml') {\n // For dynamic sitemap route, remove the extension\n entrypointKey = entrypointKey.slice(0, -'.xml'.length)\n }\n }\n entrypointKey = entrypointKey + '/route'\n }\n return entrypointKey\n}\n"],"names":["AssetMapper","addMetadataIdToRoute","addRouteSuffix","handleEntrypoints","handlePagesErrorRoute","handleRouteType","hasEntrypointForKey","msToNs","normalizedPageToTurbopackStructureRoute","printNonFatalIssue","processTopLevelIssues","removeRouteSuffix","onceErrorSet","Set","shouldEmitOnceWarning","issue","severity","title","stage","value","has","add","renderStyledStringToErrorAnsi","includes","isRelevantWarning","Log","warn","formatIssue","currentTopLevelIssues","result","clear","issues","issueKey","getIssueKey","set","MILLISECONDS_IN_NANOSECOND","BigInt","ms","Math","floor","dev","page","pathname","route","currentEntryIssues","entrypoints","manifestLoader","readyIds","devRewrites","productionRewrites","hooks","logErrors","shouldCreateWebpackStats","process","env","TURBOPACK_STATS","type","clientKey","getEntryKey","serverKey","documentOrAppChanged","global","app","key","writtenEndpoint","writeToDisk","handleWrittenEndpoint","processIssues","loadBuildManifest","loadPagesManifest","document","htmlEndpoint","loadClientBuildManifest","loadMiddlewareManifest","deleteMiddlewareManifest","loadFontManifest","loadWebpackStats","writeManifests","subscribeToChanges","dataEndpoint","delete","HMR_MESSAGE_SENT_TO_BROWSER","SERVER_ONLY_CHANGES","pages","e","RELOAD_PAGE","data","CLIENT_CHANGES","endpoint","rscEndpoint","change","hash","some","SERVER_COMPONENT_CHANGES","loadAppPathsManifest","loadActionManifest","Error","setPathsForKey","assetPaths","newAssetPaths","entryMap","assetPath","assetPathKeys","assetMap","get","getAssetPathsByKey","size","Array","from","getKeysByAsset","path","keys","Map","assetMapper","splitEntryKey","error","middleware","instrumentation","pageKey","_","currentEntrypoints","pagesAppEndpoint","pagesDocumentEndpoint","pagesErrorEndpoint","routes","forEach","originalName","info","handleEntrypointsDevCleanup","unsubscribeFromChanges","sendHmr","MIDDLEWARE_CHANGES","processInstrumentation","name","prop","prettyName","nodeJs","edge","finishBuilding","startBuilding","undefined","serverFields","actualInstrumentationHookFile","propagateServerField","processMiddleware","middlewareConfig","getMiddlewareManifest","match","matchers","actualMiddlewareFile","changeSubscriptions","clients","clientStates","client","state","clientIssues","id","subscriptions","unsubscribeFromHmrEvents","replace","ext","entrypointKey","isMetadataRoute","endsWith","slice","length"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;IA0baA,WAAW;eAAXA;;IAkhBGC,oBAAoB;eAApBA;;IAJAC,cAAc;eAAdA;;IA1YMC,iBAAiB;eAAjBA;;IAyRAC,qBAAqB;eAArBA;;IAvsBAC,eAAe;eAAfA;;IAqWNC,mBAAmB;eAAnBA;;IA5ZAC,MAAM;eAANA;;IA23BAC,uCAAuC;eAAvCA;;IA/4BAC,kBAAkB;eAAlBA;;IAMAC,qBAAqB;eAArBA;;IAy3BAC,iBAAiB;eAAjBA;;;kCAr7BT;6DACc;0BAQd;iCAEyB;uBAUzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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tB,eAAeuB,iBAAiB,CAAC;IACvC,MAAMvB,eAAe6B,gBAAgB,CAAC;IAEtC7B,eAAe+B,cAAc,CAAC;QAC5B7B;QACAC;QACAJ;IACF;AACF;AAEO,SAASlC,kBAAkBgC,KAAa;IAC7C,OAAOA,MAAMoH,OAAO,CAAC,YAAY;AACnC;AAEO,SAAS7J,eAAeyC,KAAa;IAC1C,OAAOA,QAAQ;AACjB;AAEO,SAAS1C,qBAAqB0C,KAAa;IAChD,OAAOA,QAAQ;AACjB;AAMO,SAASnC,wCACdmC,KAAa,EACbqH,GAAmB;IAEnB,IAAIC,gBAAgBtH;IACpB,IAAIuH,IAAAA,gCAAe,EAACD,gBAAgB;QAClCA,gBAAgBA,cAAcE,QAAQ,CAAC,YACnCF,cAAcG,KAAK,CAAC,GAAG,CAAC,SAASC,MAAM,IACvCJ;QAEJ,IAAID,KAAK;YACP,IAAIC,cAAcE,QAAQ,CAAC,uBAAuB;gBAChDF,gBAAgBA,cAAcG,KAAK,CAAC,GAAG,CAAC,qBAAqBC,MAAM;YACrE;YACA,IAAIJ,cAAcE,QAAQ,CAAC,mBAAmBH,QAAQ,QAAQ;gBAC5D,kDAAkD;gBAClDC,gBAAgBA,cAAcG,KAAK,CAAC,GAAG,CAAC,OAAOC,MAAM;YACvD;QACF;QACAJ,gBAAgBA,gBAAgB;IAClC;IACA,OAAOA;AACT","ignoreList":[0]}
|
|
1
|
+
{"version":3,"sources":["../../../src/server/dev/turbopack-utils.ts"],"sourcesContent":["import type {\n ServerFields,\n SetupOpts,\n} from '../lib/router-utils/setup-dev-bundler'\nimport type {\n Issue,\n TurbopackResult,\n Endpoint,\n RawEntrypoints,\n Update as TurbopackUpdate,\n WrittenEndpoint,\n} from '../../build/swc/types'\nimport {\n type HmrMessageSentToBrowser,\n HMR_MESSAGE_SENT_TO_BROWSER,\n} from './hot-reloader-types'\nimport * as Log from '../../build/output/log'\nimport type { PropagateToWorkersField } from '../lib/router-utils/types'\nimport type { TurbopackManifestLoader } from '../../shared/lib/turbopack/manifest-loader'\nimport type { AppRoute, Entrypoints, PageRoute } from '../../build/swc/types'\nimport {\n type EntryKey,\n getEntryKey,\n splitEntryKey,\n} from '../../shared/lib/turbopack/entry-key'\nimport type ws from 'next/dist/compiled/ws'\nimport { isMetadataRoute } from '../../lib/metadata/is-metadata-route'\nimport type { CustomRoutes } from '../../lib/load-custom-routes'\nimport {\n formatIssue,\n getIssueKey,\n isRelevantWarning,\n processIssues,\n renderStyledStringToErrorAnsi,\n type EntryIssuesMap,\n type TopLevelIssuesMap,\n} from '../../shared/lib/turbopack/utils'\nimport { MIDDLEWARE_FILENAME, PROXY_FILENAME } from '../../lib/constants'\n\nconst onceErrorSet = new Set()\n/**\n * Check if given issue is a warning to be display only once.\n * This mimics behavior of get-page-static-info's warnOnce.\n * @param issue\n * @returns\n */\nfunction shouldEmitOnceWarning(issue: Issue): boolean {\n const { severity, title, stage } = issue\n if (severity === 'warning' && title.value === 'Invalid page configuration') {\n if (onceErrorSet.has(issue)) {\n return false\n }\n onceErrorSet.add(issue)\n }\n if (\n severity === 'warning' &&\n stage === 'config' &&\n renderStyledStringToErrorAnsi(issue.title).includes(\"can't be external\")\n ) {\n if (onceErrorSet.has(issue)) {\n return false\n }\n onceErrorSet.add(issue)\n }\n\n return true\n}\n\n/// Print out an issue to the console which should not block\n/// the build by throwing out or blocking error overlay.\nexport function printNonFatalIssue(issue: Issue) {\n if (isRelevantWarning(issue) && shouldEmitOnceWarning(issue)) {\n Log.warn(formatIssue(issue))\n }\n}\n\nexport function processTopLevelIssues(\n currentTopLevelIssues: TopLevelIssuesMap,\n result: TurbopackResult\n) {\n currentTopLevelIssues.clear()\n\n for (const issue of result.issues) {\n const issueKey = getIssueKey(issue)\n currentTopLevelIssues.set(issueKey, issue)\n }\n}\n\nconst MILLISECONDS_IN_NANOSECOND = BigInt(1_000_000)\n\nexport function msToNs(ms: number): bigint {\n return BigInt(Math.floor(ms)) * MILLISECONDS_IN_NANOSECOND\n}\n\nexport type ChangeSubscriptions = Map<\n EntryKey,\n Promise<AsyncIterableIterator<TurbopackResult>>\n>\n\nexport type HandleWrittenEndpoint = (\n key: EntryKey,\n result: TurbopackResult<WrittenEndpoint>,\n forceDeleteCache: boolean\n) => boolean\n\nexport type StartChangeSubscription = (\n key: EntryKey,\n includeIssues: boolean,\n endpoint: Endpoint,\n createMessage: (\n change: TurbopackResult,\n hash: string\n ) => Promise<HmrMessageSentToBrowser> | HmrMessageSentToBrowser | void,\n onError?: (\n e: Error\n ) => Promise<HmrMessageSentToBrowser> | HmrMessageSentToBrowser | void\n) => Promise<void>\n\nexport type StopChangeSubscription = (key: EntryKey) => Promise<void>\n\nexport type SendHmr = (id: string, message: HmrMessageSentToBrowser) => void\n\nexport type StartBuilding = (\n id: string,\n requestUrl: string | undefined,\n forceRebuild: boolean\n) => () => void\n\nexport type ReadyIds = Set<string>\n\nexport type ClientState = {\n clientIssues: EntryIssuesMap\n messages: Map<string, HmrMessageSentToBrowser>\n turbopackUpdates: TurbopackUpdate[]\n subscriptions: Map<string, AsyncIterator<any>>\n}\n\nexport type ClientStateMap = WeakMap<ws, ClientState>\n\n// hooks only used by the dev server.\ntype HandleRouteTypeHooks = {\n handleWrittenEndpoint: HandleWrittenEndpoint\n subscribeToChanges: StartChangeSubscription\n}\n\nexport async function handleRouteType({\n dev,\n page,\n pathname,\n route,\n currentEntryIssues,\n entrypoints,\n manifestLoader,\n readyIds,\n devRewrites,\n productionRewrites,\n hooks,\n logErrors,\n}: {\n dev: boolean\n page: string\n pathname: string\n route: PageRoute | AppRoute\n\n currentEntryIssues: EntryIssuesMap\n entrypoints: Entrypoints\n manifestLoader: TurbopackManifestLoader\n devRewrites: SetupOpts['fsChecker']['rewrites'] | undefined\n productionRewrites: CustomRoutes['rewrites'] | undefined\n logErrors: boolean\n\n readyIds?: ReadyIds // dev\n\n hooks?: HandleRouteTypeHooks // dev\n}) {\n const shouldCreateWebpackStats = process.env.TURBOPACK_STATS != null\n\n switch (route.type) {\n case 'page': {\n const clientKey = getEntryKey('pages', 'client', page)\n const serverKey = getEntryKey('pages', 'server', page)\n\n try {\n // In the best case scenario, Turbopack chunks document, app, page separately in that order,\n // so it can happen that the chunks of document change, but the chunks of app and page\n // don't. We still need to reload the page chunks in that case though, otherwise the version\n // of the document or app component export from the pages template is stale.\n let documentOrAppChanged = false\n if (entrypoints.global.app) {\n const key = getEntryKey('pages', 'server', '_app')\n\n const writtenEndpoint = await entrypoints.global.app.writeToDisk()\n documentOrAppChanged ||=\n hooks?.handleWrittenEndpoint(key, writtenEndpoint, false) ?? false\n processIssues(\n currentEntryIssues,\n key,\n writtenEndpoint,\n false,\n logErrors\n )\n }\n await manifestLoader.loadBuildManifest('_app')\n await manifestLoader.loadPagesManifest('_app')\n\n if (entrypoints.global.document) {\n const key = getEntryKey('pages', 'server', '_document')\n\n const writtenEndpoint =\n await entrypoints.global.document.writeToDisk()\n documentOrAppChanged ||=\n hooks?.handleWrittenEndpoint(key, writtenEndpoint, false) ?? false\n processIssues(\n currentEntryIssues,\n key,\n writtenEndpoint,\n false,\n logErrors\n )\n }\n await manifestLoader.loadPagesManifest('_document')\n\n const writtenEndpoint = await route.htmlEndpoint.writeToDisk()\n hooks?.handleWrittenEndpoint(\n serverKey,\n writtenEndpoint,\n documentOrAppChanged\n )\n\n const type = writtenEndpoint?.type\n\n await manifestLoader.loadClientBuildManifest(page)\n await manifestLoader.loadBuildManifest(page)\n await manifestLoader.loadPagesManifest(page)\n if (type === 'edge') {\n await manifestLoader.loadMiddlewareManifest(page, 'pages')\n } else {\n manifestLoader.deleteMiddlewareManifest(serverKey)\n }\n await manifestLoader.loadFontManifest('/_app', 'pages')\n await manifestLoader.loadFontManifest(page, 'pages')\n\n if (shouldCreateWebpackStats) {\n await manifestLoader.loadWebpackStats(page, 'pages')\n }\n\n manifestLoader.writeManifests({\n devRewrites,\n productionRewrites,\n entrypoints,\n })\n\n processIssues(\n currentEntryIssues,\n serverKey,\n writtenEndpoint,\n false,\n logErrors\n )\n } finally {\n if (dev) {\n // TODO subscriptions should only be caused by the WebSocket connections\n // otherwise we don't known when to unsubscribe and this leaking\n hooks?.subscribeToChanges(\n serverKey,\n false,\n route.dataEndpoint,\n () => {\n // Report the next compilation again\n readyIds?.delete(pathname)\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.SERVER_ONLY_CHANGES,\n pages: [page],\n }\n },\n (e) => {\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.RELOAD_PAGE,\n data: `error in ${page} data subscription: ${e}`,\n }\n }\n )\n hooks?.subscribeToChanges(\n clientKey,\n false,\n route.htmlEndpoint,\n () => {\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.CLIENT_CHANGES,\n }\n },\n (e) => {\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.RELOAD_PAGE,\n data: `error in ${page} html subscription: ${e}`,\n }\n }\n )\n if (entrypoints.global.document) {\n hooks?.subscribeToChanges(\n getEntryKey('pages', 'server', '_document'),\n false,\n entrypoints.global.document,\n () => {\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.RELOAD_PAGE,\n data: '_document has changed (page route)',\n }\n },\n (e) => {\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.RELOAD_PAGE,\n data: `error in _document subscription (page route): ${e}`,\n }\n }\n )\n }\n }\n }\n\n break\n }\n case 'page-api': {\n const key = getEntryKey('pages', 'server', page)\n\n const writtenEndpoint = await route.endpoint.writeToDisk()\n hooks?.handleWrittenEndpoint(key, writtenEndpoint, false)\n\n const type = writtenEndpoint.type\n\n await manifestLoader.loadPagesManifest(page)\n if (type === 'edge') {\n await manifestLoader.loadMiddlewareManifest(page, 'pages')\n } else {\n manifestLoader.deleteMiddlewareManifest(key)\n }\n\n manifestLoader.writeManifests({\n devRewrites,\n productionRewrites,\n entrypoints,\n })\n\n processIssues(currentEntryIssues, key, writtenEndpoint, true, logErrors)\n\n break\n }\n case 'app-page': {\n const key = getEntryKey('app', 'server', page)\n\n const writtenEndpoint = await route.htmlEndpoint.writeToDisk()\n hooks?.handleWrittenEndpoint(key, writtenEndpoint, false)\n\n if (dev) {\n // TODO subscriptions should only be caused by the WebSocket connections\n // otherwise we don't known when to unsubscribe and this leaking\n hooks?.subscribeToChanges(\n key,\n true,\n route.rscEndpoint,\n (change, hash) => {\n if (change.issues.some((issue) => issue.severity === 'error')) {\n // Ignore any updates that has errors\n // There will be another update without errors eventually\n return\n }\n // Report the next compilation again\n readyIds?.delete(pathname)\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.SERVER_COMPONENT_CHANGES,\n hash,\n }\n },\n (e) => {\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.RELOAD_PAGE,\n data: `error in ${page} app-page subscription: ${e}`,\n }\n }\n )\n }\n\n const type = writtenEndpoint.type\n\n if (type === 'edge') {\n manifestLoader.loadMiddlewareManifest(page, 'app')\n } else {\n manifestLoader.deleteMiddlewareManifest(key)\n }\n\n manifestLoader.loadBuildManifest(page, 'app')\n manifestLoader.loadAppPathsManifest(page)\n manifestLoader.loadActionManifest(page)\n manifestLoader.loadFontManifest(page, 'app')\n\n if (shouldCreateWebpackStats) {\n manifestLoader.loadWebpackStats(page, 'app')\n }\n\n manifestLoader.writeManifests({\n devRewrites,\n productionRewrites,\n entrypoints,\n })\n\n processIssues(currentEntryIssues, key, writtenEndpoint, dev, logErrors)\n\n break\n }\n case 'app-route': {\n const key = getEntryKey('app', 'server', page)\n\n const writtenEndpoint = await route.endpoint.writeToDisk()\n hooks?.handleWrittenEndpoint(key, writtenEndpoint, false)\n\n const type = writtenEndpoint.type\n\n manifestLoader.loadAppPathsManifest(page)\n\n if (type === 'edge') {\n manifestLoader.loadMiddlewareManifest(page, 'app')\n } else {\n manifestLoader.deleteMiddlewareManifest(key)\n }\n\n manifestLoader.writeManifests({\n devRewrites,\n productionRewrites,\n entrypoints,\n })\n processIssues(currentEntryIssues, key, writtenEndpoint, true, logErrors)\n\n break\n }\n default: {\n throw new Error(`unknown route type ${(route as any).type} for ${page}`)\n }\n }\n}\n\n/**\n * Maintains a mapping between entrypoins and the corresponding client asset paths.\n */\nexport class AssetMapper {\n private entryMap: Map<EntryKey, Set<string>> = new Map()\n private assetMap: Map<string, Set<EntryKey>> = new Map()\n\n /**\n * Overrides asset paths for a key and updates the mapping from path to key.\n *\n * @param key\n * @param assetPaths asset paths relative to the .next directory\n */\n setPathsForKey(key: EntryKey, assetPaths: string[]): void {\n this.delete(key)\n\n const newAssetPaths = new Set(assetPaths)\n this.entryMap.set(key, newAssetPaths)\n\n for (const assetPath of newAssetPaths) {\n let assetPathKeys = this.assetMap.get(assetPath)\n if (!assetPathKeys) {\n assetPathKeys = new Set()\n this.assetMap.set(assetPath, assetPathKeys)\n }\n\n assetPathKeys!.add(key)\n }\n }\n\n /**\n * Deletes the key and any asset only referenced by this key.\n *\n * @param key\n */\n delete(key: EntryKey) {\n for (const assetPath of this.getAssetPathsByKey(key)) {\n const assetPathKeys = this.assetMap.get(assetPath)\n\n assetPathKeys?.delete(key)\n\n if (!assetPathKeys?.size) {\n this.assetMap.delete(assetPath)\n }\n }\n\n this.entryMap.delete(key)\n }\n\n getAssetPathsByKey(key: EntryKey): string[] {\n return Array.from(this.entryMap.get(key) ?? [])\n }\n\n getKeysByAsset(path: string): EntryKey[] {\n return Array.from(this.assetMap.get(path) ?? [])\n }\n\n keys(): IterableIterator<EntryKey> {\n return this.entryMap.keys()\n }\n}\n\nexport function hasEntrypointForKey(\n entrypoints: Entrypoints,\n key: EntryKey,\n assetMapper: AssetMapper | undefined\n): boolean {\n const { type, page } = splitEntryKey(key)\n\n switch (type) {\n case 'app':\n return entrypoints.app.has(page)\n case 'pages':\n switch (page) {\n case '_app':\n return entrypoints.global.app != null\n case '_document':\n return entrypoints.global.document != null\n case '_error':\n return entrypoints.global.error != null\n default:\n return entrypoints.page.has(page)\n }\n case 'root':\n switch (page) {\n case 'middleware':\n return entrypoints.global.middleware != null\n case 'instrumentation':\n return entrypoints.global.instrumentation != null\n default:\n return false\n }\n case 'assets':\n if (!assetMapper) {\n return false\n }\n\n return assetMapper\n .getKeysByAsset(page)\n .some((pageKey) =>\n hasEntrypointForKey(entrypoints, pageKey, assetMapper)\n )\n default: {\n // validation that we covered all cases, this should never run.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const _: never = type\n return false\n }\n }\n}\n\n// hooks only used by the dev server.\ntype HandleEntrypointsHooks = {\n handleWrittenEndpoint: HandleWrittenEndpoint\n propagateServerField: (\n field: PropagateToWorkersField,\n args: any\n ) => Promise<void>\n sendHmr: SendHmr\n startBuilding: StartBuilding\n subscribeToChanges: StartChangeSubscription\n unsubscribeFromChanges: StopChangeSubscription\n unsubscribeFromHmrEvents: (client: ws, id: string) => void\n}\n\ntype HandleEntrypointsDevOpts = {\n assetMapper: AssetMapper\n changeSubscriptions: ChangeSubscriptions\n clients: Array<ws>\n clientStates: ClientStateMap\n serverFields: ServerFields\n\n hooks: HandleEntrypointsHooks\n}\n\nexport async function handleEntrypoints({\n entrypoints,\n\n currentEntrypoints,\n\n currentEntryIssues,\n manifestLoader,\n devRewrites,\n logErrors,\n dev,\n}: {\n entrypoints: TurbopackResult<RawEntrypoints>\n\n currentEntrypoints: Entrypoints\n\n currentEntryIssues: EntryIssuesMap\n manifestLoader: TurbopackManifestLoader\n devRewrites: SetupOpts['fsChecker']['rewrites'] | undefined\n productionRewrites: CustomRoutes['rewrites'] | undefined\n logErrors: boolean\n\n dev: HandleEntrypointsDevOpts\n}) {\n currentEntrypoints.global.app = entrypoints.pagesAppEndpoint\n currentEntrypoints.global.document = entrypoints.pagesDocumentEndpoint\n currentEntrypoints.global.error = entrypoints.pagesErrorEndpoint\n\n currentEntrypoints.global.instrumentation = entrypoints.instrumentation\n\n currentEntrypoints.page.clear()\n currentEntrypoints.app.clear()\n\n for (const [pathname, route] of entrypoints.routes) {\n switch (route.type) {\n case 'page':\n case 'page-api':\n currentEntrypoints.page.set(pathname, route)\n break\n case 'app-page': {\n route.pages.forEach((page) => {\n currentEntrypoints.app.set(page.originalName, {\n type: 'app-page',\n ...page,\n })\n })\n break\n }\n case 'app-route': {\n currentEntrypoints.app.set(route.originalName, route)\n break\n }\n case 'conflict':\n Log.info(`skipping ${pathname} (${route.type})`)\n break\n default:\n route satisfies never\n }\n }\n\n if (dev) {\n await handleEntrypointsDevCleanup({\n currentEntryIssues,\n currentEntrypoints,\n\n ...dev,\n })\n }\n\n const { middleware, instrumentation } = entrypoints\n\n // We check for explicit true/false, since it's initialized to\n // undefined during the first loop (middlewareChanges event is\n // unnecessary during the first serve)\n if (currentEntrypoints.global.middleware && !middleware) {\n const key = getEntryKey('root', 'server', 'middleware')\n // Went from middleware to no middleware\n await dev?.hooks.unsubscribeFromChanges(key)\n currentEntryIssues.delete(key)\n dev.hooks.sendHmr('middleware', {\n type: HMR_MESSAGE_SENT_TO_BROWSER.MIDDLEWARE_CHANGES,\n })\n } else if (!currentEntrypoints.global.middleware && middleware) {\n // Went from no middleware to middleware\n dev.hooks.sendHmr('middleware', {\n type: HMR_MESSAGE_SENT_TO_BROWSER.MIDDLEWARE_CHANGES,\n })\n }\n\n currentEntrypoints.global.middleware = middleware\n\n if (instrumentation) {\n const processInstrumentation = async (\n name: string,\n prop: 'nodeJs' | 'edge'\n ) => {\n const prettyName = {\n nodeJs: 'Node.js',\n edge: 'Edge',\n }\n const finishBuilding = dev.hooks.startBuilding(\n `instrumentation ${prettyName[prop]}`,\n undefined,\n true\n )\n const key = getEntryKey('root', 'server', name)\n\n const writtenEndpoint = await instrumentation[prop].writeToDisk()\n dev.hooks.handleWrittenEndpoint(key, writtenEndpoint, false)\n processIssues(currentEntryIssues, key, writtenEndpoint, false, logErrors)\n finishBuilding()\n }\n await processInstrumentation('instrumentation.nodeJs', 'nodeJs')\n await processInstrumentation('instrumentation.edge', 'edge')\n await manifestLoader.loadMiddlewareManifest(\n 'instrumentation',\n 'instrumentation'\n )\n manifestLoader.writeManifests({\n devRewrites,\n productionRewrites: undefined,\n entrypoints: currentEntrypoints,\n })\n\n dev.serverFields.actualInstrumentationHookFile = '/instrumentation'\n await dev.hooks.propagateServerField(\n 'actualInstrumentationHookFile',\n dev.serverFields.actualInstrumentationHookFile\n )\n } else {\n dev.serverFields.actualInstrumentationHookFile = undefined\n await dev.hooks.propagateServerField(\n 'actualInstrumentationHookFile',\n dev.serverFields.actualInstrumentationHookFile\n )\n }\n\n if (middleware) {\n const key = getEntryKey('root', 'server', 'middleware')\n\n const endpoint = middleware.endpoint\n const triggerName = middleware.isProxy\n ? PROXY_FILENAME\n : MIDDLEWARE_FILENAME\n\n async function processMiddleware() {\n const finishBuilding = dev.hooks.startBuilding(\n triggerName,\n undefined,\n true\n )\n const writtenEndpoint = await endpoint.writeToDisk()\n dev.hooks.handleWrittenEndpoint(key, writtenEndpoint, false)\n processIssues(currentEntryIssues, key, writtenEndpoint, false, logErrors)\n await manifestLoader.loadMiddlewareManifest('middleware', 'middleware')\n const middlewareConfig =\n manifestLoader.getMiddlewareManifest(key)?.middleware['/']\n\n if (dev && middlewareConfig) {\n dev.serverFields.middleware = {\n match: null as any,\n page: '/',\n matchers: middlewareConfig.matchers,\n }\n }\n finishBuilding()\n }\n await processMiddleware()\n\n if (dev) {\n dev?.hooks.subscribeToChanges(\n key,\n false,\n endpoint,\n async () => {\n const finishBuilding = dev.hooks.startBuilding(\n triggerName,\n undefined,\n true\n )\n await processMiddleware()\n await dev.hooks.propagateServerField(\n 'actualMiddlewareFile',\n dev.serverFields.actualMiddlewareFile\n )\n await dev.hooks.propagateServerField(\n 'middleware',\n dev.serverFields.middleware\n )\n manifestLoader.writeManifests({\n devRewrites,\n productionRewrites: undefined,\n entrypoints: currentEntrypoints,\n })\n\n finishBuilding?.()\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.MIDDLEWARE_CHANGES,\n }\n },\n () => {\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.MIDDLEWARE_CHANGES,\n }\n }\n )\n }\n } else {\n manifestLoader.deleteMiddlewareManifest(\n getEntryKey('root', 'server', 'middleware')\n )\n dev.serverFields.actualMiddlewareFile = undefined\n dev.serverFields.middleware = undefined\n }\n\n await dev.hooks.propagateServerField(\n 'actualMiddlewareFile',\n dev.serverFields.actualMiddlewareFile\n )\n await dev.hooks.propagateServerField(\n 'middleware',\n dev.serverFields.middleware\n )\n}\n\nasync function handleEntrypointsDevCleanup({\n currentEntryIssues,\n currentEntrypoints,\n\n assetMapper,\n changeSubscriptions,\n clients,\n clientStates,\n\n hooks,\n}: {\n currentEntrypoints: Entrypoints\n currentEntryIssues: EntryIssuesMap\n} & HandleEntrypointsDevOpts) {\n // this needs to be first as `hasEntrypointForKey` uses the `assetMapper`\n for (const key of assetMapper.keys()) {\n if (!hasEntrypointForKey(currentEntrypoints, key, assetMapper)) {\n assetMapper.delete(key)\n }\n }\n\n for (const key of changeSubscriptions.keys()) {\n // middleware is handled separately\n if (!hasEntrypointForKey(currentEntrypoints, key, assetMapper)) {\n await hooks.unsubscribeFromChanges(key)\n }\n }\n\n for (const [key] of currentEntryIssues) {\n if (!hasEntrypointForKey(currentEntrypoints, key, assetMapper)) {\n currentEntryIssues.delete(key)\n }\n }\n\n for (const client of clients) {\n const state = clientStates.get(client)\n if (!state) {\n continue\n }\n\n for (const key of state.clientIssues.keys()) {\n if (!hasEntrypointForKey(currentEntrypoints, key, assetMapper)) {\n state.clientIssues.delete(key)\n }\n }\n\n for (const id of state.subscriptions.keys()) {\n if (\n !hasEntrypointForKey(\n currentEntrypoints,\n getEntryKey('assets', 'client', id),\n assetMapper\n )\n ) {\n hooks.unsubscribeFromHmrEvents(client, id)\n }\n }\n }\n}\n\nexport async function handlePagesErrorRoute({\n currentEntryIssues,\n entrypoints,\n manifestLoader,\n devRewrites,\n productionRewrites,\n logErrors,\n hooks,\n}: {\n currentEntryIssues: EntryIssuesMap\n entrypoints: Entrypoints\n manifestLoader: TurbopackManifestLoader\n devRewrites: SetupOpts['fsChecker']['rewrites'] | undefined\n productionRewrites: CustomRoutes['rewrites'] | undefined\n logErrors: boolean\n hooks: HandleRouteTypeHooks\n}) {\n if (entrypoints.global.app) {\n const key = getEntryKey('pages', 'server', '_app')\n\n const writtenEndpoint = await entrypoints.global.app.writeToDisk()\n hooks.handleWrittenEndpoint(key, writtenEndpoint, false)\n hooks.subscribeToChanges(\n key,\n false,\n entrypoints.global.app,\n () => {\n // There's a special case for this in `../client/page-bootstrap.ts`.\n // https://github.com/vercel/next.js/blob/08d7a7e5189a835f5dcb82af026174e587575c0e/packages/next/src/client/page-bootstrap.ts#L69-L71\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.CLIENT_CHANGES,\n }\n },\n () => {\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.RELOAD_PAGE,\n data: '_app has changed (error route)',\n }\n }\n )\n processIssues(currentEntryIssues, key, writtenEndpoint, false, logErrors)\n }\n await manifestLoader.loadBuildManifest('_app')\n await manifestLoader.loadPagesManifest('_app')\n await manifestLoader.loadFontManifest('_app')\n\n if (entrypoints.global.document) {\n const key = getEntryKey('pages', 'server', '_document')\n\n const writtenEndpoint = await entrypoints.global.document.writeToDisk()\n hooks.handleWrittenEndpoint(key, writtenEndpoint, false)\n hooks.subscribeToChanges(\n key,\n false,\n entrypoints.global.document,\n () => {\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.RELOAD_PAGE,\n data: '_document has changed (error route)',\n }\n },\n (e) => {\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.RELOAD_PAGE,\n data: `error in _document subscription (error route): ${e}`,\n }\n }\n )\n processIssues(currentEntryIssues, key, writtenEndpoint, false, logErrors)\n }\n await manifestLoader.loadPagesManifest('_document')\n\n if (entrypoints.global.error) {\n const key = getEntryKey('pages', 'server', '_error')\n\n const writtenEndpoint = await entrypoints.global.error.writeToDisk()\n hooks.handleWrittenEndpoint(key, writtenEndpoint, false)\n hooks.subscribeToChanges(\n key,\n false,\n entrypoints.global.error,\n () => {\n // There's a special case for this in `../client/page-bootstrap.ts`.\n // https://github.com/vercel/next.js/blob/08d7a7e5189a835f5dcb82af026174e587575c0e/packages/next/src/client/page-bootstrap.ts#L69-L71\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.CLIENT_CHANGES,\n }\n },\n (e) => {\n return {\n type: HMR_MESSAGE_SENT_TO_BROWSER.RELOAD_PAGE,\n data: `error in _error subscription: ${e}`,\n }\n }\n )\n processIssues(currentEntryIssues, key, writtenEndpoint, false, logErrors)\n }\n await manifestLoader.loadClientBuildManifest('_error')\n await manifestLoader.loadBuildManifest('_error')\n await manifestLoader.loadPagesManifest('_error')\n await manifestLoader.loadFontManifest('_error')\n\n manifestLoader.writeManifests({\n devRewrites,\n productionRewrites,\n entrypoints,\n })\n}\n\nexport function removeRouteSuffix(route: string): string {\n return route.replace(/\\/route$/, '')\n}\n\nexport function addRouteSuffix(route: string): string {\n return route + '/route'\n}\n\nexport function addMetadataIdToRoute(route: string): string {\n return route + '/[__metadata_id__]'\n}\n\n// Since turbopack will create app pages/route entries based on the structure,\n// which means the entry keys are based on file names.\n// But for special metadata conventions we'll change the page/pathname to a different path.\n// So we need this helper to map the new path back to original turbopack entry key.\nexport function normalizedPageToTurbopackStructureRoute(\n route: string,\n ext: string | false\n): string {\n let entrypointKey = route\n if (isMetadataRoute(entrypointKey)) {\n entrypointKey = entrypointKey.endsWith('/route')\n ? entrypointKey.slice(0, -'/route'.length)\n : entrypointKey\n\n if (ext) {\n if (entrypointKey.endsWith('/[__metadata_id__]')) {\n entrypointKey = entrypointKey.slice(0, -'/[__metadata_id__]'.length)\n }\n if (entrypointKey.endsWith('/sitemap.xml') && ext !== '.xml') {\n // For dynamic sitemap route, remove the extension\n entrypointKey = entrypointKey.slice(0, -'.xml'.length)\n }\n }\n entrypointKey = entrypointKey + '/route'\n }\n return entrypointKey\n}\n"],"names":["AssetMapper","addMetadataIdToRoute","addRouteSuffix","handleEntrypoints","handlePagesErrorRoute","handleRouteType","hasEntrypointForKey","msToNs","normalizedPageToTurbopackStructureRoute","printNonFatalIssue","processTopLevelIssues","removeRouteSuffix","onceErrorSet","Set","shouldEmitOnceWarning","issue","severity","title","stage","value","has","add","renderStyledStringToErrorAnsi","includes","isRelevantWarning","Log","warn","formatIssue","currentTopLevelIssues","result","clear","issues","issueKey","getIssueKey","set","MILLISECONDS_IN_NANOSECOND","BigInt","ms","Math","floor","dev","page","pathname","route","currentEntryIssues","entrypoints","manifestLoader","readyIds","devRewrites","productionRewrites","hooks","logErrors","shouldCreateWebpackStats","process","env","TURBOPACK_STATS","type","clientKey","getEntryKey","serverKey","documentOrAppChanged","global","app","key","writtenEndpoint","writeToDisk","handleWrittenEndpoint","processIssues","loadBuildManifest","loadPagesManifest","document","htmlEndpoint","loadClientBuildManifest","loadMiddlewareManifest","deleteMiddlewareManifest","loadFontManifest","loadWebpackStats","writeManifests","subscribeToChanges","dataEndpoint","delete","HMR_MESSAGE_SENT_TO_BROWSER","SERVER_ONLY_CHANGES","pages","e","RELOAD_PAGE","data","CLIENT_CHANGES","endpoint","rscEndpoint","change","hash","some","SERVER_COMPONENT_CHANGES","loadAppPathsManifest","loadActionManifest","Error","setPathsForKey","assetPaths","newAssetPaths","entryMap","assetPath","assetPathKeys","assetMap","get","getAssetPathsByKey","size","Array","from","getKeysByAsset","path","keys","Map","assetMapper","splitEntryKey","error","middleware","instrumentation","pageKey","_","currentEntrypoints","pagesAppEndpoint","pagesDocumentEndpoint","pagesErrorEndpoint","routes","forEach","originalName","info","handleEntrypointsDevCleanup","unsubscribeFromChanges","sendHmr","MIDDLEWARE_CHANGES","processInstrumentation","name","prop","prettyName","nodeJs","edge","finishBuilding","startBuilding","undefined","serverFields","actualInstrumentationHookFile","propagateServerField","triggerName","isProxy","PROXY_FILENAME","MIDDLEWARE_FILENAME","processMiddleware","middlewareConfig","getMiddlewareManifest","match","matchers","actualMiddlewareFile","changeSubscriptions","clients","clientStates","client","state","clientIssues","id","subscriptions","unsubscribeFromHmrEvents","replace","ext","entrypointKey","isMetadataRoute","endsWith","sl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ClDC,gBAAgBA,cAAcG,KAAK,CAAC,GAAG,CAAC,OAAOC,MAAM;YACvD;QACF;QACAJ,gBAAgBA,gBAAgB;IAClC;IACA,OAAOA;AACT","ignoreList":[0]}
|
|
@@ -83,7 +83,7 @@ function logStartInfo({ networkUrl, appUrl, envInfo, experimentalFeatures, logBu
|
|
|
83
83
|
bundlerSuffix = ' (webpack)';
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
_log.bootstrap(`${(0, _picocolors.bold)((0, _picocolors.purple)(`${_log.prefixes.ready} Next.js ${"16.0.0-
|
|
86
|
+
_log.bootstrap(`${(0, _picocolors.bold)((0, _picocolors.purple)(`${_log.prefixes.ready} Next.js ${"16.0.0-canary.1"}`))}${bundlerSuffix}`);
|
|
87
87
|
if (appUrl) {
|
|
88
88
|
_log.bootstrap(`- Local: ${appUrl}`);
|
|
89
89
|
}
|
|
@@ -179,7 +179,7 @@ async function getRequestHandlers({ dir, port, isDev, onDevServerCleanup, server
|
|
|
179
179
|
async function startServer(serverOptions) {
|
|
180
180
|
const { dir, isDev, hostname, minimalMode, allowRetry, keepAliveTimeout, selfSignedCertificate } = serverOptions;
|
|
181
181
|
let { port } = serverOptions;
|
|
182
|
-
process.title = `next-server (v${"16.0.0-
|
|
182
|
+
process.title = `next-server (v${"16.0.0-canary.1"})`;
|
|
183
183
|
let handlersReady = ()=>{};
|
|
184
184
|
let handlersError = ()=>{};
|
|
185
185
|
let handlersPromise = new Promise((resolve, reject)=>{
|
|
@@ -67,6 +67,7 @@ const _nodemoduleloader = require("./lib/module-loader/node-module-loader");
|
|
|
67
67
|
const _nofallbackerrorexternal = require("../shared/lib/no-fallback-error.external");
|
|
68
68
|
const _instrumentationglobalsexternal = require("./lib/router-utils/instrumentation-globals.external");
|
|
69
69
|
const _routerservercontext = require("./lib/router-utils/router-server-context");
|
|
70
|
+
const _globalbehaviors = require("./node-environment-extensions/global-behaviors");
|
|
70
71
|
function _export_star(from, to) {
|
|
71
72
|
Object.keys(from).forEach(function(k) {
|
|
72
73
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -494,6 +495,7 @@ class NextNodeServer extends _baseserver.default {
|
|
|
494
495
|
}
|
|
495
496
|
return result.finished;
|
|
496
497
|
};
|
|
498
|
+
(0, _globalbehaviors.installGlobalBehaviors)(this.nextConfig);
|
|
497
499
|
const isDev = options.dev ?? false;
|
|
498
500
|
this.isDev = isDev;
|
|
499
501
|
this.sriEnabled = Boolean((_options_conf_experimental = options.conf.experimental) == null ? void 0 : (_options_conf_experimental_sri = _options_conf_experimental.sri) == null ? void 0 : _options_conf_experimental_sri.algorithm);
|