Skip to content

Commit a732ae8

Browse files
authored
ref(nextjs): Stop setting redundant productionBrowserSourceMaps in config (#3765)
Before this change, `withSentryConfig` both set `productionBrowserSourceMaps` to `true` in the main `nextjs` config and set `devtool` to `source-map` in the webpack config. It turns out, though, that the only thing the former change does is cause nextjs to make the latter change itself. [1] (All other references to `productionBrowserSourceMaps` in the nextjs code are merely type annotations or instances of passing the value from one function to another. [2] The linked code is the only place that value is actually used.) Therefore, since we're making the `devtool` config change ourselves, the `productionBrowserSourceMaps` config change was redundant, and could be removed. (Of the two config changes, we wanted to remove this one and not the `devtool` one, since we want sourcemaps for both server and client builds. `devtool` affects both, whereas `productionBrowserSourceMaps` (as the name implies) only affects the client build.) [1] https://github.com/vercel/next.js/blob/fa138358e1df7ca6d1bab7da57e18031d5abbf27/packages/next/build/webpack/config/blocks/base.ts#L39-L43 [2] https://github.com/vercel/next.js/search?q=productionBrowserSourceMaps
1 parent a904415 commit a732ae8

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

packages/nextjs/src/config/index.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,17 @@ export function withSentryConfig(
1212
userNextConfig: ExportedNextConfig = {},
1313
userSentryWebpackPluginOptions: Partial<SentryWebpackPluginOptions> = {},
1414
): NextConfigFunction | NextConfigObject {
15-
const partialConfig = {
16-
// TODO When we add a way to disable the webpack plugin, doing so should turn this off, too
17-
productionBrowserSourceMaps: true,
18-
webpack: constructWebpackConfigFunction(userNextConfig, userSentryWebpackPluginOptions),
19-
};
15+
const newWebpackConfig = constructWebpackConfigFunction(userNextConfig, userSentryWebpackPluginOptions);
2016

2117
// If the user has passed us a function, we need to return a function, so that we have access to `phase` and
2218
// `defaults` in order to pass them along to the user's function
2319
if (typeof userNextConfig === 'function') {
2420
return (phase: string, defaults: { defaultConfig: { [key: string]: unknown } }): NextConfigObject => ({
2521
...userNextConfig(phase, defaults),
26-
...partialConfig,
22+
webpack: newWebpackConfig,
2723
});
2824
}
2925

3026
// Otherwise, we can just merge their config with ours and return an object.
31-
return { ...userNextConfig, ...partialConfig };
27+
return { ...userNextConfig, webpack: newWebpackConfig };
3228
}

packages/nextjs/test/config.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ describe('withSentryConfig', () => {
115115

116116
expect(finalConfig).toEqual(
117117
expect.objectContaining({
118-
productionBrowserSourceMaps: true,
119118
webpack: expect.any(Function), // `webpack` is tested specifically elsewhere
120119
}),
121120
);
@@ -133,7 +132,6 @@ describe('withSentryConfig', () => {
133132
expect(finalConfig).toEqual(
134133
expect.objectContaining({
135134
...userNextConfig,
136-
productionBrowserSourceMaps: true,
137135
webpack: expect.any(Function), // `webpack` is tested specifically elsewhere
138136
}),
139137
);
@@ -147,7 +145,6 @@ describe('withSentryConfig', () => {
147145
expect(finalConfig).toEqual(
148146
expect.objectContaining({
149147
...userNextConfigFunction(),
150-
productionBrowserSourceMaps: true,
151148
webpack: expect.any(Function), // `webpack` is tested specifically elsewhere
152149
}),
153150
);

0 commit comments

Comments
 (0)