@@ -876,16 +876,13 @@ describe('withSentryConfig', () => {
876
876
expect ( finalConfig . compiler ?. runAfterProductionCompile ) . toBeInstanceOf ( Function ) ;
877
877
} ) ;
878
878
879
- it ( 'works with turbopack builds when TURBOPACK env is set ' , ( ) => {
879
+ it ( 'defaults to true for turbopack when useRunAfterProductionCompileHook is not specified ' , ( ) => {
880
880
process . env . TURBOPACK = '1' ;
881
881
vi . spyOn ( util , 'getNextjsVersion' ) . mockReturnValue ( '15.4.1' ) ;
882
882
vi . spyOn ( util , 'supportsProductionCompileHook' ) . mockReturnValue ( true ) ;
883
883
884
- const sentryOptions = {
885
- useRunAfterProductionCompileHook : true ,
886
- } ;
884
+ const sentryOptions = { } ; // No useRunAfterProductionCompileHook specified
887
885
888
- // Use a clean copy of the config to avoid test interference
889
886
const cleanConfig = { ...exportedNextConfig } ;
890
887
delete cleanConfig . compiler ;
891
888
@@ -896,20 +893,78 @@ describe('withSentryConfig', () => {
896
893
delete process . env . TURBOPACK ;
897
894
} ) ;
898
895
899
- it ( 'works with webpack builds when TURBOPACK env is not set ' , ( ) => {
896
+ it ( 'defaults to false for webpack when useRunAfterProductionCompileHook is not specified ' , ( ) => {
900
897
delete process . env . TURBOPACK ;
901
898
vi . spyOn ( util , 'supportsProductionCompileHook' ) . mockReturnValue ( true ) ;
902
899
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
+
903
915
const sentryOptions = {
904
- useRunAfterProductionCompileHook : true ,
916
+ useRunAfterProductionCompileHook : false ,
905
917
} ;
906
918
907
- // Use a clean copy of the config to avoid test interference
908
919
const cleanConfig = { ...exportedNextConfig } ;
909
920
delete cleanConfig . compiler ;
910
921
911
922
const finalConfig = materializeFinalNextConfig ( cleanConfig , undefined , sentryOptions ) ;
912
923
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
+
913
968
expect ( finalConfig . compiler ?. runAfterProductionCompile ) . toBeInstanceOf ( Function ) ;
914
969
} ) ;
915
970
} ) ;
0 commit comments