Skip to content

Commit 03e0d02

Browse files
authored
feat(nextjs): Directly forward sourcemaps.disable to webpack plugin (#15109)
1 parent a017048 commit 03e0d02

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

packages/nextjs/src/config/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export type SentryBuildOptions = {
122122
*/
123123
sourcemaps?: {
124124
/**
125-
* Disable any functionality related to source maps upload.
125+
* Disable any functionality related to source maps.
126126
*/
127127
disable?: boolean;
128128

packages/nextjs/src/config/webpackPluginOptions.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function getWebpackPluginOptions(
2323
const distDir = (userNextConfig as NextConfigObject).distDir?.replace(/\\/g, '/') ?? '.next';
2424
const distDirAbsPath = path.posix.join(projectDir, distDir);
2525

26-
let sourcemapUploadAssets: string[] = [];
26+
const sourcemapUploadAssets: string[] = [];
2727
const sourcemapUploadIgnore: string[] = [];
2828

2929
if (isServer) {
@@ -51,10 +51,6 @@ export function getWebpackPluginOptions(
5151
);
5252
}
5353

54-
if (sentryBuildOptions.sourcemaps?.disable) {
55-
sourcemapUploadAssets = [];
56-
}
57-
5854
return {
5955
authToken: sentryBuildOptions.authToken,
6056
headers: sentryBuildOptions.headers,
@@ -69,6 +65,7 @@ export function getWebpackPluginOptions(
6965
silent: sentryBuildOptions.silent,
7066
url: sentryBuildOptions.sentryUrl,
7167
sourcemaps: {
68+
disable: sentryBuildOptions.sourcemaps?.disable,
7269
rewriteSources(source) {
7370
if (source.startsWith('webpack://_N_E/')) {
7471
return source.replace('webpack://_N_E/', '');

packages/nextjs/test/config/webpack/webpackPluginOptions.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,11 @@ describe('getWebpackPluginOptions()', () => {
173173
});
174174
});
175175

176-
it('sets `sourcemaps.assets` to an empty array when `sourcemaps.disable` is true', () => {
176+
it('sets `sourcemaps.disable` plugin options to true when `sourcemaps.disable` is true', () => {
177177
const buildContext = generateBuildContext({ isServer: false });
178178
const generatedPluginOptions = getWebpackPluginOptions(buildContext, { sourcemaps: { disable: true } }, undefined);
179179
expect(generatedPluginOptions.sourcemaps).toMatchObject({
180-
assets: [],
180+
disable: true,
181181
});
182182
});
183183

0 commit comments

Comments
 (0)