@@ -977,6 +977,39 @@ describe('moduleMetadataInjection with applicationKey', () => {
977977 } ) ;
978978 } ) ;
979979
980+ it ( 'should add metadata loader rule when top-level applicationKey is set and Next.js >= 16' , ( ) => {
981+ const userNextConfig : NextConfigObject = { } ;
982+
983+ const result = constructTurbopackConfig ( {
984+ userNextConfig,
985+ userSentryOptions : { applicationKey : 'my-top-level-key' } ,
986+ nextJsVersion : '16.0.0' ,
987+ } ) ;
988+
989+ const rule = result . rules ! [ '*.{ts,tsx,js,jsx,mjs,cjs}' ] as {
990+ loaders : Array < { loader : string ; options : { applicationKey : string } } > ;
991+ } ;
992+ expect ( rule . loaders [ 0 ] ! . options . applicationKey ) . toBe ( 'my-top-level-key' ) ;
993+ } ) ;
994+
995+ it ( 'should prefer top-level applicationKey over deprecated _experimental.turbopackApplicationKey' , ( ) => {
996+ const userNextConfig : NextConfigObject = { } ;
997+
998+ const result = constructTurbopackConfig ( {
999+ userNextConfig,
1000+ userSentryOptions : {
1001+ applicationKey : 'top-level-key' ,
1002+ _experimental : { turbopackApplicationKey : 'deprecated-key' } ,
1003+ } ,
1004+ nextJsVersion : '16.0.0' ,
1005+ } ) ;
1006+
1007+ const rule = result . rules ! [ '*.{ts,tsx,js,jsx,mjs,cjs}' ] as {
1008+ loaders : Array < { loader : string ; options : { applicationKey : string } } > ;
1009+ } ;
1010+ expect ( rule . loaders [ 0 ] ! . options . applicationKey ) . toBe ( 'top-level-key' ) ;
1011+ } ) ;
1012+
9801013 it ( 'should only exclude Next.js polyfills, not all foreign modules' , ( ) => {
9811014 const userNextConfig : NextConfigObject = { } ;
9821015
0 commit comments