-
-
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
Open
nicohrubec
wants to merge
3
commits into
develop
Choose a base branch
from
feat/nuxt-remove-deprecated-module-options
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
769aa9a
ref(nuxt)!: Remove deprecated `sourceMapsUploadOptions` module option
nicohrubec ab62810
test(nuxt): Cover root-level option resolution and `sourcemaps.disable`
nicohrubec e5e5210
ref(nuxt): Preserve original filesToDeleteAfterUpload truthiness sema…
nicohrubec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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,51 @@ 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, | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Users can set `filesToDeleteAfterUpload` themselves. If they don't, we fall back to deleting the | ||
| * client/server source maps — but only the ones Sentry generated itself (i.e. when the user didn't | ||
| * configure source maps at all). If the user explicitly set source maps, we leave their files alone. | ||
| */ | ||
|
Comment on lines
+165
to
+169
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) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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