@@ -876,16 +876,13 @@ describe('withSentryConfig', () => {
876876 expect ( finalConfig . compiler ?. runAfterProductionCompile ) . toBeInstanceOf ( Function ) ;
877877 } ) ;
878878
879- it ( 'works with turbopack builds when TURBOPACK env is set ' , ( ) => {
879+ it ( 'defaults to true for turbopack when useRunAfterProductionCompileHook is not specified ' , ( ) => {
880880 process . env . TURBOPACK = '1' ;
881881 vi . spyOn ( util , 'getNextjsVersion' ) . mockReturnValue ( '15.4.1' ) ;
882882 vi . spyOn ( util , 'supportsProductionCompileHook' ) . mockReturnValue ( true ) ;
883883
884- const sentryOptions = {
885- useRunAfterProductionCompileHook : true ,
886- } ;
884+ const sentryOptions = { } ; // No useRunAfterProductionCompileHook specified
887885
888- // Use a clean copy of the config to avoid test interference
889886 const cleanConfig = { ...exportedNextConfig } ;
890887 delete cleanConfig . compiler ;
891888
@@ -896,20 +893,78 @@ describe('withSentryConfig', () => {
896893 delete process . env . TURBOPACK ;
897894 } ) ;
898895
899- it ( 'works with webpack builds when TURBOPACK env is not set ' , ( ) => {
896+ it ( 'defaults to false for webpack when useRunAfterProductionCompileHook is not specified ' , ( ) => {
900897 delete process . env . TURBOPACK ;
901898 vi . spyOn ( util , 'supportsProductionCompileHook' ) . mockReturnValue ( true ) ;
902899
900+ const sentryOptions = { } ; // No useRunAfterProductionCompileHook specified
901+
902+ const cleanConfig = { ...exportedNextConfig } ;
903+ delete cleanConfig . compiler ;
904+
905+ const finalConfig = materializeFinalNextConfig ( cleanConfig , undefined , sentryOptions ) ;
906+
907+ expect ( finalConfig . compiler ?. runAfterProductionCompile ) . toBeUndefined ( ) ;
908+ } ) ;
909+
910+ it ( 'respects explicit false setting for turbopack' , ( ) => {
911+ process . env . TURBOPACK = '1' ;
912+ vi . spyOn ( util , 'getNextjsVersion' ) . mockReturnValue ( '15.4.1' ) ;
913+ vi . spyOn ( util , 'supportsProductionCompileHook' ) . mockReturnValue ( true ) ;
914+
903915 const sentryOptions = {
904- useRunAfterProductionCompileHook : true ,
916+ useRunAfterProductionCompileHook : false ,
905917 } ;
906918
907- // Use a clean copy of the config to avoid test interference
908919 const cleanConfig = { ...exportedNextConfig } ;
909920 delete cleanConfig . compiler ;
910921
911922 const finalConfig = materializeFinalNextConfig ( cleanConfig , undefined , sentryOptions ) ;
912923
924+ expect ( finalConfig . compiler ?. runAfterProductionCompile ) . toBeUndefined ( ) ;
925+
926+ delete process . env . TURBOPACK ;
927+ } ) ;
928+
929+ it ( 'respects explicit true setting for webpack' , ( ) => {
930+ delete process . env . TURBOPACK ;
931+ vi . spyOn ( util , 'supportsProductionCompileHook' ) . mockReturnValue ( true ) ;
932+
933+ const sentryOptions = {
934+ useRunAfterProductionCompileHook : true ,
935+ } ;
936+
937+ const finalConfig = materializeFinalNextConfig ( exportedNextConfig , undefined , sentryOptions ) ;
938+
939+ expect ( finalConfig . compiler ?. runAfterProductionCompile ) . toBeInstanceOf ( Function ) ;
940+ } ) ;
941+
942+ it ( 'works with turbopack builds when TURBOPACK env is set' , ( ) => {
943+ process . env . TURBOPACK = '1' ;
944+ vi . spyOn ( util , 'getNextjsVersion' ) . mockReturnValue ( '15.4.1' ) ;
945+ vi . spyOn ( util , 'supportsProductionCompileHook' ) . mockReturnValue ( true ) ;
946+
947+ const sentryOptions = {
948+ useRunAfterProductionCompileHook : true ,
949+ } ;
950+
951+ const finalConfig = materializeFinalNextConfig ( exportedNextConfig , undefined , sentryOptions ) ;
952+
953+ expect ( finalConfig . compiler ?. runAfterProductionCompile ) . toBeInstanceOf ( Function ) ;
954+
955+ delete process . env . TURBOPACK ;
956+ } ) ;
957+
958+ it ( 'works with webpack builds when TURBOPACK env is not set' , ( ) => {
959+ delete process . env . TURBOPACK ;
960+ vi . spyOn ( util , 'supportsProductionCompileHook' ) . mockReturnValue ( true ) ;
961+
962+ const sentryOptions = {
963+ useRunAfterProductionCompileHook : true ,
964+ } ;
965+
966+ const finalConfig = materializeFinalNextConfig ( exportedNextConfig , undefined , sentryOptions ) ;
967+
913968 expect ( finalConfig . compiler ?. runAfterProductionCompile ) . toBeInstanceOf ( Function ) ;
914969 } ) ;
915970 } ) ;
0 commit comments