next 15.2.0-canary.61 → 15.2.0-canary.62

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.

Potentially problematic release.


This version of next might be problematic. Click here for more details.

Files changed (31) hide show
  1. package/dist/bin/next +1 -1
  2. package/dist/build/index.js +2 -2
  3. package/dist/build/swc/index.js +1 -1
  4. package/dist/build/webpack-config.js +2 -2
  5. package/dist/client/app-bootstrap.js +1 -1
  6. package/dist/client/components/react-dev-overlay/server/middleware-turbopack.js +1 -1
  7. package/dist/client/components/react-dev-overlay/server/middleware-turbopack.js.map +1 -1
  8. package/dist/client/index.js +1 -1
  9. package/dist/esm/build/index.js +2 -2
  10. package/dist/esm/build/swc/index.js +1 -1
  11. package/dist/esm/build/webpack-config.js +2 -2
  12. package/dist/esm/client/app-bootstrap.js +1 -1
  13. package/dist/esm/client/components/react-dev-overlay/server/middleware-turbopack.js +1 -1
  14. package/dist/esm/client/components/react-dev-overlay/server/middleware-turbopack.js.map +1 -1
  15. package/dist/esm/client/index.js +1 -1
  16. package/dist/esm/server/config.js +1 -1
  17. package/dist/esm/server/dev/hot-reloader-turbopack.js +3 -3
  18. package/dist/esm/server/dev/hot-reloader-turbopack.js.map +1 -1
  19. package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
  20. package/dist/esm/server/lib/app-info-log.js +1 -1
  21. package/dist/esm/server/lib/start-server.js +1 -1
  22. package/dist/server/config.js +1 -1
  23. package/dist/server/dev/hot-reloader-turbopack.js +3 -3
  24. package/dist/server/dev/hot-reloader-turbopack.js.map +1 -1
  25. package/dist/server/dev/hot-reloader-webpack.js +1 -1
  26. package/dist/server/lib/app-info-log.js +1 -1
  27. package/dist/server/lib/start-server.js +1 -1
  28. package/dist/telemetry/anonymous-meta.js +1 -1
  29. package/dist/telemetry/events/session-stopped.js +2 -2
  30. package/dist/telemetry/events/version.js +2 -2
  31. package/package.json +15 -15
package/dist/bin/next CHANGED
@@ -75,7 +75,7 @@ const program = new NextRootCommand();
75
75
  program.name('next').description('The Next.js CLI allows you to develop, build, start your application, and more.').configureHelp({
76
76
  formatHelp: (cmd, helper)=>(0, _formatclihelpoutput.formatCliHelpOutput)(cmd, helper),
77
77
  subcommandTerm: (cmd)=>`${cmd.name()} ${cmd.usage()}`
78
- }).helpCommand(false).helpOption('-h, --help', 'Displays this message.').version(`Next.js v${"15.2.0-canary.61"}`, '-v, --version', 'Outputs the Next.js version.');
78
+ }).helpCommand(false).helpOption('-h, --help', 'Displays this message.').version(`Next.js v${"15.2.0-canary.62"}`, '-v, --version', 'Outputs the Next.js version.');
79
79
  program.command('build').description('Creates an optimized production build of your application. The output displays information about each route.').argument('[directory]', `A directory on which to build the application. ${(0, _picocolors.italic)('If no directory is provided, the current directory will be used.')}`).option('-d, --debug', 'Enables a more verbose build output.').option('--no-lint', 'Disables linting.').option('--no-mangling', 'Disables mangling.').option('--profile', 'Enables production profiling for React.').option('--experimental-app-only', 'Builds only App Router routes.').addOption(new _commander.Option('--experimental-turbo').hideHelp()).addOption(new _commander.Option('--experimental-build-mode [mode]', 'Uses an experimental build mode.').choices([
80
80
  'compile',
81
81
  'generate'
@@ -364,7 +364,7 @@ async function build(dir, reactProductionProfiling = false, debugOutput = false,
364
364
  const nextBuildSpan = (0, _trace.trace)('next-build', undefined, {
365
365
  buildMode: experimentalBuildMode,
366
366
  isTurboBuild: String(turboNextBuild),
367
- version: "15.2.0-canary.61"
367
+ version: "15.2.0-canary.62"
368
368
  });
369
369
  _buildcontext.NextBuildContext.nextBuildSpan = nextBuildSpan;
370
370
  _buildcontext.NextBuildContext.dir = dir;
@@ -723,7 +723,7 @@ async function build(dir, reactProductionProfiling = false, debugOutput = false,
723
723
  // Files outside of the distDir can be "type": "module"
724
724
  await writeFileUtf8(_path.default.join(distDir, 'package.json'), '{"type": "commonjs"}');
725
725
  // These are written to distDir, so they need to come after creating and cleaning distDr.
726
- await (0, _builddiagnostics.recordFrameworkVersion)("15.2.0-canary.61");
726
+ await (0, _builddiagnostics.recordFrameworkVersion)("15.2.0-canary.62");
727
727
  await (0, _builddiagnostics.updateBuildDiagnostics)({
728
728
  buildStage: 'start'
729
729
  });
@@ -119,7 +119,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
119
119
  }
120
120
  return newObj;
121
121
  }
122
- const nextVersion = "15.2.0-canary.61";
122
+ const nextVersion = "15.2.0-canary.62";
123
123
  const ArchName = (0, _os.arch)();
124
124
  const PlatformName = (0, _os.platform)();
125
125
  function infoLog(...args) {
@@ -1536,7 +1536,7 @@ async function getBaseWebpackConfig(dir, { buildId, encryptionKey, config, compi
1536
1536
  isClient && new _copyfileplugin.CopyFilePlugin({
1537
1537
  // file path to build output of `@next/polyfill-nomodule`
1538
1538
  filePath: require.resolve('./polyfills/polyfill-nomodule'),
1539
- cacheKey: "15.2.0-canary.61",
1539
+ cacheKey: "15.2.0-canary.62",
1540
1540
  name: `static/chunks/polyfills${dev ? '' : '-[hash]'}.js`,
1541
1541
  minimize: false,
1542
1542
  info: {
@@ -1769,7 +1769,7 @@ async function getBaseWebpackConfig(dir, { buildId, encryptionKey, config, compi
1769
1769
  // - Next.js location on disk (some loaders use absolute paths and some resolve options depend on absolute paths)
1770
1770
  // - Next.js version
1771
1771
  // - next.config.js keys that affect compilation
1772
- version: `${__dirname}|${"15.2.0-canary.61"}|${configVars}`,
1772
+ version: `${__dirname}|${"15.2.0-canary.62"}|${configVars}`,
1773
1773
  cacheDirectory: _path.default.join(distDir, 'cache', 'webpack'),
1774
1774
  // For production builds, it's more efficient to compress all cache files together instead of compression each one individually.
1775
1775
  // So we disable compression here and allow the build runner to take care of compressing the cache as a whole.
@@ -13,7 +13,7 @@ Object.defineProperty(exports, "appBootstrap", {
13
13
  return appBootstrap;
14
14
  }
15
15
  });
16
- const version = "15.2.0-canary.61";
16
+ const version = "15.2.0-canary.62";
17
17
  window.next = {
18
18
  version,
19
19
  appDir: true
@@ -79,7 +79,7 @@ async function batchedTraceSource(project, frame) {
79
79
  let source = null;
80
80
  const originalFile = sourceFrame.originalFile;
81
81
  // Don't look up source for node_modules or internals. These can often be large bundled files.
82
- const ignored = shouldIgnorePath(originalFile != null ? originalFile : sourceFrame.file) || // isInternal means resource starts with turbopack://[turbopack]
82
+ const ignored = shouldIgnorePath(originalFile != null ? originalFile : sourceFrame.file) || // isInternal means resource starts with turbopack:///[turbopack]
83
83
  !!sourceFrame.isInternal;
84
84
  if (originalFile && !ignored) {
85
85
  let sourcePromise = currentSourcesByFile.get(originalFile);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/server/middleware-turbopack.ts"],"sourcesContent":["import type { IncomingMessage, ServerResponse } from 'http'\nimport {\n badRequest,\n getOriginalCodeFrame,\n internalServerError,\n json,\n jsonString,\n noContent,\n notFound,\n type OriginalStackFrameResponse,\n type OriginalStackFramesRequest,\n type OriginalStackFramesResponse,\n} from './shared'\n\nimport fs, { constants as FS } from 'fs/promises'\nimport path from 'path'\nimport url from 'url'\nimport { launchEditor } from '../internal/helpers/launchEditor'\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 '../internal/helpers/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()\nexport async 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\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 column: frame.column ?? 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?.startsWith('file://')\n ? relativeToCwd(originalPosition.source)\n : 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\nfunction relativeToCwd(file: string): string {\n const relPath = path.relative(process.cwd(), url.fileURLToPath(file))\n // TODO(sokra) include a ./ here to make it a relative path\n return relPath\n}\n\nasync function createOriginalStackFrame(\n project: Project,\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 return {\n originalStackFrame: traced.frame,\n originalCodeFrame: getOriginalCodeFrame(traced.frame, traced.source),\n }\n}\n\nexport function getOverlayMiddleware(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_original-stack-frames') {\n if (req.method !== 'POST') {\n return 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(project, frame)\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 json(res, result)\n } else if (pathname === '/__nextjs_launch-editor') {\n const frame = createStackFrame(searchParams)\n\n if (!frame) return badRequest(res)\n\n const fileExists = await fs.access(frame.file, FS.F_OK).then(\n () => true,\n () => false\n )\n if (!fileExists) return 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 internalServerError(res)\n }\n\n return 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 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 json(res, sourceMap.payload)\n }\n\n return 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 jsonString(res, sourceMapString)\n }\n\n if (filename.startsWith('file:')) {\n const sourceMap = await getSourceMapFromFile(filename)\n\n if (sourceMap) {\n return json(res, sourceMap)\n }\n }\n } catch (error) {\n console.error('Failed to get source map:', error)\n }\n\n noContent(res)\n }\n}\n"],"names":["batchedTraceSource","getOverlayMiddleware","getSourceMapMiddleware","shouldIgnorePath","modulePath","includes","startsWith","currentSourcesByFile","Map","project","frame","file","decodeURIComponent","undefined","lineNumber","line","column","methodName","ignored","arguments","source","currentDirectoryFileUrl","pathToFileURL","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","findSourceMap","cause","Error","consumer","SourceMapConsumer","traced","originalPosition","originalPositionFor","sourceContent","sourceContentFor","destroy","applicableSourceMap","console","error","sourceIndex","sources","indexOf","ignoreList","originalStackFrame","relativeToCwd","relPath","path","relative","url","fileURLToPath","createOriginalStackFrame","originalCodeFrame","getOriginalCodeFrame","req","res","next","pathname","URL","method","badRequest","Promise","resolve","reject","data","on","chunk","request","JSON","parse","stackFrames","result","all","stackFrame","status","reason","value","inspect","colors","json","fileExists","fs","access","FS","F_OK","then","notFound","launchEditor","err","log","internalServerError","noContent","filename","sourceMap","decodeURI","isAbsolute","sourceMapString","getSourceMap","jsonString","getSourceMapFromFile"],"mappings":";;;;;;;;;;;;;;;;IA0CsBA,kBAAkB;eAAlBA;;IAkUNC,oBAAoB;eAApBA;;IAsEAC,sBAAsB;eAAtBA;;;;;wBAtaT;oEAE6B;+DACnB;8DACD;8BACa;6BAMtB;sCAE8B;4BACgB;yBACvB;0BACN;AAExB,SAASC,iBAAiBC,UAAkB;IAC1C,OACEA,WAAWC,QAAQ,CAAC,mBACpB,2EAA2E;IAC3ED,WAAWC,Q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A,MAAM2H,YAAYnE,IAAAA,yBAAa,EAACkE;YAEhC,IAAIC,WAAW;gBACb,OAAOd,IAAAA,YAAI,EAACxB,KAAKsC,UAAU9E,OAAO;YACpC;YAEA,OAAO4E,IAAAA,iBAAS,EAACpC;QACnB;QAEA,IAAI;YACF,kDAAkD;YAClDqC,WAAWE,UAAUF;YAErB,IAAI7C,aAAI,CAACgD,UAAU,CAACH,WAAW;gBAC7BA,WAAW3C,YAAG,CAAC/D,aAAa,CAAC0G,UAAUvG,IAAI;YAC7C;YAEA,MAAM2G,kBAAkB,MAAM3H,QAAQ4H,YAAY,CAACL;YAEnD,IAAII,iBAAiB;gBACnB,OAAOE,IAAAA,kBAAU,EAAC3C,KAAKyC;YACzB;YAEA,IAAIJ,SAAS1H,UAAU,CAAC,UAAU;gBAChC,MAAM2H,YAAY,MAAMM,IAAAA,0CAAoB,EAACP;gBAE7C,IAAIC,WAAW;oBACb,OAAOd,IAAAA,YAAI,EAACxB,KAAKsC;gBACnB;YACF;QACF,EAAE,OAAOtD,OAAO;YACdD,QAAQC,KAAK,CAAC,6BAA6BA;QAC7C;QAEAoD,IAAAA,iBAAS,EAACpC;IACZ;AACF"}
1
+ {"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/server/middleware-turbopack.ts"],"sourcesContent":["import type { IncomingMessage, ServerResponse } from 'http'\nimport {\n badRequest,\n getOriginalCodeFrame,\n internalServerError,\n json,\n jsonString,\n noContent,\n notFound,\n type OriginalStackFrameResponse,\n type OriginalStackFramesRequest,\n type OriginalStackFramesResponse,\n} from './shared'\n\nimport fs, { constants as FS } from 'fs/promises'\nimport path from 'path'\nimport url from 'url'\nimport { launchEditor } from '../internal/helpers/launchEditor'\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 '../internal/helpers/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()\nexport async 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\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 column: frame.column ?? 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?.startsWith('file://')\n ? relativeToCwd(originalPosition.source)\n : 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\nfunction relativeToCwd(file: string): string {\n const relPath = path.relative(process.cwd(), url.fileURLToPath(file))\n // TODO(sokra) include a ./ here to make it a relative path\n return relPath\n}\n\nasync function createOriginalStackFrame(\n project: Project,\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 return {\n originalStackFrame: traced.frame,\n originalCodeFrame: getOriginalCodeFrame(traced.frame, traced.source),\n }\n}\n\nexport function getOverlayMiddleware(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_original-stack-frames') {\n if (req.method !== 'POST') {\n return 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(project, frame)\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 json(res, result)\n } else if (pathname === '/__nextjs_launch-editor') {\n const frame = createStackFrame(searchParams)\n\n if (!frame) return badRequest(res)\n\n const fileExists = await fs.access(frame.file, FS.F_OK).then(\n () => true,\n () => false\n )\n if (!fileExists) return 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 internalServerError(res)\n }\n\n return 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 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 json(res, sourceMap.payload)\n }\n\n return 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 jsonString(res, sourceMapString)\n }\n\n if (filename.startsWith('file:')) {\n const sourceMap = await getSourceMapFromFile(filename)\n\n if (sourceMap) {\n return json(res, sourceMap)\n }\n }\n } catch (error) {\n console.error('Failed to get source map:', error)\n }\n\n noContent(res)\n }\n}\n"],"names":["batchedTraceSource","getOverlayMiddleware","getSourceMapMiddleware","shouldIgnorePath","modulePath","includes","startsWith","currentSourcesByFile","Map","project","frame","file","decodeURIComponent","undefined","lineNumber","line","column","methodName","ignored","arguments","source","currentDirectoryFileUrl","pathToFileURL","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","findSourceMap","cause","Error","consumer","SourceMapConsumer","traced","originalPosition","originalPositionFor","sourceContent","sourceContentFor","destroy","applicableSourceMap","console","error","sourceIndex","sources","indexOf","ignoreList","originalStackFrame","relativeToCwd","relPath","path","relative","url","fileURLToPath","createOriginalStackFrame","originalCodeFrame","getOriginalCodeFrame","req","res","next","pathname","URL","method","badRequest","Promise","resolve","reject","data","on","chunk","request","JSON","parse","stackFrames","result","all","stackFrame","status","reason","value","inspect","colors","json","fileExists","fs","access","FS","F_OK","then","notFound","launchEditor","err","log","internalServerError","noContent","filename","sourceMap","decodeURI","isAbsolute","sourceMapString","getSourceMap","jsonString","getSourceMapFromFile"],"mappings":";;;;;;;;;;;;;;;;IA0CsBA,kBAAkB;eAAlBA;;IAkUNC,oBAAoB;eAApBA;;IAsEAC,sBAAsB;eAAtBA;;;;;wBAtaT;oEAE6B;+DACnB;8DACD;8BACa;6BAMtB;sCAE8B;4BACgB;yBACvB;0BACN;AAExB,SAASC,iBAAiBC,UAAkB;IAC1C,OACEA,WAAWC,QAAQ,CAAC,mBACpB,2EAA2E;IAC3ED,WAAWC,QAAQ,CAAC,gBACpBD,WAAWE,UAAU,CAAC;AAE1B;AAIA,MAAMC,uBAA4D,IAAIC;AAC/D,eAAeR,mBACpBS,OAAgB,EAChBC,KAA0B;IAE1B,MAAMC,OAAOD,MAAMC,IAAI,GAEnBC,mBAAmBF,MAAMC,IAAI,IAC7BE;IAEJ,IAAI,CAACF,MAAM;IAEX,yFAAyF;IACzF,iHAAiH;IACjH,IAAIA,KAAKL,UAAU,CAAC,UAAU;YAIZI,aACJA,eACIA;QALhB,OAAO;YACLA,OAAO;gBACLC;gBACAG,YAAYJ,CAAAA,cAAAA,MAAMK,IAAI,YAAVL,cAAc;gBAC1BM,QAAQN,CAAAA,gBAAAA,MAAMM,MAAM,YAAZN,gBAAgB;gBACxBO,YAAYP,CAAAA,oBAAAA,MAAMO,UAAU,YAAhBP,oBAAoB;gBAChCQ,SAAS;gBACTC,WAAW,EAAE;YACf;YACAC,QAAQ;QACV;IACF;IAEA,MAAMC,0BAA0BC,IAAAA,sBAAa,EAACC,QAAQC,GAAG,IAAIC,IAAI;IAEjE,MAAMC,cAAc,MAAMjB,QAAQkB,WAAW,CAACjB,OAAOW;IACrD,IAAI,CAACK,aAAa;YAIAhB,cACJA,gBACIA;QALhB,OAAO;YACLA,OAAO;gBACLC;gBACAG,YAAYJ,CAAAA,eAAAA,MAAMK,IA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AgB;IACrD,OAAO,eACLiF,GAAoB,EACpBC,GAAmB,EACnBC,IAAgB;QAEhB,MAAM,EAAEC,QAAQ,EAAE7C,YAAY,EAAE,GAAG,IAAI8C,IAAIJ,IAAIL,GAAG,EAAG;QAErD,IAAIQ,aAAa,wBAAwB;YACvC,OAAOD;QACT;QAEA,IAAIoC,WAAWhF,aAAajB,GAAG,CAAC;QAEhC,IAAI,CAACiG,UAAU;YACb,OAAOhC,IAAAA,kBAAU,EAACL;QACpB;QAEA,mDAAmD;QACnD,iEAAiE;QACjE,IACEqC,SAAS1H,UAAU,CAAC,iBACpB0H,SAAS1H,UAAU,CAAC,yBACpB;YACA,MAAM2H,YAAYnE,IAAAA,yBAAa,EAACkE;YAEhC,IAAIC,WAAW;gBACb,OAAOd,IAAAA,YAAI,EAACxB,KAAKsC,UAAU9E,OAAO;YACpC;YAEA,OAAO4E,IAAAA,iBAAS,EAACpC;QACnB;QAEA,IAAI;YACF,kDAAkD;YAClDqC,WAAWE,UAAUF;YAErB,IAAI7C,aAAI,CAACgD,UAAU,CAACH,WAAW;gBAC7BA,WAAW3C,YAAG,CAAC/D,aAAa,CAAC0G,UAAUvG,IAAI;YAC7C;YAEA,MAAM2G,kBAAkB,MAAM3H,QAAQ4H,YAAY,CAACL;YAEnD,IAAII,iBAAiB;gBACnB,OAAOE,IAAAA,kBAAU,EAAC3C,KAAKyC;YACzB;YAEA,IAAIJ,SAAS1H,UAAU,CAAC,UAAU;gBAChC,MAAM2H,YAAY,MAAMM,IAAAA,0CAAoB,EAACP;gBAE7C,IAAIC,WAAW;oBACb,OAAOd,IAAAA,YAAI,EAACxB,KAAKsC;gBACnB;YACF;QACF,EAAE,OAAOtD,OAAO;YACdD,QAAQC,KAAK,CAAC,6BAA6BA;QAC7C;QAEAoD,IAAAA,iBAAS,EAACpC;IACZ;AACF"}
@@ -62,7 +62,7 @@ const _onrecoverableerror = require("./react-client-callbacks/on-recoverable-err
62
62
  const _tracer = /*#__PURE__*/ _interop_require_default._(require("./tracing/tracer"));
63
63
  const _reporttosocket = /*#__PURE__*/ _interop_require_default._(require("./tracing/report-to-socket"));
64
64
  const _isnextroutererror = require("./components/is-next-router-error");
65
- const version = "15.2.0-canary.61";
65
+ const version = "15.2.0-canary.62";
66
66
  let router;
67
67
  const emitter = (0, _mitt.default)();
68
68
  const looseToArray = (input)=>[].slice.call(input);
@@ -296,7 +296,7 @@ export default async function build(dir, reactProductionProfiling = false, debug
296
296
  const nextBuildSpan = trace('next-build', undefined, {
297
297
  buildMode: experimentalBuildMode,
298
298
  isTurboBuild: String(turboNextBuild),
299
- version: "15.2.0-canary.61"
299
+ version: "15.2.0-canary.62"
300
300
  });
301
301
  NextBuildContext.nextBuildSpan = nextBuildSpan;
302
302
  NextBuildContext.dir = dir;
@@ -655,7 +655,7 @@ export default async function build(dir, reactProductionProfiling = false, debug
655
655
  // Files outside of the distDir can be "type": "module"
656
656
  await writeFileUtf8(path.join(distDir, 'package.json'), '{"type": "commonjs"}');
657
657
  // These are written to distDir, so they need to come after creating and cleaning distDr.
658
- await recordFrameworkVersion("15.2.0-canary.61");
658
+ await recordFrameworkVersion("15.2.0-canary.62");
659
659
  await updateBuildDiagnostics({
660
660
  buildStage: 'start'
661
661
  });
@@ -11,7 +11,7 @@ import { isDeepStrictEqual } from 'util';
11
11
  import { getDefineEnv } from '../webpack/plugins/define-env-plugin';
12
12
  import { getReactCompilerLoader } from '../get-babel-loader-config';
13
13
  import { TurbopackInternalError } from '../../shared/lib/turbopack/utils';
14
- const nextVersion = "15.2.0-canary.61";
14
+ const nextVersion = "15.2.0-canary.62";
15
15
  const ArchName = arch();
16
16
  const PlatformName = platform();
17
17
  function infoLog(...args) {
@@ -1437,7 +1437,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
1437
1437
  isClient && new CopyFilePlugin({
1438
1438
  // file path to build output of `@next/polyfill-nomodule`
1439
1439
  filePath: require.resolve('./polyfills/polyfill-nomodule'),
1440
- cacheKey: "15.2.0-canary.61",
1440
+ cacheKey: "15.2.0-canary.62",
1441
1441
  name: `static/chunks/polyfills${dev ? '' : '-[hash]'}.js`,
1442
1442
  minimize: false,
1443
1443
  info: {
@@ -1670,7 +1670,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
1670
1670
  // - Next.js location on disk (some loaders use absolute paths and some resolve options depend on absolute paths)
1671
1671
  // - Next.js version
1672
1672
  // - next.config.js keys that affect compilation
1673
- version: `${__dirname}|${"15.2.0-canary.61"}|${configVars}`,
1673
+ version: `${__dirname}|${"15.2.0-canary.62"}|${configVars}`,
1674
1674
  cacheDirectory: path.join(distDir, 'cache', 'webpack'),
1675
1675
  // For production builds, it's more efficient to compress all cache files together instead of compression each one individually.
1676
1676
  // So we disable compression here and allow the build runner to take care of compressing the cache as a whole.
@@ -3,7 +3,7 @@
3
3
  * sure the following scripts are executed in the correct order:
4
4
  * - Polyfills
5
5
  * - next/script with `beforeInteractive` strategy
6
- */ const version = "15.2.0-canary.61";
6
+ */ const version = "15.2.0-canary.62";
7
7
  window.next = {
8
8
  version,
9
9
  appDir: true
@@ -51,7 +51,7 @@ export async function batchedTraceSource(project, frame) {
51
51
  let source = null;
52
52
  const originalFile = sourceFrame.originalFile;
53
53
  // Don't look up source for node_modules or internals. These can often be large bundled files.
54
- const ignored = shouldIgnorePath(originalFile != null ? originalFile : sourceFrame.file) || // isInternal means resource starts with turbopack://[turbopack]
54
+ const ignored = shouldIgnorePath(originalFile != null ? originalFile : sourceFrame.file) || // isInternal means resource starts with turbopack:///[turbopack]
55
55
  !!sourceFrame.isInternal;
56
56
  if (originalFile && !ignored) {
57
57
  let sourcePromise = currentSourcesByFile.get(originalFile);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/server/middleware-turbopack.ts"],"sourcesContent":["import type { IncomingMessage, ServerResponse } from 'http'\nimport {\n badRequest,\n getOriginalCodeFrame,\n internalServerError,\n json,\n jsonString,\n noContent,\n notFound,\n type OriginalStackFrameResponse,\n type OriginalStackFramesRequest,\n type OriginalStackFramesResponse,\n} from './shared'\n\nimport fs, { constants as FS } from 'fs/promises'\nimport path from 'path'\nimport url from 'url'\nimport { launchEditor } from '../internal/helpers/launchEditor'\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 '../internal/helpers/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()\nexport async 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\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 column: frame.column ?? 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?.startsWith('file://')\n ? relativeToCwd(originalPosition.source)\n : 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\nfunction relativeToCwd(file: string): string {\n const relPath = path.relative(process.cwd(), url.fileURLToPath(file))\n // TODO(sokra) include a ./ here to make it a relative path\n return relPath\n}\n\nasync function createOriginalStackFrame(\n project: Project,\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 return {\n originalStackFrame: traced.frame,\n originalCodeFrame: getOriginalCodeFrame(traced.frame, traced.source),\n }\n}\n\nexport function getOverlayMiddleware(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_original-stack-frames') {\n if (req.method !== 'POST') {\n return 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(project, frame)\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 json(res, result)\n } else if (pathname === '/__nextjs_launch-editor') {\n const frame = createStackFrame(searchParams)\n\n if (!frame) return badRequest(res)\n\n const fileExists = await fs.access(frame.file, FS.F_OK).then(\n () => true,\n () => false\n )\n if (!fileExists) return 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 internalServerError(res)\n }\n\n return 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 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 json(res, sourceMap.payload)\n }\n\n return 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 jsonString(res, sourceMapString)\n }\n\n if (filename.startsWith('file:')) {\n const sourceMap = await getSourceMapFromFile(filename)\n\n if (sourceMap) {\n return json(res, sourceMap)\n }\n }\n } catch (error) {\n console.error('Failed to get source map:', error)\n }\n\n noContent(res)\n }\n}\n"],"names":["badRequest","getOriginalCodeFrame","internalServerError","json","jsonString","noContent","notFound","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","relativeToCwd","relPath","relative","fileURLToPath","createOriginalStackFrame","originalCodeFrame","getOverlayMiddleware","req","res","next","pathname","URL","method","Promise","resolve","reject","data","on","chunk","request","JSON","parse","stackFrames","result","all","stackFrame","status","reason","value","colors","fileExists","access","F_OK","then","err","log","getSourceMapMiddleware","filename","sourceMap","decodeURI","isAbsolute","sourceMapString","getSourceMap"],"mappings":"AACA,SACEA,UAAU,EACVC,oBAAoB,EACpBC,mBAAmB,EACnBC,IAAI,EACJC,UAAU,EACVC,SAAS,EACTC,QAAQ,QAIH,WAAU;AAEjB,OAAOC,MAAMC,aAAaC,EAAE,QAAQ,cAAa;AACjD,OAAOC,UAAU,OAAM;AACvB,OAAOC,SAAS,MAAK;AACrB,SAASC,YAAY,QAAQ,mCAAkC;AAE/D,SACEC,iBAAiB,QAGZ,kCAAiC;AAExC,SAASC,oBAAoB,QAAQ,+CAA8C;AACnF,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,OAAO,eAAeC,mBACpBC,OAAgB,EAChBC,KAA0B;IAE1B,MAAMC,OAAOD,MAAMC,IAAI,GAEnBC,mBAAmBF,MAAMC,IAAI,IAC7BE;IAEJ,IAAI,CAACF,MAAM;IAEX,yFAAyF;IACzF,iHAAiH;IACjH,IAAIA,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SAAS9G,UAAU,CAAC,UAAU;gBAChC,MAAM+G,YAAY,MAAMtH,qBAAqBqH;gBAE7C,IAAIC,WAAW;oBACb,OAAOjI,KAAKmG,KAAK8B;gBACnB;YACF;QACF,EAAE,OAAO5C,OAAO;YACdD,QAAQC,KAAK,CAAC,6BAA6BA;QAC7C;QAEAnF,UAAUiG;IACZ;AACF"}
1
+ {"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/server/middleware-turbopack.ts"],"sourcesContent":["import type { IncomingMessage, ServerResponse } from 'http'\nimport {\n badRequest,\n getOriginalCodeFrame,\n internalServerError,\n json,\n jsonString,\n noContent,\n notFound,\n type OriginalStackFrameResponse,\n type OriginalStackFramesRequest,\n type OriginalStackFramesResponse,\n} from './shared'\n\nimport fs, { constants as FS } from 'fs/promises'\nimport path from 'path'\nimport url from 'url'\nimport { launchEditor } from '../internal/helpers/launchEditor'\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 '../internal/helpers/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()\nexport async 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\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 column: frame.column ?? 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?.startsWith('file://')\n ? relativeToCwd(originalPosition.source)\n : 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\nfunction relativeToCwd(file: string): string {\n const relPath = path.relative(process.cwd(), url.fileURLToPath(file))\n // TODO(sokra) include a ./ here to make it a relative path\n return relPath\n}\n\nasync function createOriginalStackFrame(\n project: Project,\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 return {\n originalStackFrame: traced.frame,\n originalCodeFrame: getOriginalCodeFrame(traced.frame, traced.source),\n }\n}\n\nexport function getOverlayMiddleware(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_original-stack-frames') {\n if (req.method !== 'POST') {\n return 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(project, frame)\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 json(res, result)\n } else if (pathname === '/__nextjs_launch-editor') {\n const frame = createStackFrame(searchParams)\n\n if (!frame) return badRequest(res)\n\n const fileExists = await fs.access(frame.file, FS.F_OK).then(\n () => true,\n () => false\n )\n if (!fileExists) return 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 internalServerError(res)\n }\n\n return 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 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 json(res, sourceMap.payload)\n }\n\n return 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 jsonString(res, sourceMapString)\n }\n\n if (filename.startsWith('file:')) {\n const sourceMap = await getSourceMapFromFile(filename)\n\n if (sourceMap) {\n return json(res, sourceMap)\n }\n }\n } catch (error) {\n console.error('Failed to get source map:', error)\n }\n\n noContent(res)\n }\n}\n"],"names":["badRequest","getOriginalCodeFrame","internalServerError","json","jsonString","noContent","notFound","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","relativeToCwd","relPath","relative","fileURLToPath","createOriginalStackFrame","originalCodeFrame","getOverlayMiddleware","req","res","next","pathname","URL","method","Promise","resolve","reject","data","on","chunk","request","JSON","parse","stackFrames","result","all","stackFrame","status","reason","value","colors","fileExists","access","F_OK","then","err","log","getSourceMapMiddleware","filename","sourceMap","decodeURI","isAbsolute","sourceMapString","getSourceMap"],"mappings":"AACA,SACEA,UAAU,EACVC,oBAAoB,EACpBC,mBAAmB,EACnBC,IAAI,EACJC,UAAU,EACVC,SAAS,EACTC,QAAQ,QAIH,WAAU;AAEjB,OAAOC,MAAMC,aAAaC,EAAE,QAAQ,cAAa;AACjD,OAAOC,UAAU,OAAM;AACvB,OAAOC,SAAS,MAAK;AACrB,SAASC,YAAY,QAAQ,mCAAkC;AAE/D,SACEC,iBAAiB,QAGZ,kCAAiC;AAExC,SAASC,oBAAoB,QAAQ,+CAA8C;AACnF,SAASC,aAAa,QAA+B,cAAa;AAClE,SAASC,aA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pB;YACA,MAAM+G,YAAYrH,cAAcoH;YAEhC,IAAIC,WAAW;gBACb,OAAOjI,KAAKmG,KAAK8B,UAAUlE,OAAO;YACpC;YAEA,OAAO7D,UAAUiG;QACnB;QAEA,IAAI;YACF,kDAAkD;YAClD6B,WAAWE,UAAUF;YAErB,IAAIzH,KAAK4H,UAAU,CAACH,WAAW;gBAC7BA,WAAWxH,IAAIK,aAAa,CAACmH,UAAU3F,IAAI;YAC7C;YAEA,MAAM+F,kBAAkB,MAAM9G,QAAQ+G,YAAY,CAACL;YAEnD,IAAII,iBAAiB;gBACnB,OAAOnI,WAAWkG,KAAKiC;YACzB;YAEA,IAAIJ,SAAS9G,UAAU,CAAC,UAAU;gBAChC,MAAM+G,YAAY,MAAMtH,qBAAqBqH;gBAE7C,IAAIC,WAAW;oBACb,OAAOjI,KAAKmG,KAAK8B;gBACnB;YACF;QACF,EAAE,OAAO5C,OAAO;YACdD,QAAQC,KAAK,CAAC,6BAA6BA;QAC7C;QAEAnF,UAAUiG;IACZ;AACF"}
@@ -27,7 +27,7 @@ import { onRecoverableError } from './react-client-callbacks/on-recoverable-erro
27
27
  import tracer from './tracing/tracer';
28
28
  import reportToSocket from './tracing/report-to-socket';
29
29
  import { isNextRouterError } from './components/is-next-router-error';
30
- export const version = "15.2.0-canary.61";
30
+ export const version = "15.2.0-canary.62";
31
31
  export let router;
32
32
  export const emitter = mitt();
33
33
  const looseToArray = (input)=>[].slice.call(input);
@@ -184,7 +184,7 @@ function assignDefaults(dir, userConfig, silent) {
184
184
  configurable: true
185
185
  });
186
186
  }
187
- if (!((_process_env___NEXT_VERSION = "15.2.0-canary.61") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_LOCAL_DEV) {
187
+ if (!((_process_env___NEXT_VERSION = "15.2.0-canary.62") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_LOCAL_DEV) {
188
188
  var _result_experimental7, _result_experimental8, _result_experimental_turbo3, _result_experimental9;
189
189
  // Prevents usage of certain experimental features outside of canary
190
190
  if ((_result_experimental7 = result.experimental) == null ? void 0 : _result_experimental7.ppr) {
@@ -36,7 +36,7 @@ const wsServer = new ws.Server({
36
36
  const isTestMode = !!(process.env.NEXT_TEST_MODE || process.env.__NEXT_TEST_MODE || process.env.DEBUG);
37
37
  const sessionId = Math.floor(Number.MAX_SAFE_INTEGER * Math.random());
38
38
  /**
39
- * Replaces turbopack://[project] with the specified project in the `source` field.
39
+ * Replaces turbopack:///[project] with the specified project in the `source` field.
40
40
  */ function rewriteTurbopackSources(projectRoot, sourceMap) {
41
41
  if ('sections' in sourceMap) {
42
42
  for (const section of sourceMap.sections){
@@ -44,7 +44,7 @@ const sessionId = Math.floor(Number.MAX_SAFE_INTEGER * Math.random());
44
44
  }
45
45
  } else {
46
46
  for(let i = 0; i < sourceMap.sources.length; i++){
47
- sourceMap.sources[i] = pathToFileURL(join(projectRoot, sourceMap.sources[i].replace(/turbopack:\/\/\[project\]/, ''))).toString();
47
+ sourceMap.sources[i] = pathToFileURL(join(projectRoot, sourceMap.sources[i].replace(/turbopack:\/\/\/\[project\]/, ''))).toString();
48
48
  }
49
49
  }
50
50
  }
@@ -80,7 +80,7 @@ export async function createHotReloaderTurbopack(opts, serverFields, distDir, re
80
80
  }
81
81
  const hasRewrites = opts.fsChecker.rewrites.afterFiles.length > 0 || opts.fsChecker.rewrites.beforeFiles.length > 0 || opts.fsChecker.rewrites.fallback.length > 0;
82
82
  const hotReloaderSpan = trace('hot-reloader', undefined, {
83
- version: "15.2.0-canary.61"
83
+ version: "15.2.0-canary.62"
84
84
  });
85
85
  // Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
86
86
  // of the current `next dev` invocation.