next 15.4.0-canary.98 → 15.4.0-canary.99
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/app-page-turbo.runtime.dev.js +2 -2
- package/dist/compiled/next-server/app-page-turbo.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/app-page.runtime.dev.js +2 -2
- package/dist/compiled/next-server/app-page.runtime.dev.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/next-devtools/server/launch-editor.js +18 -0
- package/dist/esm/next-devtools/server/launch-editor.js.map +1 -1
- package/dist/esm/server/dev/hot-reloader-turbopack.js +6 -2
- package/dist/esm/server/dev/hot-reloader-turbopack.js.map +1 -1
- package/dist/esm/server/dev/hot-reloader-webpack.js +4 -2
- package/dist/esm/server/dev/hot-reloader-webpack.js.map +1 -1
- package/dist/esm/server/dev/middleware-turbopack.js +17 -11
- package/dist/esm/server/dev/middleware-turbopack.js.map +1 -1
- package/dist/esm/server/dev/middleware-webpack.js +19 -12
- 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/router-utils/setup-dev-bundler.js +5 -1
- package/dist/esm/server/lib/router-utils/setup-dev-bundler.js.map +1 -1
- package/dist/esm/server/lib/start-server.js +1 -1
- package/dist/esm/shared/lib/canary-only.js +1 -1
- package/dist/next-devtools/server/launch-editor.d.ts +4 -0
- package/dist/next-devtools/server/launch-editor.js +22 -1
- package/dist/next-devtools/server/launch-editor.js.map +1 -1
- package/dist/server/dev/hot-reloader-turbopack.d.ts +3 -1
- package/dist/server/dev/hot-reloader-turbopack.js +6 -2
- package/dist/server/dev/hot-reloader-turbopack.js.map +1 -1
- package/dist/server/dev/hot-reloader-webpack.d.ts +3 -1
- package/dist/server/dev/hot-reloader-webpack.js +4 -2
- package/dist/server/dev/hot-reloader-webpack.js.map +1 -1
- package/dist/server/dev/middleware-turbopack.d.ts +5 -1
- package/dist/server/dev/middleware-turbopack.js +16 -51
- package/dist/server/dev/middleware-turbopack.js.map +1 -1
- package/dist/server/dev/middleware-webpack.d.ts +1 -0
- package/dist/server/dev/middleware-webpack.js +18 -11
- package/dist/server/dev/middleware-webpack.js.map +1 -1
- package/dist/server/lib/app-info-log.js +1 -1
- package/dist/server/lib/router-utils/setup-dev-bundler.js +5 -1
- package/dist/server/lib/router-utils/setup-dev-bundler.js.map +1 -1
- package/dist/server/lib/start-server.js +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
@@ -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 fs, { constants as FS } from 'fs/promises'\nimport path from 'path'\nimport url from 'url'\nimport { launchEditor } 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(project: Project, projectPath: string) {\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 frame = createStackFrame(searchParams)\n\n if (!frame) return middlewareResponse.badRequest(res)\n\n const fileExists = await fs.access(frame.file, FS.F_OK).then(\n () => true,\n () => false\n )\n if (!fileExists) return middlewareResponse.notFound(res)\n\n try {\n launchEditor(frame.file, frame.line ?? 1, frame.column ?? 1)\n } catch (err) {\n console.log('Failed to launch editor:', err)\n return middlewareResponse.internalServerError(res)\n }\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","fs","constants","FS","path","url","launchEditor","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","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","fileExists","access","F_OK","then","notFound","err","log","internalServerError","noContent","getSourceMapMiddleware","filename","sourceMap","decodeURI","isAbsolute","sourceMapString","getSourceMap","jsonString"],"mappings":"AACA,SACEA,oBAAoB,QAIf,oCAAmC;AAC1C,SAASC,kBAAkB,QAAQ,iDAAgD;AACnF,OAAOC,MAAMC,aAAaC,EAAE,QAAQ,cAAa;AACjD,OAAOC,UAAU,OAAM;AACvB,OAAOC,SAAS,MAAK;AACrB,SAASC,YAAY,QAAQ,2CAA0C;AAEvE,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;AAIA,MAAMC,uBAA4D,IAAIC;AACtE,eAAeC,mBACbC,OAAgB,EAChBC,KAA0B;IAE1B,MAAMC,OAAOD,MAAMC,IAAI,GAEnBC,m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AAuB9G,OAAgB;IACrD,OAAO,eACL4E,GAAoB,EACpBC,GAAmB,EACnBC,IAAgB;QAEhB,MAAM,EAAEC,QAAQ,EAAEzC,YAAY,EAAE,GAAG,IAAI0C,IAAIJ,IAAI1F,GAAG,EAAG;QAErD,IAAI6F,aAAa,wBAAwB;YACvC,OAAOD;QACT;QAEA,IAAIiC,WAAWzE,aAAajB,GAAG,CAAC;QAEhC,IAAI,CAAC0F,UAAU;YACb,OAAOlI,mBAAmBqG,UAAU,CAACL;QACvC;QAEA,mDAAmD;QACnD,iEAAiE;QACjE,IACEkC,SAASnH,UAAU,CAAC,iBACpBmH,SAASnH,UAAU,CAAC,yBACpB;YACA,MAAMoH,YAAY1H,cAAcyH;YAEhC,IAAIC,WAAW;gBACb,OAAOnI,mBAAmBuH,IAAI,CAACvB,KAAKmC,UAAUvE,OAAO;YACvD;YAEA,OAAO5D,mBAAmBgI,SAAS,CAAChC;QACtC;QAEA,IAAI;YACF,kDAAkD;YAClDkC,WAAWE,UAAUF;YAErB,IAAI9H,KAAKiI,UAAU,CAACH,WAAW;gBAC7BA,WAAW7H,IAAIK,aAAa,CAACwH,UAAUhG,IAAI;YAC7C;YAEA,MAAMoG,kBAAkB,MAAMnH,QAAQoH,YAAY,CAACL;YAEnD,IAAII,iBAAiB;gBACnB,OAAOtI,mBAAmBwI,UAAU,CAACxC,KAAKsC;YAC5C;YAEA,IAAIJ,SAASnH,UAAU,CAAC,UAAU;gBAChC,MAAMoH,YAAY,MAAM3H,qBAAqB0H;gBAE7C,IAAIC,WAAW;oBACb,OAAOnI,mBAAmBuH,IAAI,CAACvB,KAAKmC;gBACtC;YACF;QACF,EAAE,OAAOjD,OAAO;YACdD,QAAQC,KAAK,CAAC,6BAA6BA;QAC7C;QAEAlF,mBAAmBgI,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 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;AAC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tC;QAEA,IAAI;YACF,kDAAkD;YAClDkC,WAAWE,UAAUF;YAErB,IAAI/H,KAAKkI,UAAU,CAACH,WAAW;gBAC7BA,WAAW9H,IAAIK,aAAa,CAACyH,UAAUjG,IAAI;YAC7C;YAEA,MAAMqG,kBAAkB,MAAMpH,QAAQqH,YAAY,CAACL;YAEnD,IAAII,iBAAiB;gBACnB,OAAOpI,mBAAmBsI,UAAU,CAACxC,KAAKsC;YAC5C;YAEA,IAAIJ,SAASpH,UAAU,CAAC,UAAU;gBAChC,MAAMqH,YAAY,MAAM5H,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,10 +1,9 @@
|
|
1
|
-
import { constants as FS, promises as fs } from 'fs';
|
2
1
|
import { findSourceMap } from 'module';
|
3
2
|
import path from 'path';
|
4
3
|
import { fileURLToPath, pathToFileURL } from 'url';
|
5
4
|
import { SourceMapConsumer } from 'next/dist/compiled/source-map08';
|
6
5
|
import { getSourceMapFromFile } from './get-source-map-from-file';
|
7
|
-
import {
|
6
|
+
import { openFileInEditor } from '../../next-devtools/server/launch-editor';
|
8
7
|
import { getOriginalCodeFrame } from '../../next-devtools/server/shared';
|
9
8
|
import { middlewareResponse } from '../../next-devtools/server/middleware-response';
|
10
9
|
export { getSourceMapFromFile };
|
@@ -321,7 +320,7 @@ async function getOriginalStackFrame({ isServer, isEdgeServer, isAppDirectory, f
|
|
321
320
|
return originalStackFrameResponse;
|
322
321
|
}
|
323
322
|
export function getOverlayMiddleware(options) {
|
324
|
-
const { rootDirectory, clientStats, serverStats, edgeServerStats } = options;
|
323
|
+
const { rootDirectory, isSrcDir, clientStats, serverStats, edgeServerStats } = options;
|
325
324
|
return async function(req, res, next) {
|
326
325
|
const { pathname, searchParams } = new URL(`http://n${req.url}`);
|
327
326
|
if (pathname === '/__nextjs_original-stack-frames') {
|
@@ -364,15 +363,23 @@ export function getOverlayMiddleware(options) {
|
|
364
363
|
arguments: searchParams.getAll('arguments').filter(Boolean)
|
365
364
|
};
|
366
365
|
if (!frame.file) return middlewareResponse.badRequest(res);
|
367
|
-
|
368
|
-
const
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
}
|
374
|
-
|
375
|
-
|
366
|
+
let openEditorResult;
|
367
|
+
const isAppRelativePath = searchParams.get('isAppRelativePath') === '1';
|
368
|
+
if (isAppRelativePath) {
|
369
|
+
const relativeFilePath = searchParams.get('file') || '';
|
370
|
+
const absoluteFilePath = path.join(rootDirectory, 'app', isSrcDir ? 'src' : '', relativeFilePath);
|
371
|
+
openEditorResult = await openFileInEditor(absoluteFilePath, 1, 1);
|
372
|
+
} else {
|
373
|
+
// frame files may start with their webpack layer, like (middleware)/middleware.js
|
374
|
+
const filePath = path.resolve(rootDirectory, frame.file.replace(/^\([^)]+\)\//, ''));
|
375
|
+
openEditorResult = await openFileInEditor(filePath, frame.lineNumber, frame.column ?? 1);
|
376
|
+
}
|
377
|
+
if (openEditorResult.error) {
|
378
|
+
console.error('Failed to launch editor:', openEditorResult.error);
|
379
|
+
return middlewareResponse.internalServerError(res, openEditorResult.error);
|
380
|
+
}
|
381
|
+
if (!openEditorResult.found) {
|
382
|
+
return middlewareResponse.notFound(res);
|
376
383
|
}
|
377
384
|
return middlewareResponse.noContent(res);
|
378
385
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/server/dev/middleware-webpack.ts"],"sourcesContent":["import { constants as FS, promises as fs } from 'fs'\nimport { findSourceMap, type SourceMap } from 'module'\nimport path from 'path'\nimport { fileURLToPath, pathToFileURL } from 'url'\nimport {\n SourceMapConsumer,\n type BasicSourceMapConsumer,\n} from 'next/dist/compiled/source-map08'\nimport type { StackFrame } from 'next/dist/compiled/stacktrace-parser'\nimport { getSourceMapFromFile } from './get-source-map-from-file'\nimport { launchEditor } from '../../next-devtools/server/launch-editor'\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'\nexport { getSourceMapFromFile }\n\nimport type { IncomingMessage, ServerResponse } from 'http'\nimport type webpack from 'webpack'\nimport type {\n NullableMappedPosition,\n RawSourceMap,\n} from 'next/dist/compiled/source-map08'\nimport { formatFrameSourceFile } from '../../next-devtools/shared/webpack-module-path'\nimport type { MappedPosition } from 'source-map'\nimport { inspect } from 'util'\n\nfunction shouldIgnoreSource(sourceURL: string): boolean {\n return (\n sourceURL.includes('node_modules') ||\n // Only relevant for when Next.js is symlinked e.g. in the Next.js monorepo\n sourceURL.includes('next/dist') ||\n sourceURL.startsWith('node:')\n )\n}\n\ntype IgnoredSources = Array<{ url: string; ignored: boolean }>\n\nexport interface IgnorableStackFrame extends StackFrame {\n ignored: boolean\n}\n\ntype SourceAttributes = {\n sourcePosition: NullableMappedPosition\n sourceContent: string | null\n}\n\ntype Source =\n | {\n type: 'file'\n sourceMap: RawSourceMap\n ignoredSources: IgnoredSources\n moduleURL: string\n }\n | {\n type: 'bundle'\n sourceMap: RawSourceMap\n ignoredSources: IgnoredSources\n compilation: webpack.Compilation\n moduleId: string\n moduleURL: string\n }\n\nfunction getModuleById(\n id: string | undefined,\n compilation: webpack.Compilation\n) {\n const { chunkGraph, modules } = compilation\n\n return [...modules].find((module) => chunkGraph.getModuleId(module) === id)\n}\n\nfunction findModuleNotFoundFromError(errorMessage: string | undefined) {\n return errorMessage?.match(/'([^']+)' module/)?.[1]\n}\n\nfunction getSourcePath(source: string) {\n if (source.startsWith('file://')) {\n return fileURLToPath(source)\n }\n return source.replace(/^(webpack:\\/\\/\\/|webpack:\\/\\/|webpack:\\/\\/_N_E\\/)/, '')\n}\n\n/**\n * @returns 1-based lines and 0-based columns\n */\nasync function findOriginalSourcePositionAndContent(\n sourceMap: RawSourceMap,\n position: { lineNumber: number | null; column: number | null }\n): Promise<SourceAttributes | null> {\n let consumer: BasicSourceMapConsumer\n try {\n consumer = await new SourceMapConsumer(sourceMap)\n } catch (cause) {\n throw new Error(\n `${sourceMap.file}: Invalid source map. Only conformant source maps can be used to find the original code.`,\n { cause }\n )\n }\n\n try {\n const sourcePosition = consumer.originalPositionFor({\n line: position.lineNumber ?? 1,\n // 0-based columns out requires 0-based columns in.\n column: (position.column ?? 1) - 1,\n })\n\n if (!sourcePosition.source) {\n return null\n }\n\n const sourceContent: string | null =\n consumer.sourceContentFor(\n sourcePosition.source,\n /* returnNullOnMissing */ true\n ) ?? null\n\n return {\n sourcePosition,\n sourceContent,\n }\n } finally {\n consumer.destroy()\n }\n}\n\nexport function getIgnoredSources(\n sourceMap: RawSourceMap & { ignoreList?: number[] }\n): IgnoredSources {\n const ignoreList = new Set<number>(sourceMap.ignoreList ?? [])\n const moduleFilenames = sourceMap?.sources ?? []\n\n for (let index = 0; index < moduleFilenames.length; index++) {\n // bundlerFilePath case: webpack://./app/page.tsx\n const webpackSourceURL = moduleFilenames[index]\n // Format the path to the normal file path\n const formattedFilePath = formatFrameSourceFile(webpackSourceURL)\n if (shouldIgnoreSource(formattedFilePath)) {\n ignoreList.add(index)\n }\n }\n\n const ignoredSources = sourceMap.sources.map((source, index) => {\n return {\n url: source,\n ignored: ignoreList.has(sourceMap.sources.indexOf(source)),\n content: sourceMap.sourcesContent?.[index] ?? null,\n }\n })\n return ignoredSources\n}\n\nfunction isIgnoredSource(\n source: Source,\n sourcePosition: MappedPosition | NullableMappedPosition\n) {\n if (sourcePosition.source == null) {\n return true\n }\n for (const ignoredSource of source.ignoredSources) {\n if (ignoredSource.ignored && ignoredSource.url === sourcePosition.source) {\n return true\n }\n }\n\n return false\n}\n\nfunction findOriginalSourcePositionAndContentFromCompilation(\n moduleId: string | undefined,\n importedModule: string,\n compilation: webpack.Compilation\n): SourceAttributes | null {\n const module = getModuleById(moduleId, compilation)\n return module?.buildInfo?.importLocByPath?.get(importedModule) ?? null\n}\n\nexport async function createOriginalStackFrame({\n source,\n rootDirectory,\n frame,\n errorMessage,\n}: {\n source: Source\n rootDirectory: string\n frame: StackFrame\n errorMessage?: string\n}): Promise<OriginalStackFrameResponse | null> {\n const moduleNotFound = findModuleNotFoundFromError(errorMessage)\n const result = await (() => {\n if (moduleNotFound) {\n if (source.type === 'file') {\n return undefined\n }\n\n return findOriginalSourcePositionAndContentFromCompilation(\n source.moduleId,\n moduleNotFound,\n source.compilation\n )\n }\n return findOriginalSourcePositionAndContent(source.sourceMap, frame)\n })()\n\n if (!result) {\n return null\n }\n const { sourcePosition, sourceContent } = result\n\n if (!sourcePosition.source) {\n return null\n }\n\n const ignored =\n isIgnoredSource(source, sourcePosition) ||\n // If the source file is externals, should be excluded even it's not ignored source.\n // e.g. webpack://next/dist/.. needs to be ignored\n shouldIgnoreSource(source.moduleURL)\n\n const sourcePath = getSourcePath(\n // When sourcePosition.source is the loader path the modulePath is generally better.\n (sourcePosition.source!.includes('|')\n ? source.moduleURL\n : sourcePosition.source) || source.moduleURL\n )\n const filePath = path.resolve(rootDirectory, sourcePath)\n const resolvedFilePath = path.relative(rootDirectory, filePath)\n\n const traced: IgnorableStackFrame = {\n file: resolvedFilePath,\n lineNumber: sourcePosition.line,\n column: (sourcePosition.column ?? 0) + 1,\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 // default is not a valid identifier in JS so webpack uses a custom variable when it's an unnamed default export\n // Resolve it back to `default` for the method name if the source position didn't have the method.\n frame.methodName\n ?.replace('__WEBPACK_DEFAULT_EXPORT__', 'default')\n ?.replace('__webpack_exports__.', ''),\n arguments: [],\n ignored,\n }\n\n return {\n originalStackFrame: traced,\n originalCodeFrame: getOriginalCodeFrame(traced, sourceContent),\n }\n}\n\nasync function getSourceMapFromCompilation(\n id: string,\n compilation: webpack.Compilation\n): Promise<RawSourceMap | undefined> {\n try {\n const module = getModuleById(id, compilation)\n\n if (!module) {\n return undefined\n }\n\n // @ts-expect-error The types for `CodeGenerationResults.get` require a\n // runtime to be passed as second argument, but apparently it also works\n // without it.\n const codeGenerationResult = compilation.codeGenerationResults.get(module)\n const source = codeGenerationResult?.sources.get('javascript')\n\n return source?.map() ?? undefined\n } catch (err) {\n console.error(`Failed to lookup module by ID (\"${id}\"):`, err)\n return undefined\n }\n}\n\nasync function getSource(\n sourceURL: string,\n options: {\n getCompilations: () => webpack.Compilation[]\n }\n): Promise<Source | undefined> {\n const { getCompilations } = options\n\n // Rspack is now using file:// URLs for source maps. Remove the rsc prefix to produce the file:/// url.\n sourceURL = sourceURL.replace(/(.*)\\/(?=file:\\/\\/)/, '')\n\n let nativeSourceMap: SourceMap | undefined\n try {\n nativeSourceMap = findSourceMap(sourceURL)\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 (nativeSourceMap !== undefined) {\n const sourceMapPayload = nativeSourceMap.payload\n return {\n type: 'file',\n sourceMap: sourceMapPayload,\n ignoredSources: getIgnoredSources(sourceMapPayload),\n moduleURL: sourceURL,\n }\n }\n\n if (path.isAbsolute(sourceURL)) {\n sourceURL = pathToFileURL(sourceURL).href\n }\n\n if (sourceURL.startsWith('file:')) {\n const sourceMap = await getSourceMapFromFile(sourceURL)\n return sourceMap\n ? {\n type: 'file',\n sourceMap,\n ignoredSources: getIgnoredSources(sourceMap),\n moduleURL: sourceURL,\n }\n : undefined\n }\n\n // webpack-internal:///./src/hello.tsx => ./src/hello.tsx\n // rsc://React/Server/webpack-internal:///(rsc)/./src/hello.tsx?42 => (rsc)/./src/hello.tsx\n // webpack://_N_E/./src/hello.tsx => ./src/hello.tsx\n const moduleId = sourceURL\n .replace(\n /^(rsc:\\/\\/React\\/[^/]+\\/)?(webpack-internal:\\/\\/\\/|webpack:\\/\\/(_N_E\\/)?)/,\n ''\n )\n .replace(/\\?\\d+$/, '')\n\n // (rsc)/./src/hello.tsx => ./src/hello.tsx\n const moduleURL = moduleId.replace(/^(\\(.*\\)\\/?)/, '')\n\n for (const compilation of getCompilations()) {\n const sourceMap = await getSourceMapFromCompilation(moduleId, compilation)\n\n if (sourceMap) {\n const ignoredSources = getIgnoredSources(sourceMap)\n return {\n type: 'bundle',\n sourceMap,\n compilation,\n moduleId,\n moduleURL,\n ignoredSources,\n }\n }\n }\n\n return undefined\n}\n\nfunction getOriginalStackFrames({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frames,\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n}: {\n isServer: boolean\n isEdgeServer: boolean\n isAppDirectory: boolean\n frames: StackFrame[]\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n rootDirectory: string\n}): Promise<OriginalStackFramesResponse> {\n return Promise.all(\n frames.map(\n (frame): Promise<OriginalStackFramesResponse[number]> =>\n getOriginalStackFrame({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frame,\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n }).then(\n (value) => {\n return {\n status: 'fulfilled',\n value,\n }\n },\n (reason) => {\n return {\n status: 'rejected',\n reason: inspect(reason, { colors: false }),\n }\n }\n )\n )\n )\n}\n\nasync function getOriginalStackFrame({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frame,\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n}: {\n isServer: boolean\n isEdgeServer: boolean\n isAppDirectory: boolean\n frame: StackFrame\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n rootDirectory: string\n}): Promise<OriginalStackFrameResponse> {\n const filename = frame.file ?? ''\n const source = await getSource(filename, {\n getCompilations: () => {\n const compilations: webpack.Compilation[] = []\n\n // Try Client Compilation first. In `pages` we leverage\n // `isClientError` to check. In `app` it depends on if it's a server\n // / client component and when the code throws. E.g. during HTML\n // rendering it's the server/edge compilation.\n if ((!isEdgeServer && !isServer) || isAppDirectory) {\n const compilation = clientStats()?.compilation\n\n if (compilation) {\n compilations.push(compilation)\n }\n }\n\n // Try Server Compilation. In `pages` this could be something\n // imported in getServerSideProps/getStaticProps as the code for\n // those is tree-shaken. In `app` this finds server components and\n // code that was imported from a server component. It also covers\n // when client component code throws during HTML rendering.\n if (isServer || isAppDirectory) {\n const compilation = serverStats()?.compilation\n\n if (compilation) {\n compilations.push(compilation)\n }\n }\n\n // Try Edge Server Compilation. Both cases are the same as Server\n // Compilation, main difference is that it covers `runtime: 'edge'`\n // pages/app routes.\n if (isEdgeServer || isAppDirectory) {\n const compilation = edgeServerStats()?.compilation\n\n if (compilation) {\n compilations.push(compilation)\n }\n }\n\n return compilations\n },\n })\n\n let defaultNormalizedStackFrameLocation = frame.file\n if (\n defaultNormalizedStackFrameLocation !== null &&\n defaultNormalizedStackFrameLocation.startsWith('file://')\n ) {\n defaultNormalizedStackFrameLocation = path.relative(\n rootDirectory,\n fileURLToPath(defaultNormalizedStackFrameLocation)\n )\n }\n // This stack frame is used for the one that couldn't locate the source or source mapped frame\n const defaultStackFrame: IgnorableStackFrame = {\n file: defaultNormalizedStackFrameLocation,\n lineNumber: frame.lineNumber,\n column: frame.column ?? 1,\n methodName: frame.methodName,\n ignored: shouldIgnoreSource(filename),\n arguments: [],\n }\n if (!source) {\n // return original stack frame with no source map\n return {\n originalStackFrame: defaultStackFrame,\n originalCodeFrame: null,\n }\n }\n\n const originalStackFrameResponse = await createOriginalStackFrame({\n frame,\n source,\n rootDirectory,\n })\n\n if (!originalStackFrameResponse) {\n return {\n originalStackFrame: defaultStackFrame,\n originalCodeFrame: null,\n }\n }\n\n return originalStackFrameResponse\n}\n\nexport function getOverlayMiddleware(options: {\n rootDirectory: string\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n}) {\n const { rootDirectory, clientStats, serverStats, edgeServerStats } = options\n\n return async function (\n req: IncomingMessage,\n res: ServerResponse,\n next: () => void\n ): Promise<void> {\n const { pathname, searchParams } = new URL(`http://n${req.url}`)\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 try {\n const { frames, isServer, isEdgeServer, isAppDirectory } = JSON.parse(\n body\n ) as OriginalStackFramesRequest\n\n return middlewareResponse.json(\n res,\n await getOriginalStackFrames({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frames: frames.map((frame) => ({\n ...frame,\n lineNumber: frame.lineNumber ?? 0,\n column: frame.column ?? 0,\n })),\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n })\n )\n } catch (err) {\n return middlewareResponse.badRequest(res)\n }\n } else if (pathname === '/__nextjs_launch-editor') {\n const frame = {\n file: searchParams.get('file') as string,\n methodName: searchParams.get('methodName') as string,\n lineNumber: parseInt(searchParams.get('lineNumber') ?? '0', 10) || 0,\n column: parseInt(searchParams.get('column') ?? '0', 10) || 0,\n arguments: searchParams.getAll('arguments').filter(Boolean),\n } satisfies StackFrame\n\n if (!frame.file) return middlewareResponse.badRequest(res)\n\n // frame files may start with their webpack layer, like (middleware)/middleware.js\n const filePath = path.resolve(\n rootDirectory,\n frame.file.replace(/^\\([^)]+\\)\\//, '')\n )\n const fileExists = await fs.access(filePath, FS.F_OK).then(\n () => true,\n () => false\n )\n if (!fileExists) return middlewareResponse.notFound(res)\n\n try {\n launchEditor(filePath, frame.lineNumber, frame.column ?? 1)\n } catch (err) {\n console.log('Failed to launch editor:', err)\n return middlewareResponse.internalServerError(res)\n }\n\n return middlewareResponse.noContent(res)\n }\n\n return next()\n }\n}\n\nexport function getSourceMapMiddleware(options: {\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n}) {\n const { clientStats, serverStats, edgeServerStats } = options\n\n return async function (\n req: IncomingMessage,\n res: ServerResponse,\n next: () => void\n ): Promise<void> {\n const { pathname, searchParams } = new URL(`http://n${req.url}`)\n\n if (pathname !== '/__nextjs_source-map') {\n return next()\n }\n\n const filename = searchParams.get('filename')\n\n if (!filename) {\n return middlewareResponse.badRequest(res)\n }\n\n let source: Source | undefined\n\n try {\n source = await getSource(filename, {\n getCompilations: () => {\n const compilations: webpack.Compilation[] = []\n\n for (const stats of [\n clientStats(),\n serverStats(),\n edgeServerStats(),\n ]) {\n if (stats?.compilation) {\n compilations.push(stats.compilation)\n }\n }\n\n return compilations\n },\n })\n } catch (error) {\n return middlewareResponse.internalServerError(res, error)\n }\n\n if (!source) {\n return middlewareResponse.noContent(res)\n }\n\n return middlewareResponse.json(res, source.sourceMap)\n }\n}\n"],"names":["constants","FS","promises","fs","findSourceMap","path","fileURLToPath","pathToFileURL","SourceMapConsumer","getSourceMapFromFile","launchEditor","getOriginalCodeFrame","middlewareResponse","formatFrameSourceFile","inspect","shouldIgnoreSource","sourceURL","includes","startsWith","getModuleById","id","compilation","chunkGraph","modules","find","module","getModuleId","findModuleNotFoundFromError","errorMessage","match","getSourcePath","source","replace","findOriginalSourcePositionAndContent","sourceMap","position","consumer","cause","Error","file","sourcePosition","originalPositionFor","line","lineNumber","column","sourceContent","sourceContentFor","destroy","getIgnoredSources","ignoreList","Set","moduleFilenames","sources","index","length","webpackSourceURL","formattedFilePath","add","ignoredSources","map","url","ignored","has","indexOf","content","sourcesContent","isIgnoredSource","ignoredSource","findOriginalSourcePositionAndContentFromCompilation","moduleId","importedModule","buildInfo","importLocByPath","get","createOriginalStackFrame","rootDirectory","frame","moduleNotFound","result","type","undefined","moduleURL","sourcePath","filePath","resolve","resolvedFilePath","relative","traced","methodName","arguments","originalStackFrame","originalCodeFrame","getSourceMapFromCompilation","codeGenerationResult","codeGenerationResults","err","console","error","getSource","options","getCompilations","nativeSourceMap","sourceMapPayload","payload","isAbsolute","href","getOriginalStackFrames","isServer","isEdgeServer","isAppDirectory","frames","clientStats","serverStats","edgeServerStats","Promise","all","getOriginalStackFrame","then","value","status","reason","colors","filename","compilations","push","defaultNormalizedStackFrameLocation","defaultStackFrame","originalStackFrameResponse","getOverlayMiddleware","req","res","next","pathname","searchParams","URL","method","badRequest","body","reject","data","on","chunk","JSON","parse","json","parseInt","getAll","filter","Boolean","fileExists","access","F_OK","notFound","log","internalServerError","noContent","getSourceMapMiddleware","stats"],"mappings":"AAAA,SAASA,aAAaC,EAAE,EAAEC,YAAYC,EAAE,QAAQ,KAAI;AACpD,SAASC,aAAa,QAAwB,SAAQ;AACtD,OAAOC,UAAU,OAAM;AACvB,SAASC,aAAa,EAAEC,aAAa,QAAQ,MAAK;AAClD,SACEC,iBAAiB,QAEZ,kCAAiC;AAExC,SAASC,oBAAoB,QAAQ,6BAA4B;AACjE,SAASC,YAAY,QAAQ,2CAA0C;AACvE,SACEC,oBAAoB,QAIf,oCAAmC;AAC1C,SAASC,kBAAkB,QAAQ,iDAAgD;AACnF,SAASH,oBAAoB,GAAE;AAQ/B,SAASI,qBAAqB,QAAQ,iDAAgD;AAEtF,SAASC,OAAO,QAAQ,OAAM;AAE9B,SAASC,mBAAmBC,SAAiB;IAC3C,OACEA,UAAUC,QAAQ,CAAC,mBACnB,2EAA2E;IAC3ED,UAAUC,QAAQ,CAAC,gBACnBD,UAAUE,UAAU,CAAC;AAEzB;AA6BA,SAASC,cACPC,EAAsB,EACtBC,WAAgC;IAEhC,MAAM,EAAEC,UAAU,EAAEC,OAAO,EAAE,GAAGF;IAEhC,OAAO;WAAIE;KAAQ,CAACC,IAAI,CAAC,CAACC,SAAWH,WAAWI,WAAW,CAACD,YAAYL;AAC1E;AAEA,SAASO,4BAA4BC,YAA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E;4BACtBsG,aAAaC,IAAI,CAACiC,MAAMxI,WAAW;wBACrC;oBACF;oBAEA,OAAOsG;gBACT;YACF;QACF,EAAE,OAAO1B,OAAO;YACd,OAAOrF,mBAAmB8I,mBAAmB,CAACxB,KAAKjC;QACrD;QAEA,IAAI,CAAClE,QAAQ;YACX,OAAOnB,mBAAmB+I,SAAS,CAACzB;QACtC;QAEA,OAAOtH,mBAAmBoI,IAAI,CAACd,KAAKnG,OAAOG,SAAS;IACtD;AACF","ignoreList":[0]}
|
1
|
+
{"version":3,"sources":["../../../src/server/dev/middleware-webpack.ts"],"sourcesContent":["import { findSourceMap, type SourceMap } from 'module'\nimport path from 'path'\nimport { fileURLToPath, pathToFileURL } from 'url'\nimport {\n SourceMapConsumer,\n type BasicSourceMapConsumer,\n} from 'next/dist/compiled/source-map08'\nimport type { StackFrame } from 'next/dist/compiled/stacktrace-parser'\nimport { getSourceMapFromFile } from './get-source-map-from-file'\nimport { openFileInEditor } from '../../next-devtools/server/launch-editor'\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'\nexport { getSourceMapFromFile }\n\nimport type { IncomingMessage, ServerResponse } from 'http'\nimport type webpack from 'webpack'\nimport type {\n NullableMappedPosition,\n RawSourceMap,\n} from 'next/dist/compiled/source-map08'\nimport { formatFrameSourceFile } from '../../next-devtools/shared/webpack-module-path'\nimport type { MappedPosition } from 'source-map'\nimport { inspect } from 'util'\n\nfunction shouldIgnoreSource(sourceURL: string): boolean {\n return (\n sourceURL.includes('node_modules') ||\n // Only relevant for when Next.js is symlinked e.g. in the Next.js monorepo\n sourceURL.includes('next/dist') ||\n sourceURL.startsWith('node:')\n )\n}\n\ntype IgnoredSources = Array<{ url: string; ignored: boolean }>\n\nexport interface IgnorableStackFrame extends StackFrame {\n ignored: boolean\n}\n\ntype SourceAttributes = {\n sourcePosition: NullableMappedPosition\n sourceContent: string | null\n}\n\ntype Source =\n | {\n type: 'file'\n sourceMap: RawSourceMap\n ignoredSources: IgnoredSources\n moduleURL: string\n }\n | {\n type: 'bundle'\n sourceMap: RawSourceMap\n ignoredSources: IgnoredSources\n compilation: webpack.Compilation\n moduleId: string\n moduleURL: string\n }\n\nfunction getModuleById(\n id: string | undefined,\n compilation: webpack.Compilation\n) {\n const { chunkGraph, modules } = compilation\n\n return [...modules].find((module) => chunkGraph.getModuleId(module) === id)\n}\n\nfunction findModuleNotFoundFromError(errorMessage: string | undefined) {\n return errorMessage?.match(/'([^']+)' module/)?.[1]\n}\n\nfunction getSourcePath(source: string) {\n if (source.startsWith('file://')) {\n return fileURLToPath(source)\n }\n return source.replace(/^(webpack:\\/\\/\\/|webpack:\\/\\/|webpack:\\/\\/_N_E\\/)/, '')\n}\n\n/**\n * @returns 1-based lines and 0-based columns\n */\nasync function findOriginalSourcePositionAndContent(\n sourceMap: RawSourceMap,\n position: { lineNumber: number | null; column: number | null }\n): Promise<SourceAttributes | null> {\n let consumer: BasicSourceMapConsumer\n try {\n consumer = await new SourceMapConsumer(sourceMap)\n } catch (cause) {\n throw new Error(\n `${sourceMap.file}: Invalid source map. Only conformant source maps can be used to find the original code.`,\n { cause }\n )\n }\n\n try {\n const sourcePosition = consumer.originalPositionFor({\n line: position.lineNumber ?? 1,\n // 0-based columns out requires 0-based columns in.\n column: (position.column ?? 1) - 1,\n })\n\n if (!sourcePosition.source) {\n return null\n }\n\n const sourceContent: string | null =\n consumer.sourceContentFor(\n sourcePosition.source,\n /* returnNullOnMissing */ true\n ) ?? null\n\n return {\n sourcePosition,\n sourceContent,\n }\n } finally {\n consumer.destroy()\n }\n}\n\nexport function getIgnoredSources(\n sourceMap: RawSourceMap & { ignoreList?: number[] }\n): IgnoredSources {\n const ignoreList = new Set<number>(sourceMap.ignoreList ?? [])\n const moduleFilenames = sourceMap?.sources ?? []\n\n for (let index = 0; index < moduleFilenames.length; index++) {\n // bundlerFilePath case: webpack://./app/page.tsx\n const webpackSourceURL = moduleFilenames[index]\n // Format the path to the normal file path\n const formattedFilePath = formatFrameSourceFile(webpackSourceURL)\n if (shouldIgnoreSource(formattedFilePath)) {\n ignoreList.add(index)\n }\n }\n\n const ignoredSources = sourceMap.sources.map((source, index) => {\n return {\n url: source,\n ignored: ignoreList.has(sourceMap.sources.indexOf(source)),\n content: sourceMap.sourcesContent?.[index] ?? null,\n }\n })\n return ignoredSources\n}\n\nfunction isIgnoredSource(\n source: Source,\n sourcePosition: MappedPosition | NullableMappedPosition\n) {\n if (sourcePosition.source == null) {\n return true\n }\n for (const ignoredSource of source.ignoredSources) {\n if (ignoredSource.ignored && ignoredSource.url === sourcePosition.source) {\n return true\n }\n }\n\n return false\n}\n\nfunction findOriginalSourcePositionAndContentFromCompilation(\n moduleId: string | undefined,\n importedModule: string,\n compilation: webpack.Compilation\n): SourceAttributes | null {\n const module = getModuleById(moduleId, compilation)\n return module?.buildInfo?.importLocByPath?.get(importedModule) ?? null\n}\n\nexport async function createOriginalStackFrame({\n source,\n rootDirectory,\n frame,\n errorMessage,\n}: {\n source: Source\n rootDirectory: string\n frame: StackFrame\n errorMessage?: string\n}): Promise<OriginalStackFrameResponse | null> {\n const moduleNotFound = findModuleNotFoundFromError(errorMessage)\n const result = await (() => {\n if (moduleNotFound) {\n if (source.type === 'file') {\n return undefined\n }\n\n return findOriginalSourcePositionAndContentFromCompilation(\n source.moduleId,\n moduleNotFound,\n source.compilation\n )\n }\n return findOriginalSourcePositionAndContent(source.sourceMap, frame)\n })()\n\n if (!result) {\n return null\n }\n const { sourcePosition, sourceContent } = result\n\n if (!sourcePosition.source) {\n return null\n }\n\n const ignored =\n isIgnoredSource(source, sourcePosition) ||\n // If the source file is externals, should be excluded even it's not ignored source.\n // e.g. webpack://next/dist/.. needs to be ignored\n shouldIgnoreSource(source.moduleURL)\n\n const sourcePath = getSourcePath(\n // When sourcePosition.source is the loader path the modulePath is generally better.\n (sourcePosition.source!.includes('|')\n ? source.moduleURL\n : sourcePosition.source) || source.moduleURL\n )\n const filePath = path.resolve(rootDirectory, sourcePath)\n const resolvedFilePath = path.relative(rootDirectory, filePath)\n\n const traced: IgnorableStackFrame = {\n file: resolvedFilePath,\n lineNumber: sourcePosition.line,\n column: (sourcePosition.column ?? 0) + 1,\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 // default is not a valid identifier in JS so webpack uses a custom variable when it's an unnamed default export\n // Resolve it back to `default` for the method name if the source position didn't have the method.\n frame.methodName\n ?.replace('__WEBPACK_DEFAULT_EXPORT__', 'default')\n ?.replace('__webpack_exports__.', ''),\n arguments: [],\n ignored,\n }\n\n return {\n originalStackFrame: traced,\n originalCodeFrame: getOriginalCodeFrame(traced, sourceContent),\n }\n}\n\nasync function getSourceMapFromCompilation(\n id: string,\n compilation: webpack.Compilation\n): Promise<RawSourceMap | undefined> {\n try {\n const module = getModuleById(id, compilation)\n\n if (!module) {\n return undefined\n }\n\n // @ts-expect-error The types for `CodeGenerationResults.get` require a\n // runtime to be passed as second argument, but apparently it also works\n // without it.\n const codeGenerationResult = compilation.codeGenerationResults.get(module)\n const source = codeGenerationResult?.sources.get('javascript')\n\n return source?.map() ?? undefined\n } catch (err) {\n console.error(`Failed to lookup module by ID (\"${id}\"):`, err)\n return undefined\n }\n}\n\nasync function getSource(\n sourceURL: string,\n options: {\n getCompilations: () => webpack.Compilation[]\n }\n): Promise<Source | undefined> {\n const { getCompilations } = options\n\n // Rspack is now using file:// URLs for source maps. Remove the rsc prefix to produce the file:/// url.\n sourceURL = sourceURL.replace(/(.*)\\/(?=file:\\/\\/)/, '')\n\n let nativeSourceMap: SourceMap | undefined\n try {\n nativeSourceMap = findSourceMap(sourceURL)\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 (nativeSourceMap !== undefined) {\n const sourceMapPayload = nativeSourceMap.payload\n return {\n type: 'file',\n sourceMap: sourceMapPayload,\n ignoredSources: getIgnoredSources(sourceMapPayload),\n moduleURL: sourceURL,\n }\n }\n\n if (path.isAbsolute(sourceURL)) {\n sourceURL = pathToFileURL(sourceURL).href\n }\n\n if (sourceURL.startsWith('file:')) {\n const sourceMap = await getSourceMapFromFile(sourceURL)\n return sourceMap\n ? {\n type: 'file',\n sourceMap,\n ignoredSources: getIgnoredSources(sourceMap),\n moduleURL: sourceURL,\n }\n : undefined\n }\n\n // webpack-internal:///./src/hello.tsx => ./src/hello.tsx\n // rsc://React/Server/webpack-internal:///(rsc)/./src/hello.tsx?42 => (rsc)/./src/hello.tsx\n // webpack://_N_E/./src/hello.tsx => ./src/hello.tsx\n const moduleId = sourceURL\n .replace(\n /^(rsc:\\/\\/React\\/[^/]+\\/)?(webpack-internal:\\/\\/\\/|webpack:\\/\\/(_N_E\\/)?)/,\n ''\n )\n .replace(/\\?\\d+$/, '')\n\n // (rsc)/./src/hello.tsx => ./src/hello.tsx\n const moduleURL = moduleId.replace(/^(\\(.*\\)\\/?)/, '')\n\n for (const compilation of getCompilations()) {\n const sourceMap = await getSourceMapFromCompilation(moduleId, compilation)\n\n if (sourceMap) {\n const ignoredSources = getIgnoredSources(sourceMap)\n return {\n type: 'bundle',\n sourceMap,\n compilation,\n moduleId,\n moduleURL,\n ignoredSources,\n }\n }\n }\n\n return undefined\n}\n\nfunction getOriginalStackFrames({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frames,\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n}: {\n isServer: boolean\n isEdgeServer: boolean\n isAppDirectory: boolean\n frames: StackFrame[]\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n rootDirectory: string\n}): Promise<OriginalStackFramesResponse> {\n return Promise.all(\n frames.map(\n (frame): Promise<OriginalStackFramesResponse[number]> =>\n getOriginalStackFrame({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frame,\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n }).then(\n (value) => {\n return {\n status: 'fulfilled',\n value,\n }\n },\n (reason) => {\n return {\n status: 'rejected',\n reason: inspect(reason, { colors: false }),\n }\n }\n )\n )\n )\n}\n\nasync function getOriginalStackFrame({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frame,\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n}: {\n isServer: boolean\n isEdgeServer: boolean\n isAppDirectory: boolean\n frame: StackFrame\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n rootDirectory: string\n}): Promise<OriginalStackFrameResponse> {\n const filename = frame.file ?? ''\n const source = await getSource(filename, {\n getCompilations: () => {\n const compilations: webpack.Compilation[] = []\n\n // Try Client Compilation first. In `pages` we leverage\n // `isClientError` to check. In `app` it depends on if it's a server\n // / client component and when the code throws. E.g. during HTML\n // rendering it's the server/edge compilation.\n if ((!isEdgeServer && !isServer) || isAppDirectory) {\n const compilation = clientStats()?.compilation\n\n if (compilation) {\n compilations.push(compilation)\n }\n }\n\n // Try Server Compilation. In `pages` this could be something\n // imported in getServerSideProps/getStaticProps as the code for\n // those is tree-shaken. In `app` this finds server components and\n // code that was imported from a server component. It also covers\n // when client component code throws during HTML rendering.\n if (isServer || isAppDirectory) {\n const compilation = serverStats()?.compilation\n\n if (compilation) {\n compilations.push(compilation)\n }\n }\n\n // Try Edge Server Compilation. Both cases are the same as Server\n // Compilation, main difference is that it covers `runtime: 'edge'`\n // pages/app routes.\n if (isEdgeServer || isAppDirectory) {\n const compilation = edgeServerStats()?.compilation\n\n if (compilation) {\n compilations.push(compilation)\n }\n }\n\n return compilations\n },\n })\n\n let defaultNormalizedStackFrameLocation = frame.file\n if (\n defaultNormalizedStackFrameLocation !== null &&\n defaultNormalizedStackFrameLocation.startsWith('file://')\n ) {\n defaultNormalizedStackFrameLocation = path.relative(\n rootDirectory,\n fileURLToPath(defaultNormalizedStackFrameLocation)\n )\n }\n // This stack frame is used for the one that couldn't locate the source or source mapped frame\n const defaultStackFrame: IgnorableStackFrame = {\n file: defaultNormalizedStackFrameLocation,\n lineNumber: frame.lineNumber,\n column: frame.column ?? 1,\n methodName: frame.methodName,\n ignored: shouldIgnoreSource(filename),\n arguments: [],\n }\n if (!source) {\n // return original stack frame with no source map\n return {\n originalStackFrame: defaultStackFrame,\n originalCodeFrame: null,\n }\n }\n\n const originalStackFrameResponse = await createOriginalStackFrame({\n frame,\n source,\n rootDirectory,\n })\n\n if (!originalStackFrameResponse) {\n return {\n originalStackFrame: defaultStackFrame,\n originalCodeFrame: null,\n }\n }\n\n return originalStackFrameResponse\n}\n\nexport function getOverlayMiddleware(options: {\n rootDirectory: string\n isSrcDir: boolean\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n}) {\n const { rootDirectory, isSrcDir, clientStats, serverStats, edgeServerStats } =\n options\n\n return async function (\n req: IncomingMessage,\n res: ServerResponse,\n next: () => void\n ): Promise<void> {\n const { pathname, searchParams } = new URL(`http://n${req.url}`)\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 try {\n const { frames, isServer, isEdgeServer, isAppDirectory } = JSON.parse(\n body\n ) as OriginalStackFramesRequest\n\n return middlewareResponse.json(\n res,\n await getOriginalStackFrames({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frames: frames.map((frame) => ({\n ...frame,\n lineNumber: frame.lineNumber ?? 0,\n column: frame.column ?? 0,\n })),\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n })\n )\n } catch (err) {\n return middlewareResponse.badRequest(res)\n }\n } else if (pathname === '/__nextjs_launch-editor') {\n const frame = {\n file: searchParams.get('file') as string,\n methodName: searchParams.get('methodName') as string,\n lineNumber: parseInt(searchParams.get('lineNumber') ?? '0', 10) || 0,\n column: parseInt(searchParams.get('column') ?? '0', 10) || 0,\n arguments: searchParams.getAll('arguments').filter(Boolean),\n } satisfies StackFrame\n\n if (!frame.file) return middlewareResponse.badRequest(res)\n\n let openEditorResult\n const isAppRelativePath = searchParams.get('isAppRelativePath') === '1'\n if (isAppRelativePath) {\n const relativeFilePath = searchParams.get('file') || ''\n const absoluteFilePath = path.join(\n rootDirectory,\n 'app',\n isSrcDir ? 'src' : '',\n relativeFilePath\n )\n openEditorResult = await openFileInEditor(absoluteFilePath, 1, 1)\n } else {\n // frame files may start with their webpack layer, like (middleware)/middleware.js\n const filePath = path.resolve(\n rootDirectory,\n frame.file.replace(/^\\([^)]+\\)\\//, '')\n )\n openEditorResult = await openFileInEditor(\n filePath,\n frame.lineNumber,\n frame.column ?? 1\n )\n }\n if (openEditorResult.error) {\n console.error('Failed to launch editor:', openEditorResult.error)\n return middlewareResponse.internalServerError(\n res,\n openEditorResult.error\n )\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(options: {\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n}) {\n const { clientStats, serverStats, edgeServerStats } = options\n\n return async function (\n req: IncomingMessage,\n res: ServerResponse,\n next: () => void\n ): Promise<void> {\n const { pathname, searchParams } = new URL(`http://n${req.url}`)\n\n if (pathname !== '/__nextjs_source-map') {\n return next()\n }\n\n const filename = searchParams.get('filename')\n\n if (!filename) {\n return middlewareResponse.badRequest(res)\n }\n\n let source: Source | undefined\n\n try {\n source = await getSource(filename, {\n getCompilations: () => {\n const compilations: webpack.Compilation[] = []\n\n for (const stats of [\n clientStats(),\n serverStats(),\n edgeServerStats(),\n ]) {\n if (stats?.compilation) {\n compilations.push(stats.compilation)\n }\n }\n\n return compilations\n },\n })\n } catch (error) {\n return middlewareResponse.internalServerError(res, error)\n }\n\n if (!source) {\n return middlewareResponse.noContent(res)\n }\n\n return middlewareResponse.json(res, source.sourceMap)\n }\n}\n"],"names":["findSourceMap","path","fileURLToPath","pathToFileURL","SourceMapConsumer","getSourceMapFromFile","openFileInEditor","getOriginalCodeFrame","middlewareResponse","formatFrameSourceFile","inspect","shouldIgnoreSource","sourceURL","includes","startsWith","getModuleById","id","compilation","chunkGraph","modules","find","module","getModuleId","findModuleNotFoundFromError","errorMessage","match","getSourcePath","source","replace","findOriginalSourcePositionAndContent","sourceMap","position","consumer","cause","Error","file","sourcePosition","originalPositionFor","line","lineNumber","column","sourceContent","sourceContentFor","destroy","getIgnoredSources","ignoreList","Set","moduleFilenames","sources","index","length","webpackSourceURL","formattedFilePath","add","ignoredSources","map","url","ignored","has","indexOf","content","sourcesContent","isIgnoredSource","ignoredSource","findOriginalSourcePositionAndContentFromCompilation","moduleId","importedModule","buildInfo","importLocByPath","get","createOriginalStackFrame","rootDirectory","frame","moduleNotFound","result","type","undefined","moduleURL","sourcePath","filePath","resolve","resolvedFilePath","relative","traced","methodName","arguments","originalStackFrame","originalCodeFrame","getSourceMapFromCompilation","codeGenerationResult","codeGenerationResults","err","console","error","getSource","options","getCompilations","nativeSourceMap","sourceMapPayload","payload","isAbsolute","href","getOriginalStackFrames","isServer","isEdgeServer","isAppDirectory","frames","clientStats","serverStats","edgeServerStats","Promise","all","getOriginalStackFrame","then","value","status","reason","colors","filename","compilations","push","defaultNormalizedStackFrameLocation","defaultStackFrame","originalStackFrameResponse","getOverlayMiddleware","isSrcDir","req","res","next","pathname","searchParams","URL","method","badRequest","body","reject","data","on","chunk","JSON","parse","json","parseInt","getAll","filter","Boolean","openEditorResult","isAppRelativePath","relativeFilePath","absoluteFilePath","join","internalServerError","found","notFound","noContent","getSourceMapMiddleware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AQ;YACX,OAAOnB,mBAAmBkJ,SAAS,CAAC3B;QACtC;QAEA,OAAOvH,mBAAmBqI,IAAI,CAACd,KAAKpG,OAAOG,SAAS;IACtD;AACF","ignoreList":[0]}
|
@@ -12,7 +12,7 @@ export function logStartInfo({ networkUrl, appUrl, envInfo, experimentalFeatures
|
|
12
12
|
} else {
|
13
13
|
bundlerSuffix = '';
|
14
14
|
}
|
15
|
-
Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"15.4.0-canary.
|
15
|
+
Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"15.4.0-canary.99"}`))}${bundlerSuffix}`);
|
16
16
|
if (appUrl) {
|
17
17
|
Log.bootstrap(`- Local: ${appUrl}`);
|
18
18
|
}
|
@@ -89,6 +89,7 @@ async function startWatcher(opts) {
|
|
89
89
|
logging: nextConfig.logging !== false
|
90
90
|
});
|
91
91
|
const hotReloader = opts.turbo ? await createHotReloaderTurbopack(opts, serverFields, distDir, resetFetch) : new HotReloaderWebpack(opts.dir, {
|
92
|
+
isSrcDir: opts.isSrcDir,
|
92
93
|
appDir,
|
93
94
|
pagesDir,
|
94
95
|
distDir,
|
@@ -701,7 +702,10 @@ async function startWatcher(opts) {
|
|
701
702
|
}
|
702
703
|
export async function setupDevBundler(opts) {
|
703
704
|
const isSrcDir = path.relative(opts.dir, opts.pagesDir || opts.appDir || '').startsWith('src');
|
704
|
-
const result = await startWatcher(
|
705
|
+
const result = await startWatcher({
|
706
|
+
...opts,
|
707
|
+
isSrcDir
|
708
|
+
});
|
705
709
|
opts.telemetry.record(eventCliSession(path.join(opts.dir, opts.nextConfig.distDir), opts.nextConfig, {
|
706
710
|
webpackVersion: 5,
|
707
711
|
isSrcDir,
|