From 813e5b488d91e45cf45c27cb1524606be1f7dccd Mon Sep 17 00:00:00 2001 From: Nicolas Hrubec Date: Thu, 30 Jul 2026 16:41:51 +0200 Subject: [PATCH] ref(sveltekit)!: Remove deprecated `sourceMapsUploadOptions` Vite plugin option Co-Authored-By: Claude Opus 4.8 (1M context) --- .../sveltekit/src/vite/sentryVitePlugins.ts | 48 +--- packages/sveltekit/src/vite/sourceMaps.ts | 2 +- packages/sveltekit/src/vite/types.ts | 149 ------------ .../test/vite/sentrySvelteKitPlugins.test.ts | 221 +++++------------- 4 files changed, 69 insertions(+), 351 deletions(-) diff --git a/packages/sveltekit/src/vite/sentryVitePlugins.ts b/packages/sveltekit/src/vite/sentryVitePlugins.ts index 7fb4312edf7a..17a79dd06955 100644 --- a/packages/sveltekit/src/vite/sentryVitePlugins.ts +++ b/packages/sveltekit/src/vite/sentryVitePlugins.ts @@ -187,41 +187,25 @@ export function generateVitePluginOptions( }; } - // todo(v11): remove deprecated options (Also from options type) - // Source Maps if (svelteKitPluginOptions.autoUploadSourceMaps && process.env.NODE_ENV !== 'development') { const { - // eslint-disable-next-line typescript/no-deprecated - unstable_sentryVitePluginOptions: deprecated_unstableSourceMapUploadOptions, - ...deprecatedSourceMapUploadOptions - // eslint-disable-next-line typescript/no-deprecated - } = svelteKitPluginOptions.sourceMapsUploadOptions || {}; - - const { - // eslint-disable-next-line @typescript-eslint/no-unused-vars,typescript/no-deprecated - sourceMapsUploadOptions: _filtered1, // eslint-disable-next-line @typescript-eslint/no-unused-vars - unstable_sentryVitePluginOptions: _filtered2, + autoUploadSourceMaps: _filtered1, // eslint-disable-next-line @typescript-eslint/no-unused-vars - autoUploadSourceMaps: _filtered3, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - autoInstrument: _filtered4, + autoInstrument: _filtered2, + unstable_sentryVitePluginOptions, sentryUrl, ...newSvelteKitPluginOptions } = svelteKitPluginOptions; - const { unstable_sentryVitePluginOptions } = svelteKitPluginOptions; - sentryVitePluginsOptions = { ...(sentryVitePluginsOptions ? sentryVitePluginsOptions : {}), - ...deprecatedSourceMapUploadOptions, ...newSvelteKitPluginOptions, url: sentryUrl, - ...deprecated_unstableSourceMapUploadOptions, ...unstable_sentryVitePluginOptions, adapter: svelteKitPluginOptions.adapter, @@ -229,38 +213,16 @@ export function generateVitePluginOptions( debug: svelteKitPluginOptions.debug, }; - // Handle sourcemaps options - merge deprecated and new, with new taking precedence - if ( - // eslint-disable-next-line typescript/no-deprecated - deprecatedSourceMapUploadOptions.sourcemaps || - svelteKitPluginOptions.sourcemaps || - deprecated_unstableSourceMapUploadOptions?.sourcemaps || - unstable_sentryVitePluginOptions?.sourcemaps - ) { + if (svelteKitPluginOptions.sourcemaps || unstable_sentryVitePluginOptions?.sourcemaps) { sentryVitePluginsOptions.sourcemaps = { - // eslint-disable-next-line typescript/no-deprecated - ...deprecatedSourceMapUploadOptions.sourcemaps, ...svelteKitPluginOptions.sourcemaps, - // Also handle nested deprecated options from unstable plugin options - ...deprecated_unstableSourceMapUploadOptions?.sourcemaps, ...unstable_sentryVitePluginOptions?.sourcemaps, }; } - // Handle release options - merge deprecated and new, with new taking precedence - if ( - // eslint-disable-next-line typescript/no-deprecated - deprecatedSourceMapUploadOptions.release || - svelteKitPluginOptions.release || - deprecated_unstableSourceMapUploadOptions?.release || - unstable_sentryVitePluginOptions?.release - ) { + if (svelteKitPluginOptions.release || unstable_sentryVitePluginOptions?.release) { sentryVitePluginsOptions.release = { - // eslint-disable-next-line typescript/no-deprecated - ...deprecatedSourceMapUploadOptions.release, ...svelteKitPluginOptions.release, - // Also handle nested deprecated options from unstable plugin options - ...deprecated_unstableSourceMapUploadOptions?.release, ...unstable_sentryVitePluginOptions?.release, }; } diff --git a/packages/sveltekit/src/vite/sourceMaps.ts b/packages/sveltekit/src/vite/sourceMaps.ts index 25b6b3865212..f165d33afdf4 100644 --- a/packages/sveltekit/src/vite/sourceMaps.ts +++ b/packages/sveltekit/src/vite/sourceMaps.ts @@ -140,7 +140,7 @@ export async function makeCustomSentryVitePlugins( debug && // eslint-disable-next-line no-console console.info( - `[Sentry] Automatically setting \`sourceMapsUploadOptions.sourcemaps.filesToDeleteAfterUpload: [${defaultFileDeletionGlob + `[Sentry] Automatically setting \`sourcemaps.filesToDeleteAfterUpload: [${defaultFileDeletionGlob .map(file => `"${file}"`) .join(', ')}]\` to delete generated source maps after they were uploaded to Sentry.`, ); diff --git a/packages/sveltekit/src/vite/types.ts b/packages/sveltekit/src/vite/types.ts index 6994df980d16..064a492301fe 100644 --- a/packages/sveltekit/src/vite/types.ts +++ b/packages/sveltekit/src/vite/types.ts @@ -8,149 +8,6 @@ export type CustomSentryVitePluginOptions = SentryVitePluginOptions & { adapter?: SupportedSvelteKitAdapters; }; -/** - * Options for the Sentry Vite plugin to customize and override the release creation and source maps upload process. - * See [Sentry Vite Plugin Options](https://github.com/getsentry/sentry-javascript-bundler-plugins/tree/main/packages/vite-plugin#configuration) for a detailed description. - */ -type SourceMapsUploadOptions = { - /** - * The auth token to use when uploading source maps to Sentry. - * - * Instead of specifying this option, you can also set the `SENTRY_AUTH_TOKEN` environment variable. - * - * To create an auth token, follow this guide: - * @see https://docs.sentry.io/product/accounts/auth-tokens/#organization-auth-tokens - * - * @deprecated Use option `authToken` instead of `sourceMapsUploadOptions.authToken` - */ - authToken?: string; - - /** - * The organization slug of your Sentry organization. - * Instead of specifying this option, you can also set the `SENTRY_ORG` environment variable. - * - * @deprecated Use option `org` instead of `sourceMapsUploadOptions.org` - */ - org?: string; - - /** - * The project slug of your Sentry project. - * Instead of specifying this option, you can also set the `SENTRY_PROJECT` environment variable. - * - * @deprecated Use option `project` instead of `sourceMapsUploadOptions.project` - */ - project?: string; - - /** - * If this flag is `true`, the Sentry plugin will collect some telemetry data and send it to Sentry. - * It will not collect any sensitive or user-specific data. - * - * @default true - * @deprecated Use option `telemetry` instead of `sourceMapsUploadOptions.telemetry` - */ - telemetry?: boolean; - - /** - * Options related to sourcemaps - * @deprecated Use `sourcemaps` instead of `sourceMapsUploadOptions.sourcemaps` - */ - sourcemaps?: { - /** - * A glob or an array of globs that specify the build artifacts and source maps that will be uploaded to Sentry. - * - * If this option is not specified, sensible defaults based on your adapter and svelte.config.js - * setup will be used. Use this option to override these defaults, for instance if you have a - * customized build setup that diverges from SvelteKit's defaults. - * - * The globbing patterns must follow the implementation of the `glob` package. - * @see https://www.npmjs.com/package/glob#glob-primer - * @deprecated Use `sourcemaps.assets` instead of `sourceMapsUploadOptions.sourcemaps.assets` - */ - assets?: string | Array; - - /** - * A glob or an array of globs that specifies which build artifacts should not be uploaded to Sentry. - * - * @default [] - By default no files are ignored. Thus, all files matching the `assets` glob - * or the default value for `assets` are uploaded. - * - * The globbing patterns follow the implementation of the glob package. (https://www.npmjs.com/package/glob) - * - * @deprecated Use `sourcemaps.ignore` instead of `sourceMapsUploadOptions.sourcemaps.ignore` - */ - ignore?: string | Array; - - /** - * A glob or an array of globs that specifies the build artifacts that should be deleted after the artifact - * upload to Sentry has been completed. - * - * @default [] - By default no files are deleted. - * - * The globbing patterns follow the implementation of the glob package. (https://www.npmjs.com/package/glob) - * - * @deprecated Use `sourcemaps.filesToDeleteAfterUpload` instead of `sourceMapsUploadOptions.sourcemaps.filesToDeleteAfterUpload` - */ - filesToDeleteAfterUpload?: string | Array; - }; - - /** - * Options related to managing the Sentry releases for a build. - * - * Note: Managing releases is optional and not required for uploading source maps. - * - * @deprecated Use `release` instead of `sourceMapsUploadOptions.release` - */ - release?: { - /** - * Unique identifier for the release you want to create. - * This value can also be specified via the SENTRY_RELEASE environment variable. - * - * Defaults to automatically detecting a value for your environment. This includes values for Cordova, Heroku, - * AWS CodeBuild, CircleCI, Xcode, and Gradle, and otherwise uses the git HEAD's commit SHA (the latter requires - * access to git CLI and for the root directory to be a valid repository). - * - * If you didn't provide a value and the plugin can't automatically detect one, no release will be created. - * - * @deprecated Use `release.name` instead of `sourceMapsUploadOptions.release.name` - */ - name?: string; - - /** - * Whether the plugin should inject release information into the build for the SDK to pick it up when - * sending events. - * - * Defaults to `true`. - * - * @deprecated Use `release.inject` instead of `sourceMapsUploadOptions.release.inject` - */ - inject?: boolean; - }; - - /** - * The URL of the Sentry instance to upload the source maps to. - * - * @deprecated Use `sentryUrl` instead of `sourceMapsUploadOptions.url` - */ - url?: string; - - /** - * Options to further customize the Sentry Vite Plugin (@sentry/bundler-plugins/vite) behavior directly. - * Options specified in this object take precedence over the options specified in - * the `sourcemaps` and `release` objects. - * - * @see https://www.npmjs.com/package/@sentry/vite-plugin/v/2.14.2#options which lists all available options. - * - * Warning: Options within this object are subject to change at any time. - * We DO NOT guarantee semantic versioning for these options, meaning breaking - * changes can occur at any time within a major SDK version. - * - * Furthermore, some options are untested with SvelteKit specifically. Use with caution. - * - * @deprecated Use `unstable_sentryVitePluginOptions` instead of `sourceMapsUploadOptions.unstable_sentryVitePluginOptions` - */ - unstable_sentryVitePluginOptions?: Partial; -}; - /** Options for the Sentry SvelteKit plugin */ export type SentrySvelteKitPluginOptions = BuildTimeOptionsBase & UnstableVitePluginOptions> & { @@ -189,10 +46,4 @@ export type SentrySvelteKitPluginOptions = BuildTimeOptionsBase & * @default true`. */ autoUploadSourceMaps?: boolean; - - /** * Options related to source maps upload to Sentry - * - * @deprecated This option was deprecated as it adds unnecessary nesting. Put the options one level higher to the root-level of the Sentry Svelte plugin options. - */ - sourceMapsUploadOptions?: SourceMapsUploadOptions; }; diff --git a/packages/sveltekit/test/vite/sentrySvelteKitPlugins.test.ts b/packages/sveltekit/test/vite/sentrySvelteKitPlugins.test.ts index 586fb5906e48..b32fa56cda04 100644 --- a/packages/sveltekit/test/vite/sentrySvelteKitPlugins.test.ts +++ b/packages/sveltekit/test/vite/sentrySvelteKitPlugins.test.ts @@ -35,13 +35,6 @@ vi.spyOn(console, 'warn').mockImplementation(() => { function getSentrySvelteKitPlugins(options?: Parameters[0]): Promise { return sentrySvelteKit({ - sourceMapsUploadOptions: { - authToken: 'token', - org: 'org', - project: 'project', - // eslint-disable-next-line typescript/no-deprecated - ...options?.sourceMapsUploadOptions, - }, ...options, }); } @@ -129,12 +122,10 @@ describe('sentrySvelteKit()', () => { const makePluginSpy = vi.spyOn(sourceMaps, 'makeCustomSentryVitePlugins'); await getSentrySvelteKitPlugins({ debug: true, - sourceMapsUploadOptions: { - sourcemaps: { - assets: ['foo/*.js'], - ignore: ['bar/*.js'], - filesToDeleteAfterUpload: ['baz/*.js'], - }, + sourcemaps: { + assets: ['foo/*.js'], + ignore: ['bar/*.js'], + filesToDeleteAfterUpload: ['baz/*.js'], }, autoInstrument: false, adapter: 'vercel', @@ -158,32 +149,30 @@ describe('sentrySvelteKit()', () => { const makePluginSpy = vi.spyOn(sourceMaps, 'makeCustomSentryVitePlugins'); await getSentrySvelteKitPlugins({ debug: true, - sourceMapsUploadOptions: { - org: 'my-org', + org: 'my-org', + sourcemaps: { + assets: ['nope/*.js'], + filesToDeleteAfterUpload: ['baz/*.js'], + }, + release: { + inject: false, + name: '2.0.0', + }, + unstable_sentryVitePluginOptions: { + org: 'other-org', sourcemaps: { - assets: ['nope/*.js'], - filesToDeleteAfterUpload: ['baz/*.js'], + assets: ['foo/*.js'], + ignore: ['bar/*.js'], }, release: { - inject: false, - name: '2.0.0', - }, - unstable_sentryVitePluginOptions: { - org: 'other-org', - sourcemaps: { - assets: ['foo/*.js'], - ignore: ['bar/*.js'], - }, - release: { - name: '3.0.0', - setCommits: { - auto: true, - }, - }, - headers: { - 'X-My-Header': 'foo', + name: '3.0.0', + setCommits: { + auto: true, }, }, + headers: { + 'X-My-Header': 'foo', + }, }, autoInstrument: false, adapter: 'vercel', @@ -272,19 +261,17 @@ describe('generateVitePluginOptions', () => { process.env.NODE_ENV = originalEnv; }); - it('applies user-defined sourceMapsUploadOptions', () => { + it('applies user-defined source maps options', () => { const originalEnv = process.env.NODE_ENV; process.env.NODE_ENV = 'production'; // Ensure we're not in development mode const options: SentrySvelteKitPluginOptions = { autoUploadSourceMaps: true, - sourceMapsUploadOptions: { - authToken: 'token', - org: 'org', - project: 'project', - sourcemaps: { - assets: ['foo/*.js'], - }, + authToken: 'token', + org: 'org', + project: 'project', + sourcemaps: { + assets: ['foo/*.js'], }, }; const expected: CustomSentryVitePluginOptions = { @@ -307,18 +294,16 @@ describe('generateVitePluginOptions', () => { const options: SentrySvelteKitPluginOptions = { autoUploadSourceMaps: true, - sourceMapsUploadOptions: { - authToken: 'token', - org: 'org', - project: 'project', + authToken: 'token', + org: 'org', + project: 'project', + sourcemaps: { + assets: ['foo/*.js'], + }, + unstable_sentryVitePluginOptions: { + org: 'unstable-org', sourcemaps: { - assets: ['foo/*.js'], - }, - unstable_sentryVitePluginOptions: { - org: 'unstable-org', - sourcemaps: { - assets: ['unstable/*.js'], - }, + assets: ['unstable/*.js'], }, }, }; @@ -342,16 +327,14 @@ describe('generateVitePluginOptions', () => { const options: SentrySvelteKitPluginOptions = { autoUploadSourceMaps: true, - sourceMapsUploadOptions: { + release: { + name: '1.0.0', + }, + unstable_sentryVitePluginOptions: { release: { - name: '1.0.0', - }, - unstable_sentryVitePluginOptions: { - release: { - name: '2.0.0', - setCommits: { - auto: true, - }, + name: '2.0.0', + setCommits: { + auto: true, }, }, }, @@ -378,11 +361,9 @@ describe('generateVitePluginOptions', () => { autoUploadSourceMaps: true, adapter: 'vercel', debug: true, - sourceMapsUploadOptions: { - authToken: 'token', - org: 'org', - project: 'project', - }, + authToken: 'token', + org: 'org', + project: 'project', }; const expected: CustomSentryVitePluginOptions = { authToken: 'token', @@ -397,7 +378,7 @@ describe('generateVitePluginOptions', () => { process.env.NODE_ENV = originalEnv; }); - it('applies bundleSizeOptimizations AND sourceMapsUploadOptions when both are set', () => { + it('applies bundleSizeOptimizations AND source maps options when both are set', () => { const originalEnv = process.env.NODE_ENV; process.env.NODE_ENV = 'production'; // Ensure we're not in development mode @@ -408,13 +389,11 @@ describe('generateVitePluginOptions', () => { excludeDebugStatements: false, }, autoUploadSourceMaps: true, - sourceMapsUploadOptions: { - authToken: 'token', - org: 'org', - project: 'project', - sourcemaps: { - assets: ['foo/*.js'], - }, + authToken: 'token', + org: 'org', + project: 'project', + sourcemaps: { + assets: ['foo/*.js'], }, }; const expected = { @@ -442,12 +421,6 @@ describe('generateVitePluginOptions', () => { options: { autoUploadSourceMaps: true, org: 'root-org', - sourceMapsUploadOptions: { - org: 'deprecated-org', - unstable_sentryVitePluginOptions: { - org: 'unstable-org', - }, - }, unstable_sentryVitePluginOptions: { org: 'new-unstable-org', }, @@ -459,12 +432,6 @@ describe('generateVitePluginOptions', () => { options: { autoUploadSourceMaps: true, project: 'root-project', - sourceMapsUploadOptions: { - project: 'deprecated-project', - unstable_sentryVitePluginOptions: { - project: 'unstable-project', - }, - }, unstable_sentryVitePluginOptions: { project: 'new-unstable-project', }, @@ -476,12 +443,6 @@ describe('generateVitePluginOptions', () => { options: { autoUploadSourceMaps: true, authToken: 'root-token', - sourceMapsUploadOptions: { - authToken: 'deprecated-token', - unstable_sentryVitePluginOptions: { - authToken: 'unstable-token', - }, - }, unstable_sentryVitePluginOptions: { authToken: 'new-unstable-token', }, @@ -493,12 +454,6 @@ describe('generateVitePluginOptions', () => { options: { autoUploadSourceMaps: true, telemetry: true, - sourceMapsUploadOptions: { - telemetry: false, - unstable_sentryVitePluginOptions: { - telemetry: true, - }, - }, unstable_sentryVitePluginOptions: { telemetry: false, }, @@ -510,12 +465,6 @@ describe('generateVitePluginOptions', () => { options: { autoUploadSourceMaps: true, sentryUrl: 'https://root.sentry.io', - sourceMapsUploadOptions: { - url: 'https://deprecated.sentry.io', - unstable_sentryVitePluginOptions: { - url: 'https://unstable.sentry.io', - }, - }, unstable_sentryVitePluginOptions: { url: 'https://new-unstable.sentry.io', }, @@ -553,19 +502,6 @@ describe('generateVitePluginOptions', () => { ignore: ['root/ignore/*.js'], filesToDeleteAfterUpload: ['root/delete/*.js'], }, - sourceMapsUploadOptions: { - sourcemaps: { - assets: ['deprecated/*.js'], - ignore: ['deprecated/ignore/*.js'], - filesToDeleteAfterUpload: ['deprecated/delete/*.js'], - }, - unstable_sentryVitePluginOptions: { - sourcemaps: { - assets: ['unstable/*.js'], - ignore: ['unstable/ignore/*.js'], - }, - }, - }, unstable_sentryVitePluginOptions: { sourcemaps: { assets: ['new-unstable/*.js'], @@ -577,9 +513,9 @@ describe('generateVitePluginOptions', () => { const result = generateVitePluginOptions(options); expect(result?.sourcemaps).toEqual({ - assets: ['new-unstable/*.js'], // new unstable takes precedence - ignore: ['unstable/ignore/*.js'], // from deprecated unstable (not overridden by new unstable) - filesToDeleteAfterUpload: ['new-unstable/delete/*.js'], // new unstable takes precedence + assets: ['new-unstable/*.js'], // unstable takes precedence + ignore: ['root/ignore/*.js'], // from root (not overridden by unstable) + filesToDeleteAfterUpload: ['new-unstable/delete/*.js'], // unstable takes precedence }); }); @@ -598,28 +534,16 @@ describe('generateVitePluginOptions', () => { const options: SentrySvelteKitPluginOptions = { autoUploadSourceMaps: true, release: newReleaseOptions, - sourceMapsUploadOptions: { - release: { - name: 'deprecated-release', - inject: false, - }, - unstable_sentryVitePluginOptions: { - release: { name: 'deprecated-unstable-release', setCommits: { auto: true } }, - }, - }, unstable_sentryVitePluginOptions: { release: newUnstableReleaseOptions }, }; const result = generateVitePluginOptions(options); expect(result?.release).toEqual({ - name: newUnstableReleaseOptions.name, - inject: newReleaseOptions.inject, - setCommits: { - auto: true, // from deprecated unstable (not overridden) - }, + name: newUnstableReleaseOptions.name, // from unstable + inject: newReleaseOptions.inject, // from root (not overridden by unstable) deploy: { - env: 'production', // from new unstable + env: 'production', // from unstable }, }); }); @@ -635,30 +559,11 @@ describe('generateVitePluginOptions', () => { debug: false, sourcemaps: { assets: ['root/*.js'], + ignore: ['root/ignore/*.js'], }, release: { name: 'root-1.0.0', - }, - sourceMapsUploadOptions: { - org: 'deprecated-org', - project: 'deprecated-project', - authToken: 'deprecated-token', - telemetry: false, - url: 'https://deprecated.sentry.io', - sourcemaps: { - assets: ['deprecated/*.js'], - ignore: ['deprecated/ignore/*.js'], - }, - release: { - name: 'deprecated-1.0.0', - inject: false, - }, - unstable_sentryVitePluginOptions: { - org: 'old-unstable-org', - sourcemaps: { - assets: ['old-unstable/*.js'], - }, - }, + inject: false, }, unstable_sentryVitePluginOptions: { org: 'new-unstable-org', @@ -683,7 +588,7 @@ describe('generateVitePluginOptions', () => { url: 'https://root.sentry.io', sourcemaps: { assets: ['new-unstable/*.js'], - ignore: ['deprecated/ignore/*.js'], + ignore: ['root/ignore/*.js'], filesToDeleteAfterUpload: ['new-unstable/delete/*.js'], }, release: {