Skip to content

Commit ac45e57

Browse files
authored
feat(nextjs): Print Turbopack note for deprecated webpack options (#18769)
closes #18758 Prints a note if a user is using deprecated webpack options with turbopack.
1 parent cc93c68 commit ac45e57

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

packages/nextjs/src/config/withSentryConfig.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,16 @@ function migrateDeprecatedWebpackOptions(userSentryOptions: SentryBuildOptions):
122122
return newValue ?? deprecatedValue;
123123
};
124124

125-
const deprecatedMessage = (deprecatedPath: string, newPath: string): string =>
126-
`[@sentry/nextjs] DEPRECATION WARNING: ${deprecatedPath} is deprecated and will be removed in a future version. Use ${newPath} instead.`;
125+
const deprecatedMessage = (deprecatedPath: string, newPath: string): string => {
126+
const message = `[@sentry/nextjs] DEPRECATION WARNING: ${deprecatedPath} is deprecated and will be removed in a future version. Use ${newPath} instead.`;
127+
128+
// In Turbopack builds, webpack configuration is not applied, so webpack-scoped options won't have any effect.
129+
if (detectActiveBundler() === 'turbopack' && newPath.startsWith('webpack.')) {
130+
return `${message} (Not supported with Turbopack.)`;
131+
}
132+
133+
return message;
134+
};
127135

128136
/* eslint-disable deprecation/deprecation */
129137
// Migrate each deprecated option to the new path, but only if the new path isn't already set

packages/nextjs/test/config/withSentryConfig.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,21 @@ describe('withSentryConfig', () => {
390390
);
391391
});
392392

393+
it('adds a turbopack note when the deprecated option only applies to webpack', () => {
394+
process.env.TURBOPACK = '1';
395+
vi.spyOn(util, 'getNextjsVersion').mockReturnValue('16.0.0');
396+
397+
const sentryOptions = {
398+
disableLogger: true,
399+
};
400+
401+
materializeFinalNextConfig(exportedNextConfig, undefined, sentryOptions);
402+
403+
expect(consoleWarnSpy).toHaveBeenCalledWith(
404+
expect.stringContaining('Use webpack.treeshake.removeDebugLogging instead. (Not supported with Turbopack.)'),
405+
);
406+
});
407+
393408
it('does not warn when using new webpack path', () => {
394409
delete process.env.TURBOPACK;
395410

0 commit comments

Comments
 (0)