@@ -22,20 +22,9 @@ export function setupSourceMaps(
2222 nuxt : Nuxt ,
2323 addVitePlugin : ( plugin : Plugin [ ] , options ?: { dev ?: boolean ; build ?: boolean } ) => void ,
2424) : void {
25- // TODO(v11): remove deprecated options (also from SentryNuxtModuleOptions type)
26-
2725 const isDebug = moduleOptions . debug ;
2826
29- // eslint-disable-next-line typescript/no-deprecated
30- const sourceMapsUploadOptions = moduleOptions . sourceMapsUploadOptions || { } ;
31-
32- const sourceMapsEnabled =
33- moduleOptions . sourcemaps ?. disable === true
34- ? false
35- : moduleOptions . sourcemaps ?. disable === false
36- ? true
37- : // eslint-disable-next-line typescript/no-deprecated
38- ( sourceMapsUploadOptions . enabled ?? true ) ;
27+ const sourceMapsEnabled = moduleOptions . sourcemaps ?. disable !== true ;
3928
4029 // In case we overwrite the source map settings, we default to deleting the files
4130 const shouldDeleteFilesFallback = { client : true , server : true } ;
@@ -62,11 +51,7 @@ export function setupSourceMaps(
6251 ? 'server-side'
6352 : 'client-side' ;
6453
65- if (
66- ! moduleOptions . sourcemaps ?. filesToDeleteAfterUpload &&
67- // eslint-disable-next-line typescript/no-deprecated
68- ! sourceMapsUploadOptions . sourcemaps ?. filesToDeleteAfterUpload
69- ) {
54+ if ( ! moduleOptions . sourcemaps ?. filesToDeleteAfterUpload ) {
7055 // eslint-disable-next-line no-console
7156 console . log (
7257 `[Sentry] We enabled \`'hidden'\` source maps for your ${ enabledDeleteFallbacks } build. Source map files will be automatically deleted after uploading them to Sentry.` ,
@@ -131,65 +116,27 @@ function normalizePath(path: string): string {
131116 *
132117 * Only exported for Testing purposes.
133118 */
134- // todo(v11): This "eslint-disable" can be removed again once we remove deprecated options.
135- // eslint-disable-next-line complexity
136119export function getPluginOptions (
137120 moduleOptions : SentryNuxtModuleOptions ,
138121 shouldDeleteFilesFallback ?: { client : boolean ; server : boolean } ,
139122) : SentryVitePluginOptions | SentryRollupPluginOptions {
140- // eslint-disable-next-line typescript/no-deprecated
141- const sourceMapsUploadOptions = moduleOptions . sourceMapsUploadOptions || { } ;
142-
143- const shouldDeleteFilesAfterUpload = shouldDeleteFilesFallback ?. client || shouldDeleteFilesFallback ?. server ;
144- const fallbackFilesToDelete = [
145- ...( shouldDeleteFilesFallback ?. client ? [ '.*/**/public/**/*.map' ] : [ ] ) ,
146- ...( shouldDeleteFilesFallback ?. server
147- ? [ '.*/**/server/**/*.map' , '.*/**/output/**/*.map' , '.*/**/function/**/*.map' ]
148- : [ ] ) ,
149- ] ;
150-
151- // Check for filesToDeleteAfterUpload in new location first, then deprecated location
152123 const sourcemapsOptions = moduleOptions . sourcemaps || { } ;
153- // eslint-disable-next-line typescript/no-deprecated
154- const deprecatedSourcemapsOptions = sourceMapsUploadOptions . sourcemaps || { } ;
155-
156- const filesToDeleteAfterUpload =
157- sourcemapsOptions . filesToDeleteAfterUpload ??
158- // eslint-disable-next-line typescript/no-deprecated
159- deprecatedSourcemapsOptions . filesToDeleteAfterUpload ;
160-
161- if ( typeof filesToDeleteAfterUpload === 'undefined' && shouldDeleteFilesAfterUpload && moduleOptions . debug ) {
162- // eslint-disable-next-line no-console
163- console . log (
164- `[Sentry] Setting \`sentry.sourceMapsUploadOptions.sourcemaps.filesToDeleteAfterUpload: [${ fallbackFilesToDelete
165- // Logging it as strings in the array
166- . map ( path => `"${ path } "` )
167- . join ( ', ' ) } ]\` to delete generated source maps after they were uploaded to Sentry.`,
168- ) ;
169- }
124+ const filesToDeleteAfterUpload = resolveFilesToDeleteAfterUpload ( moduleOptions , shouldDeleteFilesFallback ) ;
170125
171126 return {
172127 applicationKey : moduleOptions . applicationKey ,
173- // eslint-disable-next-line typescript/no-deprecated
174- org : moduleOptions . org ?? sourceMapsUploadOptions . org ?? process . env . SENTRY_ORG ,
175- // eslint-disable-next-line typescript/no-deprecated
176- project : moduleOptions . project ?? sourceMapsUploadOptions . project ?? process . env . SENTRY_PROJECT ,
177- // eslint-disable-next-line typescript/no-deprecated
178- authToken : moduleOptions . authToken ?? sourceMapsUploadOptions . authToken ?? process . env . SENTRY_AUTH_TOKEN ,
179- // eslint-disable-next-line typescript/no-deprecated
180- telemetry : moduleOptions . telemetry ?? sourceMapsUploadOptions . telemetry ?? true ,
181- // eslint-disable-next-line typescript/no-deprecated
182- url : moduleOptions . sentryUrl ?? sourceMapsUploadOptions . url ?? process . env . SENTRY_URL ,
128+ org : moduleOptions . org ?? process . env . SENTRY_ORG ,
129+ project : moduleOptions . project ?? process . env . SENTRY_PROJECT ,
130+ authToken : moduleOptions . authToken ?? process . env . SENTRY_AUTH_TOKEN ,
131+ telemetry : moduleOptions . telemetry ?? true ,
132+ url : moduleOptions . sentryUrl ?? process . env . SENTRY_URL ,
183133 headers : moduleOptions . headers ,
184134 debug : moduleOptions . debug ?? false ,
185- // eslint-disable-next-line typescript/no-deprecated
186- silent : moduleOptions . silent ?? sourceMapsUploadOptions . silent ?? false ,
187- // eslint-disable-next-line typescript/no-deprecated
188- errorHandler : moduleOptions . errorHandler ?? sourceMapsUploadOptions . errorHandler ,
135+ silent : moduleOptions . silent ?? false ,
136+ errorHandler : moduleOptions . errorHandler ,
189137 bundleSizeOptimizations : moduleOptions . bundleSizeOptimizations , // todo: test if this can be overridden by the user
190138 release : {
191- // eslint-disable-next-line typescript/no-deprecated
192- name : moduleOptions . release ?. name ?? sourceMapsUploadOptions . release ?. name ,
139+ name : moduleOptions . release ?. name ,
193140 // Support all release options from BuildTimeOptionsBase
194141 ...moduleOptions . release ,
195142 ...moduleOptions ?. unstable_sentryBundlerPluginOptions ?. release ,
@@ -206,21 +153,53 @@ export function getPluginOptions(
206153 // The server/client files are in different places depending on the nitro preset (e.g. '.output/server' or '.netlify/functions-internal/server')
207154 // 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).
208155 // 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/**/*'],
209- // eslint-disable-next-line typescript/no-deprecated
210- assets : sourcemapsOptions . assets ?? deprecatedSourcemapsOptions . assets ?? undefined ,
211- // eslint-disable-next-line typescript/no-deprecated
212- ignore : sourcemapsOptions . ignore ?? deprecatedSourcemapsOptions . ignore ?? undefined ,
213- filesToDeleteAfterUpload : filesToDeleteAfterUpload
214- ? filesToDeleteAfterUpload
215- : shouldDeleteFilesFallback ?. server || shouldDeleteFilesFallback ?. client
216- ? fallbackFilesToDelete
217- : undefined ,
156+ assets : sourcemapsOptions . assets ?? undefined ,
157+ ignore : sourcemapsOptions . ignore ?? undefined ,
158+ filesToDeleteAfterUpload,
218159 rewriteSources : sourcemapsOptions . rewriteSources ?? normalizePath ,
219160 ...moduleOptions ?. unstable_sentryBundlerPluginOptions ?. sourcemaps ,
220161 } ,
221162 } ;
222163}
223164
165+ /**
166+ * Resolves the `filesToDeleteAfterUpload` value: the user-specified globs if provided, otherwise the
167+ * client/server fallback globs when Sentry enabled source maps itself. Logs the fallback in debug mode.
168+ */
169+ function resolveFilesToDeleteAfterUpload (
170+ moduleOptions : SentryNuxtModuleOptions ,
171+ shouldDeleteFilesFallback ?: { client : boolean ; server : boolean } ,
172+ ) : string | Array < string > | undefined {
173+ const userFilesToDeleteAfterUpload = moduleOptions . sourcemaps ?. filesToDeleteAfterUpload ;
174+ if ( typeof userFilesToDeleteAfterUpload !== 'undefined' ) {
175+ return userFilesToDeleteAfterUpload ;
176+ }
177+
178+ const shouldDeleteFilesAfterUpload = shouldDeleteFilesFallback ?. client || shouldDeleteFilesFallback ?. server ;
179+ if ( ! shouldDeleteFilesAfterUpload ) {
180+ return undefined ;
181+ }
182+
183+ const fallbackFilesToDelete = [
184+ ...( shouldDeleteFilesFallback ?. client ? [ '.*/**/public/**/*.map' ] : [ ] ) ,
185+ ...( shouldDeleteFilesFallback ?. server
186+ ? [ '.*/**/server/**/*.map' , '.*/**/output/**/*.map' , '.*/**/function/**/*.map' ]
187+ : [ ] ) ,
188+ ] ;
189+
190+ if ( moduleOptions . debug ) {
191+ // eslint-disable-next-line no-console
192+ console . log (
193+ `[Sentry] Setting \`sentry.sourcemaps.filesToDeleteAfterUpload: [${ fallbackFilesToDelete
194+ // Logging it as strings in the array
195+ . map ( path => `"${ path } "` )
196+ . join ( ', ' ) } ]\` to delete generated source maps after they were uploaded to Sentry.`,
197+ ) ;
198+ }
199+
200+ return fallbackFilesToDelete ;
201+ }
202+
224203/* There are multiple ways to set up source maps (https://github.com/getsentry/sentry-javascript/issues/13993 and https://github.com/getsentry/sentry-javascript/pull/15859)
225204 1. User explicitly disabled source maps
226205 - keep this setting (emit a warning that errors won't be unminified in Sentry)
0 commit comments