Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nextjs): Only delete clientside bundle source maps with sourcemaps.deleteFilesAfterUpload #13102

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ assert.match(buildStdout, /(λ|ƒ) \/server-component\/parameter\/\[\.\.\.parame
assert.match(buildStdout, /(λ|ƒ) \/server-component\/parameter\/\[parameter\]/);

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

export {};
9 changes: 6 additions & 3 deletions packages/nextjs/src/config/webpackPluginOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@ export function getWebpackPluginOptions(
ignore: sentryBuildOptions.sourcemaps?.ignore ?? sourcemapUploadIgnore,
filesToDeleteAfterUpload: sentryBuildOptions.sourcemaps?.deleteSourcemapsAfterUpload
? [
path.join(distDirAbsPath, '**', '*.js.map'),
path.join(distDirAbsPath, '**', '*.mjs.map'),
path.join(distDirAbsPath, '**', '*.cjs.map'),
// We only care to delete client bundle source maps because they would be the ones being served.
// Removing the server source maps crashes Vercel builds for (thus far) unknown reasons:
// https://github.com/getsentry/sentry-javascript/issues/13099
path.join(distDirAbsPath, 'static', '**', '*.js.map'),
path.join(distDirAbsPath, 'static', '**', '*.mjs.map'),
path.join(distDirAbsPath, 'static', '**', '*.cjs.map'),
]
: undefined,
...sentryBuildOptions.unstable_sentryWebpackPluginOptions?.sourcemaps,
Expand Down
Loading