Skip to content

Commit 13a2050

Browse files
committed
add option to use hidden-source-map
1 parent ff923f9 commit 13a2050

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

packages/nextjs/src/config/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export type NextConfigObject = {
2020
sentry?: {
2121
disableServerWebpackPlugin?: boolean;
2222
disableClientWebpackPlugin?: boolean;
23+
hideSourceMaps?: boolean;
2324
};
2425
} & {
2526
// other `next.config.js` options

packages/nextjs/src/config/webpack.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,11 @@ export function constructWebpackConfigFunction(
7777
if (enableWebpackPlugin) {
7878
// TODO Handle possibility that user is using `SourceMapDevToolPlugin` (see
7979
// https://webpack.js.org/plugins/source-map-dev-tool-plugin/)
80-
// TODO Give user option to use `hidden-source-map` ?
8180

8281
// Next doesn't let you change this is dev even if you want to - see
8382
// https://github.com/vercel/next.js/blob/master/errors/improper-devtool.md
8483
if (!buildContext.dev) {
85-
newConfig.devtool = 'source-map';
84+
newConfig.devtool = userNextConfig.sentry?.hideSourceMaps ? 'hidden-source-map' : 'source-map';
8685
}
8786

8887
newConfig.plugins = newConfig.plugins || [];

packages/nextjs/test/config.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,19 @@ describe('webpack config', () => {
300300
expect(finalWebpackConfig).toEqual(expect.objectContaining(materializedUserWebpackConfig));
301301
});
302302

303+
it('allows for the use of `hidden-source-map` as `devtool` value', async () => {
304+
const userNextConfigHiddenSourceMaps = { ...userNextConfig, sentry: { ...userNextConfig.sentry } };
305+
userNextConfigHiddenSourceMaps.sentry.hideSourceMaps = true;
306+
307+
const finalWebpackConfig = await materializeFinalWebpackConfig({
308+
userNextConfig: userNextConfigHiddenSourceMaps,
309+
incomingWebpackConfig: serverWebpackConfig,
310+
incomingWebpackBuildContext: serverBuildContext,
311+
});
312+
313+
expect(finalWebpackConfig.devtool).toEqual('hidden-source-map');
314+
});
315+
303316
describe('webpack `entry` property config', () => {
304317
const serverConfigFilePath = `./${SERVER_SDK_CONFIG_FILE}`;
305318
const clientConfigFilePath = `./${CLIENT_SDK_CONFIG_FILE}`;

0 commit comments

Comments
 (0)