Skip to content

Commit 769aa9a

Browse files
nicohrubecclaude
andcommitted
ref(nuxt)!: Remove deprecated sourceMapsUploadOptions module option
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 2a913fd commit 769aa9a

4 files changed

Lines changed: 61 additions & 402 deletions

File tree

packages/nuxt/src/common/types.ts

Lines changed: 0 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -22,156 +22,6 @@ export type SentryNuxtServerOptions = Parameters<typeof initNode>[0] & {
2222
enableNitroErrorHandler?: boolean;
2323
};
2424

25-
type SourceMapsOptions = {
26-
/**
27-
* Suppresses all logs.
28-
*
29-
* @default false
30-
* @deprecated Use option `silent` instead of `sourceMapsUploadOptions.silent`
31-
*/
32-
silent?: boolean;
33-
34-
/**
35-
* When an error occurs during release creation or sourcemaps upload, the plugin will call this function.
36-
*
37-
* By default, the plugin will simply throw an error, thereby stopping the bundling process.
38-
* If an `errorHandler` callback is provided, compilation will continue, unless an error is
39-
* thrown in the provided callback.
40-
*
41-
* To allow compilation to continue but still emit a warning, set this option to the following:
42-
*
43-
* ```js
44-
* (err) => {
45-
* console.warn(err);
46-
* }
47-
* ```
48-
*
49-
* @deprecated Use option `errorHandler` instead of `sourceMapsUploadOptions.errorHandler`
50-
*/
51-
errorHandler?: (err: Error) => void;
52-
53-
/**
54-
* Options related to managing the Sentry releases for a build.
55-
*
56-
* More info: https://docs.sentry.io/product/releases/
57-
*
58-
* @deprecated Use option `release` instead of `sourceMapsUploadOptions.release`
59-
*/
60-
release?: {
61-
/**
62-
* Unique identifier for the release you want to create.
63-
*
64-
* This value can also be specified via the `SENTRY_RELEASE` environment variable.
65-
*
66-
* Defaults to automatically detecting a value for your environment.
67-
* This includes values for Cordova, Heroku, AWS CodeBuild, CircleCI, Xcode, and Gradle, and otherwise uses the git `HEAD`'s commit SHA.
68-
* (the latter requires access to git CLI and for the root directory to be a valid repository)
69-
*
70-
* If you didn't provide a value and the plugin can't automatically detect one, no release will be created.
71-
*
72-
* @deprecated Use `release.name` instead of `sourceMapsUploadOptions.release.name`
73-
*/
74-
name?: string;
75-
};
76-
77-
/**
78-
* If this flag is `true`, and an auth token is detected, the Sentry SDK will
79-
* automatically generate and upload source maps to Sentry during a production build.
80-
*
81-
* @default true
82-
* @deprecated Use option `sourcemaps.disable` instead of `sourceMapsUploadOptions.enabled`
83-
*/
84-
enabled?: boolean;
85-
86-
/**
87-
* The auth token to use when uploading source maps to Sentry.
88-
*
89-
* Instead of specifying this option, you can also set the `SENTRY_AUTH_TOKEN` environment variable.
90-
*
91-
* To create an auth token, follow this guide:
92-
* @see https://docs.sentry.io/product/accounts/auth-tokens/#organization-auth-tokens
93-
* @deprecated Use option `authToken` instead of `sourceMapsUploadOptions.authToken`
94-
*/
95-
authToken?: string;
96-
97-
/**
98-
* The organization slug of your Sentry organization.
99-
* Instead of specifying this option, you can also set the `SENTRY_ORG` environment variable.
100-
* @deprecated Use option `org` instead of `sourceMapsUploadOptions.org`
101-
*/
102-
org?: string;
103-
104-
/**
105-
* The URL of your Sentry instance if you're using self-hosted Sentry.
106-
*
107-
* @default https://sentry.io by default the plugin will point towards the Sentry SaaS URL
108-
* @deprecated Use `sentryUrl` instead of `sourceMapsUploadOptions.url`
109-
*/
110-
url?: string;
111-
112-
/**
113-
* The project slug of your Sentry project.
114-
* Instead of specifying this option, you can also set the `SENTRY_PROJECT` environment variable.
115-
*
116-
* @deprecated Use option `project` instead of `sourceMapsUploadOptions.project`
117-
*/
118-
project?: string;
119-
120-
/**
121-
* If this flag is `true`, the Sentry plugin will collect some telemetry data and send it to Sentry.
122-
* It will not collect any sensitive or user-specific data.
123-
*
124-
* @default true
125-
* @deprecated Use option `telemetry` instead of `sourceMapsUploadOptions.telemetry`
126-
*/
127-
telemetry?: boolean;
128-
129-
/**
130-
* Options related to sourcemaps
131-
*
132-
* @deprecated Use option `sourcemaps` instead of `sourceMapsUploadOptions.sourcemaps`
133-
*/
134-
sourcemaps?: {
135-
/**
136-
* A glob or an array of globs that specify the build artifacts and source maps that will be uploaded to Sentry.
137-
*
138-
* If this option is not specified, sensible defaults based on your adapter and nuxt.config.js
139-
* setup will be used. Use this option to override these defaults, for instance if you have a
140-
* customized build setup that diverges from Nuxt's defaults.
141-
*
142-
* The globbing patterns must follow the implementation of the `glob` package.
143-
* @see https://www.npmjs.com/package/glob#glob-primer
144-
*
145-
* @deprecated Use option `sourcemaps.assets` instead of `sourceMapsUploadOptions.sourcemaps.assets`
146-
*/
147-
assets?: string | Array<string>;
148-
149-
/**
150-
* A glob or an array of globs that specifies which build artifacts should not be uploaded to Sentry.
151-
*
152-
* @default [] - By default no files are ignored. Thus, all files matching the `assets` glob
153-
* or the default value for `assets` are uploaded.
154-
*
155-
* The globbing patterns follow the implementation of the glob package. (https://www.npmjs.com/package/glob)
156-
*
157-
* @deprecated Use option `sourcemaps.ignore` instead of `sourceMapsUploadOptions.sourcemaps.ignore`
158-
*/
159-
ignore?: string | Array<string>;
160-
161-
/**
162-
* A glob or an array of globs that specifies the build artifacts that should be deleted after the artifact
163-
* upload to Sentry has been completed.
164-
*
165-
* @default [] - By default no files are deleted.
166-
*
167-
* The globbing patterns follow the implementation of the glob package. (https://www.npmjs.com/package/glob)
168-
*
169-
* @deprecated Use option `sourcemaps.filesToDeleteAfterUpload` instead of `sourceMapsUploadOptions.sourcemaps.filesToDeleteAfterUpload`
170-
*/
171-
filesToDeleteAfterUpload?: string | Array<string>;
172-
};
173-
};
174-
17525
/**
17626
* Build options for the Sentry module. These options are used during build-time by the Sentry SDK.
17727
*/
@@ -200,17 +50,6 @@ export type SentryNuxtModuleOptions = BuildTimeOptionsBase & {
20050
useDiagnosticsChannelInjection?: boolean;
20151
};
20252

203-
/**
204-
* Options for the Sentry Vite plugin to customize the source maps upload process.
205-
*
206-
* These options are always read from the `sentry` module options in the `nuxt.config.(js|ts).
207-
* Do not define them in the `sentry.client.config.(js|ts)` or `sentry.server.config.(js|ts)` files.
208-
*
209-
* @deprecated This option was deprecated as it adds unnecessary nesting.
210-
* Put the options one level higher to the root-level of the `sentry` module options.
211-
*/
212-
sourceMapsUploadOptions?: SourceMapsOptions;
213-
21453
/**
21554
*
21655
* Enables (partial) server tracing by automatically injecting Sentry for environments where modifying the node option `--import` is not possible.

packages/nuxt/src/vite/sourceMaps.ts

Lines changed: 52 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -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
136119
export 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)

packages/nuxt/test/vite/buildOptions.test-d.ts

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -75,49 +75,6 @@ describe('Sentry Nuxt build-time options type', () => {
7575
expectTypeOf(completeOptions).toEqualTypeOf<SentryNuxtModuleOptions>();
7676
});
7777

78-
it('includes all deprecated options', () => {
79-
const completeOptions: SentryNuxtModuleOptions = {
80-
// SentryNuxtModuleOptions specific options
81-
enabled: true,
82-
debug: true,
83-
autoInjectServerSentry: 'experimental_dynamic-import', // No need for 'as const' with type assertion
84-
experimental_entrypointWrappedFunctions: ['default', 'handler', 'server', 'customExport'],
85-
unstable_sentryBundlerPluginOptions: {
86-
// Rollup plugin options
87-
bundleSizeOptimizations: {
88-
excludeDebugStatements: true,
89-
},
90-
// Vite plugin options
91-
sourcemaps: {
92-
assets: './dist/**/*',
93-
},
94-
},
95-
96-
// Deprecated sourceMapsUploadOptions
97-
sourceMapsUploadOptions: {
98-
silent: false,
99-
// eslint-disable-next-line no-console
100-
errorHandler: (err: Error) => console.warn(err),
101-
release: {
102-
name: 'deprecated-release',
103-
},
104-
enabled: true,
105-
authToken: 'deprecated-token',
106-
org: 'deprecated-org',
107-
url: 'https://deprecated.sentry.io',
108-
project: 'deprecated-project',
109-
telemetry: false,
110-
sourcemaps: {
111-
assets: './build/**/*',
112-
ignore: ['./build/*.spec.js'],
113-
filesToDeleteAfterUpload: ['./build/*.map'],
114-
},
115-
},
116-
};
117-
118-
expectTypeOf(completeOptions).toEqualTypeOf<SentryNuxtModuleOptions>();
119-
});
120-
12178
it('allows partial configuration', () => {
12279
const minimalOptions: SentryNuxtModuleOptions = { enabled: true };
12380

0 commit comments

Comments
 (0)