@@ -17,10 +17,20 @@ export type SourceMapSetting = boolean | 'hidden' | 'inline';
17
17
* Setup source maps for Sentry inside the Nuxt module during build time (in Vite for Nuxt and Rollup for Nitro).
18
18
*/
19
19
export function setupSourceMaps ( moduleOptions : SentryNuxtModuleOptions , nuxt : Nuxt ) : void {
20
+ // TODO(v11): remove deprecated options (also from SentryNuxtModuleOptions type)
21
+
20
22
const isDebug = moduleOptions . debug ;
21
23
24
+ // eslint-disable-next-line deprecation/deprecation
22
25
const sourceMapsUploadOptions = moduleOptions . sourceMapsUploadOptions || { } ;
23
- const sourceMapsEnabled = sourceMapsUploadOptions . enabled ?? true ;
26
+
27
+ const sourceMapsEnabled =
28
+ moduleOptions . sourcemaps ?. disable === true
29
+ ? false
30
+ : moduleOptions . sourcemaps ?. disable === false
31
+ ? true
32
+ : // eslint-disable-next-line deprecation/deprecation
33
+ sourceMapsUploadOptions . enabled ?? true ;
24
34
25
35
// In case we overwrite the source map settings, we default to deleting the files
26
36
let shouldDeleteFilesFallback = { client : true , server : true } ;
@@ -42,6 +52,8 @@ export function setupSourceMaps(moduleOptions: SentryNuxtModuleOptions, nuxt: Nu
42
52
43
53
if (
44
54
isDebug &&
55
+ ! moduleOptions . sourcemaps ?. filesToDeleteAfterUpload &&
56
+ // eslint-disable-next-line deprecation/deprecation
45
57
! sourceMapsUploadOptions . sourcemaps ?. filesToDeleteAfterUpload &&
46
58
( shouldDeleteFilesFallback . client || shouldDeleteFilesFallback . server )
47
59
) {
@@ -134,10 +146,13 @@ function normalizePath(path: string): string {
134
146
*
135
147
* Only exported for Testing purposes.
136
148
*/
149
+ // todo(v11): This "eslint-disable" can be removed again once we remove deprecated options.
150
+ // eslint-disable-next-line complexity
137
151
export function getPluginOptions (
138
152
moduleOptions : SentryNuxtModuleOptions ,
139
153
shouldDeleteFilesFallback ?: { client : boolean ; server : boolean } ,
140
154
) : SentryVitePluginOptions | SentryRollupPluginOptions {
155
+ // eslint-disable-next-line deprecation/deprecation
141
156
const sourceMapsUploadOptions = moduleOptions . sourceMapsUploadOptions || { } ;
142
157
143
158
const shouldDeleteFilesAfterUpload = shouldDeleteFilesFallback ?. client || shouldDeleteFilesFallback ?. server ;
@@ -148,10 +163,17 @@ export function getPluginOptions(
148
163
: [ ] ) ,
149
164
] ;
150
165
151
- if (
152
- typeof sourceMapsUploadOptions . sourcemaps ?. filesToDeleteAfterUpload === 'undefined' &&
153
- shouldDeleteFilesAfterUpload
154
- ) {
166
+ // Check for filesToDeleteAfterUpload in new location first, then deprecated location
167
+ const sourcemapsOptions = moduleOptions . sourcemaps || { } ;
168
+ // eslint-disable-next-line deprecation/deprecation
169
+ const deprecatedSourcemapsOptions = sourceMapsUploadOptions . sourcemaps || { } ;
170
+
171
+ const filesToDeleteAfterUpload =
172
+ sourcemapsOptions . filesToDeleteAfterUpload ??
173
+ // eslint-disable-next-line deprecation/deprecation
174
+ deprecatedSourcemapsOptions . filesToDeleteAfterUpload ;
175
+
176
+ if ( typeof filesToDeleteAfterUpload === 'undefined' && shouldDeleteFilesAfterUpload ) {
155
177
consoleSandbox ( ( ) => {
156
178
// eslint-disable-next-line no-console
157
179
console . log (
@@ -164,16 +186,28 @@ export function getPluginOptions(
164
186
}
165
187
166
188
return {
167
- org : sourceMapsUploadOptions . org ?? process . env . SENTRY_ORG ,
168
- project : sourceMapsUploadOptions . project ?? process . env . SENTRY_PROJECT ,
169
- authToken : sourceMapsUploadOptions . authToken ?? process . env . SENTRY_AUTH_TOKEN ,
170
- telemetry : sourceMapsUploadOptions . telemetry ?? true ,
171
- url : sourceMapsUploadOptions . url ?? process . env . SENTRY_URL ,
189
+ // eslint-disable-next-line deprecation/deprecation
190
+ org : moduleOptions . org ?? sourceMapsUploadOptions . org ?? process . env . SENTRY_ORG ,
191
+ // eslint-disable-next-line deprecation/deprecation
192
+ project : moduleOptions . project ?? sourceMapsUploadOptions . project ?? process . env . SENTRY_PROJECT ,
193
+ // eslint-disable-next-line deprecation/deprecation
194
+ authToken : moduleOptions . authToken ?? sourceMapsUploadOptions . authToken ?? process . env . SENTRY_AUTH_TOKEN ,
195
+ // eslint-disable-next-line deprecation/deprecation
196
+ telemetry : moduleOptions . telemetry ?? sourceMapsUploadOptions . telemetry ?? true ,
197
+ // eslint-disable-next-line deprecation/deprecation
198
+ url : moduleOptions . sentryUrl ?? sourceMapsUploadOptions . url ?? process . env . SENTRY_URL ,
199
+ headers : moduleOptions . headers ,
172
200
debug : moduleOptions . debug ?? false ,
173
- silent : sourceMapsUploadOptions . silent ?? false ,
174
- errorHandler : sourceMapsUploadOptions . errorHandler ,
201
+ // eslint-disable-next-line deprecation/deprecation
202
+ silent : moduleOptions . silent ?? sourceMapsUploadOptions . silent ?? false ,
203
+ // eslint-disable-next-line deprecation/deprecation
204
+ errorHandler : moduleOptions . errorHandler ?? sourceMapsUploadOptions . errorHandler ,
205
+ bundleSizeOptimizations : moduleOptions . bundleSizeOptimizations , // todo: test if this can be overridden by the user
175
206
release : {
176
- name : sourceMapsUploadOptions . release ?. name ,
207
+ // eslint-disable-next-line deprecation/deprecation
208
+ name : moduleOptions . release ?. name ?? sourceMapsUploadOptions . release ?. name ,
209
+ // Support all release options from BuildTimeOptionsBase
210
+ ...moduleOptions . release ,
177
211
...moduleOptions ?. unstable_sentryBundlerPluginOptions ?. release ,
178
212
} ,
179
213
_metaOptions : {
@@ -184,13 +218,16 @@ export function getPluginOptions(
184
218
...moduleOptions ?. unstable_sentryBundlerPluginOptions ,
185
219
186
220
sourcemaps : {
221
+ disable : moduleOptions . sourcemaps ?. disable ,
187
222
// The server/client files are in different places depending on the nitro preset (e.g. '.output/server' or '.netlify/functions-internal/server')
188
223
// We cannot determine automatically how the build folder looks like (depends on the preset), so we have to accept that source maps are uploaded multiple times (with the vitePlugin for Nuxt and the rollupPlugin for Nitro).
189
224
// If we could know where the server/client assets are located, we could do something like this (based on the Nitro preset): isNitro ? ['./.output/server/**/*'] : ['./.output/public/**/*'],
190
- assets : sourceMapsUploadOptions . sourcemaps ?. assets ?? undefined ,
191
- ignore : sourceMapsUploadOptions . sourcemaps ?. ignore ?? undefined ,
192
- filesToDeleteAfterUpload : sourceMapsUploadOptions . sourcemaps ?. filesToDeleteAfterUpload
193
- ? sourceMapsUploadOptions . sourcemaps ?. filesToDeleteAfterUpload
225
+ // eslint-disable-next-line deprecation/deprecation
226
+ assets : sourcemapsOptions . assets ?? deprecatedSourcemapsOptions . assets ?? undefined ,
227
+ // eslint-disable-next-line deprecation/deprecation
228
+ ignore : sourcemapsOptions . ignore ?? deprecatedSourcemapsOptions . ignore ?? undefined ,
229
+ filesToDeleteAfterUpload : filesToDeleteAfterUpload
230
+ ? filesToDeleteAfterUpload
194
231
: shouldDeleteFilesFallback ?. server || shouldDeleteFilesFallback ?. client
195
232
? fallbackFilesToDelete
196
233
: undefined ,
0 commit comments