next 15.4.0-canary.114 → 15.4.0-canary.116
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 +2 -2
- package/dist/build/swc/index.js +1 -1
- 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-devtools/index.js +1 -1
- package/dist/compiled/next-devtools/index.js.map +1 -1
- package/dist/compiled/next-server/app-page-experimental.runtime.dev.js +2 -2
- package/dist/compiled/next-server/app-page-experimental.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/pages-api-turbo.runtime.dev.js +1 -1
- package/dist/compiled/next-server/pages-api-turbo.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/pages-api-turbo.runtime.prod.js +1 -1
- package/dist/compiled/next-server/pages-api-turbo.runtime.prod.js.map +1 -1
- package/dist/compiled/next-server/pages-api.runtime.dev.js +1 -1
- package/dist/compiled/next-server/pages-api.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/pages-turbo.runtime.dev.js +1 -1
- package/dist/compiled/next-server/pages-turbo.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/pages-turbo.runtime.prod.js +1 -1
- package/dist/compiled/next-server/pages-turbo.runtime.prod.js.map +1 -1
- package/dist/compiled/next-server/pages.runtime.dev.js +1 -1
- package/dist/compiled/next-server/pages.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/server.runtime.prod.js +1 -1
- package/dist/compiled/next-server/server.runtime.prod.js.map +1 -1
- package/dist/esm/build/index.js +2 -2
- package/dist/esm/build/swc/index.js +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/server/dev/hot-reloader-turbopack.js +1 -1
- package/dist/esm/server/dev/hot-reloader-turbopack.js.map +1 -1
- package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/esm/server/dev/middleware-turbopack.js +2 -20
- package/dist/esm/server/dev/middleware-turbopack.js.map +1 -1
- package/dist/esm/server/dev/middleware-webpack.js +13 -10
- package/dist/esm/server/dev/middleware-webpack.js.map +1 -1
- package/dist/esm/server/lib/app-info-log.js +1 -1
- package/dist/esm/server/lib/source-maps.js +38 -0
- package/dist/esm/server/lib/source-maps.js.map +1 -0
- package/dist/esm/server/lib/start-server.js +1 -1
- package/dist/esm/server/patch-error-inspect.js +3 -32
- package/dist/esm/server/patch-error-inspect.js.map +1 -1
- package/dist/esm/shared/lib/canary-only.js +1 -1
- package/dist/server/dev/hot-reloader-turbopack.js +1 -1
- package/dist/server/dev/hot-reloader-turbopack.js.map +1 -1
- package/dist/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/server/dev/middleware-turbopack.js +2 -20
- package/dist/server/dev/middleware-turbopack.js.map +1 -1
- package/dist/server/dev/middleware-webpack.d.ts +4 -4
- package/dist/server/dev/middleware-webpack.js +14 -14
- package/dist/server/dev/middleware-webpack.js.map +1 -1
- package/dist/server/lib/app-info-log.js +1 -1
- package/dist/server/lib/source-maps.d.ts +36 -0
- package/dist/server/lib/source-maps.js +57 -0
- package/dist/server/lib/source-maps.js.map +1 -0
- package/dist/server/lib/start-server.js +1 -1
- package/dist/server/patch-error-inspect.d.ts +1 -20
- package/dist/server/patch-error-inspect.js +3 -32
- package/dist/server/patch-error-inspect.js.map +1 -1
- package/dist/shared/lib/canary-only.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
package/dist/esm/build/index.js
CHANGED
@@ -320,7 +320,7 @@ export default async function build(dir, reactProductionProfiling = false, debug
|
|
320
320
|
const nextBuildSpan = trace('next-build', undefined, {
|
321
321
|
buildMode: experimentalBuildMode,
|
322
322
|
isTurboBuild: String(isTurbopack),
|
323
|
-
version: "15.4.0-canary.
|
323
|
+
version: "15.4.0-canary.116"
|
324
324
|
});
|
325
325
|
NextBuildContext.nextBuildSpan = nextBuildSpan;
|
326
326
|
NextBuildContext.dir = dir;
|
@@ -707,7 +707,7 @@ export default async function build(dir, reactProductionProfiling = false, debug
|
|
707
707
|
// Files outside of the distDir can be "type": "module"
|
708
708
|
await writeFileUtf8(path.join(distDir, 'package.json'), '{"type": "commonjs"}');
|
709
709
|
// These are written to distDir, so they need to come after creating and cleaning distDr.
|
710
|
-
await recordFrameworkVersion("15.4.0-canary.
|
710
|
+
await recordFrameworkVersion("15.4.0-canary.116");
|
711
711
|
await updateBuildDiagnostics({
|
712
712
|
buildStage: 'start'
|
713
713
|
});
|
@@ -11,7 +11,7 @@ import { isDeepStrictEqual } from 'util';
|
|
11
11
|
import { getDefineEnv } from '../define-env';
|
12
12
|
import { getReactCompilerLoader } from '../get-babel-loader-config';
|
13
13
|
import { TurbopackInternalError } from '../../shared/lib/turbopack/utils';
|
14
|
-
const nextVersion = "15.4.0-canary.
|
14
|
+
const nextVersion = "15.4.0-canary.116";
|
15
15
|
const ArchName = arch();
|
16
16
|
const PlatformName = platform();
|
17
17
|
function infoLog(...args) {
|
@@ -1588,7 +1588,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
|
|
1588
1588
|
isClient && new CopyFilePlugin({
|
1589
1589
|
// file path to build output of `@next/polyfill-nomodule`
|
1590
1590
|
filePath: require.resolve('./polyfills/polyfill-nomodule'),
|
1591
|
-
cacheKey: "15.4.0-canary.
|
1591
|
+
cacheKey: "15.4.0-canary.116",
|
1592
1592
|
name: `static/chunks/polyfills${dev ? '' : '-[hash]'}.js`,
|
1593
1593
|
minimize: false,
|
1594
1594
|
info: {
|
@@ -1768,7 +1768,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
|
|
1768
1768
|
// - Next.js location on disk (some loaders use absolute paths and some resolve options depend on absolute paths)
|
1769
1769
|
// - Next.js version
|
1770
1770
|
// - next.config.js keys that affect compilation
|
1771
|
-
version: `${__dirname}|${"15.4.0-canary.
|
1771
|
+
version: `${__dirname}|${"15.4.0-canary.116"}|${configVars}`,
|
1772
1772
|
cacheDirectory: path.join(distDir, 'cache', 'webpack'),
|
1773
1773
|
// For production builds, it's more efficient to compress all cache files together instead of compression each one individually.
|
1774
1774
|
// So we disable compression here and allow the build runner to take care of compressing the cache as a whole.
|
package/dist/esm/client/index.js
CHANGED
@@ -26,7 +26,7 @@ import { SearchParamsContext, PathParamsContext } from '../shared/lib/hooks-clie
|
|
26
26
|
import { onRecoverableError } from './react-client-callbacks/on-recoverable-error';
|
27
27
|
import tracer from './tracing/tracer';
|
28
28
|
import { isNextRouterError } from './components/is-next-router-error';
|
29
|
-
export const version = "15.4.0-canary.
|
29
|
+
export const version = "15.4.0-canary.116";
|
30
30
|
export let router;
|
31
31
|
export const emitter = mitt();
|
32
32
|
const looseToArray = (input)=>[].slice.call(input);
|
@@ -86,7 +86,7 @@ export async function createHotReloaderTurbopack(opts, serverFields, distDir, re
|
|
86
86
|
}
|
87
87
|
const hasRewrites = opts.fsChecker.rewrites.afterFiles.length > 0 || opts.fsChecker.rewrites.beforeFiles.length > 0 || opts.fsChecker.rewrites.fallback.length > 0;
|
88
88
|
const hotReloaderSpan = trace('hot-reloader', undefined, {
|
89
|
-
version: "15.4.0-canary.
|
89
|
+
version: "15.4.0-canary.116"
|
90
90
|
});
|
91
91
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
92
92
|
// of the current `next dev` invocation.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/server/dev/hot-reloader-turbopack.ts"],"sourcesContent":["import type { Socket } from 'net'\nimport { mkdir, writeFile } from 'fs/promises'\nimport { join, extname } from 'path'\nimport { pathToFileURL } from 'url'\n\nimport ws from 'next/dist/compiled/ws'\n\nimport type { OutputState } from '../../build/output/store'\nimport { store as consoleStore } from '../../build/output/store'\nimport type {\n CompilationError,\n HMR_ACTION_TYPES,\n NextJsHotReloaderInterface,\n ReloadPageAction,\n SyncAction,\n TurbopackConnectedAction,\n} from './hot-reloader-types'\nimport { HMR_ACTIONS_SENT_TO_BROWSER } from './hot-reloader-types'\nimport type {\n Update as TurbopackUpdate,\n Endpoint,\n WrittenEndpoint,\n TurbopackResult,\n Project,\n Entrypoints,\n} from '../../build/swc/types'\nimport { createDefineEnv } from '../../build/swc'\nimport * as Log from '../../build/output/log'\nimport {\n getVersionInfo,\n matchNextPageBundleRequest,\n} from './hot-reloader-webpack'\nimport { BLOCKED_PAGES } from '../../shared/lib/constants'\nimport {\n getOverlayMiddleware,\n getSourceMapMiddleware,\n} from './middleware-turbopack'\nimport { PageNotFoundError } from '../../shared/lib/utils'\nimport { debounce } from '../utils'\nimport { deleteCache, deleteFromRequireCache } from './require-cache'\nimport {\n clearAllModuleContexts,\n clearModuleContext,\n} from '../lib/render-server'\nimport { denormalizePagePath } from '../../shared/lib/page-path/denormalize-page-path'\nimport { trace } from '../../trace'\nimport {\n AssetMapper,\n type ChangeSubscriptions,\n type ClientState,\n handleEntrypoints,\n handlePagesErrorRoute,\n handleRouteType,\n hasEntrypointForKey,\n msToNs,\n type ReadyIds,\n type SendHmr,\n type StartBuilding,\n processTopLevelIssues,\n printNonFatalIssue,\n normalizedPageToTurbopackStructureRoute,\n} from './turbopack-utils'\nimport {\n propagateServerField,\n type ServerFields,\n type SetupOpts,\n} from '../lib/router-utils/setup-dev-bundler'\nimport { TurbopackManifestLoader } from '../../shared/lib/turbopack/manifest-loader'\nimport { findPagePathData } from './on-demand-entry-handler'\nimport type { RouteDefinition } from '../route-definitions/route-definition'\nimport {\n type EntryKey,\n getEntryKey,\n splitEntryKey,\n} from '../../shared/lib/turbopack/entry-key'\nimport { FAST_REFRESH_RUNTIME_RELOAD } from './messages'\nimport { generateEncryptionKeyBase64 } from '../app-render/encryption-utils-server'\nimport { isAppPageRouteDefinition } from '../route-definitions/app-page-route-definition'\nimport { normalizeAppPath } from '../../shared/lib/router/utils/app-paths'\nimport { getNodeDebugType } from '../lib/utils'\nimport { isMetadataRouteFile } from '../../lib/metadata/is-metadata-route'\nimport {\n setBundlerFindSourceMapImplementation,\n type ModernSourceMapPayload,\n} from '../patch-error-inspect'\nimport { getNextErrorFeedbackMiddleware } from '../../next-devtools/server/get-next-error-feedback-middleware'\nimport {\n formatIssue,\n getTurbopackJsConfig,\n isPersistentCachingEnabled,\n isWellKnownError,\n processIssues,\n renderStyledStringToErrorAnsi,\n type EntryIssuesMap,\n type TopLevelIssuesMap,\n} from '../../shared/lib/turbopack/utils'\nimport { getDevOverlayFontMiddleware } from '../../next-devtools/server/font/get-dev-overlay-font-middleware'\nimport { devIndicatorServerState } from './dev-indicator-server-state'\nimport { getDisableDevIndicatorMiddleware } from '../../next-devtools/server/dev-indicator-middleware'\nimport { getRestartDevServerMiddleware } from '../../next-devtools/server/restart-dev-server-middleware'\nimport { backgroundLogCompilationEvents } from '../../shared/lib/turbopack/compilation-events'\nimport { getSupportedBrowsers } from '../../build/utils'\n\nconst wsServer = new ws.Server({ noServer: true })\nconst isTestMode = !!(\n process.env.NEXT_TEST_MODE ||\n process.env.__NEXT_TEST_MODE ||\n process.env.DEBUG\n)\n\nconst sessionId = Math.floor(Number.MAX_SAFE_INTEGER * Math.random())\n\n/**\n * Replaces turbopack:///[project] with the specified project in the `source` field.\n */\nfunction rewriteTurbopackSources(\n projectRoot: string,\n sourceMap: ModernSourceMapPayload\n): void {\n if ('sections' in sourceMap) {\n for (const section of sourceMap.sections) {\n rewriteTurbopackSources(projectRoot, section.map)\n }\n } else {\n for (let i = 0; i < sourceMap.sources.length; i++) {\n sourceMap.sources[i] = pathToFileURL(\n join(\n projectRoot,\n sourceMap.sources[i].replace(/turbopack:\\/\\/\\/\\[project\\]/, '')\n )\n ).toString()\n }\n }\n}\n\nfunction getSourceMapFromTurbopack(\n project: Project,\n projectRoot: string,\n sourceURL: string\n): ModernSourceMapPayload | undefined {\n let sourceMapJson: string | null = null\n\n try {\n sourceMapJson = project.getSourceMapSync(sourceURL)\n } catch (err) {}\n\n if (sourceMapJson === null) {\n return undefined\n } else {\n const payload: ModernSourceMapPayload = JSON.parse(sourceMapJson)\n // The sourcemap from Turbopack is not yet written to disk so its `sources`\n // are not absolute paths yet. We need to rewrite them to be absolute paths.\n rewriteTurbopackSources(projectRoot, payload)\n return payload\n }\n}\n\nexport async function createHotReloaderTurbopack(\n opts: SetupOpts & { isSrcDir: boolean },\n serverFields: ServerFields,\n distDir: string,\n resetFetch: () => void\n): Promise<NextJsHotReloaderInterface> {\n const dev = true\n const buildId = 'development'\n const { nextConfig, dir: projectPath } = opts\n\n const { loadBindings } =\n require('../../build/swc') as typeof import('../../build/swc')\n\n let bindings = await loadBindings()\n\n // For the debugging purpose, check if createNext or equivalent next instance setup in test cases\n // works correctly. Normally `run-test` hides output so only will be visible when `--debug` flag is used.\n if (isTestMode) {\n ;(require('console') as typeof import('console')).log(\n 'Creating turbopack project',\n {\n dir: projectPath,\n testMode: isTestMode,\n }\n )\n }\n\n const hasRewrites =\n opts.fsChecker.rewrites.afterFiles.length > 0 ||\n opts.fsChecker.rewrites.beforeFiles.length > 0 ||\n opts.fsChecker.rewrites.fallback.length > 0\n\n const hotReloaderSpan = trace('hot-reloader', undefined, {\n version: process.env.__NEXT_VERSION as string,\n })\n // Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing\n // of the current `next dev` invocation.\n hotReloaderSpan.stop()\n\n const encryptionKey = await generateEncryptionKeyBase64({\n isBuild: false,\n distDir,\n })\n\n // TODO: Implement\n let clientRouterFilters: any\n if (nextConfig.experimental.clientRouterFilter) {\n // TODO this need to be set correctly for persistent caching to work\n }\n\n const supportedBrowsers = await getSupportedBrowsers(projectPath, dev)\n const currentNodeJsVersion = process.versions.node\n\n const project = await bindings.turbo.createProject(\n {\n projectPath: projectPath,\n rootPath:\n opts.nextConfig.turbopack?.root ||\n opts.nextConfig.outputFileTracingRoot ||\n projectPath,\n distDir,\n nextConfig: opts.nextConfig,\n jsConfig: await getTurbopackJsConfig(projectPath, nextConfig),\n watch: {\n enable: dev,\n pollIntervalMs: nextConfig.watchOptions?.pollIntervalMs,\n },\n dev,\n env: process.env as Record<string, string>,\n defineEnv: createDefineEnv({\n isTurbopack: true,\n clientRouterFilters,\n config: nextConfig,\n dev,\n distDir,\n projectPath,\n fetchCacheKeyPrefix: opts.nextConfig.experimental.fetchCacheKeyPrefix,\n hasRewrites,\n // TODO: Implement\n middlewareMatchers: undefined,\n rewrites: opts.fsChecker.rewrites,\n }),\n buildId,\n encryptionKey,\n previewProps: opts.fsChecker.prerenderManifest.preview,\n browserslistQuery: supportedBrowsers.join(', '),\n noMangling: false,\n currentNodeJsVersion,\n },\n {\n persistentCaching: isPersistentCachingEnabled(opts.nextConfig),\n memoryLimit: opts.nextConfig.experimental?.turbopackMemoryLimit,\n }\n )\n backgroundLogCompilationEvents(project, {\n eventTypes: ['StartupCacheInvalidationEvent'],\n })\n setBundlerFindSourceMapImplementation(\n getSourceMapFromTurbopack.bind(null, project, projectPath)\n )\n opts.onDevServerCleanup?.(async () => {\n setBundlerFindSourceMapImplementation(() => undefined)\n await project.onExit()\n })\n const entrypointsSubscription = project.entrypointsSubscribe()\n\n const currentWrittenEntrypoints: Map<EntryKey, WrittenEndpoint> = new Map()\n const currentEntrypoints: Entrypoints = {\n global: {\n app: undefined,\n document: undefined,\n error: undefined,\n\n middleware: undefined,\n instrumentation: undefined,\n },\n\n page: new Map(),\n app: new Map(),\n }\n\n const currentTopLevelIssues: TopLevelIssuesMap = new Map()\n const currentEntryIssues: EntryIssuesMap = new Map()\n\n const manifestLoader = new TurbopackManifestLoader({\n buildId,\n distDir,\n encryptionKey,\n })\n\n // Dev specific\n const changeSubscriptions: ChangeSubscriptions = new Map()\n const serverPathState = new Map<string, string>()\n const readyIds: ReadyIds = new Set()\n let currentEntriesHandlingResolve: ((value?: unknown) => void) | undefined\n let currentEntriesHandling = new Promise(\n (resolve) => (currentEntriesHandlingResolve = resolve)\n )\n\n const assetMapper = new AssetMapper()\n\n function clearRequireCache(\n key: EntryKey,\n writtenEndpoint: WrittenEndpoint,\n {\n force,\n }: {\n // Always clear the cache, don't check if files have changed\n force?: boolean\n } = {}\n ): boolean {\n if (force) {\n for (const { path, contentHash } of writtenEndpoint.serverPaths) {\n serverPathState.set(path, contentHash)\n }\n } else {\n // Figure out if the server files have changed\n let hasChange = false\n for (const { path, contentHash } of writtenEndpoint.serverPaths) {\n // We ignore source maps\n if (path.endsWith('.map')) continue\n const localKey = `${key}:${path}`\n const localHash = serverPathState.get(localKey)\n const globalHash = serverPathState.get(path)\n if (\n (localHash && localHash !== contentHash) ||\n (globalHash && globalHash !== contentHash)\n ) {\n hasChange = true\n serverPathState.set(key, contentHash)\n serverPathState.set(path, contentHash)\n } else {\n if (!localHash) {\n serverPathState.set(key, contentHash)\n }\n if (!globalHash) {\n serverPathState.set(path, contentHash)\n }\n }\n }\n\n if (!hasChange) {\n return false\n }\n }\n\n resetFetch()\n\n const hasAppPaths = writtenEndpoint.serverPaths.some(({ path: p }) =>\n p.startsWith('server/app')\n )\n\n if (hasAppPaths) {\n deleteFromRequireCache(\n require.resolve(\n 'next/dist/compiled/next-server/app-page-turbo.runtime.dev.js'\n )\n )\n deleteFromRequireCache(\n require.resolve(\n 'next/dist/compiled/next-server/app-page-turbo-experimental.runtime.dev.js'\n )\n )\n }\n\n const serverPaths = writtenEndpoint.serverPaths.map(({ path: p }) =>\n join(distDir, p)\n )\n\n for (const file of serverPaths) {\n clearModuleContext(file)\n deleteCache(file)\n }\n\n return true\n }\n\n const buildingIds = new Set()\n\n const startBuilding: StartBuilding = (id, requestUrl, forceRebuild) => {\n if (!forceRebuild && readyIds.has(id)) {\n return () => {}\n }\n if (buildingIds.size === 0) {\n consoleStore.setState(\n {\n loading: true,\n trigger: id,\n url: requestUrl,\n } as OutputState,\n true\n )\n }\n buildingIds.add(id)\n return function finishBuilding() {\n if (buildingIds.size === 0) {\n return\n }\n readyIds.add(id)\n buildingIds.delete(id)\n if (buildingIds.size === 0) {\n hmrEventHappened = false\n consoleStore.setState(\n {\n loading: false,\n } as OutputState,\n true\n )\n }\n }\n }\n\n let hmrEventHappened = false\n let hmrHash = 0\n\n const clients = new Set<ws>()\n const clientStates = new WeakMap<ws, ClientState>()\n\n function sendToClient(client: ws, payload: HMR_ACTION_TYPES) {\n client.send(JSON.stringify(payload))\n }\n\n function sendEnqueuedMessages() {\n for (const [, issueMap] of currentEntryIssues) {\n if (\n [...issueMap.values()].filter((i) => i.severity !== 'warning').length >\n 0\n ) {\n // During compilation errors we want to delay the HMR events until errors are fixed\n return\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 [, issueMap] of state.clientIssues) {\n if (\n [...issueMap.values()].filter((i) => i.severity !== 'warning')\n .length > 0\n ) {\n // During compilation errors we want to delay the HMR events until errors are fixed\n return\n }\n }\n\n for (const payload of state.hmrPayloads.values()) {\n sendToClient(client, payload)\n }\n state.hmrPayloads.clear()\n\n if (state.turbopackUpdates.length > 0) {\n sendToClient(client, {\n action: HMR_ACTIONS_SENT_TO_BROWSER.TURBOPACK_MESSAGE,\n data: state.turbopackUpdates,\n })\n state.turbopackUpdates.length = 0\n }\n }\n }\n const sendEnqueuedMessagesDebounce = debounce(sendEnqueuedMessages, 2)\n\n const sendHmr: SendHmr = (id: string, payload: HMR_ACTION_TYPES) => {\n for (const client of clients) {\n clientStates.get(client)?.hmrPayloads.set(id, payload)\n }\n\n hmrEventHappened = true\n sendEnqueuedMessagesDebounce()\n }\n\n function sendTurbopackMessage(payload: TurbopackUpdate) {\n // TODO(PACK-2049): For some reason we end up emitting hundreds of issues messages on bigger apps,\n // a lot of which are duplicates.\n // They are currently not handled on the client at all, so might as well not send them for now.\n payload.diagnostics = []\n payload.issues = []\n\n for (const client of clients) {\n clientStates.get(client)?.turbopackUpdates.push(payload)\n }\n\n hmrEventHappened = true\n sendEnqueuedMessagesDebounce()\n }\n\n async function subscribeToChanges(\n key: EntryKey,\n includeIssues: boolean,\n endpoint: Endpoint,\n makePayload: (\n change: TurbopackResult,\n hash: string\n ) => Promise<HMR_ACTION_TYPES> | HMR_ACTION_TYPES | void,\n onError?: (\n error: Error\n ) => Promise<HMR_ACTION_TYPES> | HMR_ACTION_TYPES | void\n ) {\n if (changeSubscriptions.has(key)) {\n return\n }\n\n const { side } = splitEntryKey(key)\n\n const changedPromise = endpoint[`${side}Changed`](includeIssues)\n changeSubscriptions.set(key, changedPromise)\n try {\n const changed = await changedPromise\n\n for await (const change of changed) {\n processIssues(currentEntryIssues, key, change, false, true)\n // TODO: Get an actual content hash from Turbopack.\n const payload = await makePayload(change, String(++hmrHash))\n if (payload) {\n sendHmr(key, payload)\n }\n }\n } catch (e) {\n changeSubscriptions.delete(key)\n const payload = await onError?.(e as Error)\n if (payload) {\n sendHmr(key, payload)\n }\n return\n }\n changeSubscriptions.delete(key)\n }\n\n async function unsubscribeFromChanges(key: EntryKey) {\n const subscription = await changeSubscriptions.get(key)\n if (subscription) {\n await subscription.return?.()\n changeSubscriptions.delete(key)\n }\n currentEntryIssues.delete(key)\n }\n\n async function subscribeToHmrEvents(client: ws, id: string) {\n const key = getEntryKey('assets', 'client', id)\n if (!hasEntrypointForKey(currentEntrypoints, key, assetMapper)) {\n // maybe throw an error / force the client to reload?\n return\n }\n\n const state = clientStates.get(client)\n if (!state || state.subscriptions.has(id)) {\n return\n }\n\n const subscription = project!.hmrEvents(id)\n state.subscriptions.set(id, subscription)\n\n // The subscription will always emit once, which is the initial\n // computation. This is not a change, so swallow it.\n try {\n await subscription.next()\n\n for await (const data of subscription) {\n processIssues(state.clientIssues, key, data, false, true)\n if (data.type !== 'issues') {\n sendTurbopackMessage(data)\n }\n }\n } catch (e) {\n // The client might be using an HMR session from a previous server, tell them\n // to fully reload the page to resolve the issue. We can't use\n // `hotReloader.send` since that would force every connected client to\n // reload, only this client is out of date.\n const reloadAction: ReloadPageAction = {\n action: HMR_ACTIONS_SENT_TO_BROWSER.RELOAD_PAGE,\n data: `error in HMR event subscription for ${id}: ${e}`,\n }\n sendToClient(client, reloadAction)\n client.close()\n return\n }\n }\n\n function unsubscribeFromHmrEvents(client: ws, id: string) {\n const state = clientStates.get(client)\n if (!state) {\n return\n }\n\n const subscription = state.subscriptions.get(id)\n subscription?.return!()\n\n const key = getEntryKey('assets', 'client', id)\n state.clientIssues.delete(key)\n }\n\n async function handleEntrypointsSubscription() {\n for await (const entrypoints of entrypointsSubscription) {\n if (!currentEntriesHandlingResolve) {\n currentEntriesHandling = new Promise(\n // eslint-disable-next-line no-loop-func\n (resolve) => (currentEntriesHandlingResolve = resolve)\n )\n }\n\n processTopLevelIssues(currentTopLevelIssues, entrypoints)\n\n await handleEntrypoints({\n entrypoints,\n\n currentEntrypoints,\n\n currentEntryIssues,\n manifestLoader,\n devRewrites: opts.fsChecker.rewrites,\n productionRewrites: undefined,\n logErrors: true,\n\n dev: {\n assetMapper,\n changeSubscriptions,\n clients,\n clientStates,\n serverFields,\n\n hooks: {\n handleWrittenEndpoint: (id, result, forceDeleteCache) => {\n currentWrittenEntrypoints.set(id, result)\n return clearRequireCache(id, result, { force: forceDeleteCache })\n },\n propagateServerField: propagateServerField.bind(null, opts),\n sendHmr,\n startBuilding,\n subscribeToChanges,\n unsubscribeFromChanges,\n unsubscribeFromHmrEvents,\n },\n },\n })\n\n currentEntriesHandlingResolve!()\n currentEntriesHandlingResolve = undefined\n }\n }\n\n await mkdir(join(distDir, 'server'), { recursive: true })\n await mkdir(join(distDir, 'static', buildId), { recursive: true })\n await writeFile(\n join(distDir, 'package.json'),\n JSON.stringify(\n {\n type: 'commonjs',\n },\n null,\n 2\n )\n )\n\n const middlewares = [\n getOverlayMiddleware({\n project,\n projectPath,\n isSrcDir: opts.isSrcDir,\n }),\n getSourceMapMiddleware(project),\n getNextErrorFeedbackMiddleware(opts.telemetry),\n getDevOverlayFontMiddleware(),\n getDisableDevIndicatorMiddleware(),\n getRestartDevServerMiddleware({\n telemetry: opts.telemetry,\n turbopackProject: project,\n }),\n ]\n\n const versionInfoPromise = getVersionInfo()\n\n let devtoolsFrontendUrl: string | undefined\n const nodeDebugType = getNodeDebugType()\n if (nodeDebugType) {\n const debugPort = process.debugPort\n let debugInfo\n try {\n // It requires to use 127.0.0.1 instead of localhost for server-side fetching.\n const debugInfoList = await fetch(\n `http://127.0.0.1:${debugPort}/json/list`\n ).then((res) => res.json())\n debugInfo = debugInfoList[0]\n } catch {}\n if (debugInfo) {\n devtoolsFrontendUrl = debugInfo.devtoolsFrontendUrl\n }\n }\n\n const hotReloader: NextJsHotReloaderInterface = {\n turbopackProject: project,\n activeWebpackConfigs: undefined,\n serverStats: null,\n edgeServerStats: null,\n async run(req, res, _parsedUrl) {\n // intercept page chunks request and ensure them with turbopack\n if (req.url?.startsWith('/_next/static/chunks/pages/')) {\n const params = matchNextPageBundleRequest(req.url)\n\n if (params) {\n const decodedPagePath = `/${params.path\n .map((param: string) => decodeURIComponent(param))\n .join('/')}`\n\n const denormalizedPagePath = denormalizePagePath(decodedPagePath)\n\n await hotReloader\n .ensurePage({\n page: denormalizedPagePath,\n clientOnly: false,\n definition: undefined,\n url: req.url,\n })\n .catch(console.error)\n }\n }\n\n for (const middleware of middlewares) {\n let calledNext = false\n\n await middleware(req, res, () => {\n calledNext = true\n })\n\n if (!calledNext) {\n return { finished: true }\n }\n }\n\n // Request was not finished.\n return { finished: undefined }\n },\n\n // TODO: Figure out if socket type can match the NextJsHotReloaderInterface\n onHMR(req, socket: Socket, head, onUpgrade) {\n wsServer.handleUpgrade(req, socket, head, (client) => {\n onUpgrade(client)\n const clientIssues: EntryIssuesMap = new Map()\n const subscriptions: Map<string, AsyncIterator<any>> = new Map()\n\n clients.add(client)\n clientStates.set(client, {\n clientIssues,\n hmrPayloads: new Map(),\n turbopackUpdates: [],\n subscriptions,\n })\n\n client.on('close', () => {\n // Remove active subscriptions\n for (const subscription of subscriptions.values()) {\n subscription.return?.()\n }\n clientStates.delete(client)\n clients.delete(client)\n })\n\n client.addEventListener('message', ({ data }) => {\n const parsedData = JSON.parse(\n typeof data !== 'string' ? data.toString() : data\n )\n\n // Next.js messages\n switch (parsedData.event) {\n case 'span-end': {\n hotReloaderSpan.manualTraceChild(\n parsedData.spanName,\n msToNs(parsedData.startTime),\n msToNs(parsedData.endTime),\n parsedData.attributes\n )\n break\n }\n case 'client-hmr-latency': // { id, startTime, endTime, page, updatedModules, isPageHidden }\n hotReloaderSpan.manualTraceChild(\n parsedData.event,\n msToNs(parsedData.startTime),\n msToNs(parsedData.endTime),\n {\n updatedModules: parsedData.updatedModules,\n page: parsedData.page,\n isPageHidden: parsedData.isPageHidden,\n }\n )\n break\n case 'client-error': // { errorCount, clientId }\n case 'client-warning': // { warningCount, clientId }\n case 'client-success': // { clientId }\n case 'server-component-reload-page': // { clientId }\n case 'client-reload-page': // { clientId }\n case 'client-removed-page': // { page }\n case 'client-full-reload': // { stackTrace, hadRuntimeError }\n const { hadRuntimeError, dependencyChain } = parsedData\n if (hadRuntimeError) {\n Log.warn(FAST_REFRESH_RUNTIME_RELOAD)\n }\n if (\n Array.isArray(dependencyChain) &&\n typeof dependencyChain[0] === 'string'\n ) {\n const cleanedModulePath = dependencyChain[0]\n .replace(/^\\[project\\]/, '.')\n .replace(/ \\[.*\\] \\(.*\\)$/, '')\n Log.warn(\n `Fast Refresh had to perform a full reload when ${cleanedModulePath} changed. Read more: https://nextjs.org/docs/messages/fast-refresh-reload`\n )\n }\n break\n case 'client-added-page':\n // TODO\n break\n\n default:\n // Might be a Turbopack message...\n if (!parsedData.type) {\n throw new Error(`unrecognized HMR message \"${data}\"`)\n }\n }\n\n // Turbopack messages\n switch (parsedData.type) {\n case 'turbopack-subscribe':\n subscribeToHmrEvents(client, parsedData.path)\n break\n\n case 'turbopack-unsubscribe':\n unsubscribeFromHmrEvents(client, parsedData.path)\n break\n\n default:\n if (!parsedData.event) {\n throw new Error(`unrecognized Turbopack HMR message \"${data}\"`)\n }\n }\n })\n\n const turbopackConnected: TurbopackConnectedAction = {\n action: HMR_ACTIONS_SENT_TO_BROWSER.TURBOPACK_CONNECTED,\n data: { sessionId },\n }\n sendToClient(client, turbopackConnected)\n\n const errors: CompilationError[] = []\n\n for (const entryIssues of currentEntryIssues.values()) {\n for (const issue of entryIssues.values()) {\n if (issue.severity !== 'warning') {\n errors.push({\n message: formatIssue(issue),\n })\n } else {\n printNonFatalIssue(issue)\n }\n }\n }\n\n if (devIndicatorServerState.disabledUntil < Date.now()) {\n devIndicatorServerState.disabledUntil = 0\n }\n\n ;(async function () {\n const versionInfo = await versionInfoPromise\n\n const sync: SyncAction = {\n action: HMR_ACTIONS_SENT_TO_BROWSER.SYNC,\n errors,\n warnings: [],\n hash: '',\n versionInfo,\n debug: {\n devtoolsFrontendUrl,\n },\n devIndicator: devIndicatorServerState,\n }\n\n sendToClient(client, sync)\n })()\n })\n },\n\n send(action) {\n const payload = JSON.stringify(action)\n for (const client of clients) {\n client.send(payload)\n }\n },\n\n setHmrServerError(_error) {\n // Not implemented yet.\n },\n clearHmrServerError() {\n // Not implemented yet.\n },\n async start() {},\n async getCompilationErrors(page) {\n const appEntryKey = getEntryKey('app', 'server', page)\n const pagesEntryKey = getEntryKey('pages', 'server', page)\n\n const topLevelIssues = currentTopLevelIssues.values()\n\n const thisEntryIssues =\n currentEntryIssues.get(appEntryKey) ??\n currentEntryIssues.get(pagesEntryKey)\n\n if (thisEntryIssues !== undefined && thisEntryIssues.size > 0) {\n // If there is an error related to the requesting page we display it instead of the first error\n return [...topLevelIssues, ...thisEntryIssues.values()]\n .map((issue) => {\n const formattedIssue = formatIssue(issue)\n if (issue.severity === 'warning') {\n printNonFatalIssue(issue)\n return null\n } else if (isWellKnownError(issue)) {\n Log.error(formattedIssue)\n }\n\n return new Error(formattedIssue)\n })\n .filter((error) => error !== null)\n }\n\n // Otherwise, return all errors across pages\n const errors = []\n for (const issue of topLevelIssues) {\n if (issue.severity !== 'warning') {\n errors.push(new Error(formatIssue(issue)))\n }\n }\n for (const entryIssues of currentEntryIssues.values()) {\n for (const issue of entryIssues.values()) {\n if (issue.severity !== 'warning') {\n const message = formatIssue(issue)\n errors.push(new Error(message))\n } else {\n printNonFatalIssue(issue)\n }\n }\n }\n return errors\n },\n async invalidate({\n // .env files or tsconfig/jsconfig change\n reloadAfterInvalidation,\n }) {\n if (reloadAfterInvalidation) {\n for (const [key, entrypoint] of currentWrittenEntrypoints) {\n clearRequireCache(key, entrypoint, { force: true })\n }\n\n await clearAllModuleContexts()\n this.send({\n action: HMR_ACTIONS_SENT_TO_BROWSER.SERVER_COMPONENT_CHANGES,\n hash: String(++hmrHash),\n })\n }\n },\n async buildFallbackError() {\n // Not implemented yet.\n },\n async ensurePage({\n page: inputPage,\n // Unused parameters\n // clientOnly,\n appPaths,\n definition,\n isApp,\n url: requestUrl,\n }) {\n // When there is no route definition this is an internal file not a route the user added.\n // Middleware and instrumentation are handled in turbpack-utils.ts handleEntrypoints instead.\n if (!definition) {\n if (inputPage === '/middleware') return\n if (inputPage === '/src/middleware') return\n if (inputPage === '/instrumentation') return\n if (inputPage === '/src/instrumentation') return\n }\n\n return hotReloaderSpan\n .traceChild('ensure-page', {\n inputPage,\n })\n .traceAsyncFn(async () => {\n if (BLOCKED_PAGES.includes(inputPage) && inputPage !== '/_error') {\n return\n }\n\n await currentEntriesHandling\n\n // TODO We shouldn't look into the filesystem again. This should use the information from entrypoints\n let routeDef: Pick<\n RouteDefinition,\n 'filename' | 'bundlePath' | 'page'\n > =\n definition ??\n (await findPagePathData(\n projectPath,\n inputPage,\n nextConfig.pageExtensions,\n opts.pagesDir,\n opts.appDir,\n !!nextConfig.experimental.globalNotFound\n ))\n\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 let page = routeDef.page\n if (appPaths) {\n const normalizedPage = normalizeAppPath(page)\n\n // filter out paths that are not exact matches (e.g. catchall)\n const matchingAppPaths = appPaths.filter(\n (path) => normalizeAppPath(path) === normalizedPage\n )\n\n // the last item in the array is the root page, if there are parallel routes\n page = matchingAppPaths[matchingAppPaths.length - 1]\n }\n\n const pathname = definition?.pathname ?? inputPage\n\n if (page === '/_error') {\n let finishBuilding = startBuilding(pathname, requestUrl, false)\n try {\n await handlePagesErrorRoute({\n currentEntryIssues,\n entrypoints: currentEntrypoints,\n manifestLoader,\n devRewrites: opts.fsChecker.rewrites,\n productionRewrites: undefined,\n logErrors: true,\n hooks: {\n subscribeToChanges,\n handleWrittenEndpoint: (id, result, forceDeleteCache) => {\n currentWrittenEntrypoints.set(id, result)\n assetMapper.setPathsForKey(id, result.clientPaths)\n return clearRequireCache(id, result, {\n force: forceDeleteCache,\n })\n },\n },\n })\n } finally {\n finishBuilding()\n }\n return\n }\n\n const isInsideAppDir = routeDef.bundlePath.startsWith('app/')\n const isEntryMetadataRouteFile = isMetadataRouteFile(\n routeDef.filename.replace(opts.appDir || '', ''),\n nextConfig.pageExtensions,\n true\n )\n const normalizedAppPage = isEntryMetadataRouteFile\n ? normalizedPageToTurbopackStructureRoute(\n page,\n extname(routeDef.filename)\n )\n : page\n\n const route = isInsideAppDir\n ? currentEntrypoints.app.get(normalizedAppPage)\n : currentEntrypoints.page.get(page)\n\n if (!route) {\n // TODO: why is this entry missing in turbopack?\n if (page === '/middleware') return\n if (page === '/src/middleware') return\n if (page === '/instrumentation') return\n if (page === '/src/instrumentation') return\n\n throw new PageNotFoundError(`route not found ${page}`)\n }\n\n // We don't throw on ensureOpts.isApp === true for page-api\n // since this can happen when app pages make\n // api requests to page API routes.\n if (isApp && route.type === 'page') {\n throw new Error(`mis-matched route type: isApp && page for ${page}`)\n }\n\n const finishBuilding = startBuilding(pathname, requestUrl, false)\n try {\n await handleRouteType({\n dev,\n page,\n pathname,\n route,\n currentEntryIssues,\n entrypoints: currentEntrypoints,\n manifestLoader,\n readyIds,\n devRewrites: opts.fsChecker.rewrites,\n productionRewrites: undefined,\n logErrors: true,\n\n hooks: {\n subscribeToChanges,\n handleWrittenEndpoint: (id, result, forceDeleteCache) => {\n currentWrittenEntrypoints.set(id, result)\n assetMapper.setPathsForKey(id, result.clientPaths)\n return clearRequireCache(id, result, {\n force: forceDeleteCache,\n })\n },\n },\n })\n } finally {\n finishBuilding()\n }\n })\n },\n close() {\n for (const wsClient of clients) {\n // it's okay to not cleanly close these websocket connections, this is dev\n wsClient.terminate()\n }\n clients.clear()\n },\n }\n\n handleEntrypointsSubscription().catch((err) => {\n console.error(err)\n process.exit(1)\n })\n\n // Write empty manifests\n await currentEntriesHandling\n await manifestLoader.writeManifests({\n devRewrites: opts.fsChecker.rewrites,\n productionRewrites: undefined,\n entrypoints: currentEntrypoints,\n })\n\n async function handleProjectUpdates() {\n for await (const updateMessage of project.updateInfoSubscribe(30)) {\n switch (updateMessage.updateType) {\n case 'start': {\n hotReloader.send({ action: HMR_ACTIONS_SENT_TO_BROWSER.BUILDING })\n break\n }\n case 'end': {\n sendEnqueuedMessages()\n\n function addErrors(\n errorsMap: Map<string, CompilationError>,\n issues: EntryIssuesMap\n ) {\n for (const issueMap of issues.values()) {\n for (const [key, issue] of issueMap) {\n if (issue.severity === 'warning') continue\n if (errorsMap.has(key)) continue\n\n const message = formatIssue(issue)\n\n errorsMap.set(key, {\n message,\n details: issue.detail\n ? renderStyledStringToErrorAnsi(issue.detail)\n : undefined,\n })\n }\n }\n }\n\n const errors = new Map<string, CompilationError>()\n addErrors(errors, currentEntryIssues)\n\n for (const client of clients) {\n const state = clientStates.get(client)\n if (!state) {\n continue\n }\n\n const clientErrors = new Map(errors)\n addErrors(clientErrors, state.clientIssues)\n\n sendToClient(client, {\n action: HMR_ACTIONS_SENT_TO_BROWSER.BUILT,\n hash: String(++hmrHash),\n errors: [...clientErrors.values()],\n warnings: [],\n })\n }\n\n if (hmrEventHappened) {\n const time = updateMessage.value.duration\n const timeMessage =\n time > 2000 ? `${Math.round(time / 100) / 10}s` : `${time}ms`\n Log.event(`Compiled in ${timeMessage}`)\n hmrEventHappened = false\n }\n break\n }\n default:\n }\n }\n }\n\n handleProjectUpdates().catch((err) => {\n console.error(err)\n process.exit(1)\n })\n\n return hotReloader\n}\n"],"names":["mkdir","writeFile","join","extname","pathToFileURL","ws","store","consoleStore","HMR_ACTIONS_SENT_TO_BROWSER","createDefineEnv","Log","getVersionInfo","matchNextPageBundleRequest","BLOCKED_PAGES","getOverlayMiddleware","getSourceMapMiddleware","PageNotFoundError","debounce","deleteCache","deleteFromRequireCache","clearAllModuleContexts","clearModuleContext","denormalizePagePath","trace","AssetMapper","handleEntrypoints","handlePagesErrorRoute","handleRouteType","hasEntrypointForKey","msToNs","processTopLevelIssues","printNonFatalIssue","normalizedPageToTurbopackStructureRoute","propagateServerField","TurbopackManifestLoader","findPagePathData","getEntryKey","splitEntryKey","FAST_REFRESH_RUNTIME_RELOAD","generateEncryptionKeyBase64","isAppPageRouteDefinition","normalizeAppPath","getNodeDebugType","isMetadataRouteFile","setBundlerFindSourceMapImplementation","getNextErrorFeedbackMiddleware","formatIssue","getTurbopackJsConfig","isPersistentCachingEnabled","isWellKnownError","processIssues","renderStyledStringToErrorAnsi","getDevOverlayFontMiddleware","devIndicatorServerState","getDisableDevIndicatorMiddleware","getRestartDevServerMiddleware","backgroundLogCompilationEvents","getSupportedBrowsers","wsServer","Server","noServer","isTestMode","process","env","NEXT_TEST_MODE","__NEXT_TEST_MODE","DEBUG","sessionId","Math","floor","Number","MAX_SAFE_INTEGER","random","rewriteTurbopackSources","projectRoot","sourceMap","section","sections","map","i","sources","length","replace","toString","getSourceMapFromTurbopack","project","sourceURL","sourceMapJson","getSourceMapSync","err","undefined","payload","JSON","parse","createHotReloaderTurbopack","opts","serverFields","distDir","resetFetch","nextConfig","dev","buildId","dir","projectPath","loadBindings","require","bindings","log","testMode","hasRewrites","fsChecker","rewrites","afterFiles","beforeFiles","fallback","hotReloaderSpan","version","__NEXT_VERSION","stop","encryptionKey","isBuild","clientRouterFilters","experimental","clientRouterFilter","supportedBrowsers","currentNodeJsVersion","versions","node","turbo","createProject","rootPath","turbopack","root","outputFileTracingRoot","jsConfig","watch","enable","pollIntervalMs","watchOptions","defineEnv","isTurbopack","config","fetchCacheKeyPrefix","middlewareMatchers","previewProps","prerenderManifest","preview","browserslistQuery","noMangling","persistentCaching","memoryLimit","turbopackMemoryLimit","eventTypes","bind","onDevServerCleanup","onExit","entrypointsSubscription","entrypointsSubscribe","currentWrittenEntrypoints","Map","currentEntrypoints","global","app","document","error","middleware","instrumentation","page","currentTopLevelIssues","currentEntryIssues","manifestLoader","changeSubscriptions","serverPathState","readyIds","Set","currentEntriesHandlingResolve","currentEntriesHandling","Promise","resolve","assetMapper","clearRequireCache","key","writtenEndpoint","force","path","contentHash","serverPaths","set","hasChange","endsWith","localKey","localHash","get","globalHash","hasAppPaths","some","p","startsWith","file","buildingIds","startBuilding","id","requestUrl","forceRebuild","has","size","setState","loading","trigger","url","add","finishBuilding","delete","hmrEventHappened","hmrHash","clients","clientStates","WeakMap","sendToClient","client","send","stringify","sendEnqueuedMessages","issueMap","values","filter","severity","state","clientIssues","hmrPayloads","clear","turbopackUpdates","action","TURBOPACK_MESSAGE","data","sendEnqueuedMessagesDebounce","sendHmr","sendTurbopackMessage","diagnostics","issues","push","subscribeToChanges","includeIssues","endpoint","makePayload","onError","side","changedPromise","changed","change","String","e","unsubscribeFromChanges","subscription","return","subscribeToHmrEvents","subscriptions","hmrEvents","next","type","reloadAction","RELOAD_PAGE","close","unsubscribeFromHmrEvents","handleEntrypointsSubscription","entrypoints","devRewrites","productionRewrites","logErrors","hooks","handleWrittenEndpoint","result","forceDeleteCache","recursive","middlewares","isSrcDir","telemetry","turbopackProject","versionInfoPromise","devtoolsFrontendUrl","nodeDebugType","debugPort","debugInfo","debugInfoList","fetch","then","res","json","hotReloader","activeWebpackConfigs","serverStats","edgeServerStats","run","req","_parsedUrl","params","decodedPagePath","param","decodeURIComponent","denormalizedPagePath","ensurePage","clientOnly","definition","catch","console","calledNext","finished","onHMR","socket","head","onUpgrade","handleUpgrade","on","addEventListener","parsedData","event","manualTraceChild","spanName","startTime","endTime","attributes","updatedModules","isPageHidden","hadRuntimeError","dependencyChain","warn","Array","isArray","cleanedModulePath","Error","turbopackConnected","TURBOPACK_CONNECTED","errors","entryIssues","issue","message","disabledUntil","Date","now","versionInfo","sync","SYNC","warnings","hash","debug","devIndicator","setHmrServerError","_error","clearHmrServerError","start","getCompilationErrors","appEntryKey","pagesEntryKey","topLevelIssues","thisEntryIssues","formattedIssue","invalidate","reloadAfterInvalidation","entrypoint","SERVER_COMPONENT_CHANGES","buildFallbackError","inputPage","appPaths","isApp","traceChild","traceAsyncFn","includes","routeDef","pageExtensions","pagesDir","appDir","globalNotFound","normalizedPage","matchingAppPaths","pathname","setPathsForKey","clientPaths","isInsideAppDir","bundlePath","isEntryMetadataRouteFile","filename","normalizedAppPage","route","wsClient","terminate","exit","writeManifests","handleProjectUpdates","updateMessage","updateInfoSubscribe","updateType","BUILDING","addErrors","errorsMap","details","detail","clientErrors","BUILT","time","value","duration","timeMessage","round"],"mappings":"AACA,SAASA,KAAK,EAAEC,SAAS,QAAQ,cAAa;AAC9C,SAASC,IAAI,EAAEC,OAAO,QAAQ,OAAM;AACpC,SAASC,aAAa,QAAQ,MAAK;AAEnC,OAAOC,QAAQ,wBAAuB;AAGtC,SAASC,SAASC,YAAY,QAAQ,2BAA0B;AAShE,SAASC,2BAA2B,QAAQ,uBAAsB;AASlE,SAASC,eAAe,QAAQ,kBAAiB;AACjD,YAAYC,SAAS,yBAAwB;AAC7C,SACEC,cAAc,EACdC,0BAA0B,QACrB,yBAAwB;AAC/B,SAASC,aAAa,QAAQ,6BAA4B;AAC1D,SACEC,oBAAoB,EACpBC,sBAAsB,QACjB,yBAAwB;AAC/B,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,QAAQ,QAAQ,WAAU;AACnC,SAASC,WAAW,EAAEC,sBAAsB,QAAQ,kBAAiB;AACrE,SACEC,sBAAs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C,YAAY;4BAE1CV,aAAaC,QAAQ;gCACnBa,QAAQhO,4BAA4BqY,KAAK;gCACzCtD,MAAM7F,OAAO,EAAEpC;gCACfsH,QAAQ;uCAAIgE,aAAa5K,MAAM;iCAAG;gCAClCsH,UAAU,EAAE;4BACd;wBACF;wBAEA,IAAIjI,kBAAkB;4BACpB,MAAMyL,OAAOV,cAAcW,KAAK,CAACC,QAAQ;4BACzC,MAAMC,cACJH,OAAO,OAAO,GAAG1U,KAAK8U,KAAK,CAACJ,OAAO,OAAO,GAAG,CAAC,CAAC,GAAG,GAAGA,KAAK,EAAE,CAAC;4BAC/DpY,IAAIiT,KAAK,CAAC,CAAC,YAAY,EAAEsF,aAAa;4BACtC5L,mBAAmB;wBACrB;wBACA;oBACF;gBACA;YACF;QACF;IACF;IAEA8K,uBAAuBpF,KAAK,CAAC,CAACtN;QAC5BuN,QAAQ5I,KAAK,CAAC3E;QACd3B,QAAQmU,IAAI,CAAC;IACf;IAEA,OAAOjG;AACT","ignoreList":[0]}
|
1
|
+
{"version":3,"sources":["../../../src/server/dev/hot-reloader-turbopack.ts"],"sourcesContent":["import type { Socket } from 'net'\nimport { mkdir, writeFile } from 'fs/promises'\nimport { join, extname } from 'path'\nimport { pathToFileURL } from 'url'\n\nimport ws from 'next/dist/compiled/ws'\n\nimport type { OutputState } from '../../build/output/store'\nimport { store as consoleStore } from '../../build/output/store'\nimport type {\n CompilationError,\n HMR_ACTION_TYPES,\n NextJsHotReloaderInterface,\n ReloadPageAction,\n SyncAction,\n TurbopackConnectedAction,\n} from './hot-reloader-types'\nimport { HMR_ACTIONS_SENT_TO_BROWSER } from './hot-reloader-types'\nimport type {\n Update as TurbopackUpdate,\n Endpoint,\n WrittenEndpoint,\n TurbopackResult,\n Project,\n Entrypoints,\n} from '../../build/swc/types'\nimport { createDefineEnv } from '../../build/swc'\nimport * as Log from '../../build/output/log'\nimport {\n getVersionInfo,\n matchNextPageBundleRequest,\n} from './hot-reloader-webpack'\nimport { BLOCKED_PAGES } from '../../shared/lib/constants'\nimport {\n getOverlayMiddleware,\n getSourceMapMiddleware,\n} from './middleware-turbopack'\nimport { PageNotFoundError } from '../../shared/lib/utils'\nimport { debounce } from '../utils'\nimport { deleteCache, deleteFromRequireCache } from './require-cache'\nimport {\n clearAllModuleContexts,\n clearModuleContext,\n} from '../lib/render-server'\nimport { denormalizePagePath } from '../../shared/lib/page-path/denormalize-page-path'\nimport { trace } from '../../trace'\nimport {\n AssetMapper,\n type ChangeSubscriptions,\n type ClientState,\n handleEntrypoints,\n handlePagesErrorRoute,\n handleRouteType,\n hasEntrypointForKey,\n msToNs,\n type ReadyIds,\n type SendHmr,\n type StartBuilding,\n processTopLevelIssues,\n printNonFatalIssue,\n normalizedPageToTurbopackStructureRoute,\n} from './turbopack-utils'\nimport {\n propagateServerField,\n type ServerFields,\n type SetupOpts,\n} from '../lib/router-utils/setup-dev-bundler'\nimport { TurbopackManifestLoader } from '../../shared/lib/turbopack/manifest-loader'\nimport { findPagePathData } from './on-demand-entry-handler'\nimport type { RouteDefinition } from '../route-definitions/route-definition'\nimport {\n type EntryKey,\n getEntryKey,\n splitEntryKey,\n} from '../../shared/lib/turbopack/entry-key'\nimport { FAST_REFRESH_RUNTIME_RELOAD } from './messages'\nimport { generateEncryptionKeyBase64 } from '../app-render/encryption-utils-server'\nimport { isAppPageRouteDefinition } from '../route-definitions/app-page-route-definition'\nimport { normalizeAppPath } from '../../shared/lib/router/utils/app-paths'\nimport type { ModernSourceMapPayload } from '../lib/source-maps'\nimport { getNodeDebugType } from '../lib/utils'\nimport { isMetadataRouteFile } from '../../lib/metadata/is-metadata-route'\nimport { setBundlerFindSourceMapImplementation } from '../patch-error-inspect'\nimport { getNextErrorFeedbackMiddleware } from '../../next-devtools/server/get-next-error-feedback-middleware'\nimport {\n formatIssue,\n getTurbopackJsConfig,\n isPersistentCachingEnabled,\n isWellKnownError,\n processIssues,\n renderStyledStringToErrorAnsi,\n type EntryIssuesMap,\n type TopLevelIssuesMap,\n} from '../../shared/lib/turbopack/utils'\nimport { getDevOverlayFontMiddleware } from '../../next-devtools/server/font/get-dev-overlay-font-middleware'\nimport { devIndicatorServerState } from './dev-indicator-server-state'\nimport { getDisableDevIndicatorMiddleware } from '../../next-devtools/server/dev-indicator-middleware'\nimport { getRestartDevServerMiddleware } from '../../next-devtools/server/restart-dev-server-middleware'\nimport { backgroundLogCompilationEvents } from '../../shared/lib/turbopack/compilation-events'\nimport { getSupportedBrowsers } from '../../build/utils'\n\nconst wsServer = new ws.Server({ noServer: true })\nconst isTestMode = !!(\n process.env.NEXT_TEST_MODE ||\n process.env.__NEXT_TEST_MODE ||\n process.env.DEBUG\n)\n\nconst sessionId = Math.floor(Number.MAX_SAFE_INTEGER * Math.random())\n\n/**\n * Replaces turbopack:///[project] with the specified project in the `source` field.\n */\nfunction rewriteTurbopackSources(\n projectRoot: string,\n sourceMap: ModernSourceMapPayload\n): void {\n if ('sections' in sourceMap) {\n for (const section of sourceMap.sections) {\n rewriteTurbopackSources(projectRoot, section.map)\n }\n } else {\n for (let i = 0; i < sourceMap.sources.length; i++) {\n sourceMap.sources[i] = pathToFileURL(\n join(\n projectRoot,\n sourceMap.sources[i].replace(/turbopack:\\/\\/\\/\\[project\\]/, '')\n )\n ).toString()\n }\n }\n}\n\nfunction getSourceMapFromTurbopack(\n project: Project,\n projectRoot: string,\n sourceURL: string\n): ModernSourceMapPayload | undefined {\n let sourceMapJson: string | null = null\n\n try {\n sourceMapJson = project.getSourceMapSync(sourceURL)\n } catch (err) {}\n\n if (sourceMapJson === null) {\n return undefined\n } else {\n const payload: ModernSourceMapPayload = JSON.parse(sourceMapJson)\n // The sourcemap from Turbopack is not yet written to disk so its `sources`\n // are not absolute paths yet. We need to rewrite them to be absolute paths.\n rewriteTurbopackSources(projectRoot, payload)\n return payload\n }\n}\n\nexport async function createHotReloaderTurbopack(\n opts: SetupOpts & { isSrcDir: boolean },\n serverFields: ServerFields,\n distDir: string,\n resetFetch: () => void\n): Promise<NextJsHotReloaderInterface> {\n const dev = true\n const buildId = 'development'\n const { nextConfig, dir: projectPath } = opts\n\n const { loadBindings } =\n require('../../build/swc') as typeof import('../../build/swc')\n\n let bindings = await loadBindings()\n\n // For the debugging purpose, check if createNext or equivalent next instance setup in test cases\n // works correctly. Normally `run-test` hides output so only will be visible when `--debug` flag is used.\n if (isTestMode) {\n ;(require('console') as typeof import('console')).log(\n 'Creating turbopack project',\n {\n dir: projectPath,\n testMode: isTestMode,\n }\n )\n }\n\n const hasRewrites =\n opts.fsChecker.rewrites.afterFiles.length > 0 ||\n opts.fsChecker.rewrites.beforeFiles.length > 0 ||\n opts.fsChecker.rewrites.fallback.length > 0\n\n const hotReloaderSpan = trace('hot-reloader', undefined, {\n version: process.env.__NEXT_VERSION as string,\n })\n // Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing\n // of the current `next dev` invocation.\n hotReloaderSpan.stop()\n\n const encryptionKey = await generateEncryptionKeyBase64({\n isBuild: false,\n distDir,\n })\n\n // TODO: Implement\n let clientRouterFilters: any\n if (nextConfig.experimental.clientRouterFilter) {\n // TODO this need to be set correctly for persistent caching to work\n }\n\n const supportedBrowsers = await getSupportedBrowsers(projectPath, dev)\n const currentNodeJsVersion = process.versions.node\n\n const project = await bindings.turbo.createProject(\n {\n projectPath: projectPath,\n rootPath:\n opts.nextConfig.turbopack?.root ||\n opts.nextConfig.outputFileTracingRoot ||\n projectPath,\n distDir,\n nextConfig: opts.nextConfig,\n jsConfig: await getTurbopackJsConfig(projectPath, nextConfig),\n watch: {\n enable: dev,\n pollIntervalMs: nextConfig.watchOptions?.pollIntervalMs,\n },\n dev,\n env: process.env as Record<string, string>,\n defineEnv: createDefineEnv({\n isTurbopack: true,\n clientRouterFilters,\n config: nextConfig,\n dev,\n distDir,\n projectPath,\n fetchCacheKeyPrefix: opts.nextConfig.experimental.fetchCacheKeyPrefix,\n hasRewrites,\n // TODO: Implement\n middlewareMatchers: undefined,\n rewrites: opts.fsChecker.rewrites,\n }),\n buildId,\n encryptionKey,\n previewProps: opts.fsChecker.prerenderManifest.preview,\n browserslistQuery: supportedBrowsers.join(', '),\n noMangling: false,\n currentNodeJsVersion,\n },\n {\n persistentCaching: isPersistentCachingEnabled(opts.nextConfig),\n memoryLimit: opts.nextConfig.experimental?.turbopackMemoryLimit,\n }\n )\n backgroundLogCompilationEvents(project, {\n eventTypes: ['StartupCacheInvalidationEvent'],\n })\n setBundlerFindSourceMapImplementation(\n getSourceMapFromTurbopack.bind(null, project, projectPath)\n )\n opts.onDevServerCleanup?.(async () => {\n setBundlerFindSourceMapImplementation(() => undefined)\n await project.onExit()\n })\n const entrypointsSubscription = project.entrypointsSubscribe()\n\n const currentWrittenEntrypoints: Map<EntryKey, WrittenEndpoint> = new Map()\n const currentEntrypoints: Entrypoints = {\n global: {\n app: undefined,\n document: undefined,\n error: undefined,\n\n middleware: undefined,\n instrumentation: undefined,\n },\n\n page: new Map(),\n app: new Map(),\n }\n\n const currentTopLevelIssues: TopLevelIssuesMap = new Map()\n const currentEntryIssues: EntryIssuesMap = new Map()\n\n const manifestLoader = new TurbopackManifestLoader({\n buildId,\n distDir,\n encryptionKey,\n })\n\n // Dev specific\n const changeSubscriptions: ChangeSubscriptions = new Map()\n const serverPathState = new Map<string, string>()\n const readyIds: ReadyIds = new Set()\n let currentEntriesHandlingResolve: ((value?: unknown) => void) | undefined\n let currentEntriesHandling = new Promise(\n (resolve) => (currentEntriesHandlingResolve = resolve)\n )\n\n const assetMapper = new AssetMapper()\n\n function clearRequireCache(\n key: EntryKey,\n writtenEndpoint: WrittenEndpoint,\n {\n force,\n }: {\n // Always clear the cache, don't check if files have changed\n force?: boolean\n } = {}\n ): boolean {\n if (force) {\n for (const { path, contentHash } of writtenEndpoint.serverPaths) {\n serverPathState.set(path, contentHash)\n }\n } else {\n // Figure out if the server files have changed\n let hasChange = false\n for (const { path, contentHash } of writtenEndpoint.serverPaths) {\n // We ignore source maps\n if (path.endsWith('.map')) continue\n const localKey = `${key}:${path}`\n const localHash = serverPathState.get(localKey)\n const globalHash = serverPathState.get(path)\n if (\n (localHash && localHash !== contentHash) ||\n (globalHash && globalHash !== contentHash)\n ) {\n hasChange = true\n serverPathState.set(key, contentHash)\n serverPathState.set(path, contentHash)\n } else {\n if (!localHash) {\n serverPathState.set(key, contentHash)\n }\n if (!globalHash) {\n serverPathState.set(path, contentHash)\n }\n }\n }\n\n if (!hasChange) {\n return false\n }\n }\n\n resetFetch()\n\n const hasAppPaths = writtenEndpoint.serverPaths.some(({ path: p }) =>\n p.startsWith('server/app')\n )\n\n if (hasAppPaths) {\n deleteFromRequireCache(\n require.resolve(\n 'next/dist/compiled/next-server/app-page-turbo.runtime.dev.js'\n )\n )\n deleteFromRequireCache(\n require.resolve(\n 'next/dist/compiled/next-server/app-page-turbo-experimental.runtime.dev.js'\n )\n )\n }\n\n const serverPaths = writtenEndpoint.serverPaths.map(({ path: p }) =>\n join(distDir, p)\n )\n\n for (const file of serverPaths) {\n clearModuleContext(file)\n deleteCache(file)\n }\n\n return true\n }\n\n const buildingIds = new Set()\n\n const startBuilding: StartBuilding = (id, requestUrl, forceRebuild) => {\n if (!forceRebuild && readyIds.has(id)) {\n return () => {}\n }\n if (buildingIds.size === 0) {\n consoleStore.setState(\n {\n loading: true,\n trigger: id,\n url: requestUrl,\n } as OutputState,\n true\n )\n }\n buildingIds.add(id)\n return function finishBuilding() {\n if (buildingIds.size === 0) {\n return\n }\n readyIds.add(id)\n buildingIds.delete(id)\n if (buildingIds.size === 0) {\n hmrEventHappened = false\n consoleStore.setState(\n {\n loading: false,\n } as OutputState,\n true\n )\n }\n }\n }\n\n let hmrEventHappened = false\n let hmrHash = 0\n\n const clients = new Set<ws>()\n const clientStates = new WeakMap<ws, ClientState>()\n\n function sendToClient(client: ws, payload: HMR_ACTION_TYPES) {\n client.send(JSON.stringify(payload))\n }\n\n function sendEnqueuedMessages() {\n for (const [, issueMap] of currentEntryIssues) {\n if (\n [...issueMap.values()].filter((i) => i.severity !== 'warning').length >\n 0\n ) {\n // During compilation errors we want to delay the HMR events until errors are fixed\n return\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 [, issueMap] of state.clientIssues) {\n if (\n [...issueMap.values()].filter((i) => i.severity !== 'warning')\n .length > 0\n ) {\n // During compilation errors we want to delay the HMR events until errors are fixed\n return\n }\n }\n\n for (const payload of state.hmrPayloads.values()) {\n sendToClient(client, payload)\n }\n state.hmrPayloads.clear()\n\n if (state.turbopackUpdates.length > 0) {\n sendToClient(client, {\n action: HMR_ACTIONS_SENT_TO_BROWSER.TURBOPACK_MESSAGE,\n data: state.turbopackUpdates,\n })\n state.turbopackUpdates.length = 0\n }\n }\n }\n const sendEnqueuedMessagesDebounce = debounce(sendEnqueuedMessages, 2)\n\n const sendHmr: SendHmr = (id: string, payload: HMR_ACTION_TYPES) => {\n for (const client of clients) {\n clientStates.get(client)?.hmrPayloads.set(id, payload)\n }\n\n hmrEventHappened = true\n sendEnqueuedMessagesDebounce()\n }\n\n function sendTurbopackMessage(payload: TurbopackUpdate) {\n // TODO(PACK-2049): For some reason we end up emitting hundreds of issues messages on bigger apps,\n // a lot of which are duplicates.\n // They are currently not handled on the client at all, so might as well not send them for now.\n payload.diagnostics = []\n payload.issues = []\n\n for (const client of clients) {\n clientStates.get(client)?.turbopackUpdates.push(payload)\n }\n\n hmrEventHappened = true\n sendEnqueuedMessagesDebounce()\n }\n\n async function subscribeToChanges(\n key: EntryKey,\n includeIssues: boolean,\n endpoint: Endpoint,\n makePayload: (\n change: TurbopackResult,\n hash: string\n ) => Promise<HMR_ACTION_TYPES> | HMR_ACTION_TYPES | void,\n onError?: (\n error: Error\n ) => Promise<HMR_ACTION_TYPES> | HMR_ACTION_TYPES | void\n ) {\n if (changeSubscriptions.has(key)) {\n return\n }\n\n const { side } = splitEntryKey(key)\n\n const changedPromise = endpoint[`${side}Changed`](includeIssues)\n changeSubscriptions.set(key, changedPromise)\n try {\n const changed = await changedPromise\n\n for await (const change of changed) {\n processIssues(currentEntryIssues, key, change, false, true)\n // TODO: Get an actual content hash from Turbopack.\n const payload = await makePayload(change, String(++hmrHash))\n if (payload) {\n sendHmr(key, payload)\n }\n }\n } catch (e) {\n changeSubscriptions.delete(key)\n const payload = await onError?.(e as Error)\n if (payload) {\n sendHmr(key, payload)\n }\n return\n }\n changeSubscriptions.delete(key)\n }\n\n async function unsubscribeFromChanges(key: EntryKey) {\n const subscription = await changeSubscriptions.get(key)\n if (subscription) {\n await subscription.return?.()\n changeSubscriptions.delete(key)\n }\n currentEntryIssues.delete(key)\n }\n\n async function subscribeToHmrEvents(client: ws, id: string) {\n const key = getEntryKey('assets', 'client', id)\n if (!hasEntrypointForKey(currentEntrypoints, key, assetMapper)) {\n // maybe throw an error / force the client to reload?\n return\n }\n\n const state = clientStates.get(client)\n if (!state || state.subscriptions.has(id)) {\n return\n }\n\n const subscription = project!.hmrEvents(id)\n state.subscriptions.set(id, subscription)\n\n // The subscription will always emit once, which is the initial\n // computation. This is not a change, so swallow it.\n try {\n await subscription.next()\n\n for await (const data of subscription) {\n processIssues(state.clientIssues, key, data, false, true)\n if (data.type !== 'issues') {\n sendTurbopackMessage(data)\n }\n }\n } catch (e) {\n // The client might be using an HMR session from a previous server, tell them\n // to fully reload the page to resolve the issue. We can't use\n // `hotReloader.send` since that would force every connected client to\n // reload, only this client is out of date.\n const reloadAction: ReloadPageAction = {\n action: HMR_ACTIONS_SENT_TO_BROWSER.RELOAD_PAGE,\n data: `error in HMR event subscription for ${id}: ${e}`,\n }\n sendToClient(client, reloadAction)\n client.close()\n return\n }\n }\n\n function unsubscribeFromHmrEvents(client: ws, id: string) {\n const state = clientStates.get(client)\n if (!state) {\n return\n }\n\n const subscription = state.subscriptions.get(id)\n subscription?.return!()\n\n const key = getEntryKey('assets', 'client', id)\n state.clientIssues.delete(key)\n }\n\n async function handleEntrypointsSubscription() {\n for await (const entrypoints of entrypointsSubscription) {\n if (!currentEntriesHandlingResolve) {\n currentEntriesHandling = new Promise(\n // eslint-disable-next-line no-loop-func\n (resolve) => (currentEntriesHandlingResolve = resolve)\n )\n }\n\n processTopLevelIssues(currentTopLevelIssues, entrypoints)\n\n await handleEntrypoints({\n entrypoints,\n\n currentEntrypoints,\n\n currentEntryIssues,\n manifestLoader,\n devRewrites: opts.fsChecker.rewrites,\n productionRewrites: undefined,\n logErrors: true,\n\n dev: {\n assetMapper,\n changeSubscriptions,\n clients,\n clientStates,\n serverFields,\n\n hooks: {\n handleWrittenEndpoint: (id, result, forceDeleteCache) => {\n currentWrittenEntrypoints.set(id, result)\n return clearRequireCache(id, result, { force: forceDeleteCache })\n },\n propagateServerField: propagateServerField.bind(null, opts),\n sendHmr,\n startBuilding,\n subscribeToChanges,\n unsubscribeFromChanges,\n unsubscribeFromHmrEvents,\n },\n },\n })\n\n currentEntriesHandlingResolve!()\n currentEntriesHandlingResolve = undefined\n }\n }\n\n await mkdir(join(distDir, 'server'), { recursive: true })\n await mkdir(join(distDir, 'static', buildId), { recursive: true })\n await writeFile(\n join(distDir, 'package.json'),\n JSON.stringify(\n {\n type: 'commonjs',\n },\n null,\n 2\n )\n )\n\n const middlewares = [\n getOverlayMiddleware({\n project,\n projectPath,\n isSrcDir: opts.isSrcDir,\n }),\n getSourceMapMiddleware(project),\n getNextErrorFeedbackMiddleware(opts.telemetry),\n getDevOverlayFontMiddleware(),\n getDisableDevIndicatorMiddleware(),\n getRestartDevServerMiddleware({\n telemetry: opts.telemetry,\n turbopackProject: project,\n }),\n ]\n\n const versionInfoPromise = getVersionInfo()\n\n let devtoolsFrontendUrl: string | undefined\n const nodeDebugType = getNodeDebugType()\n if (nodeDebugType) {\n const debugPort = process.debugPort\n let debugInfo\n try {\n // It requires to use 127.0.0.1 instead of localhost for server-side fetching.\n const debugInfoList = await fetch(\n `http://127.0.0.1:${debugPort}/json/list`\n ).then((res) => res.json())\n debugInfo = debugInfoList[0]\n } catch {}\n if (debugInfo) {\n devtoolsFrontendUrl = debugInfo.devtoolsFrontendUrl\n }\n }\n\n const hotReloader: NextJsHotReloaderInterface = {\n turbopackProject: project,\n activeWebpackConfigs: undefined,\n serverStats: null,\n edgeServerStats: null,\n async run(req, res, _parsedUrl) {\n // intercept page chunks request and ensure them with turbopack\n if (req.url?.startsWith('/_next/static/chunks/pages/')) {\n const params = matchNextPageBundleRequest(req.url)\n\n if (params) {\n const decodedPagePath = `/${params.path\n .map((param: string) => decodeURIComponent(param))\n .join('/')}`\n\n const denormalizedPagePath = denormalizePagePath(decodedPagePath)\n\n await hotReloader\n .ensurePage({\n page: denormalizedPagePath,\n clientOnly: false,\n definition: undefined,\n url: req.url,\n })\n .catch(console.error)\n }\n }\n\n for (const middleware of middlewares) {\n let calledNext = false\n\n await middleware(req, res, () => {\n calledNext = true\n })\n\n if (!calledNext) {\n return { finished: true }\n }\n }\n\n // Request was not finished.\n return { finished: undefined }\n },\n\n // TODO: Figure out if socket type can match the NextJsHotReloaderInterface\n onHMR(req, socket: Socket, head, onUpgrade) {\n wsServer.handleUpgrade(req, socket, head, (client) => {\n onUpgrade(client)\n const clientIssues: EntryIssuesMap = new Map()\n const subscriptions: Map<string, AsyncIterator<any>> = new Map()\n\n clients.add(client)\n clientStates.set(client, {\n clientIssues,\n hmrPayloads: new Map(),\n turbopackUpdates: [],\n subscriptions,\n })\n\n client.on('close', () => {\n // Remove active subscriptions\n for (const subscription of subscriptions.values()) {\n subscription.return?.()\n }\n clientStates.delete(client)\n clients.delete(client)\n })\n\n client.addEventListener('message', ({ data }) => {\n const parsedData = JSON.parse(\n typeof data !== 'string' ? data.toString() : data\n )\n\n // Next.js messages\n switch (parsedData.event) {\n case 'span-end': {\n hotReloaderSpan.manualTraceChild(\n parsedData.spanName,\n msToNs(parsedData.startTime),\n msToNs(parsedData.endTime),\n parsedData.attributes\n )\n break\n }\n case 'client-hmr-latency': // { id, startTime, endTime, page, updatedModules, isPageHidden }\n hotReloaderSpan.manualTraceChild(\n parsedData.event,\n msToNs(parsedData.startTime),\n msToNs(parsedData.endTime),\n {\n updatedModules: parsedData.updatedModules,\n page: parsedData.page,\n isPageHidden: parsedData.isPageHidden,\n }\n )\n break\n case 'client-error': // { errorCount, clientId }\n case 'client-warning': // { warningCount, clientId }\n case 'client-success': // { clientId }\n case 'server-component-reload-page': // { clientId }\n case 'client-reload-page': // { clientId }\n case 'client-removed-page': // { page }\n case 'client-full-reload': // { stackTrace, hadRuntimeError }\n const { hadRuntimeError, dependencyChain } = parsedData\n if (hadRuntimeError) {\n Log.warn(FAST_REFRESH_RUNTIME_RELOAD)\n }\n if (\n Array.isArray(dependencyChain) &&\n typeof dependencyChain[0] === 'string'\n ) {\n const cleanedModulePath = dependencyChain[0]\n .replace(/^\\[project\\]/, '.')\n .replace(/ \\[.*\\] \\(.*\\)$/, '')\n Log.warn(\n `Fast Refresh had to perform a full reload when ${cleanedModulePath} changed. Read more: https://nextjs.org/docs/messages/fast-refresh-reload`\n )\n }\n break\n case 'client-added-page':\n // TODO\n break\n\n default:\n // Might be a Turbopack message...\n if (!parsedData.type) {\n throw new Error(`unrecognized HMR message \"${data}\"`)\n }\n }\n\n // Turbopack messages\n switch (parsedData.type) {\n case 'turbopack-subscribe':\n subscribeToHmrEvents(client, parsedData.path)\n break\n\n case 'turbopack-unsubscribe':\n unsubscribeFromHmrEvents(client, parsedData.path)\n break\n\n default:\n if (!parsedData.event) {\n throw new Error(`unrecognized Turbopack HMR message \"${data}\"`)\n }\n }\n })\n\n const turbopackConnected: TurbopackConnectedAction = {\n action: HMR_ACTIONS_SENT_TO_BROWSER.TURBOPACK_CONNECTED,\n data: { sessionId },\n }\n sendToClient(client, turbopackConnected)\n\n const errors: CompilationError[] = []\n\n for (const entryIssues of currentEntryIssues.values()) {\n for (const issue of entryIssues.values()) {\n if (issue.severity !== 'warning') {\n errors.push({\n message: formatIssue(issue),\n })\n } else {\n printNonFatalIssue(issue)\n }\n }\n }\n\n if (devIndicatorServerState.disabledUntil < Date.now()) {\n devIndicatorServerState.disabledUntil = 0\n }\n\n ;(async function () {\n const versionInfo = await versionInfoPromise\n\n const sync: SyncAction = {\n action: HMR_ACTIONS_SENT_TO_BROWSER.SYNC,\n errors,\n warnings: [],\n hash: '',\n versionInfo,\n debug: {\n devtoolsFrontendUrl,\n },\n devIndicator: devIndicatorServerState,\n }\n\n sendToClient(client, sync)\n })()\n })\n },\n\n send(action) {\n const payload = JSON.stringify(action)\n for (const client of clients) {\n client.send(payload)\n }\n },\n\n setHmrServerError(_error) {\n // Not implemented yet.\n },\n clearHmrServerError() {\n // Not implemented yet.\n },\n async start() {},\n async getCompilationErrors(page) {\n const appEntryKey = getEntryKey('app', 'server', page)\n const pagesEntryKey = getEntryKey('pages', 'server', page)\n\n const topLevelIssues = currentTopLevelIssues.values()\n\n const thisEntryIssues =\n currentEntryIssues.get(appEntryKey) ??\n currentEntryIssues.get(pagesEntryKey)\n\n if (thisEntryIssues !== undefined && thisEntryIssues.size > 0) {\n // If there is an error related to the requesting page we display it instead of the first error\n return [...topLevelIssues, ...thisEntryIssues.values()]\n .map((issue) => {\n const formattedIssue = formatIssue(issue)\n if (issue.severity === 'warning') {\n printNonFatalIssue(issue)\n return null\n } else if (isWellKnownError(issue)) {\n Log.error(formattedIssue)\n }\n\n return new Error(formattedIssue)\n })\n .filter((error) => error !== null)\n }\n\n // Otherwise, return all errors across pages\n const errors = []\n for (const issue of topLevelIssues) {\n if (issue.severity !== 'warning') {\n errors.push(new Error(formatIssue(issue)))\n }\n }\n for (const entryIssues of currentEntryIssues.values()) {\n for (const issue of entryIssues.values()) {\n if (issue.severity !== 'warning') {\n const message = formatIssue(issue)\n errors.push(new Error(message))\n } else {\n printNonFatalIssue(issue)\n }\n }\n }\n return errors\n },\n async invalidate({\n // .env files or tsconfig/jsconfig change\n reloadAfterInvalidation,\n }) {\n if (reloadAfterInvalidation) {\n for (const [key, entrypoint] of currentWrittenEntrypoints) {\n clearRequireCache(key, entrypoint, { force: true })\n }\n\n await clearAllModuleContexts()\n this.send({\n action: HMR_ACTIONS_SENT_TO_BROWSER.SERVER_COMPONENT_CHANGES,\n hash: String(++hmrHash),\n })\n }\n },\n async buildFallbackError() {\n // Not implemented yet.\n },\n async ensurePage({\n page: inputPage,\n // Unused parameters\n // clientOnly,\n appPaths,\n definition,\n isApp,\n url: requestUrl,\n }) {\n // When there is no route definition this is an internal file not a route the user added.\n // Middleware and instrumentation are handled in turbpack-utils.ts handleEntrypoints instead.\n if (!definition) {\n if (inputPage === '/middleware') return\n if (inputPage === '/src/middleware') return\n if (inputPage === '/instrumentation') return\n if (inputPage === '/src/instrumentation') return\n }\n\n return hotReloaderSpan\n .traceChild('ensure-page', {\n inputPage,\n })\n .traceAsyncFn(async () => {\n if (BLOCKED_PAGES.includes(inputPage) && inputPage !== '/_error') {\n return\n }\n\n await currentEntriesHandling\n\n // TODO We shouldn't look into the filesystem again. This should use the information from entrypoints\n let routeDef: Pick<\n RouteDefinition,\n 'filename' | 'bundlePath' | 'page'\n > =\n definition ??\n (await findPagePathData(\n projectPath,\n inputPage,\n nextConfig.pageExtensions,\n opts.pagesDir,\n opts.appDir,\n !!nextConfig.experimental.globalNotFound\n ))\n\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 let page = routeDef.page\n if (appPaths) {\n const normalizedPage = normalizeAppPath(page)\n\n // filter out paths that are not exact matches (e.g. catchall)\n const matchingAppPaths = appPaths.filter(\n (path) => normalizeAppPath(path) === normalizedPage\n )\n\n // the last item in the array is the root page, if there are parallel routes\n page = matchingAppPaths[matchingAppPaths.length - 1]\n }\n\n const pathname = definition?.pathname ?? inputPage\n\n if (page === '/_error') {\n let finishBuilding = startBuilding(pathname, requestUrl, false)\n try {\n await handlePagesErrorRoute({\n currentEntryIssues,\n entrypoints: currentEntrypoints,\n manifestLoader,\n devRewrites: opts.fsChecker.rewrites,\n productionRewrites: undefined,\n logErrors: true,\n hooks: {\n subscribeToChanges,\n handleWrittenEndpoint: (id, result, forceDeleteCache) => {\n currentWrittenEntrypoints.set(id, result)\n assetMapper.setPathsForKey(id, result.clientPaths)\n return clearRequireCache(id, result, {\n force: forceDeleteCache,\n })\n },\n },\n })\n } finally {\n finishBuilding()\n }\n return\n }\n\n const isInsideAppDir = routeDef.bundlePath.startsWith('app/')\n const isEntryMetadataRouteFile = isMetadataRouteFile(\n routeDef.filename.replace(opts.appDir || '', ''),\n nextConfig.pageExtensions,\n true\n )\n const normalizedAppPage = isEntryMetadataRouteFile\n ? normalizedPageToTurbopackStructureRoute(\n page,\n extname(routeDef.filename)\n )\n : page\n\n const route = isInsideAppDir\n ? currentEntrypoints.app.get(normalizedAppPage)\n : currentEntrypoints.page.get(page)\n\n if (!route) {\n // TODO: why is this entry missing in turbopack?\n if (page === '/middleware') return\n if (page === '/src/middleware') return\n if (page === '/instrumentation') return\n if (page === '/src/instrumentation') return\n\n throw new PageNotFoundError(`route not found ${page}`)\n }\n\n // We don't throw on ensureOpts.isApp === true for page-api\n // since this can happen when app pages make\n // api requests to page API routes.\n if (isApp && route.type === 'page') {\n throw new Error(`mis-matched route type: isApp && page for ${page}`)\n }\n\n const finishBuilding = startBuilding(pathname, requestUrl, false)\n try {\n await handleRouteType({\n dev,\n page,\n pathname,\n route,\n currentEntryIssues,\n entrypoints: currentEntrypoints,\n manifestLoader,\n readyIds,\n devRewrites: opts.fsChecker.rewrites,\n productionRewrites: undefined,\n logErrors: true,\n\n hooks: {\n subscribeToChanges,\n handleWrittenEndpoint: (id, result, forceDeleteCache) => {\n currentWrittenEntrypoints.set(id, result)\n assetMapper.setPathsForKey(id, result.clientPaths)\n return clearRequireCache(id, result, {\n force: forceDeleteCache,\n })\n },\n },\n })\n } finally {\n finishBuilding()\n }\n })\n },\n close() {\n for (const wsClient of clients) {\n // it's okay to not cleanly close these websocket connections, this is dev\n wsClient.terminate()\n }\n clients.clear()\n },\n }\n\n handleEntrypointsSubscription().catch((err) => {\n console.error(err)\n process.exit(1)\n })\n\n // Write empty manifests\n await currentEntriesHandling\n await manifestLoader.writeManifests({\n devRewrites: opts.fsChecker.rewrites,\n productionRewrites: undefined,\n entrypoints: currentEntrypoints,\n })\n\n async function handleProjectUpdates() {\n for await (const updateMessage of project.updateInfoSubscribe(30)) {\n switch (updateMessage.updateType) {\n case 'start': {\n hotReloader.send({ action: HMR_ACTIONS_SENT_TO_BROWSER.BUILDING })\n break\n }\n case 'end': {\n sendEnqueuedMessages()\n\n function addErrors(\n errorsMap: Map<string, CompilationError>,\n issues: EntryIssuesMap\n ) {\n for (const issueMap of issues.values()) {\n for (const [key, issue] of issueMap) {\n if (issue.severity === 'warning') continue\n if (errorsMap.has(key)) continue\n\n const message = formatIssue(issue)\n\n errorsMap.set(key, {\n message,\n details: issue.detail\n ? renderStyledStringToErrorAnsi(issue.detail)\n : undefined,\n })\n }\n }\n }\n\n const errors = new Map<string, CompilationError>()\n addErrors(errors, currentEntryIssues)\n\n for (const client of clients) {\n const state = clientStates.get(client)\n if (!state) {\n continue\n }\n\n const clientErrors = new Map(errors)\n addErrors(clientErrors, state.clientIssues)\n\n sendToClient(client, {\n action: HMR_ACTIONS_SENT_TO_BROWSER.BUILT,\n hash: String(++hmrHash),\n errors: [...clientErrors.values()],\n warnings: [],\n })\n }\n\n if (hmrEventHappened) {\n const time = updateMessage.value.duration\n const timeMessage =\n time > 2000 ? `${Math.round(time / 100) / 10}s` : `${time}ms`\n Log.event(`Compiled in ${timeMessage}`)\n hmrEventHappened = false\n }\n break\n }\n default:\n }\n }\n }\n\n handleProjectUpdates().catch((err) => {\n console.error(err)\n process.exit(1)\n })\n\n return hotReloader\n}\n"],"names":["mkdir","writeFile","join","extname","pathToFileURL","ws","store","consoleStore","HMR_ACTIONS_SENT_TO_BROWSER","createDefineEnv","Log","getVersionInfo","matchNextPageBundleRequest","BLOCKED_PAGES","getOverlayMiddleware","getSourceMapMiddleware","PageNotFoundError","debounce","deleteCache","deleteFromRequireCache","clearAllModuleContexts","clearModuleContext","denormalizePagePath","trace","AssetMapper","handleEntrypoints","handlePagesErrorRoute","handleRouteType","hasEntrypointForKey","msToNs","processTopLevelIssues","printNonFatalIssue","normalizedPageToTurbopackStructureRoute","propagateServerField","TurbopackManifestLoader","findPagePathData","getEntryKey","splitEntryKey","FAST_REFRESH_RUNTIME_RELOAD","generateEncryptionKeyBase64","isAppPageRouteDefinition","normalizeAppPath","getNodeDebugType","isMetadataRouteFile","setBundlerFindSourceMapImplementation","getNextErrorFeedbackMiddleware","formatIssue","getTurbopackJsConfig","isPersistentCachingEnabled","isWellKnownError","processIssues","renderStyledStringToErrorAnsi","getDevOverlayFontMiddleware","devIndicatorServerState","getDisableDevIndicatorMiddleware","getRestartDevServerMiddleware","backgroundLogCompilationEvents","getSupportedBrowsers","wsServer","Server","noServer","isTestMode","process","env","NEXT_TEST_MODE","__NEXT_TEST_MODE","DEBUG","sessionId","Math","floor","Number","MAX_SAFE_INTEGER","random","rewriteTurbopackSources","projectRoot","sourceMap","section","sections","map","i","sources","length","replace","toString","getSourceMapFromTurbopack","project","sourceURL","sourceMapJson","getSourceMapSync","err","undefined","payload","JSON","parse","createHotReloaderTurbopack","opts","serverFields","distDir","resetFetch","nextConfig","dev","buildId","dir","projectPath","loadBindings","require","bindings","log","testMode","hasRewrites","fsChecker","rewrites","afterFiles","beforeFiles","fallback","hotReloaderSpan","version","__NEXT_VERSION","stop","encryptionKey","isBuild","clientRouterFilters","experimental","clientRouterFilter","supportedBrowsers","currentNodeJsVersion","versions","node","turbo","createProject","rootPath","turbopack","root","outputFileTracingRoot","jsConfig","watch","enable","pollIntervalMs","watchOptions","defineEnv","isTurbopack","config","fetchCacheKeyPrefix","middlewareMatchers","previewProps","prerenderManifest","preview","browserslistQuery","noMangling","persistentCaching","memoryLimit","turbopackMemoryLimit","eventTypes","bind","onDevServerCleanup","onExit","entrypointsSubscription","entrypointsSubscribe","currentWrittenEntrypoints","Map","currentEntrypoints","global","app","document","error","middleware","instrumentation","page","currentTopLevelIssues","currentEntryIssues","manifestLoader","changeSubscriptions","serverPathState","readyIds","Set","currentEntriesHandlingResolve","currentEntriesHandling","Promise","resolve","assetMapper","clearRequireCache","key","writtenEndpoint","force","path","contentHash","serverPaths","set","hasChange","endsWith","localKey","localHash","get","globalHash","hasAppPaths","some","p","startsWith","file","buildingIds","startBuilding","id","requestUrl","forceRebuild","has","size","setState","loading","trigger","url","add","finishBuilding","delete","hmrEventHappened","hmrHash","clients","clientStates","WeakMap","sendToClient","client","send","stringify","sendEnqueuedMessages","issueMap","values","filter","severity","state","clientIssues","hmrPayloads","clear","turbopackUpdates","action","TURBOPACK_MESSAGE","data","sendEnqueuedMessagesDebounce","sendHmr","sendTurbopackMessage","diagnostics","issues","push","subscribeToChanges","includeIssues","endpoint","makePayload","onError","side","changedPromise","changed","change","String","e","unsubscribeFromChanges","subscription","return","subscribeToHmrEvents","subscriptions","hmrEvents","next","type","reloadAction","RELOAD_PAGE","close","unsubscribeFromHmrEvents","handleEntrypointsSubscription","entrypoints","devRewrites","productionRewrites","logErrors","hooks","handleWrittenEndpoint","result","forceDeleteCache","recursive","middlewares","isSrcDir","telemetry","turbopackProject","versionInfoPromise","devtoolsFrontendUrl","nodeDebugType","debugPort","debugInfo","debugInfoList","fetch","then","res","json","hotReloader","activeWebpackConfigs","serverStats","edgeServerStats","run","req","_parsedUrl","params","decodedPagePath","param","decodeURIComponent","denormalizedPagePath","ensurePage","clientOnly","definition","catch","console","calledNext","finished","onHMR","socket","head","onUpgrade","handleUpgrade","on","addEventListener","parsedData","event","manualTraceChild","spanName","startTime","endTime","attributes","updatedModules","isPageHidden","hadRuntimeError","dependencyChain","warn","Array","isArray","cleanedModulePath","Error","turbopackConnected","TURBOPACK_CONNECTED","errors","entryIssues","issue","message","disabledUntil","Date","now","versionInfo","sync","SYNC","warnings","hash","debug","devIndicator","setHmrServerError","_error","clearHmrServerError","start","getCompilationErrors","appEntryKey","pagesEntryKey","topLevelIssues","thisEntryIssues","formattedIssue","invalidate","reloadAfterInvalidation","entrypoint","SERVER_COMPONENT_CHANGES","buildFallbackError","inputPage","appPaths","isApp","traceChild","traceAsyncFn","includes","routeDef","pageExtensions","pagesDir","appDir","globalNotFound","normalizedPage","matchingAppPaths","pathname","setPathsForKey","clientPaths","isInsideAppDir","bundlePath","isEntryMetadataRouteFile","filename","normalizedAppPage","route","wsClient","terminate","exit","writeManifests","handleProjectUpdates","updateMessage","updateInfoSubscribe","updateType","BUILDING","addErrors","errorsMap","details","detail","clientErrors","BUILT","time","value","duration","timeMessage","round"],"mappings":"AACA,SAASA,KAAK,EAAEC,SAAS,QAAQ,cAAa;AAC9C,SAASC,IAAI,EAAEC,OAAO,QAAQ,OAAM;AACpC,SAASC,aAAa,QAAQ,MAAK;AAEnC,OAAOC,QAAQ,wBAAuB;AAGtC,SAASC,SAASC,YAAY,QAAQ,2BAA0B;AAShE,SAASC,2BAA2B,QAAQ,uBAAsB;AASlE,SAASC,eAAe,QAAQ,kBAAiB;AACjD,YAAYC,SAAS,yBAAwB;AAC7C,SACEC,cAAc,EACdC,0BAA0B,QACrB,yBAAwB;AAC/B,SAASC,aAAa,QAAQ,6BAA4B;AAC1D,SACEC,oBAAoB,EACpBC,sBAAsB,QACjB,yBAAwB;AAC/B,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,QAAQ,QAAQ,WAAU;AACnC,SAASC,WAAW,EAAEC,sBAAsB,QAAQ,kBAAiB;AACrE,SACEC,sBAAsB,EACtBC,kBAAkB,QACb,uBAAsB;AAC7B,SAASC,mBAAmB,QAAQ,mDAAkD;AACtF,SAASC,KAAK,QAAQ,cAAa;AACnC,SACEC,WAAW,EAGXC,iBAAiB,EACjBC,qBAAqB,EACrBC,eAAe,EACfC,mBAAmB,EACnBC,MAAM,EAINC,qBAAqB,EACrBC,kBAAkB,EAClBC,uCAAuC,QAClC,oBAAmB;AAC1B,SACEC,oBAAoB,QAGf,wCAAuC;AAC9C,SAASC,uBAAuB,QAAQ,6CAA4C;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AO,GAAG,CAAC,CAAC,GAAG,GAAGA,KAAK,EAAE,CAAC;4BAC/DpY,IAAIiT,KAAK,CAAC,CAAC,YAAY,EAAEsF,aAAa;4BACtC5L,mBAAmB;wBACrB;wBACA;oBACF;gBACA;YACF;QACF;IACF;IAEA8K,uBAAuBpF,KAAK,CAAC,CAACtN;QAC5BuN,QAAQ5I,KAAK,CAAC3E;QACd3B,QAAQmU,IAAI,CAAC;IACf;IAEA,OAAOjG;AACT","ignoreList":[0]}
|
@@ -184,7 +184,7 @@ export default class HotReloaderWebpack {
|
|
184
184
|
this.previewProps = previewProps;
|
185
185
|
this.rewrites = rewrites;
|
186
186
|
this.hotReloaderSpan = trace('hot-reloader', undefined, {
|
187
|
-
version: "15.4.0-canary.
|
187
|
+
version: "15.4.0-canary.116"
|
188
188
|
});
|
189
189
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
190
190
|
// of the current `next dev` invocation.
|
@@ -4,6 +4,7 @@ import path from 'path';
|
|
4
4
|
import url from 'url';
|
5
5
|
import { openFileInEditor } from '../../next-devtools/server/launch-editor';
|
6
6
|
import { SourceMapConsumer } from 'next/dist/compiled/source-map08';
|
7
|
+
import { findApplicableSourceMapPayload } from '../lib/source-maps';
|
7
8
|
import { getSourceMapFromFile } from './get-source-map-from-file';
|
8
9
|
import { findSourceMap } from 'node:module';
|
9
10
|
import { pathToFileURL } from 'node:url';
|
@@ -118,25 +119,6 @@ function createStackFrame(searchParams) {
|
|
118
119
|
isServer: searchParams.get('isServer') === 'true'
|
119
120
|
};
|
120
121
|
}
|
121
|
-
/**
|
122
|
-
* Finds the sourcemap payload applicable to a given frame.
|
123
|
-
* Equal to the input unless an Index Source Map is used.
|
124
|
-
*/ function findApplicableSourceMapPayload(frame, payload) {
|
125
|
-
if ('sections' in payload) {
|
126
|
-
const frameLine = frame.line ?? 0;
|
127
|
-
const frameColumn = frame.column ?? 0;
|
128
|
-
// Sections must not overlap and must be sorted: https://tc39.es/source-map/#section-object
|
129
|
-
// Therefore the last section that has an offset less than or equal to the frame is the applicable one.
|
130
|
-
// TODO(veil): Binary search
|
131
|
-
let section = payload.sections[0];
|
132
|
-
for(let i = 0; i < payload.sections.length && payload.sections[i].offset.line <= frameLine && payload.sections[i].offset.column <= frameColumn; i++){
|
133
|
-
section = payload.sections[i];
|
134
|
-
}
|
135
|
-
return section === undefined ? undefined : section.map;
|
136
|
-
} else {
|
137
|
-
return payload;
|
138
|
-
}
|
139
|
-
}
|
140
122
|
/**
|
141
123
|
* @returns 1-based lines and 0-based columns
|
142
124
|
*/ async function nativeTraceSource(frame) {
|
@@ -193,7 +175,7 @@ function createStackFrame(searchParams) {
|
|
193
175
|
// TODO(NDX-531): Spy on prepareStackTrace to get the enclosing line number for method name mapping.
|
194
176
|
_frame_methodName_replace, _frame_methodName;
|
195
177
|
const { originalPosition, sourceContent } = traced;
|
196
|
-
const applicableSourceMap = findApplicableSourceMapPayload(frame, sourceMapPayload);
|
178
|
+
const applicableSourceMap = findApplicableSourceMapPayload(frame.line ?? 0, frame.column ?? 0, sourceMapPayload);
|
197
179
|
// TODO(veil): Upstream a method to sourcemap consumer that immediately says if a frame is ignored or not.
|
198
180
|
let ignored = false;
|
199
181
|
if (applicableSourceMap === undefined) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/server/dev/middleware-turbopack.ts"],"sourcesContent":["import type { IncomingMessage, ServerResponse } from 'http'\nimport {\n getOriginalCodeFrame,\n type OriginalStackFrameResponse,\n type OriginalStackFramesRequest,\n type OriginalStackFramesResponse,\n} from '../../next-devtools/server/shared'\nimport { middlewareResponse } from '../../next-devtools/server/middleware-response'\nimport path from 'path'\nimport url from 'url'\nimport { openFileInEditor } from '../../next-devtools/server/launch-editor'\nimport type { StackFrame } from 'next/dist/compiled/stacktrace-parser'\nimport {\n SourceMapConsumer,\n type BasicSourceMapConsumer,\n type NullableMappedPosition,\n} from 'next/dist/compiled/source-map08'\nimport type { Project, TurbopackStackFrame } from '../../build/swc/types'\nimport { getSourceMapFromFile } from './get-source-map-from-file'\nimport { findSourceMap, type SourceMapPayload } from 'node:module'\nimport { pathToFileURL } from 'node:url'\nimport { inspect } from 'node:util'\n\nfunction shouldIgnorePath(modulePath: string): boolean {\n return (\n modulePath.includes('node_modules') ||\n // Only relevant for when Next.js is symlinked e.g. in the Next.js monorepo\n modulePath.includes('next/dist') ||\n modulePath.startsWith('node:')\n )\n}\n\ntype IgnorableStackFrame = StackFrame & { ignored: boolean }\n\nconst currentSourcesByFile: Map<string, Promise<string | null>> = new Map()\nasync function batchedTraceSource(\n project: Project,\n frame: TurbopackStackFrame\n): Promise<{ frame: IgnorableStackFrame; source: string | null } | undefined> {\n const file = frame.file\n ? // TODO(veil): Why are the frames sent encoded?\n decodeURIComponent(frame.file)\n : undefined\n\n if (!file) return\n\n // For node internals they cannot traced the actual source code with project.traceSource,\n // we need an early return to indicate it's ignored to avoid the unknown scheme error from `project.traceSource`.\n if (file.startsWith('node:')) {\n return {\n frame: {\n file,\n lineNumber: frame.line ?? 0,\n column: frame.column ?? 0,\n methodName: frame.methodName ?? '<unknown>',\n ignored: true,\n arguments: [],\n },\n source: null,\n }\n }\n\n const currentDirectoryFileUrl = pathToFileURL(process.cwd()).href\n\n const sourceFrame = await project.traceSource(frame, currentDirectoryFileUrl)\n if (!sourceFrame) {\n return {\n frame: {\n file,\n lineNumber: frame.line ?? 0,\n column: frame.column ?? 0,\n methodName: frame.methodName ?? '<unknown>',\n ignored: shouldIgnorePath(file),\n arguments: [],\n },\n source: null,\n }\n }\n\n let source = null\n const originalFile = sourceFrame.originalFile\n\n // Don't look up source for node_modules or internals. These can often be large bundled files.\n const ignored =\n shouldIgnorePath(originalFile ?? sourceFrame.file) ||\n // isInternal means resource starts with turbopack:///[turbopack]\n !!sourceFrame.isInternal\n if (originalFile && !ignored) {\n let sourcePromise = currentSourcesByFile.get(originalFile)\n if (!sourcePromise) {\n sourcePromise = project.getSourceForAsset(originalFile)\n currentSourcesByFile.set(originalFile, sourcePromise)\n setTimeout(() => {\n // Cache file reads for 100ms, as frames will often reference the same\n // files and can be large.\n currentSourcesByFile.delete(originalFile!)\n }, 100)\n }\n source = await sourcePromise\n }\n\n // TODO: get ignoredList from turbopack source map\n const ignorableFrame = {\n file: sourceFrame.file,\n lineNumber: sourceFrame.line ?? 0,\n column: sourceFrame.column ?? 0,\n methodName:\n // We ignore the sourcemapped name since it won't be the correct name.\n // The callsite will point to the column of the variable name instead of the\n // name of the enclosing function.\n // TODO(NDX-531): Spy on prepareStackTrace to get the enclosing line number for method name mapping.\n frame.methodName ?? '<unknown>',\n ignored,\n arguments: [],\n }\n\n return {\n frame: ignorableFrame,\n source,\n }\n}\nfunction parseFile(fileParam: string | null): string | undefined {\n if (!fileParam) {\n return undefined\n }\n\n // rsc://React/Server/file://<filename>?42 => file://<filename>\n return fileParam.replace(/^rsc:\\/\\/React\\/[^/]+\\//, '').replace(/\\?\\d+$/, '')\n}\n\nfunction createStackFrames(\n body: OriginalStackFramesRequest\n): TurbopackStackFrame[] {\n const { frames, isServer } = body\n\n return frames\n .map((frame): TurbopackStackFrame | undefined => {\n const file = parseFile(frame.file)\n\n if (!file) {\n return undefined\n }\n\n return {\n file,\n methodName: frame.methodName ?? '<unknown>',\n line: frame.lineNumber ?? 0,\n column: frame.column ?? 0,\n isServer,\n } satisfies TurbopackStackFrame\n })\n .filter((f): f is TurbopackStackFrame => f !== undefined)\n}\n\nfunction createStackFrame(\n searchParams: URLSearchParams\n): TurbopackStackFrame | undefined {\n const file = parseFile(searchParams.get('file'))\n\n if (!file) {\n return undefined\n }\n\n return {\n file,\n methodName: searchParams.get('methodName') ?? '<unknown>',\n line: parseInt(searchParams.get('lineNumber') ?? '0', 10) || 0,\n column: parseInt(searchParams.get('column') ?? '0', 10) || 0,\n isServer: searchParams.get('isServer') === 'true',\n } satisfies TurbopackStackFrame\n}\n\n/**\n * https://tc39.es/source-map/#index-map\n */\ninterface IndexSourceMapSection {\n offset: {\n line: number\n column: number\n }\n map: ModernRawSourceMap\n}\n\n// TODO(veil): Upstream types\ninterface IndexSourceMap {\n version: number\n file: string\n sections: IndexSourceMapSection[]\n}\n\ninterface ModernRawSourceMap extends SourceMapPayload {\n ignoreList?: number[]\n}\n\ntype ModernSourceMapPayload = ModernRawSourceMap | IndexSourceMap\n\n/**\n * Finds the sourcemap payload applicable to a given frame.\n * Equal to the input unless an Index Source Map is used.\n */\nfunction findApplicableSourceMapPayload(\n frame: TurbopackStackFrame,\n payload: ModernSourceMapPayload\n): ModernRawSourceMap | undefined {\n if ('sections' in payload) {\n const frameLine = frame.line ?? 0\n const frameColumn = frame.column ?? 0\n // Sections must not overlap and must be sorted: https://tc39.es/source-map/#section-object\n // Therefore the last section that has an offset less than or equal to the frame is the applicable one.\n // TODO(veil): Binary search\n let section: IndexSourceMapSection | undefined = payload.sections[0]\n for (\n let i = 0;\n i < payload.sections.length &&\n payload.sections[i].offset.line <= frameLine &&\n payload.sections[i].offset.column <= frameColumn;\n i++\n ) {\n section = payload.sections[i]\n }\n\n return section === undefined ? undefined : section.map\n } else {\n return payload\n }\n}\n\n/**\n * @returns 1-based lines and 0-based columns\n */\nasync function nativeTraceSource(\n frame: TurbopackStackFrame\n): Promise<{ frame: IgnorableStackFrame; source: string | null } | undefined> {\n const sourceURL = // TODO(veil): Why are the frames sent encoded?\n decodeURIComponent(frame.file)\n let sourceMapPayload: ModernSourceMapPayload | undefined\n try {\n sourceMapPayload = findSourceMap(sourceURL)?.payload\n } catch (cause) {\n throw new Error(\n `${sourceURL}: Invalid source map. Only conformant source maps can be used to find the original code.`,\n { cause }\n )\n }\n\n if (sourceMapPayload !== undefined) {\n let consumer: BasicSourceMapConsumer\n try {\n consumer = await new SourceMapConsumer(sourceMapPayload)\n } catch (cause) {\n throw new Error(\n `${sourceURL}: Invalid source map. Only conformant source maps can be used to find the original code.`,\n { cause }\n )\n }\n let traced: {\n originalPosition: NullableMappedPosition\n sourceContent: string | null\n } | null\n try {\n const originalPosition = consumer.originalPositionFor({\n line: frame.line ?? 1,\n // 0-based columns out requires 0-based columns in.\n column: (frame.column ?? 1) - 1,\n })\n\n if (originalPosition.source === null) {\n traced = null\n } else {\n const sourceContent: string | null =\n consumer.sourceContentFor(\n originalPosition.source,\n /* returnNullOnMissing */ true\n ) ?? null\n\n traced = { originalPosition, sourceContent }\n }\n } finally {\n consumer.destroy()\n }\n\n if (traced !== null) {\n const { originalPosition, sourceContent } = traced\n const applicableSourceMap = findApplicableSourceMapPayload(\n frame,\n sourceMapPayload\n )\n\n // TODO(veil): Upstream a method to sourcemap consumer that immediately says if a frame is ignored or not.\n let ignored = false\n if (applicableSourceMap === undefined) {\n console.error(\n 'No applicable source map found in sections for frame',\n frame\n )\n } else {\n // TODO: O(n^2). Consider moving `ignoreList` into a Set\n const sourceIndex = applicableSourceMap.sources.indexOf(\n originalPosition.source!\n )\n ignored =\n applicableSourceMap.ignoreList?.includes(sourceIndex) ??\n // When sourcemap is not available, fallback to checking `frame.file`.\n // e.g. In pages router, nextjs server code is not bundled into the page.\n shouldIgnorePath(frame.file)\n }\n\n const originalStackFrame: IgnorableStackFrame = {\n methodName:\n // We ignore the sourcemapped name since it won't be the correct name.\n // The callsite will point to the column of the variable name instead of the\n // name of the enclosing function.\n // TODO(NDX-531): Spy on prepareStackTrace to get the enclosing line number for method name mapping.\n frame.methodName\n ?.replace('__WEBPACK_DEFAULT_EXPORT__', 'default')\n ?.replace('__webpack_exports__.', '') || '<unknown>',\n column: (originalPosition.column ?? 0) + 1,\n file: originalPosition.source,\n lineNumber: originalPosition.line ?? 0,\n // TODO: c&p from async createOriginalStackFrame but why not frame.arguments?\n arguments: [],\n ignored,\n }\n\n return {\n frame: originalStackFrame,\n source: sourceContent,\n }\n }\n }\n\n return undefined\n}\n\nasync function createOriginalStackFrame(\n project: Project,\n projectPath: string,\n frame: TurbopackStackFrame\n): Promise<OriginalStackFrameResponse | null> {\n const traced =\n (await nativeTraceSource(frame)) ??\n // TODO(veil): When would the bundler know more than native?\n // If it's faster, try the bundler first and fall back to native later.\n (await batchedTraceSource(project, frame))\n if (!traced) {\n return null\n }\n\n let normalizedStackFrameLocation = traced.frame.file\n if (\n normalizedStackFrameLocation !== null &&\n normalizedStackFrameLocation.startsWith('file://')\n ) {\n normalizedStackFrameLocation = path.relative(\n projectPath,\n url.fileURLToPath(normalizedStackFrameLocation)\n )\n }\n\n return {\n originalStackFrame: {\n arguments: traced.frame.arguments,\n column: traced.frame.column,\n file: normalizedStackFrameLocation,\n ignored: traced.frame.ignored,\n lineNumber: traced.frame.lineNumber,\n methodName: traced.frame.methodName,\n },\n originalCodeFrame: getOriginalCodeFrame(traced.frame, traced.source),\n }\n}\n\nexport function getOverlayMiddleware({\n project,\n projectPath,\n isSrcDir,\n}: {\n project: Project\n projectPath: string\n isSrcDir: boolean\n}) {\n return async function (\n req: IncomingMessage,\n res: ServerResponse,\n next: () => void\n ): Promise<void> {\n const { pathname, searchParams } = new URL(req.url!, 'http://n')\n\n if (pathname === '/__nextjs_original-stack-frames') {\n if (req.method !== 'POST') {\n return middlewareResponse.badRequest(res)\n }\n\n const body = await new Promise<string>((resolve, reject) => {\n let data = ''\n req.on('data', (chunk) => {\n data += chunk\n })\n req.on('end', () => resolve(data))\n req.on('error', reject)\n })\n\n const request = JSON.parse(body) as OriginalStackFramesRequest\n const stackFrames = createStackFrames(request)\n const result: OriginalStackFramesResponse = await Promise.all(\n stackFrames.map(async (frame) => {\n try {\n const stackFrame = await createOriginalStackFrame(\n project,\n projectPath,\n frame\n )\n if (stackFrame === null) {\n return {\n status: 'rejected',\n reason: 'Failed to create original stack frame',\n }\n }\n return { status: 'fulfilled', value: stackFrame }\n } catch (error) {\n return {\n status: 'rejected',\n reason: inspect(error, { colors: false }),\n }\n }\n })\n )\n\n return middlewareResponse.json(res, result)\n } else if (pathname === '/__nextjs_launch-editor') {\n const isAppRelativePath = searchParams.get('isAppRelativePath') === '1'\n\n let openEditorResult\n if (isAppRelativePath) {\n const relativeFilePath = searchParams.get('file') || ''\n const absoluteFilePath = path.join(\n projectPath,\n 'app',\n isSrcDir ? 'src' : '',\n relativeFilePath\n )\n openEditorResult = await openFileInEditor(absoluteFilePath, 1, 1)\n } else {\n const frame = createStackFrame(searchParams)\n if (!frame) return middlewareResponse.badRequest(res)\n openEditorResult = await openFileInEditor(\n frame.file,\n frame.line ?? 1,\n frame.column ?? 1\n )\n }\n\n if (openEditorResult.error) {\n return middlewareResponse.internalServerError(res)\n }\n if (!openEditorResult.found) {\n return middlewareResponse.notFound(res)\n }\n return middlewareResponse.noContent(res)\n }\n\n return next()\n }\n}\n\nexport function getSourceMapMiddleware(project: Project) {\n return async function (\n req: IncomingMessage,\n res: ServerResponse,\n next: () => void\n ): Promise<void> {\n const { pathname, searchParams } = new URL(req.url!, 'http://n')\n\n if (pathname !== '/__nextjs_source-map') {\n return next()\n }\n\n let filename = searchParams.get('filename')\n\n if (!filename) {\n return middlewareResponse.badRequest(res)\n }\n\n // TODO(veil): Always try the native version first.\n // Externals could also be files that aren't bundled via Webpack.\n if (\n filename.startsWith('webpack://') ||\n filename.startsWith('webpack-internal:///')\n ) {\n const sourceMap = findSourceMap(filename)\n\n if (sourceMap) {\n return middlewareResponse.json(res, sourceMap.payload)\n }\n\n return middlewareResponse.noContent(res)\n }\n\n try {\n // Turbopack chunk filenames might be URL-encoded.\n filename = decodeURI(filename)\n\n if (path.isAbsolute(filename)) {\n filename = url.pathToFileURL(filename).href\n }\n\n const sourceMapString = await project.getSourceMap(filename)\n\n if (sourceMapString) {\n return middlewareResponse.jsonString(res, sourceMapString)\n }\n\n if (filename.startsWith('file:')) {\n const sourceMap = await getSourceMapFromFile(filename)\n\n if (sourceMap) {\n return middlewareResponse.json(res, sourceMap)\n }\n }\n } catch (error) {\n console.error('Failed to get source map:', error)\n }\n\n middlewareResponse.noContent(res)\n }\n}\n"],"names":["getOriginalCodeFrame","middlewareResponse","path","url","openFileInEditor","SourceMapConsumer","getSourceMapFromFile","findSourceMap","pathToFileURL","inspect","shouldIgnorePath","modulePath","includes","startsWith","currentSourcesByFile","Map","batchedTraceSource","project","frame","file","decodeURIComponent","undefined","lineNumber","line","column","methodName","ignored","arguments","source","currentDirectoryFileUrl","process","cwd","href","sourceFrame","traceSource","originalFile","isInternal","sourcePromise","get","getSourceForAsset","set","setTimeout","delete","ignorableFrame","parseFile","fileParam","replace","createStackFrames","body","frames","isServer","map","filter","f","createStackFrame","searchParams","parseInt","findApplicableSourceMapPayload","payload","frameLine","frameColumn","section","sections","i","length","offset","nativeTraceSource","sourceURL","sourceMapPayload","cause","Error","consumer","traced","originalPosition","originalPositionFor","sourceContent","sourceContentFor","destroy","applicableSourceMap","console","error","sourceIndex","sources","indexOf","ignoreList","originalStackFrame","createOriginalStackFrame","projectPath","normalizedStackFrameLocation","relative","fileURLToPath","originalCodeFrame","getOverlayMiddleware","isSrcDir","req","res","next","pathname","URL","method","badRequest","Promise","resolve","reject","data","on","chunk","request","JSON","parse","stackFrames","result","all","stackFrame","status","reason","value","colors","json","isAppRelativePath","openEditorResult","relativeFilePath","absoluteFilePath","join","internalServerError","found","notFound","noContent","getSourceMapMiddleware","filename","sourceMap","decodeURI","isAbsolute","sourceMapString","getSourceMap","jsonString"],"mappings":"AACA,SACEA,oBAAoB,QAIf,oCAAmC;AAC1C,SAASC,kBAAkB,QAAQ,iDAAgD;AACnF,OAAOC,UAAU,OAAM;AACvB,OAAOC,SAAS,MAAK;AACrB,SAASC,gBAAgB,QAAQ,2CAA0C;AAE3E,SACEC,iBAAiB,QAGZ,kCAAiC;AAExC,SAASC,oBAAoB,QAAQ,6BAA4B;AACjE,SAASC,aAAa,QAA+B,cAAa;AAClE,SAASC,aAAa,QAAQ,WAAU;AACxC,SAASC,OAAO,QAAQ,YAAW;AAEnC,SAASC,iBAAiBC,UAAkB;IAC1C,OACEA,WAAWC,QAAQ,CAAC,mBACpB,2EAA2E;IAC3ED,WAAWC,QAAQ,CAAC,gBACpBD,WAAWE,UAAU,CAAC;AAE1B;AAI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5H,qBAAqB2H;gBAE7C,IAAIC,WAAW;oBACb,OAAOjI,mBAAmBqH,IAAI,CAACvB,KAAKmC;gBACtC;YACF;QACF,EAAE,OAAOlD,OAAO;YACdD,QAAQC,KAAK,CAAC,6BAA6BA;QAC7C;QAEA/E,mBAAmB8H,SAAS,CAAChC;IAC/B;AACF","ignoreList":[0]}
|
1
|
+
{"version":3,"sources":["../../../src/server/dev/middleware-turbopack.ts"],"sourcesContent":["import type { IncomingMessage, ServerResponse } from 'http'\nimport {\n getOriginalCodeFrame,\n type OriginalStackFrameResponse,\n type OriginalStackFramesRequest,\n type OriginalStackFramesResponse,\n} from '../../next-devtools/server/shared'\nimport { middlewareResponse } from '../../next-devtools/server/middleware-response'\nimport path from 'path'\nimport url from 'url'\nimport { openFileInEditor } from '../../next-devtools/server/launch-editor'\nimport type { StackFrame } from 'next/dist/compiled/stacktrace-parser'\nimport {\n SourceMapConsumer,\n type NullableMappedPosition,\n} from 'next/dist/compiled/source-map08'\nimport type { Project, TurbopackStackFrame } from '../../build/swc/types'\nimport {\n type ModernSourceMapPayload,\n findApplicableSourceMapPayload,\n} from '../lib/source-maps'\nimport { getSourceMapFromFile } from './get-source-map-from-file'\nimport { findSourceMap } from 'node:module'\nimport { pathToFileURL } from 'node:url'\nimport { inspect } from 'node:util'\n\nfunction shouldIgnorePath(modulePath: string): boolean {\n return (\n modulePath.includes('node_modules') ||\n // Only relevant for when Next.js is symlinked e.g. in the Next.js monorepo\n modulePath.includes('next/dist') ||\n modulePath.startsWith('node:')\n )\n}\n\ntype IgnorableStackFrame = StackFrame & { ignored: boolean }\n\nconst currentSourcesByFile: Map<string, Promise<string | null>> = new Map()\nasync function batchedTraceSource(\n project: Project,\n frame: TurbopackStackFrame\n): Promise<{ frame: IgnorableStackFrame; source: string | null } | undefined> {\n const file = frame.file\n ? // TODO(veil): Why are the frames sent encoded?\n decodeURIComponent(frame.file)\n : undefined\n\n if (!file) return\n\n // For node internals they cannot traced the actual source code with project.traceSource,\n // we need an early return to indicate it's ignored to avoid the unknown scheme error from `project.traceSource`.\n if (file.startsWith('node:')) {\n return {\n frame: {\n file,\n lineNumber: frame.line ?? 0,\n column: frame.column ?? 0,\n methodName: frame.methodName ?? '<unknown>',\n ignored: true,\n arguments: [],\n },\n source: null,\n }\n }\n\n const currentDirectoryFileUrl = pathToFileURL(process.cwd()).href\n\n const sourceFrame = await project.traceSource(frame, currentDirectoryFileUrl)\n if (!sourceFrame) {\n return {\n frame: {\n file,\n lineNumber: frame.line ?? 0,\n column: frame.column ?? 0,\n methodName: frame.methodName ?? '<unknown>',\n ignored: shouldIgnorePath(file),\n arguments: [],\n },\n source: null,\n }\n }\n\n let source = null\n const originalFile = sourceFrame.originalFile\n\n // Don't look up source for node_modules or internals. These can often be large bundled files.\n const ignored =\n shouldIgnorePath(originalFile ?? sourceFrame.file) ||\n // isInternal means resource starts with turbopack:///[turbopack]\n !!sourceFrame.isInternal\n if (originalFile && !ignored) {\n let sourcePromise = currentSourcesByFile.get(originalFile)\n if (!sourcePromise) {\n sourcePromise = project.getSourceForAsset(originalFile)\n currentSourcesByFile.set(originalFile, sourcePromise)\n setTimeout(() => {\n // Cache file reads for 100ms, as frames will often reference the same\n // files and can be large.\n currentSourcesByFile.delete(originalFile!)\n }, 100)\n }\n source = await sourcePromise\n }\n\n // TODO: get ignoredList from turbopack source map\n const ignorableFrame = {\n file: sourceFrame.file,\n lineNumber: sourceFrame.line ?? 0,\n column: sourceFrame.column ?? 0,\n methodName:\n // We ignore the sourcemapped name since it won't be the correct name.\n // The callsite will point to the column of the variable name instead of the\n // name of the enclosing function.\n // TODO(NDX-531): Spy on prepareStackTrace to get the enclosing line number for method name mapping.\n frame.methodName ?? '<unknown>',\n ignored,\n arguments: [],\n }\n\n return {\n frame: ignorableFrame,\n source,\n }\n}\nfunction parseFile(fileParam: string | null): string | undefined {\n if (!fileParam) {\n return undefined\n }\n\n // rsc://React/Server/file://<filename>?42 => file://<filename>\n return fileParam.replace(/^rsc:\\/\\/React\\/[^/]+\\//, '').replace(/\\?\\d+$/, '')\n}\n\nfunction createStackFrames(\n body: OriginalStackFramesRequest\n): TurbopackStackFrame[] {\n const { frames, isServer } = body\n\n return frames\n .map((frame): TurbopackStackFrame | undefined => {\n const file = parseFile(frame.file)\n\n if (!file) {\n return undefined\n }\n\n return {\n file,\n methodName: frame.methodName ?? '<unknown>',\n line: frame.lineNumber ?? 0,\n column: frame.column ?? 0,\n isServer,\n } satisfies TurbopackStackFrame\n })\n .filter((f): f is TurbopackStackFrame => f !== undefined)\n}\n\nfunction createStackFrame(\n searchParams: URLSearchParams\n): TurbopackStackFrame | undefined {\n const file = parseFile(searchParams.get('file'))\n\n if (!file) {\n return undefined\n }\n\n return {\n file,\n methodName: searchParams.get('methodName') ?? '<unknown>',\n line: parseInt(searchParams.get('lineNumber') ?? '0', 10) || 0,\n column: parseInt(searchParams.get('column') ?? '0', 10) || 0,\n isServer: searchParams.get('isServer') === 'true',\n } satisfies TurbopackStackFrame\n}\n\n/**\n * @returns 1-based lines and 0-based columns\n */\nasync function nativeTraceSource(\n frame: TurbopackStackFrame\n): Promise<{ frame: IgnorableStackFrame; source: string | null } | undefined> {\n const sourceURL = // TODO(veil): Why are the frames sent encoded?\n decodeURIComponent(frame.file)\n let sourceMapPayload: ModernSourceMapPayload | undefined\n try {\n sourceMapPayload = findSourceMap(sourceURL)?.payload\n } catch (cause) {\n throw new Error(\n `${sourceURL}: Invalid source map. Only conformant source maps can be used to find the original code.`,\n { cause }\n )\n }\n\n if (sourceMapPayload !== undefined) {\n let consumer: SourceMapConsumer\n try {\n consumer = await new SourceMapConsumer(sourceMapPayload)\n } catch (cause) {\n throw new Error(\n `${sourceURL}: Invalid source map. Only conformant source maps can be used to find the original code.`,\n { cause }\n )\n }\n let traced: {\n originalPosition: NullableMappedPosition\n sourceContent: string | null\n } | null\n try {\n const originalPosition = consumer.originalPositionFor({\n line: frame.line ?? 1,\n // 0-based columns out requires 0-based columns in.\n column: (frame.column ?? 1) - 1,\n })\n\n if (originalPosition.source === null) {\n traced = null\n } else {\n const sourceContent: string | null =\n consumer.sourceContentFor(\n originalPosition.source,\n /* returnNullOnMissing */ true\n ) ?? null\n\n traced = { originalPosition, sourceContent }\n }\n } finally {\n consumer.destroy()\n }\n\n if (traced !== null) {\n const { originalPosition, sourceContent } = traced\n const applicableSourceMap = findApplicableSourceMapPayload(\n frame.line ?? 0,\n frame.column ?? 0,\n sourceMapPayload\n )\n\n // TODO(veil): Upstream a method to sourcemap consumer that immediately says if a frame is ignored or not.\n let ignored = false\n if (applicableSourceMap === undefined) {\n console.error(\n 'No applicable source map found in sections for frame',\n frame\n )\n } else {\n // TODO: O(n^2). Consider moving `ignoreList` into a Set\n const sourceIndex = applicableSourceMap.sources.indexOf(\n originalPosition.source!\n )\n ignored =\n applicableSourceMap.ignoreList?.includes(sourceIndex) ??\n // When sourcemap is not available, fallback to checking `frame.file`.\n // e.g. In pages router, nextjs server code is not bundled into the page.\n shouldIgnorePath(frame.file)\n }\n\n const originalStackFrame: IgnorableStackFrame = {\n methodName:\n // We ignore the sourcemapped name since it won't be the correct name.\n // The callsite will point to the column of the variable name instead of the\n // name of the enclosing function.\n // TODO(NDX-531): Spy on prepareStackTrace to get the enclosing line number for method name mapping.\n frame.methodName\n ?.replace('__WEBPACK_DEFAULT_EXPORT__', 'default')\n ?.replace('__webpack_exports__.', '') || '<unknown>',\n column: (originalPosition.column ?? 0) + 1,\n file: originalPosition.source,\n lineNumber: originalPosition.line ?? 0,\n // TODO: c&p from async createOriginalStackFrame but why not frame.arguments?\n arguments: [],\n ignored,\n }\n\n return {\n frame: originalStackFrame,\n source: sourceContent,\n }\n }\n }\n\n return undefined\n}\n\nasync function createOriginalStackFrame(\n project: Project,\n projectPath: string,\n frame: TurbopackStackFrame\n): Promise<OriginalStackFrameResponse | null> {\n const traced =\n (await nativeTraceSource(frame)) ??\n // TODO(veil): When would the bundler know more than native?\n // If it's faster, try the bundler first and fall back to native later.\n (await batchedTraceSource(project, frame))\n if (!traced) {\n return null\n }\n\n let normalizedStackFrameLocation = traced.frame.file\n if (\n normalizedStackFrameLocation !== null &&\n normalizedStackFrameLocation.startsWith('file://')\n ) {\n normalizedStackFrameLocation = path.relative(\n projectPath,\n url.fileURLToPath(normalizedStackFrameLocation)\n )\n }\n\n return {\n originalStackFrame: {\n arguments: traced.frame.arguments,\n column: traced.frame.column,\n file: normalizedStackFrameLocation,\n ignored: traced.frame.ignored,\n lineNumber: traced.frame.lineNumber,\n methodName: traced.frame.methodName,\n },\n originalCodeFrame: getOriginalCodeFrame(traced.frame, traced.source),\n }\n}\n\nexport function getOverlayMiddleware({\n project,\n projectPath,\n isSrcDir,\n}: {\n project: Project\n projectPath: string\n isSrcDir: boolean\n}) {\n return async function (\n req: IncomingMessage,\n res: ServerResponse,\n next: () => void\n ): Promise<void> {\n const { pathname, searchParams } = new URL(req.url!, 'http://n')\n\n if (pathname === '/__nextjs_original-stack-frames') {\n if (req.method !== 'POST') {\n return middlewareResponse.badRequest(res)\n }\n\n const body = await new Promise<string>((resolve, reject) => {\n let data = ''\n req.on('data', (chunk) => {\n data += chunk\n })\n req.on('end', () => resolve(data))\n req.on('error', reject)\n })\n\n const request = JSON.parse(body) as OriginalStackFramesRequest\n const stackFrames = createStackFrames(request)\n const result: OriginalStackFramesResponse = await Promise.all(\n stackFrames.map(async (frame) => {\n try {\n const stackFrame = await createOriginalStackFrame(\n project,\n projectPath,\n frame\n )\n if (stackFrame === null) {\n return {\n status: 'rejected',\n reason: 'Failed to create original stack frame',\n }\n }\n return { status: 'fulfilled', value: stackFrame }\n } catch (error) {\n return {\n status: 'rejected',\n reason: inspect(error, { colors: false }),\n }\n }\n })\n )\n\n return middlewareResponse.json(res, result)\n } else if (pathname === '/__nextjs_launch-editor') {\n const isAppRelativePath = searchParams.get('isAppRelativePath') === '1'\n\n let openEditorResult\n if (isAppRelativePath) {\n const relativeFilePath = searchParams.get('file') || ''\n const absoluteFilePath = path.join(\n projectPath,\n 'app',\n isSrcDir ? 'src' : '',\n relativeFilePath\n )\n openEditorResult = await openFileInEditor(absoluteFilePath, 1, 1)\n } else {\n const frame = createStackFrame(searchParams)\n if (!frame) return middlewareResponse.badRequest(res)\n openEditorResult = await openFileInEditor(\n frame.file,\n frame.line ?? 1,\n frame.column ?? 1\n )\n }\n\n if (openEditorResult.error) {\n return middlewareResponse.internalServerError(res)\n }\n if (!openEditorResult.found) {\n return middlewareResponse.notFound(res)\n }\n return middlewareResponse.noContent(res)\n }\n\n return next()\n }\n}\n\nexport function getSourceMapMiddleware(project: Project) {\n return async function (\n req: IncomingMessage,\n res: ServerResponse,\n next: () => void\n ): Promise<void> {\n const { pathname, searchParams } = new URL(req.url!, 'http://n')\n\n if (pathname !== '/__nextjs_source-map') {\n return next()\n }\n\n let filename = searchParams.get('filename')\n\n if (!filename) {\n return middlewareResponse.badRequest(res)\n }\n\n // TODO(veil): Always try the native version first.\n // Externals could also be files that aren't bundled via Webpack.\n if (\n filename.startsWith('webpack://') ||\n filename.startsWith('webpack-internal:///')\n ) {\n const sourceMap = findSourceMap(filename)\n\n if (sourceMap) {\n return middlewareResponse.json(res, sourceMap.payload)\n }\n\n return middlewareResponse.noContent(res)\n }\n\n try {\n // Turbopack chunk filenames might be URL-encoded.\n filename = decodeURI(filename)\n\n if (path.isAbsolute(filename)) {\n filename = url.pathToFileURL(filename).href\n }\n\n const sourceMapString = await project.getSourceMap(filename)\n\n if (sourceMapString) {\n return middlewareResponse.jsonString(res, sourceMapString)\n }\n\n if (filename.startsWith('file:')) {\n const sourceMap = await getSourceMapFromFile(filename)\n\n if (sourceMap) {\n return middlewareResponse.json(res, sourceMap)\n }\n }\n } catch (error) {\n console.error('Failed to get source map:', error)\n }\n\n middlewareResponse.noContent(res)\n }\n}\n"],"names":["getOriginalCodeFrame","middlewareResponse","path","url","openFileInEditor","SourceMapConsumer","findApplicableSourceMapPayload","getSourceMapFromFile","findSourceMap","pathToFileURL","inspect","shouldIgnorePath","modulePath","includes","startsWith","currentSourcesByFile","Map","batchedTraceSource","project","frame","file","decodeURIComponent","undefined","lineNumber","line","column","methodName","ignored","arguments","source","currentDirectoryFileUrl","process","cwd","href","sourceFrame","traceSource","originalFile","isInternal","sourcePromise","get","getSourceForAsset","set","setTimeout","delete","ignorableFrame","parseFile","fileParam","replace","createStackFrames","body","frames","isServer","map","filter","f","createStackFrame","searchParams","parseInt","nativeTraceSource","sourceURL","sourceMapPayload","payload","cause","Error","consumer","traced","originalPosition","originalPositionFor","sourceContent","sourceContentFor","destroy","applicableSourceMap","console","error","sourceIndex","sources","indexOf","ignoreList","originalStackFrame","createOriginalStackFrame","projectPath","normalizedStackFrameLocation","relative","fileURLToPath","originalCodeFrame","getOverlayMiddleware","isSrcDir","req","res","next","pathname","URL","method","badRequest","Promise","resolve","reject","data","on","chunk","request","JSON","parse","stackFrames","result","all","stackFrame","status","reason","value","colors","json","isAppRelativePath","openEditorResult","relativeFilePath","absoluteFilePath","join","internalServerError","found","notFound","noContent","getSourceMapMiddleware","filename","sourceMap","decodeURI","isAbsolute","sourceMapString","getSourceMap","jsonString"],"mappings":"AACA,SACEA,oBAAoB,QAIf,oCAAmC;AAC1C,SAASC,kBAAkB,QAAQ,iDAAgD;AACnF,OAAOC,UAAU,OAAM;AACvB,OAAOC,SAAS,MAAK;AACrB,SAASC,gBAAgB,QAAQ,2CAA0C;AAE3E,SACEC,iBAAiB,QAEZ,kCAAiC;AAExC,SAEEC,8BAA8B,QACzB,qBAAoB;AAC3B,SAASC,oBAAoB,QAAQ,6BAA4B;AACjE,SAASC,aAAa,QAAQ,cAAa;AAC3C,SAASC,aAAa,QAAQ,WAAU;AACxC,SAASC,OAAO,QAAQ,YAAW;AAEnC,SAASC,iBAAiBC,UAAkB;IAC1C,OACEA,WAAWC,QAAQ,CAAC,mBACpB,2EAA2E;IAC3ED,WAAWC,QAAQ,CAAC,gBACpBD,WAAWE,UAAU,CAAC;AAE1B;AAIA,MAAMC,uBAA4D,IAAIC;AACtE,eAAeC,m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