Skip to content

Commit ce53667

Browse files
authored
fix(nextjs): Only delete clientside bundle source maps with sourcemaps.deleteFilesAfterUpload (#13102)
1 parent e3af1ce commit ce53667

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

dev-packages/e2e-tests/test-applications/nextjs-app-dir/assert-build.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ assert.match(buildStdout, /(λ|ƒ) \/server-component\/parameter\/\[\.\.\.parame
2222
assert.match(buildStdout, /(λ|ƒ) \/server-component\/parameter\/\[parameter\]/);
2323

2424
// Read the contents of the directory
25-
const files = fs.readdirSync(path.join(process.cwd(), '.next', 'server'));
25+
const files = fs.readdirSync(path.join(process.cwd(), '.next', 'static'));
2626
const mapFiles = files.filter(file => path.extname(file) === '.map');
2727
if (mapFiles.length > 0) {
28-
throw new Error('.map files found even though `sourcemaps.deleteSourcemapsAfterUpload` option is set!');
28+
throw new Error('Client bundle .map files found even though `sourcemaps.deleteSourcemapsAfterUpload` option is set!');
2929
}
3030

3131
export {};

packages/nextjs/src/config/webpackPluginOptions.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,12 @@ export function getWebpackPluginOptions(
7676
ignore: sentryBuildOptions.sourcemaps?.ignore ?? sourcemapUploadIgnore,
7777
filesToDeleteAfterUpload: sentryBuildOptions.sourcemaps?.deleteSourcemapsAfterUpload
7878
? [
79-
path.join(distDirAbsPath, '**', '*.js.map'),
80-
path.join(distDirAbsPath, '**', '*.mjs.map'),
81-
path.join(distDirAbsPath, '**', '*.cjs.map'),
79+
// We only care to delete client bundle source maps because they would be the ones being served.
80+
// Removing the server source maps crashes Vercel builds for (thus far) unknown reasons:
81+
// https://github.com/getsentry/sentry-javascript/issues/13099
82+
path.join(distDirAbsPath, 'static', '**', '*.js.map'),
83+
path.join(distDirAbsPath, 'static', '**', '*.mjs.map'),
84+
path.join(distDirAbsPath, 'static', '**', '*.cjs.map'),
8285
]
8386
: undefined,
8487
...sentryBuildOptions.unstable_sentryWebpackPluginOptions?.sourcemaps,

0 commit comments

Comments
 (0)