@@ -769,27 +769,27 @@ describe('withSentryConfig', () => {
769769 vi . restoreAllMocks ( ) ;
770770 } ) ;
771771
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' , ( ) => {
773773 vi . spyOn ( util , 'supportsProductionCompileHook' ) . mockReturnValue ( true ) ;
774774
775775 const sentryOptions = {
776- _experimental : {
777- useRunAfterProductionCompileHook : true ,
778- } ,
776+ useRunAfterProductionCompileHook : true ,
779777 } ;
780778
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 ) ;
782784
783785 expect ( finalConfig . compiler ?. runAfterProductionCompile ) . toBeInstanceOf ( Function ) ;
784786 } ) ;
785787
786- it ( 'does not set up hook when experimental flag is disabled' , ( ) => {
788+ it ( 'does not set up hook when flag is disabled' , ( ) => {
787789 vi . spyOn ( util , 'supportsProductionCompileHook' ) . mockReturnValue ( true ) ;
788790
789791 const sentryOptions = {
790- _experimental : {
791- useRunAfterProductionCompileHook : false ,
792- } ,
792+ useRunAfterProductionCompileHook : false ,
793793 } ;
794794
795795 const cleanConfig = { ...exportedNextConfig } ;
@@ -804,9 +804,7 @@ describe('withSentryConfig', () => {
804804 vi . spyOn ( util , 'supportsProductionCompileHook' ) . mockReturnValue ( false ) ;
805805
806806 const sentryOptions = {
807- _experimental : {
808- useRunAfterProductionCompileHook : true ,
809- } ,
807+ useRunAfterProductionCompileHook : true ,
810808 } ;
811809
812810 const cleanConfig = { ...exportedNextConfig } ;
@@ -829,9 +827,7 @@ describe('withSentryConfig', () => {
829827 } ;
830828
831829 const sentryOptions = {
832- _experimental : {
833- useRunAfterProductionCompileHook : true ,
834- } ,
830+ useRunAfterProductionCompileHook : true ,
835831 } ;
836832
837833 const finalConfig = materializeFinalNextConfig ( configWithExistingHook , undefined , sentryOptions ) ;
@@ -852,9 +848,7 @@ describe('withSentryConfig', () => {
852848 } ;
853849
854850 const sentryOptions = {
855- _experimental : {
856- useRunAfterProductionCompileHook : true ,
857- } ,
851+ useRunAfterProductionCompileHook : true ,
858852 } ;
859853
860854 materializeFinalNextConfig ( configWithInvalidHook , undefined , sentryOptions ) ;
@@ -873,9 +867,7 @@ describe('withSentryConfig', () => {
873867 delete configWithoutCompiler . compiler ;
874868
875869 const sentryOptions = {
876- _experimental : {
877- useRunAfterProductionCompileHook : true ,
878- } ,
870+ useRunAfterProductionCompileHook : true ,
879871 } ;
880872
881873 const finalConfig = materializeFinalNextConfig ( configWithoutCompiler , undefined , sentryOptions ) ;
@@ -890,126 +882,35 @@ describe('withSentryConfig', () => {
890882 vi . spyOn ( util , 'supportsProductionCompileHook' ) . mockReturnValue ( true ) ;
891883
892884 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 ,
933886 } ;
934887
888+ // Use a clean copy of the config to avoid test interference
935889 const cleanConfig = { ...exportedNextConfig } ;
936890 delete cleanConfig . compiler ;
937891
938892 const finalConfig = materializeFinalNextConfig ( cleanConfig , undefined , sentryOptions ) ;
939893
940894 expect ( finalConfig . compiler ?. runAfterProductionCompile ) . toBeInstanceOf ( Function ) ;
941- } ) ;
942895
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 ;
975897 } ) ;
976898
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 ;
978901 vi . spyOn ( util , 'supportsProductionCompileHook' ) . mockReturnValue ( true ) ;
979902
980903 const sentryOptions = {
981- // no _experimental property
904+ useRunAfterProductionCompileHook : true ,
982905 } ;
983906
907+ // Use a clean copy of the config to avoid test interference
984908 const cleanConfig = { ...exportedNextConfig } ;
985909 delete cleanConfig . compiler ;
986910
987911 const finalConfig = materializeFinalNextConfig ( cleanConfig , undefined , sentryOptions ) ;
988912
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 ) ;
1009913 expect ( finalConfig . compiler ?. runAfterProductionCompile ) . toBeInstanceOf ( Function ) ;
1010- expect ( finalConfig . rewrites ) . toBeInstanceOf ( Function ) ;
1011-
1012- delete process . env . TURBOPACK ;
1013914 } ) ;
1014915 } ) ;
1015916} ) ;
0 commit comments