@@ -769,27 +769,27 @@ describe('withSentryConfig', () => {
769
769
vi . restoreAllMocks ( ) ;
770
770
} ) ;
771
771
772
- it ( 'sets up runAfterProductionCompile hook when experimental flag is enabled and version is supported' , ( ) => {
772
+ it ( 'sets up runAfterProductionCompile hook when flag is enabled and version is supported' , ( ) => {
773
773
vi . spyOn ( util , 'supportsProductionCompileHook' ) . mockReturnValue ( true ) ;
774
774
775
775
const sentryOptions = {
776
- _experimental : {
777
- useRunAfterProductionCompileHook : true ,
778
- } ,
776
+ useRunAfterProductionCompileHook : true ,
779
777
} ;
780
778
781
- const finalConfig = materializeFinalNextConfig ( exportedNextConfig , undefined , sentryOptions ) ;
779
+ // Use a clean copy of the config to avoid test interference
780
+ const cleanConfig = { ...exportedNextConfig } ;
781
+ delete cleanConfig . compiler ;
782
+
783
+ const finalConfig = materializeFinalNextConfig ( cleanConfig , undefined , sentryOptions ) ;
782
784
783
785
expect ( finalConfig . compiler ?. runAfterProductionCompile ) . toBeInstanceOf ( Function ) ;
784
786
} ) ;
785
787
786
- it ( 'does not set up hook when experimental flag is disabled' , ( ) => {
788
+ it ( 'does not set up hook when flag is disabled' , ( ) => {
787
789
vi . spyOn ( util , 'supportsProductionCompileHook' ) . mockReturnValue ( true ) ;
788
790
789
791
const sentryOptions = {
790
- _experimental : {
791
- useRunAfterProductionCompileHook : false ,
792
- } ,
792
+ useRunAfterProductionCompileHook : false ,
793
793
} ;
794
794
795
795
const cleanConfig = { ...exportedNextConfig } ;
@@ -804,9 +804,7 @@ describe('withSentryConfig', () => {
804
804
vi . spyOn ( util , 'supportsProductionCompileHook' ) . mockReturnValue ( false ) ;
805
805
806
806
const sentryOptions = {
807
- _experimental : {
808
- useRunAfterProductionCompileHook : true ,
809
- } ,
807
+ useRunAfterProductionCompileHook : true ,
810
808
} ;
811
809
812
810
const cleanConfig = { ...exportedNextConfig } ;
@@ -829,9 +827,7 @@ describe('withSentryConfig', () => {
829
827
} ;
830
828
831
829
const sentryOptions = {
832
- _experimental : {
833
- useRunAfterProductionCompileHook : true ,
834
- } ,
830
+ useRunAfterProductionCompileHook : true ,
835
831
} ;
836
832
837
833
const finalConfig = materializeFinalNextConfig ( configWithExistingHook , undefined , sentryOptions ) ;
@@ -852,9 +848,7 @@ describe('withSentryConfig', () => {
852
848
} ;
853
849
854
850
const sentryOptions = {
855
- _experimental : {
856
- useRunAfterProductionCompileHook : true ,
857
- } ,
851
+ useRunAfterProductionCompileHook : true ,
858
852
} ;
859
853
860
854
materializeFinalNextConfig ( configWithInvalidHook , undefined , sentryOptions ) ;
@@ -873,9 +867,7 @@ describe('withSentryConfig', () => {
873
867
delete configWithoutCompiler . compiler ;
874
868
875
869
const sentryOptions = {
876
- _experimental : {
877
- useRunAfterProductionCompileHook : true ,
878
- } ,
870
+ useRunAfterProductionCompileHook : true ,
879
871
} ;
880
872
881
873
const finalConfig = materializeFinalNextConfig ( configWithoutCompiler , undefined , sentryOptions ) ;
@@ -890,126 +882,35 @@ describe('withSentryConfig', () => {
890
882
vi . spyOn ( util , 'supportsProductionCompileHook' ) . mockReturnValue ( true ) ;
891
883
892
884
const sentryOptions = {
893
- _experimental : {
894
- useRunAfterProductionCompileHook : true ,
895
- } ,
896
- } ;
897
-
898
- const finalConfig = materializeFinalNextConfig ( exportedNextConfig , undefined , sentryOptions ) ;
899
-
900
- expect ( finalConfig . compiler ?. runAfterProductionCompile ) . toBeInstanceOf ( Function ) ;
901
-
902
- delete process . env . TURBOPACK ;
903
- } ) ;
904
-
905
- it ( 'works with webpack builds when TURBOPACK env is not set' , ( ) => {
906
- delete process . env . TURBOPACK ;
907
- vi . spyOn ( util , 'supportsProductionCompileHook' ) . mockReturnValue ( true ) ;
908
-
909
- const sentryOptions = {
910
- _experimental : {
911
- useRunAfterProductionCompileHook : true ,
912
- } ,
913
- } ;
914
-
915
- const finalConfig = materializeFinalNextConfig ( exportedNextConfig , undefined , sentryOptions ) ;
916
-
917
- expect ( finalConfig . compiler ?. runAfterProductionCompile ) . toBeInstanceOf ( Function ) ;
918
- } ) ;
919
- } ) ;
920
-
921
- describe ( 'experimental flag handling' , ( ) => {
922
- afterEach ( ( ) => {
923
- vi . restoreAllMocks ( ) ;
924
- } ) ;
925
-
926
- it ( 'respects useRunAfterProductionCompileHook: true' , ( ) => {
927
- vi . spyOn ( util , 'supportsProductionCompileHook' ) . mockReturnValue ( true ) ;
928
-
929
- const sentryOptions = {
930
- _experimental : {
931
- useRunAfterProductionCompileHook : true ,
932
- } ,
885
+ useRunAfterProductionCompileHook : true ,
933
886
} ;
934
887
888
+ // Use a clean copy of the config to avoid test interference
935
889
const cleanConfig = { ...exportedNextConfig } ;
936
890
delete cleanConfig . compiler ;
937
891
938
892
const finalConfig = materializeFinalNextConfig ( cleanConfig , undefined , sentryOptions ) ;
939
893
940
894
expect ( finalConfig . compiler ?. runAfterProductionCompile ) . toBeInstanceOf ( Function ) ;
941
- } ) ;
942
895
943
- it ( 'respects useRunAfterProductionCompileHook: false' , ( ) => {
944
- vi . spyOn ( util , 'supportsProductionCompileHook' ) . mockReturnValue ( true ) ;
945
-
946
- const sentryOptions = {
947
- _experimental : {
948
- useRunAfterProductionCompileHook : false ,
949
- } ,
950
- } ;
951
-
952
- const cleanConfig = { ...exportedNextConfig } ;
953
- delete cleanConfig . compiler ;
954
-
955
- const finalConfig = materializeFinalNextConfig ( cleanConfig , undefined , sentryOptions ) ;
956
-
957
- expect ( finalConfig . compiler ?. runAfterProductionCompile ) . toBeUndefined ( ) ;
958
- } ) ;
959
-
960
- it ( 'does not set up hook when experimental flag is undefined' , ( ) => {
961
- vi . spyOn ( util , 'supportsProductionCompileHook' ) . mockReturnValue ( true ) ;
962
-
963
- const sentryOptions = {
964
- _experimental : {
965
- // useRunAfterProductionCompileHook not specified
966
- } ,
967
- } ;
968
-
969
- const cleanConfig = { ...exportedNextConfig } ;
970
- delete cleanConfig . compiler ;
971
-
972
- const finalConfig = materializeFinalNextConfig ( cleanConfig , undefined , sentryOptions ) ;
973
-
974
- expect ( finalConfig . compiler ?. runAfterProductionCompile ) . toBeUndefined ( ) ;
896
+ delete process . env . TURBOPACK ;
975
897
} ) ;
976
898
977
- it ( 'does not set up hook when _experimental is undefined' , ( ) => {
899
+ it ( 'works with webpack builds when TURBOPACK env is not set' , ( ) => {
900
+ delete process . env . TURBOPACK ;
978
901
vi . spyOn ( util , 'supportsProductionCompileHook' ) . mockReturnValue ( true ) ;
979
902
980
903
const sentryOptions = {
981
- // no _experimental property
904
+ useRunAfterProductionCompileHook : true ,
982
905
} ;
983
906
907
+ // Use a clean copy of the config to avoid test interference
984
908
const cleanConfig = { ...exportedNextConfig } ;
985
909
delete cleanConfig . compiler ;
986
910
987
911
const finalConfig = materializeFinalNextConfig ( cleanConfig , undefined , sentryOptions ) ;
988
912
989
- expect ( finalConfig . compiler ?. runAfterProductionCompile ) . toBeUndefined ( ) ;
990
- } ) ;
991
-
992
- it ( 'combines experimental flag with other configurations correctly' , ( ) => {
993
- process . env . TURBOPACK = '1' ;
994
- vi . spyOn ( util , 'getNextjsVersion' ) . mockReturnValue ( '15.4.1' ) ;
995
- vi . spyOn ( util , 'supportsProductionCompileHook' ) . mockReturnValue ( true ) ;
996
-
997
- const sentryOptions = {
998
- _experimental : {
999
- useRunAfterProductionCompileHook : true ,
1000
- } ,
1001
- sourcemaps : { } ,
1002
- tunnelRoute : '/tunnel' ,
1003
- } ;
1004
-
1005
- const finalConfig = materializeFinalNextConfig ( exportedNextConfig , undefined , sentryOptions ) ;
1006
-
1007
- // Should have both turbopack sourcemap config AND runAfterProductionCompile hook
1008
- expect ( finalConfig . productionBrowserSourceMaps ) . toBe ( true ) ;
1009
913
expect ( finalConfig . compiler ?. runAfterProductionCompile ) . toBeInstanceOf ( Function ) ;
1010
- expect ( finalConfig . rewrites ) . toBeInstanceOf ( Function ) ;
1011
-
1012
- delete process . env . TURBOPACK ;
1013
914
} ) ;
1014
915
} ) ;
1015
916
} ) ;
0 commit comments