@@ -16,13 +16,15 @@ export function withSentryConfig(
16
16
// `defaults` in order to pass them along to the user's function
17
17
if ( typeof exportedUserNextConfig === 'function' ) {
18
18
return function ( phase : string , defaults : { defaultConfig : NextConfigObject } ) : NextConfigObject {
19
- const userNextConfigObject = exportedUserNextConfig ( phase , defaults ) ;
19
+ let userNextConfigObject = exportedUserNextConfig ( phase , defaults ) ;
20
20
21
21
// Next 12.2.3+ warns about non-canonical properties on `userNextConfig`, so grab and then remove the `sentry`
22
22
// property there. Where we actually need it is in the webpack config function we're going to create, so pass it
23
23
// to `constructWebpackConfigFunction` so that it will be in the created function's closure.
24
24
const { sentry : userSentryOptions } = userNextConfigObject ;
25
25
delete userNextConfigObject . sentry ;
26
+ // Remind TS that there's now no `sentry` property
27
+ userNextConfigObject = userNextConfigObject as NextConfigObject ;
26
28
27
29
return {
28
30
...userNextConfigObject ,
@@ -41,9 +43,11 @@ export function withSentryConfig(
41
43
// for a more thorough explanation of what we're doing here.)
42
44
const { sentry : userSentryOptions } = exportedUserNextConfig ;
43
45
delete exportedUserNextConfig . sentry ;
46
+ // Remind TS that there's now no `sentry` property
47
+ const userNextConfigObject = exportedUserNextConfig as NextConfigObject ;
44
48
45
49
return {
46
- ...exportedUserNextConfig ,
47
- webpack : constructWebpackConfigFunction ( exportedUserNextConfig , userSentryWebpackPluginOptions , userSentryOptions ) ,
50
+ ...userNextConfigObject ,
51
+ webpack : constructWebpackConfigFunction ( userNextConfigObject , userSentryWebpackPluginOptions , userSentryOptions ) ,
48
52
} ;
49
53
}
0 commit comments