Skip to content

Commit dc95cc0

Browse files
committed
don't delete server source maps
1 parent 85c2df4 commit dc95cc0

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

packages/nextjs/src/config/getBuildPluginOptions.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,24 @@ export function getBuildPluginOptions({
5353
sourcemapUploadAssets.push(path.posix.join(normalizedDistDirAbsPath, 'static', 'chunks', '**'));
5454
} else {
5555
// Webpack client builds
56-
sourcemapUploadAssets.push(
57-
path.posix.join(normalizedDistDirAbsPath, 'static', 'chunks', 'pages', '**'),
58-
path.posix.join(normalizedDistDirAbsPath, 'static', 'chunks', 'app', '**'),
59-
);
56+
if (sentryBuildOptions.widenClientFileUpload) {
57+
sourcemapUploadAssets.push(path.posix.join(normalizedDistDirAbsPath, 'static', 'chunks', '**'));
58+
} else {
59+
sourcemapUploadAssets.push(
60+
path.posix.join(normalizedDistDirAbsPath, 'static', 'chunks', 'pages', '**'),
61+
path.posix.join(normalizedDistDirAbsPath, 'static', 'chunks', 'app', '**'),
62+
);
63+
}
6064
}
6165

6266
if (sentryBuildOptions.sourcemaps?.deleteSourcemapsAfterUpload) {
6367
filesToDeleteAfterUpload.push(
64-
path.posix.join(normalizedDistDirAbsPath, '**', '*.js.map'),
65-
path.posix.join(normalizedDistDirAbsPath, '**', '*.mjs.map'),
66-
path.posix.join(normalizedDistDirAbsPath, '**', '*.cjs.map'),
68+
// We only care to delete client bundle source maps because they would be the ones being served.
69+
// Removing the server source maps crashes Vercel builds for (thus far) unknown reasons:
70+
// https://github.com/getsentry/sentry-javascript/issues/13099
71+
path.posix.join(normalizedDistDirAbsPath, 'static', '**', '*.js.map'),
72+
path.posix.join(normalizedDistDirAbsPath, 'static', '**', '*.mjs.map'),
73+
path.posix.join(normalizedDistDirAbsPath, 'static', '**', '*.cjs.map'),
6774
);
6875
}
6976
} else {

packages/nextjs/test/config/getBuildPluginOptions.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,9 @@ describe('getBuildPluginOptions', () => {
313313
});
314314

315315
expect(result.sourcemaps?.filesToDeleteAfterUpload).toEqual([
316-
'/path/to/.next/**/*.js.map',
317-
'/path/to/.next/**/*.mjs.map',
318-
'/path/to/.next/**/*.cjs.map',
316+
'/path/to/.next/static/**/*.js.map',
317+
'/path/to/.next/static/**/*.mjs.map',
318+
'/path/to/.next/static/**/*.cjs.map',
319319
]);
320320
});
321321

@@ -336,9 +336,9 @@ describe('getBuildPluginOptions', () => {
336336
});
337337

338338
expect(result.sourcemaps?.filesToDeleteAfterUpload).toEqual([
339-
'/path/to/.next/**/*.js.map',
340-
'/path/to/.next/**/*.mjs.map',
341-
'/path/to/.next/**/*.cjs.map',
339+
'/path/to/.next/static/**/*.js.map',
340+
'/path/to/.next/static/**/*.mjs.map',
341+
'/path/to/.next/static/**/*.cjs.map',
342342
]);
343343
});
344344

@@ -802,9 +802,9 @@ describe('getBuildPluginOptions', () => {
802802
`${complexPath}/static/chunks/**`,
803803
]);
804804
expect(result.sourcemaps?.filesToDeleteAfterUpload).toEqual([
805-
`${complexPath}/**/*.js.map`,
806-
`${complexPath}/**/*.mjs.map`,
807-
`${complexPath}/**/*.cjs.map`,
805+
`${complexPath}/static/**/*.js.map`,
806+
`${complexPath}/static/**/*.mjs.map`,
807+
`${complexPath}/static/**/*.cjs.map`,
808808
]);
809809
});
810810
});

0 commit comments

Comments
 (0)