Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(nuxt)!: Remove deprecated sourceMapsUploadOptions module option#22875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
769aa9aab62810e5e52107957430File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -22,20 +22,9 @@ export function setupSourceMaps( | ||
| nuxt: Nuxt, | ||
| addVitePlugin: (plugin: Plugin[], options?: { dev?: boolean; build?: boolean }) => void, | ||
| ): void { | ||
| // TODO(v11): remove deprecated options (also from SentryNuxtModuleOptions type) | ||
| const isDebug = moduleOptions.debug; | ||
| // eslint-disable-next-line typescript/no-deprecated | ||
| const sourceMapsUploadOptions = moduleOptions.sourceMapsUploadOptions || {}; | ||
| const sourceMapsEnabled = | ||
| moduleOptions.sourcemaps?.disable === true | ||
| ? false | ||
| : moduleOptions.sourcemaps?.disable === false | ||
| ? true | ||
| : // eslint-disable-next-line typescript/no-deprecated | ||
| (sourceMapsUploadOptions.enabled ?? true); | ||
| const sourceMapsEnabled = moduleOptions.sourcemaps?.disable !== true; | ||
| // In case we overwrite the source map settings, we default to deleting the files | ||
| const shouldDeleteFilesFallback = { client: true, server: true }; | ||
| @@ -62,11 +51,7 @@ export function setupSourceMaps( | ||
| ? 'server-side' | ||
| : 'client-side'; | ||
| if ( | ||
| !moduleOptions.sourcemaps?.filesToDeleteAfterUpload && | ||
| // eslint-disable-next-line typescript/no-deprecated | ||
| !sourceMapsUploadOptions.sourcemaps?.filesToDeleteAfterUpload | ||
| ) { | ||
| if (!moduleOptions.sourcemaps?.filesToDeleteAfterUpload) { | ||
| // eslint-disable-next-line no-console | ||
| console.log( | ||
| `[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 { | ||
| * | ||
| * Only exported for Testing purposes. | ||
| */ | ||
| // todo(v11): This "eslint-disable" can be removed again once we remove deprecated options. | ||
| // eslint-disable-next-line complexity | ||
| export function getPluginOptions( | ||
| moduleOptions: SentryNuxtModuleOptions, | ||
| shouldDeleteFilesFallback?: { client: boolean; server: boolean }, | ||
| ): SentryVitePluginOptions | SentryRollupPluginOptions { | ||
| // eslint-disable-next-line typescript/no-deprecated | ||
| const sourceMapsUploadOptions = moduleOptions.sourceMapsUploadOptions || {}; | ||
| const shouldDeleteFilesAfterUpload = shouldDeleteFilesFallback?.client || shouldDeleteFilesFallback?.server; | ||
| const fallbackFilesToDelete = [ | ||
| ...(shouldDeleteFilesFallback?.client ? ['.*/**/public/**/*.map'] : []), | ||
| ...(shouldDeleteFilesFallback?.server | ||
| ? ['.*/**/server/**/*.map', '.*/**/output/**/*.map', '.*/**/function/**/*.map'] | ||
| : []), | ||
| ]; | ||
| // Check for filesToDeleteAfterUpload in new location first, then deprecated location | ||
| const sourcemapsOptions = moduleOptions.sourcemaps || {}; | ||
| // eslint-disable-next-line typescript/no-deprecated | ||
| const deprecatedSourcemapsOptions = sourceMapsUploadOptions.sourcemaps || {}; | ||
| const filesToDeleteAfterUpload = | ||
| sourcemapsOptions.filesToDeleteAfterUpload ?? | ||
| // eslint-disable-next-line typescript/no-deprecated | ||
| deprecatedSourcemapsOptions.filesToDeleteAfterUpload; | ||
| if (typeof filesToDeleteAfterUpload === 'undefined' && shouldDeleteFilesAfterUpload && moduleOptions.debug) { | ||
| // eslint-disable-next-line no-console | ||
| console.log( | ||
| `[Sentry] Setting \`sentry.sourceMapsUploadOptions.sourcemaps.filesToDeleteAfterUpload: [${fallbackFilesToDelete | ||
| // Logging it as strings in the array | ||
| .map(path => `"${path}"`) | ||
| .join(', ')}]\` to delete generated source maps after they were uploaded to Sentry.`, | ||
| ); | ||
| } | ||
| const filesToDeleteAfterUpload = resolveFilesToDeleteAfterUpload(moduleOptions, shouldDeleteFilesFallback); | ||
| return { | ||
| applicationKey: moduleOptions.applicationKey, | ||
| // eslint-disable-next-line typescript/no-deprecated | ||
| org: moduleOptions.org ?? sourceMapsUploadOptions.org ?? process.env.SENTRY_ORG, | ||
| // eslint-disable-next-line typescript/no-deprecated | ||
| project: moduleOptions.project ?? sourceMapsUploadOptions.project ?? process.env.SENTRY_PROJECT, | ||
| // eslint-disable-next-line typescript/no-deprecated | ||
| authToken: moduleOptions.authToken ?? sourceMapsUploadOptions.authToken ?? process.env.SENTRY_AUTH_TOKEN, | ||
| // eslint-disable-next-line typescript/no-deprecated | ||
| telemetry: moduleOptions.telemetry ?? sourceMapsUploadOptions.telemetry ?? true, | ||
| // eslint-disable-next-line typescript/no-deprecated | ||
| url: moduleOptions.sentryUrl ?? sourceMapsUploadOptions.url ?? process.env.SENTRY_URL, | ||
| org: moduleOptions.org ?? process.env.SENTRY_ORG, | ||
| project: moduleOptions.project ?? process.env.SENTRY_PROJECT, | ||
| authToken: moduleOptions.authToken ?? process.env.SENTRY_AUTH_TOKEN, | ||
| telemetry: moduleOptions.telemetry ?? true, | ||
| url: moduleOptions.sentryUrl ?? process.env.SENTRY_URL, | ||
| headers: moduleOptions.headers, | ||
| debug: moduleOptions.debug ?? false, | ||
| // eslint-disable-next-line typescript/no-deprecated | ||
| silent: moduleOptions.silent ?? sourceMapsUploadOptions.silent ?? false, | ||
| // eslint-disable-next-line typescript/no-deprecated | ||
| errorHandler: moduleOptions.errorHandler ?? sourceMapsUploadOptions.errorHandler, | ||
| silent: moduleOptions.silent ?? false, | ||
| errorHandler: moduleOptions.errorHandler, | ||
| bundleSizeOptimizations: moduleOptions.bundleSizeOptimizations, // todo: test if this can be overridden by the user | ||
| release: { | ||
| // eslint-disable-next-line typescript/no-deprecated | ||
| name: moduleOptions.release?.name ?? sourceMapsUploadOptions.release?.name, | ||
| name: moduleOptions.release?.name, | ||
| // Support all release options from BuildTimeOptionsBase | ||
| ...moduleOptions.release, | ||
| ...moduleOptions?.unstable_sentryBundlerPluginOptions?.release, | ||
| @@ -206,21 +153,54 @@ export function getPluginOptions( | ||
| // The server/client files are in different places depending on the nitro preset (e.g. '.output/server' or '.netlify/functions-internal/server') | ||
| // 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). | ||
| // 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/**/*'], | ||
| // eslint-disable-next-line typescript/no-deprecated | ||
| assets: sourcemapsOptions.assets ?? deprecatedSourcemapsOptions.assets ?? undefined, | ||
| // eslint-disable-next-line typescript/no-deprecated | ||
| ignore: sourcemapsOptions.ignore ?? deprecatedSourcemapsOptions.ignore ?? undefined, | ||
| filesToDeleteAfterUpload: filesToDeleteAfterUpload | ||
| ? filesToDeleteAfterUpload | ||
| : shouldDeleteFilesFallback?.server || shouldDeleteFilesFallback?.client | ||
| ? fallbackFilesToDelete | ||
| : undefined, | ||
| assets: sourcemapsOptions.assets ?? undefined, | ||
| ignore: sourcemapsOptions.ignore ?? undefined, | ||
| filesToDeleteAfterUpload, | ||
| rewriteSources: sourcemapsOptions.rewriteSources ?? normalizePath, | ||
| ...moduleOptions?.unstable_sentryBundlerPluginOptions?.sourcemaps, | ||
| }, | ||
| }; | ||
| } | ||
| /** | ||
| * Determines which files to delete after upload. If the user set `filesToDeleteAfterUpload`, we use | ||
| * that. Otherwise we only delete the source maps Sentry generated itself — i.e. the sides | ||
| * (client/server) whose `sourcemap` setting resolved to `undefined`, where Sentry stepped in and | ||
| * enabled `'hidden'`. Given Nuxt's default of `{ server: true, client: false }`, this isn't the | ||
| * default case: it only kicks in when a side is left `undefined` (whole config or a single sub-key). | ||
| * @see https://nuxt.com/docs/4.x/api/nuxt-config#sourcemap | ||
| */ | ||
Comment on lines
+165
to
+172
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nuxt has no Maybe that's worth pointing out here. Also a link to the docs: https://nuxt.com/docs/4.x/api/nuxt-config#sourcemap | ||
| function resolveFilesToDeleteAfterUpload( | ||
| moduleOptions: SentryNuxtModuleOptions, | ||
| shouldDeleteFilesFallback?: { client: boolean; server: boolean }, | ||
| ): string | Array<string> | undefined { | ||
| const shouldDeleteFilesAfterUpload = shouldDeleteFilesFallback?.client || shouldDeleteFilesFallback?.server; | ||
| const fallbackFilesToDelete = [ | ||
| ...(shouldDeleteFilesFallback?.client ? ['.*/**/public/**/*.map'] : []), | ||
| ...(shouldDeleteFilesFallback?.server | ||
| ? ['.*/**/server/**/*.map', '.*/**/output/**/*.map', '.*/**/function/**/*.map'] | ||
| : []), | ||
| ]; | ||
| const filesToDeleteAfterUpload = moduleOptions.sourcemaps?.filesToDeleteAfterUpload; | ||
| if (typeof filesToDeleteAfterUpload === 'undefined' && shouldDeleteFilesAfterUpload && moduleOptions.debug) { | ||
| // eslint-disable-next-line no-console | ||
| console.log( | ||
| `[Sentry] Setting \`sentry.sourcemaps.filesToDeleteAfterUpload: [${fallbackFilesToDelete | ||
| // Logging it as strings in the array | ||
| .map(path => `"${path}"`) | ||
| .join(', ')}]\` to delete generated source maps after they were uploaded to Sentry.`, | ||
| ); | ||
| } | ||
| return filesToDeleteAfterUpload | ||
| ? filesToDeleteAfterUpload | ||
| : shouldDeleteFilesAfterUpload | ||
| ? fallbackFilesToDelete | ||
| : undefined; | ||
| } | ||
| /* 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) | ||
| 1. User explicitly disabled source maps | ||
| - keep this setting (emit a warning that errors won't be unminified in Sentry) | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed hahaha