@@ -267,6 +267,98 @@ describe('withSentryConfig', () => {
267267
268268 expect ( finalConfig . turbopack ) . toBeUndefined ( ) ;
269269 } ) ;
270+
271+ describe ( 'webpack configuration options path' , ( ) => {
272+ afterEach ( ( ) => {
273+ delete process . env . TURBOPACK ;
274+ vi . restoreAllMocks ( ) ;
275+ } ) ;
276+
277+ it ( 'uses new webpack.disableSentryConfig option' , ( ) => {
278+ delete process . env . TURBOPACK ;
279+
280+ const originalWebpackFunction = vi . fn ( ) ;
281+ const configWithWebpack = {
282+ ...exportedNextConfig ,
283+ webpack : originalWebpackFunction ,
284+ } ;
285+
286+ const sentryOptions = {
287+ webpack : {
288+ disableSentryConfig : true ,
289+ } ,
290+ } ;
291+
292+ const finalConfig = materializeFinalNextConfig ( configWithWebpack , undefined , sentryOptions ) ;
293+ expect ( finalConfig . webpack ) . toBe ( originalWebpackFunction ) ;
294+ } ) ;
295+
296+ it ( 'new webpack path takes precedence over deprecated top-level options' , ( ) => {
297+ delete process . env . TURBOPACK ;
298+
299+ const originalWebpackFunction = vi . fn ( ) ;
300+ const configWithWebpack = {
301+ ...exportedNextConfig ,
302+ webpack : originalWebpackFunction ,
303+ } ;
304+
305+ // Both old and new paths set, new should win
306+ const sentryOptions = {
307+ disableSentryWebpackConfig : false , // deprecated - says enable
308+ webpack : {
309+ disableSentryConfig : true , // new - says disable
310+ } ,
311+ } ;
312+
313+ const finalConfig = materializeFinalNextConfig ( configWithWebpack , undefined , sentryOptions ) ;
314+ // Should preserve original webpack because new path disables it
315+ expect ( finalConfig . webpack ) . toBe ( originalWebpackFunction ) ;
316+ } ) ;
317+
318+ it ( 'falls back to deprecated option when new path is not set' , ( ) => {
319+ delete process . env . TURBOPACK ;
320+
321+ const originalWebpackFunction = vi . fn ( ) ;
322+ const configWithWebpack = {
323+ ...exportedNextConfig ,
324+ webpack : originalWebpackFunction ,
325+ } ;
326+
327+ // Only deprecated path set
328+ const sentryOptions = {
329+ disableSentryWebpackConfig : true ,
330+ } ;
331+
332+ const finalConfig = materializeFinalNextConfig ( configWithWebpack , undefined , sentryOptions ) ;
333+ // Should preserve original webpack because deprecated option disables it
334+ expect ( finalConfig . webpack ) . toBe ( originalWebpackFunction ) ;
335+ } ) ;
336+
337+ it ( 'merges webpack.treeshake.debugLogs with deprecated disableLogger' , ( ) => {
338+ delete process . env . TURBOPACK ;
339+
340+ // New webpack.treeshake.debugLogs should map to disableLogger internally
341+ const sentryOptionsNew = {
342+ webpack : {
343+ treeshake : {
344+ debugLogs : true ,
345+ } ,
346+ } ,
347+ } ;
348+
349+ const sentryOptionsOld = {
350+ disableLogger : true ,
351+ } ;
352+
353+ // Both should work the same way internally (though we can't easily test the actual effect here)
354+ const finalConfigNew = materializeFinalNextConfig ( exportedNextConfig , undefined , sentryOptionsNew ) ;
355+ const finalConfigOld = materializeFinalNextConfig ( exportedNextConfig , undefined , sentryOptionsOld ) ;
356+
357+ // Both should have webpack functions (not disabled)
358+ expect ( finalConfigNew . webpack ) . toBeInstanceOf ( Function ) ;
359+ expect ( finalConfigOld . webpack ) . toBeInstanceOf ( Function ) ;
360+ } ) ;
361+ } ) ;
270362 } ) ;
271363
272364 describe ( 'bundler detection' , ( ) => {
0 commit comments