@@ -17,10 +17,20 @@ export type SourceMapSetting = boolean | 'hidden' | 'inline';
1717 * Setup source maps for Sentry inside the Nuxt module during build time (in Vite for Nuxt and Rollup for Nitro).
1818 */
1919export function setupSourceMaps ( moduleOptions : SentryNuxtModuleOptions , nuxt : Nuxt ) : void {
20+ // TODO(v11): remove deprecated options (also from SentryNuxtModuleOptions type)
21+
2022 const isDebug = moduleOptions . debug ;
2123
24+ // eslint-disable-next-line deprecation/deprecation
2225 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 ;
2434
2535 // In case we overwrite the source map settings, we default to deleting the files
2636 let shouldDeleteFilesFallback = { client : true , server : true } ;
@@ -42,6 +52,8 @@ export function setupSourceMaps(moduleOptions: SentryNuxtModuleOptions, nuxt: Nu
4252
4353 if (
4454 isDebug &&
55+ ! moduleOptions . sourcemaps ?. filesToDeleteAfterUpload &&
56+ // eslint-disable-next-line deprecation/deprecation
4557 ! sourceMapsUploadOptions . sourcemaps ?. filesToDeleteAfterUpload &&
4658 ( shouldDeleteFilesFallback . client || shouldDeleteFilesFallback . server )
4759 ) {
@@ -134,10 +146,13 @@ function normalizePath(path: string): string {
134146 *
135147 * Only exported for Testing purposes.
136148 */
149+ // todo(v11): This "eslint-disable" can be removed again once we remove deprecated options.
150+ // eslint-disable-next-line complexity
137151export function getPluginOptions (
138152 moduleOptions : SentryNuxtModuleOptions ,
139153 shouldDeleteFilesFallback ?: { client : boolean ; server : boolean } ,
140154) : SentryVitePluginOptions | SentryRollupPluginOptions {
155+ // eslint-disable-next-line deprecation/deprecation
141156 const sourceMapsUploadOptions = moduleOptions . sourceMapsUploadOptions || { } ;
142157
143158 const shouldDeleteFilesAfterUpload = shouldDeleteFilesFallback ?. client || shouldDeleteFilesFallback ?. server ;
@@ -148,10 +163,17 @@ export function getPluginOptions(
148163 : [ ] ) ,
149164 ] ;
150165
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 ) {
155177 consoleSandbox ( ( ) => {
156178 // eslint-disable-next-line no-console
157179 console . log (
@@ -164,16 +186,28 @@ export function getPluginOptions(
164186 }
165187
166188 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 ,
172200 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
175206 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 ,
177211 ...moduleOptions ?. unstable_sentryBundlerPluginOptions ?. release ,
178212 } ,
179213 _metaOptions : {
@@ -184,13 +218,16 @@ export function getPluginOptions(
184218 ...moduleOptions ?. unstable_sentryBundlerPluginOptions ,
185219
186220 sourcemaps : {
221+ disable : moduleOptions . sourcemaps ?. disable ,
187222 // The server/client files are in different places depending on the nitro preset (e.g. '.output/server' or '.netlify/functions-internal/server')
188223 // 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).
189224 // 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
194231 : shouldDeleteFilesFallback ?. server || shouldDeleteFilesFallback ?. client
195232 ? fallbackFilesToDelete
196233 : undefined ,
0 commit comments