Skip to content

feat(nextjs): Directly forward sourcemaps.disable to webpack plugin #15109

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

Merged
merged 2 commits into from
Jan 21, 2025
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
2 changes: 1 addition & 1 deletion packages/nextjs/src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export type SentryBuildOptions = {
*/
sourcemaps?: {
/**
* Disable any functionality related to source maps upload.
* Disable any functionality related to source maps.
*/
disable?: boolean;

Expand Down
7 changes: 2 additions & 5 deletions packages/nextjs/src/config/webpackPluginOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function getWebpackPluginOptions(
const distDir = (userNextConfig as NextConfigObject).distDir?.replace(/\\/g, '/') ?? '.next';
const distDirAbsPath = path.posix.join(projectDir, distDir);

let sourcemapUploadAssets: string[] = [];
const sourcemapUploadAssets: string[] = [];
const sourcemapUploadIgnore: string[] = [];

if (isServer) {
Expand Down Expand Up @@ -51,10 +51,6 @@ export function getWebpackPluginOptions(
);
}

if (sentryBuildOptions.sourcemaps?.disable) {
sourcemapUploadAssets = [];
}

return {
authToken: sentryBuildOptions.authToken,
headers: sentryBuildOptions.headers,
Expand All @@ -69,6 +65,7 @@ export function getWebpackPluginOptions(
silent: sentryBuildOptions.silent,
url: sentryBuildOptions.sentryUrl,
sourcemaps: {
disable: sentryBuildOptions.sourcemaps?.disable,
rewriteSources(source) {
if (source.startsWith('webpack://_N_E/')) {
return source.replace('webpack://_N_E/', '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ describe('getWebpackPluginOptions()', () => {
});
});

it('sets `sourcemaps.assets` to an empty array when `sourcemaps.disable` is true', () => {
it('sets `sourcemaps.disable` plugin options to true when `sourcemaps.disable` is true', () => {
const buildContext = generateBuildContext({ isServer: false });
const generatedPluginOptions = getWebpackPluginOptions(buildContext, { sourcemaps: { disable: true } }, undefined);
expect(generatedPluginOptions.sourcemaps).toMatchObject({
assets: [],
disable: true,
});
});

Expand Down
Loading