next 15.0.4-canary.37 → 15.0.4-canary.38

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 (30) 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 +83 -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/compiled/next-server/server.runtime.prod.js.map +1 -1
  10. package/dist/esm/build/index.js +2 -2
  11. package/dist/esm/build/swc/index.js +1 -1
  12. package/dist/esm/build/webpack-config.js +2 -2
  13. package/dist/esm/client/app-bootstrap.js +1 -1
  14. package/dist/esm/client/components/react-dev-overlay/server/middleware-turbopack.js +83 -1
  15. package/dist/esm/client/components/react-dev-overlay/server/middleware-turbopack.js.map +1 -1
  16. package/dist/esm/client/index.js +1 -1
  17. package/dist/esm/server/config.js +1 -1
  18. package/dist/esm/server/dev/hot-reloader-turbopack.js +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 +1 -1
  24. package/dist/server/dev/hot-reloader-webpack.js +1 -1
  25. package/dist/server/lib/app-info-log.js +1 -1
  26. package/dist/server/lib/start-server.js +1 -1
  27. package/dist/telemetry/anonymous-meta.js +1 -1
  28. package/dist/telemetry/events/session-stopped.js +2 -2
  29. package/dist/telemetry/events/version.js +2 -2
  30. package/package.json +15 -15
@@ -293,7 +293,7 @@ export default async function build(dir, reactProductionProfiling = false, debug
293
293
  const nextBuildSpan = trace('next-build', undefined, {
294
294
  buildMode: experimentalBuildMode,
295
295
  isTurboBuild: String(turboNextBuild),
296
- version: "15.0.4-canary.37"
296
+ version: "15.0.4-canary.38"
297
297
  });
298
298
  NextBuildContext.nextBuildSpan = nextBuildSpan;
299
299
  NextBuildContext.dir = dir;
@@ -696,7 +696,7 @@ export default async function build(dir, reactProductionProfiling = false, debug
696
696
  // Files outside of the distDir can be "type": "module"
697
697
  await writeFileUtf8(path.join(distDir, 'package.json'), '{"type": "commonjs"}');
698
698
  // These are written to distDir, so they need to come after creating and cleaning distDr.
699
- await recordFrameworkVersion("15.0.4-canary.37");
699
+ await recordFrameworkVersion("15.0.4-canary.38");
700
700
  await updateBuildDiagnostics({
701
701
  buildStage: 'start'
702
702
  });
@@ -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 '../../server/dev/turbopack-utils';
14
- const nextVersion = "15.0.4-canary.37";
14
+ const nextVersion = "15.0.4-canary.38";
15
15
  const ArchName = arch();
16
16
  const PlatformName = platform();
17
17
  function infoLog(...args) {
@@ -1403,7 +1403,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
1403
1403
  isClient && new CopyFilePlugin({
1404
1404
  // file path to build output of `@next/polyfill-nomodule`
1405
1405
  filePath: require.resolve('./polyfills/polyfill-nomodule'),
1406
- cacheKey: "15.0.4-canary.37",
1406
+ cacheKey: "15.0.4-canary.38",
1407
1407
  name: `static/chunks/polyfills${dev ? '' : '-[hash]'}.js`,
1408
1408
  minimize: false,
1409
1409
  info: {
@@ -1632,7 +1632,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
1632
1632
  // - Next.js location on disk (some loaders use absolute paths and some resolve options depend on absolute paths)
1633
1633
  // - Next.js version
1634
1634
  // - next.config.js keys that affect compilation
1635
- version: `${__dirname}|${"15.0.4-canary.37"}|${configVars}`,
1635
+ version: `${__dirname}|${"15.0.4-canary.38"}|${configVars}`,
1636
1636
  cacheDirectory: path.join(distDir, 'cache', 'webpack'),
1637
1637
  // For production builds, it's more efficient to compress all cache files together instead of compression each one individually.
1638
1638
  // 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.0.4-canary.37";
6
+ */ const version = "15.0.4-canary.38";
7
7
  window.next = {
8
8
  version,
9
9
  appDir: true
@@ -3,6 +3,7 @@ import fs, { constants as FS } from 'fs/promises';
3
3
  import path from 'path';
4
4
  import url from 'url';
5
5
  import { launchEditor } from '../internal/helpers/launchEditor';
6
+ import { SourceMapConsumer } from 'next/dist/compiled/source-map08';
6
7
  import { getSourceMapFromFile } from '../internal/helpers/get-source-map-from-file';
7
8
  import { findSourceMap } from 'node:module';
8
9
  function shouldIgnorePath(modulePath) {
@@ -76,8 +77,87 @@ function createStackFrame(searchParams) {
76
77
  isServer: searchParams.get('isServer') === 'true'
77
78
  };
78
79
  }
80
+ /**
81
+ * Finds the sourcemap payload applicable to a given frame.
82
+ * Equal to the input unless an Index Source Map is used.
83
+ */ function findApplicableSourceMapPayload(frame, payload) {
84
+ if ('sections' in payload) {
85
+ var _frame_line;
86
+ const frameLine = (_frame_line = frame.line) != null ? _frame_line : 0;
87
+ var _frame_column;
88
+ const frameColumn = (_frame_column = frame.column) != null ? _frame_column : 0;
89
+ // Sections must not overlap and must be sorted: https://tc39.es/source-map/#section-object
90
+ // Therefore the last section that has an offset less than or equal to the frame is the applicable one.
91
+ // TODO(veil): Binary search
92
+ let section = payload.sections[0];
93
+ for(let i = 0; i < payload.sections.length && payload.sections[i].offset.line <= frameLine && payload.sections[i].offset.column <= frameColumn; i++){
94
+ section = payload.sections[i];
95
+ }
96
+ return section === undefined ? undefined : section.map;
97
+ } else {
98
+ return payload;
99
+ }
100
+ }
101
+ async function nativeTraceSource(frame) {
102
+ const sourceMap = findSourceMap(// TODO(veil): Why are the frames sent encoded?
103
+ decodeURIComponent(frame.file));
104
+ if (sourceMap !== undefined) {
105
+ const traced = await SourceMapConsumer.with(sourceMap.payload, null, async (consumer)=>{
106
+ var _frame_line, _frame_column;
107
+ const originalPosition = consumer.originalPositionFor({
108
+ line: (_frame_line = frame.line) != null ? _frame_line : 1,
109
+ column: (_frame_column = frame.column) != null ? _frame_column : 1
110
+ });
111
+ if (originalPosition.source === null) {
112
+ return null;
113
+ }
114
+ var _consumer_sourceContentFor;
115
+ const sourceContent = (_consumer_sourceContentFor = consumer.sourceContentFor(originalPosition.source, /* returnNullOnMissing */ true)) != null ? _consumer_sourceContentFor : null;
116
+ return {
117
+ originalPosition,
118
+ sourceContent
119
+ };
120
+ });
121
+ if (traced !== null) {
122
+ var // default is not a valid identifier in JS so webpack uses a custom variable when it's an unnamed default export
123
+ // Resolve it back to `default` for the method name if the source position didn't have the method.
124
+ _frame_methodName_replace, _frame_methodName, _originalPosition_source;
125
+ const { originalPosition, sourceContent } = traced;
126
+ const applicableSourceMap = findApplicableSourceMapPayload(frame, sourceMap.payload);
127
+ // TODO(veil): Upstream a method to sourcemap consumer that immediately says if a frame is ignored or not.
128
+ let ignored = false;
129
+ if (applicableSourceMap === undefined) {
130
+ console.error('No applicable source map found in sections for frame', frame);
131
+ } else {
132
+ var _applicableSourceMap_ignoreList;
133
+ // TODO: O(n^2). Consider moving `ignoreList` into a Set
134
+ const sourceIndex = applicableSourceMap.sources.indexOf(originalPosition.source);
135
+ var _applicableSourceMap_ignoreList_includes;
136
+ ignored = (_applicableSourceMap_ignoreList_includes = (_applicableSourceMap_ignoreList = applicableSourceMap.ignoreList) == null ? void 0 : _applicableSourceMap_ignoreList.includes(sourceIndex)) != null ? _applicableSourceMap_ignoreList_includes : false;
137
+ }
138
+ var _originalPosition_column, _originalPosition_line;
139
+ const originalStackFrame = {
140
+ methodName: originalPosition.name || ((_frame_methodName = frame.methodName) == null ? void 0 : (_frame_methodName_replace = _frame_methodName.replace('__WEBPACK_DEFAULT_EXPORT__', 'default')) == null ? void 0 : _frame_methodName_replace.replace('__webpack_exports__.', '')) || '<unknown>',
141
+ column: ((_originalPosition_column = originalPosition.column) != null ? _originalPosition_column : 0) + 1,
142
+ file: ((_originalPosition_source = originalPosition.source) == null ? void 0 : _originalPosition_source.startsWith('file://')) ? path.relative(process.cwd(), url.fileURLToPath(originalPosition.source)) : originalPosition.source,
143
+ lineNumber: (_originalPosition_line = originalPosition.line) != null ? _originalPosition_line : 0,
144
+ // TODO: c&p from async createOriginalStackFrame but why not frame.arguments?
145
+ arguments: [],
146
+ ignored
147
+ };
148
+ return {
149
+ frame: originalStackFrame,
150
+ source: sourceContent
151
+ };
152
+ }
153
+ }
154
+ return undefined;
155
+ }
79
156
  export async function createOriginalStackFrame(project, frame) {
80
- const traced = await batchedTraceSource(project, frame);
157
+ var _ref;
158
+ const traced = (_ref = await nativeTraceSource(frame)) != null ? _ref : // TODO(veil): When would the bundler know more than native?
159
+ // If it's faster, try the bundler first and fall back to native later.
160
+ await batchedTraceSource(project, frame);
81
161
  if (!traced) {
82
162
  return null;
83
163
  }
@@ -131,6 +211,8 @@ export function getSourceMapMiddleware(project) {
131
211
  if (!filename) {
132
212
  return badRequest(res);
133
213
  }
214
+ // TODO(veil): Always try the native version first.
215
+ // Externals could also be files that aren't bundled via Webpack.
134
216
  if (filename.startsWith('webpack://') || filename.startsWith('webpack-internal:///')) {
135
217
  const sourceMap = findSourceMap(filename);
136
218
  if (sourceMap) {
@@ -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 type OriginalStackFrameResponse,\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 type { Project, TurbopackStackFrame } from '../../../../build/swc/types'\nimport { getSourceMapFromFile } from '../internal/helpers/get-source-map-from-file'\nimport { findSourceMap } from 'node:module'\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 )\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 ? decodeURIComponent(frame.file) : undefined\n if (!file) return\n\n const sourceFrame = await project.traceSource(frame)\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(frame.file),\n arguments: [],\n },\n source: null,\n }\n }\n\n let source = null\n // Don't look up source for node_modules or internals. These can often be large bundled files.\n const ignored =\n shouldIgnorePath(sourceFrame.file) ||\n // isInternal means resource starts with turbopack://[turbopack]\n !!sourceFrame.isInternal\n if (sourceFrame && sourceFrame.file && !ignored) {\n let sourcePromise = currentSourcesByFile.get(sourceFrame.file)\n if (!sourcePromise) {\n sourcePromise = project.getSourceForAsset(sourceFrame.file)\n currentSourcesByFile.set(sourceFrame.file, 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(sourceFrame.file!)\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: sourceFrame.methodName ?? frame.methodName ?? '<unknown>',\n ignored,\n arguments: [],\n }\n\n return {\n frame: ignorableFrame,\n source,\n }\n}\n\nfunction createStackFrame(searchParams: URLSearchParams) {\n const fileParam = searchParams.get('file')\n\n if (!fileParam) {\n return undefined\n }\n\n // rsc://React/Server/file://<filename>?42 => file://<filename>\n const file = fileParam\n .replace(/^rsc:\\/\\/React\\/[^/]+\\//, '')\n .replace(/\\?\\d+$/, '')\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\nexport async function createOriginalStackFrame(\n project: Project,\n frame: TurbopackStackFrame\n): Promise<OriginalStackFrameResponse | null> {\n const traced = 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-frame') {\n const frame = createStackFrame(searchParams)\n\n if (!frame) return badRequest(res)\n\n let originalStackFrame: OriginalStackFrameResponse | null\n try {\n originalStackFrame = await createOriginalStackFrame(project, frame)\n } catch (e: any) {\n return internalServerError(res, e.message)\n }\n\n if (!originalStackFrame) {\n res.statusCode = 404\n res.end('Unable to resolve sourcemap')\n return\n }\n\n return json(res, originalStackFrame)\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 noContent(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 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 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","fs","constants","FS","path","url","launchEditor","getSourceMapFromFile","findSourceMap","shouldIgnorePath","modulePath","includes","currentSourcesByFile","Map","batchedTraceSource","project","frame","file","decodeURIComponent","undefined","sourceFrame","traceSource","lineNumber","line","column","methodName","ignored","arguments","source","isInternal","sourcePromise","get","getSourceForAsset","set","setTimeout","delete","ignorableFrame","createStackFrame","searchParams","fileParam","replace","parseInt","isServer","createOriginalStackFrame","traced","originalStackFrame","originalCodeFrame","getOverlayMiddleware","req","res","next","pathname","URL","e","message","statusCode","end","fileExists","access","F_OK","then","err","console","log","getSourceMapMiddleware","filename","startsWith","sourceMap","payload","decodeURI","isAbsolute","pathToFileURL","href","sourceMapString","getSourceMap","error"],"mappings":"AACA,SACEA,UAAU,EACVC,oBAAoB,EACpBC,mB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F;gBACxC,OAAOhE,oBAAoBoD;YAC7B;YAEAjD,UAAUiD;QACZ;QAEA,OAAOC;IACT;AACF;AAEA,OAAO,SAASc,uBAAuBjD,OAAgB;IACrD,OAAO,eACLiC,GAAoB,EACpBC,GAAmB,EACnBC,IAAgB;QAEhB,MAAM,EAAEC,QAAQ,EAAEb,YAAY,EAAE,GAAG,IAAIc,IAAIJ,IAAI3C,GAAG,EAAG;QAErD,IAAI8C,aAAa,wBAAwB;YACvC,OAAOD;QACT;QAEA,IAAIe,WAAW3B,aAAaP,GAAG,CAAC;QAEhC,IAAI,CAACkC,UAAU;YACb,OAAOtE,WAAWsD;QACpB;QAEA,IACEgB,SAASC,UAAU,CAAC,iBACpBD,SAASC,UAAU,CAAC,yBACpB;YACA,MAAMC,YAAY3D,cAAcyD;YAEhC,IAAIE,WAAW;gBACb,OAAOrE,KAAKmD,KAAKkB,UAAUC,OAAO;YACpC;YAEA,OAAOpE,UAAUiD;QACnB;QAEA,IAAI;YACF,kDAAkD;YAClDgB,WAAWI,UAAUJ;YAErB,IAAI7D,KAAKkE,UAAU,CAACL,WAAW;gBAC7BA,WAAW5D,IAAIkE,aAAa,CAACN,UAAUO,IAAI;YAC7C;YAEA,MAAMC,kBAAkB,MAAM1D,QAAQ2D,YAAY,CAACT;YAEnD,IAAIQ,iBAAiB;gBACnB,OAAO1E,WAAWkD,KAAKwB;YACzB;YAEA,IAAIR,SAASC,UAAU,CAAC,UAAU;gBAChC,MAAMC,YAAY,MAAM5D,qBAAqB0D;gBAE7C,IAAIE,WAAW;oBACb,OAAOrE,KAAKmD,KAAKkB;gBACnB;YACF;QACF,EAAE,OAAOQ,OAAO;YACdb,QAAQa,KAAK,CAAC,6BAA6BA;QAC7C;QAEA3E,UAAUiD;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 type OriginalStackFrameResponse,\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 { SourceMapConsumer } 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'\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 )\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 if (!file) return\n\n const sourceFrame = await project.traceSource(frame)\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(frame.file),\n arguments: [],\n },\n source: null,\n }\n }\n\n let source = null\n // Don't look up source for node_modules or internals. These can often be large bundled files.\n const ignored =\n shouldIgnorePath(sourceFrame.file) ||\n // isInternal means resource starts with turbopack://[turbopack]\n !!sourceFrame.isInternal\n if (sourceFrame && sourceFrame.file && !ignored) {\n let sourcePromise = currentSourcesByFile.get(sourceFrame.file)\n if (!sourcePromise) {\n sourcePromise = project.getSourceForAsset(sourceFrame.file)\n currentSourcesByFile.set(sourceFrame.file, 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(sourceFrame.file!)\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: sourceFrame.methodName ?? frame.methodName ?? '<unknown>',\n ignored,\n arguments: [],\n }\n\n return {\n frame: ignorableFrame,\n source,\n }\n}\n\nfunction createStackFrame(searchParams: URLSearchParams) {\n const fileParam = searchParams.get('file')\n\n if (!fileParam) {\n return undefined\n }\n\n // rsc://React/Server/file://<filename>?42 => file://<filename>\n const file = fileParam\n .replace(/^rsc:\\/\\/React\\/[^/]+\\//, '')\n .replace(/\\?\\d+$/, '')\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 sourceMap = findSourceMap(\n // TODO(veil): Why are the frames sent encoded?\n decodeURIComponent(frame.file)\n )\n if (sourceMap !== undefined) {\n const traced = await SourceMapConsumer.with(\n sourceMap.payload,\n null,\n async (consumer) => {\n const originalPosition = consumer.originalPositionFor({\n line: frame.line ?? 1,\n column: frame.column ?? 1,\n })\n\n if (originalPosition.source === null) {\n return null\n }\n\n const sourceContent: string | null =\n consumer.sourceContentFor(\n originalPosition.source,\n /* returnNullOnMissing */ true\n ) ?? null\n\n return { originalPosition, sourceContent }\n }\n )\n\n if (traced !== null) {\n const { originalPosition, sourceContent } = traced\n const applicableSourceMap = findApplicableSourceMapPayload(\n frame,\n sourceMap.payload\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 = applicableSourceMap.ignoreList?.includes(sourceIndex) ?? false\n }\n\n const originalStackFrame: IgnorableStackFrame = {\n methodName:\n originalPosition.name ||\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 '<unknown>',\n column: (originalPosition.column ?? 0) + 1,\n file: originalPosition.source?.startsWith('file://')\n ? path.relative(\n process.cwd(),\n url.fileURLToPath(originalPosition.source)\n )\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\nexport async 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-frame') {\n const frame = createStackFrame(searchParams)\n\n if (!frame) return badRequest(res)\n\n let originalStackFrame: OriginalStackFrameResponse | null\n try {\n originalStackFrame = await createOriginalStackFrame(project, frame)\n } catch (e: any) {\n return internalServerError(res, e.message)\n }\n\n if (!originalStackFrame) {\n res.statusCode = 404\n res.end('Unable to resolve sourcemap')\n return\n }\n\n return json(res, originalStackFrame)\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 noContent(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 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","fs","constants","FS","path","url","launchEditor","SourceMapConsumer","getSourceMapFromFile","findSourceMap","shouldIgnorePath","modulePath","includes","currentSourcesByFile","Map","batchedTraceSource","project","frame","file","decodeURIComponent","undefined","sourceFrame","traceSource","lineNumber","line","column","methodName","ignored","arguments","source","isInternal","sourcePromise","get","getSourceForAsset","set","setTimeout","delete","ignorableFrame","createStackFrame","searchParams","fileParam","replace","parseInt","isServer","findApplicableSourceMapPayload","payload","frameLine","frameColumn","section","sections","i","length","offset","map","nativeTraceSource","sourceMap","traced","with","consumer","originalPosition","originalPositionFor","sourceContent","sourceContentFor","applicableSourceMap","console","error","sourceIndex","sources","indexOf","ignoreList","originalStackFrame","name","startsWith","relative","process","cwd","fileURLToPath","createOriginalStackFrame","originalCodeFrame","getOverlayMiddleware","req","res","next","pathname","URL","e","message","statusCode","end","fileExists","access","F_OK","then","err","log","getSourceMapMiddleware","filename","decodeURI","isAbsolute","pathToFileURL","href","sourceMapString","getSourceMap"],"mappings":"AACA,SACEA,UAAU,E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nB;YACF;QACF,EAAE,OAAOU,OAAO;YACdD,QAAQC,KAAK,CAAC,6BAA6BA;QAC7C;QAEAjE,UAAUiF;IACZ;AACF"}
@@ -27,7 +27,7 @@ import { onRecoverableError } from './react-client-callbacks/shared';
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.0.4-canary.37";
30
+ export const version = "15.0.4-canary.38";
31
31
  export let router;
32
32
  export const emitter = mitt();
33
33
  const looseToArray = (input)=>[].slice.call(input);
@@ -155,7 +155,7 @@ function assignDefaults(dir, userConfig, silent) {
155
155
  if (((_result_experimental = result.experimental) == null ? void 0 : _result_experimental.allowDevelopmentBuild) && process.env.NODE_ENV !== 'development') {
156
156
  throw new Error(`The experimental.allowDevelopmentBuild option requires NODE_ENV to be explicitly set to 'development'.`);
157
157
  }
158
- if (!((_process_env___NEXT_VERSION = "15.0.4-canary.37") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_SKIP_CANARY_CHECK) {
158
+ if (!((_process_env___NEXT_VERSION = "15.0.4-canary.38") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_SKIP_CANARY_CHECK) {
159
159
  var _result_experimental7, _result_experimental8, _result_experimental_turbo3, _result_experimental9, _result_experimental10;
160
160
  // Prevents usage of certain experimental features outside of canary
161
161
  if ((_result_experimental7 = result.experimental) == null ? void 0 : _result_experimental7.ppr) {
@@ -48,7 +48,7 @@ export async function createHotReloaderTurbopack(opts, serverFields, distDir, re
48
48
  }
49
49
  const hasRewrites = opts.fsChecker.rewrites.afterFiles.length > 0 || opts.fsChecker.rewrites.beforeFiles.length > 0 || opts.fsChecker.rewrites.fallback.length > 0;
50
50
  const hotReloaderSpan = trace('hot-reloader', undefined, {
51
- version: "15.0.4-canary.37"
51
+ version: "15.0.4-canary.38"
52
52
  });
53
53
  // Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
54
54
  // of the current `next dev` invocation.
@@ -184,7 +184,7 @@ export default class HotReloaderWebpack {
184
184
  this.previewProps = previewProps;
185
185
  this.rewrites = rewrites;
186
186
  this.hotReloaderSpan = trace('hot-reloader', undefined, {
187
- version: "15.0.4-canary.37"
187
+ version: "15.0.4-canary.38"
188
188
  });
189
189
  // Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
190
190
  // of the current `next dev` invocation.
@@ -4,7 +4,7 @@ import { bold, purple } from '../../lib/picocolors';
4
4
  import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from '../../shared/lib/constants';
5
5
  import loadConfig, { getEnabledExperimentalFeatures } from '../config';
6
6
  export function logStartInfo({ networkUrl, appUrl, envInfo, expFeatureInfo, maxExperimentalFeatures = Infinity }) {
7
- Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"15.0.4-canary.37"}`))}${process.env.TURBOPACK ? ' (Turbopack)' : ''}`);
7
+ Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"15.0.4-canary.38"}`))}${process.env.TURBOPACK ? ' (Turbopack)' : ''}`);
8
8
  if (appUrl) {
9
9
  Log.bootstrap(`- Local: ${appUrl}`);
10
10
  }
@@ -43,7 +43,7 @@ export async function getRequestHandlers({ dir, port, isDev, onDevServerCleanup,
43
43
  export async function startServer(serverOptions) {
44
44
  const { dir, isDev, hostname, minimalMode, allowRetry, keepAliveTimeout, selfSignedCertificate } = serverOptions;
45
45
  let { port } = serverOptions;
46
- process.title = `next-server (v${"15.0.4-canary.37"})`;
46
+ process.title = `next-server (v${"15.0.4-canary.38"})`;
47
47
  let handlersReady = ()=>{};
48
48
  let handlersError = ()=>{};
49
49
  let handlersPromise = new Promise((resolve, reject)=>{
@@ -234,7 +234,7 @@ function assignDefaults(dir, userConfig, silent) {
234
234
  if (((_result_experimental = result.experimental) == null ? void 0 : _result_experimental.allowDevelopmentBuild) && process.env.NODE_ENV !== 'development') {
235
235
  throw new Error(`The experimental.allowDevelopmentBuild option requires NODE_ENV to be explicitly set to 'development'.`);
236
236
  }
237
- if (!((_process_env___NEXT_VERSION = "15.0.4-canary.37") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_SKIP_CANARY_CHECK) {
237
+ if (!((_process_env___NEXT_VERSION = "15.0.4-canary.38") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_SKIP_CANARY_CHECK) {
238
238
  var _result_experimental7, _result_experimental8, _result_experimental_turbo3, _result_experimental9, _result_experimental10;
239
239
  // Prevents usage of certain experimental features outside of canary
240
240
  if ((_result_experimental7 = result.experimental) == null ? void 0 : _result_experimental7.ppr) {
@@ -104,7 +104,7 @@ async function createHotReloaderTurbopack(opts, serverFields, distDir, resetFetc
104
104
  }
105
105
  const hasRewrites = opts.fsChecker.rewrites.afterFiles.length > 0 || opts.fsChecker.rewrites.beforeFiles.length > 0 || opts.fsChecker.rewrites.fallback.length > 0;
106
106
  const hotReloaderSpan = (0, _trace.trace)('hot-reloader', undefined, {
107
- version: "15.0.4-canary.37"
107
+ version: "15.0.4-canary.38"
108
108
  });
109
109
  // Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
110
110
  // of the current `next dev` invocation.
@@ -260,7 +260,7 @@ class HotReloaderWebpack {
260
260
  this.previewProps = previewProps;
261
261
  this.rewrites = rewrites;
262
262
  this.hotReloaderSpan = (0, _trace.trace)('hot-reloader', undefined, {
263
- version: "15.0.4-canary.37"
263
+ version: "15.0.4-canary.38"
264
264
  });
265
265
  // Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
266
266
  // of the current `next dev` invocation.
@@ -67,7 +67,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
67
67
  return newObj;
68
68
  }
69
69
  function logStartInfo({ networkUrl, appUrl, envInfo, expFeatureInfo, maxExperimentalFeatures = Infinity }) {
70
- _log.bootstrap(`${(0, _picocolors.bold)((0, _picocolors.purple)(`${_log.prefixes.ready} Next.js ${"15.0.4-canary.37"}`))}${process.env.TURBOPACK ? ' (Turbopack)' : ''}`);
70
+ _log.bootstrap(`${(0, _picocolors.bold)((0, _picocolors.purple)(`${_log.prefixes.ready} Next.js ${"15.0.4-canary.38"}`))}${process.env.TURBOPACK ? ' (Turbopack)' : ''}`);
71
71
  if (appUrl) {
72
72
  _log.bootstrap(`- Local: ${appUrl}`);
73
73
  }
@@ -111,7 +111,7 @@ async function getRequestHandlers({ dir, port, isDev, onDevServerCleanup, server
111
111
  async function startServer(serverOptions) {
112
112
  const { dir, isDev, hostname, minimalMode, allowRetry, keepAliveTimeout, selfSignedCertificate } = serverOptions;
113
113
  let { port } = serverOptions;
114
- process.title = `next-server (v${"15.0.4-canary.37"})`;
114
+ process.title = `next-server (v${"15.0.4-canary.38"})`;
115
115
  let handlersReady = ()=>{};
116
116
  let handlersError = ()=>{};
117
117
  let handlersPromise = new Promise((resolve, reject)=>{
@@ -81,7 +81,7 @@ function getAnonymousMeta() {
81
81
  isWsl: _iswsl.default,
82
82
  isCI: _ciinfo.isCI,
83
83
  ciName: _ciinfo.isCI && _ciinfo.name || null,
84
- nextVersion: "15.0.4-canary.37"
84
+ nextVersion: "15.0.4-canary.38"
85
85
  };
86
86
  return traits;
87
87
  }
@@ -11,11 +11,11 @@ Object.defineProperty(exports, "eventCliSessionStopped", {
11
11
  const EVENT_VERSION = 'NEXT_CLI_SESSION_STOPPED';
12
12
  function eventCliSessionStopped(event) {
13
13
  // This should be an invariant, if it fails our build tooling is broken.
14
- if (typeof "15.0.4-canary.37" !== 'string') {
14
+ if (typeof "15.0.4-canary.38" !== 'string') {
15
15
  return [];
16
16
  }
17
17
  const payload = {
18
- nextVersion: "15.0.4-canary.37",
18
+ nextVersion: "15.0.4-canary.38",
19
19
  nodeVersion: process.version,
20
20
  cliCommand: event.cliCommand,
21
21
  durationMilliseconds: event.durationMilliseconds,
@@ -36,12 +36,12 @@ function hasBabelConfig(dir) {
36
36
  function eventCliSession(dir, nextConfig, event) {
37
37
  var _nextConfig_experimental_staleTimes, _nextConfig_experimental_staleTimes1, _nextConfig_experimental_reactCompiler, _nextConfig_experimental_reactCompiler1;
38
38
  // This should be an invariant, if it fails our build tooling is broken.
39
- if (typeof "15.0.4-canary.37" !== 'string') {
39
+ if (typeof "15.0.4-canary.38" !== 'string') {
40
40
  return [];
41
41
  }
42
42
  const { images, i18n } = nextConfig || {};
43
43
  const payload = {
44
- nextVersion: "15.0.4-canary.37",
44
+ nextVersion: "15.0.4-canary.38",
45
45
  nodeVersion: process.version,
46
46
  cliCommand: event.cliCommand,
47
47
  isSrcDir: event.isSrcDir,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next",
3
- "version": "15.0.4-canary.37",
3
+ "version": "15.0.4-canary.38",
4
4
  "description": "The React Framework",
5
5
  "main": "./dist/server/next.js",
6
6
  "license": "MIT",
@@ -97,7 +97,7 @@
97
97
  ]
98
98
  },
99
99
  "dependencies": {
100
- "@next/env": "15.0.4-canary.37",
100
+ "@next/env": "15.0.4-canary.38",
101
101
  "@swc/counter": "0.1.3",
102
102
  "@swc/helpers": "0.5.13",
103
103
  "busboy": "1.6.0",
@@ -129,14 +129,14 @@
129
129
  },
130
130
  "optionalDependencies": {
131
131
  "sharp": "^0.33.5",
132
- "@next/swc-darwin-arm64": "15.0.4-canary.37",
133
- "@next/swc-darwin-x64": "15.0.4-canary.37",
134
- "@next/swc-linux-arm64-gnu": "15.0.4-canary.37",
135
- "@next/swc-linux-arm64-musl": "15.0.4-canary.37",
136
- "@next/swc-linux-x64-gnu": "15.0.4-canary.37",
137
- "@next/swc-linux-x64-musl": "15.0.4-canary.37",
138
- "@next/swc-win32-arm64-msvc": "15.0.4-canary.37",
139
- "@next/swc-win32-x64-msvc": "15.0.4-canary.37"
132
+ "@next/swc-darwin-arm64": "15.0.4-canary.38",
133
+ "@next/swc-darwin-x64": "15.0.4-canary.38",
134
+ "@next/swc-linux-arm64-gnu": "15.0.4-canary.38",
135
+ "@next/swc-linux-arm64-musl": "15.0.4-canary.38",
136
+ "@next/swc-linux-x64-gnu": "15.0.4-canary.38",
137
+ "@next/swc-linux-x64-musl": "15.0.4-canary.38",
138
+ "@next/swc-win32-arm64-msvc": "15.0.4-canary.38",
139
+ "@next/swc-win32-x64-msvc": "15.0.4-canary.38"
140
140
  },
141
141
  "devDependencies": {
142
142
  "@ampproject/toolbox-optimizer": "2.8.3",
@@ -169,11 +169,11 @@
169
169
  "@jest/types": "29.5.0",
170
170
  "@mswjs/interceptors": "0.23.0",
171
171
  "@napi-rs/triples": "1.2.0",
172
- "@next/font": "15.0.4-canary.37",
173
- "@next/polyfill-module": "15.0.4-canary.37",
174
- "@next/polyfill-nomodule": "15.0.4-canary.37",
175
- "@next/react-refresh-utils": "15.0.4-canary.37",
176
- "@next/swc": "15.0.4-canary.37",
172
+ "@next/font": "15.0.4-canary.38",
173
+ "@next/polyfill-module": "15.0.4-canary.38",
174
+ "@next/polyfill-nomodule": "15.0.4-canary.38",
175
+ "@next/react-refresh-utils": "15.0.4-canary.38",
176
+ "@next/swc": "15.0.4-canary.38",
177
177
  "@opentelemetry/api": "1.6.0",
178
178
  "@playwright/test": "1.41.2",
179
179
  "@swc/core": "1.9.3",