From 588e53a6ad439a7e1ce11c96b940970f6195acec Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Wed, 25 Nov 2026 21:04:52 +0000 Subject: [PATCH 1/2] feat(bundler-plugins): Deprecate `sourcemaps.disable`, `deleteSourcemapsAfterUpload` and `filesToDeleteAfterUpload` The three options keep working and log a deprecation warning when the user sets them. `sourcemaps.upload`, `sourcemaps.injectDebugIds` and `sourcemaps.delete` replace them. They will be removed in v12. --- MIGRATION.md | 45 ++++++++++++---- packages/astro/src/integration/index.ts | 5 +- packages/bundler-plugins/src/core/types.ts | 40 +++++--------- .../test/core/option-mappings.test.ts | 4 +- .../buildTimeOptionsBase.ts | 31 +++++------ .../warnOnConflictingSourceMapOptions.ts | 23 ++++++-- .../warnOnConflictingSourceMapOptions.test.ts | 53 +++++++++++++++---- packages/gatsby/gatsby-node.js | 23 +++++++- packages/gatsby/test/gatsby-node.test.ts | 46 ++++++++++++++-- .../src/config/getBuildPluginOptions.ts | 1 + .../nextjs/src/config/sourceMapOptions.ts | 3 ++ packages/nextjs/src/config/types.ts | 29 ++++------ packages/nitro/src/sourceMaps.ts | 2 + packages/nuxt/src/vite/sourceMapDeletion.ts | 5 ++ packages/nuxt/src/vite/sourceMaps.ts | 2 + .../src/vite/buildEnd/handleOnBuildEnd.ts | 2 + .../src/vite/makeCustomSentryVitePlugins.ts | 1 + packages/remix/src/vite/index.ts | 5 +- packages/remix/src/vite/sourceMaps.ts | 3 ++ packages/solidstart/src/vite/release.ts | 1 + .../src/vite/sentrySolidStartVite.ts | 9 +++- packages/solidstart/src/vite/sourceMaps.ts | 2 + packages/sveltekit/src/vite/sourceMaps.ts | 1 + .../src/vite/sentryTanstackStart.ts | 5 +- .../src/vite/sourceMaps.ts | 3 ++ .../test/vite/sentryTanstackStart.test.ts | 6 +-- 26 files changed, 253 insertions(+), 97 deletions(-) diff --git a/MIGRATION.md b/MIGRATION.md index 85a5c6d6073c..fde918187bec 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -1271,6 +1271,33 @@ Because the integration owns error capture, `setupFastifyErrorHandler` no longer -}); ``` +### `sourcemaps.disable`, `deleteSourcemapsAfterUpload` and `filesToDeleteAfterUpload` are deprecated + +Affected SDKs: the bundler plugins and all SDKs with build-time options. + +Three source map build options are deprecated. They still work, log a warning at build time, and will be removed in v12: + +| Deprecated option | Replacement | +| ---------------------------------------------------- | ---------------------------------------------------------- | +| `sourcemaps: { disable: 'disable-upload' }` | `sourcemaps: { upload: false }` | +| `sourcemaps: { disable: true }` | `sourcemaps: { upload: false, injectDebugIds: false }` | +| `sourcemaps.deleteSourcemapsAfterUpload` | `sourcemaps.delete` | +| `sourcemaps.filesToDeleteAfterUpload` | `sourcemaps.delete`, or a script that runs after the build | +| `deleteSourcemapsAfterUpload` (Gatsby plugin option) | `sourcemaps.delete` | + +`deleteSourcemapsAfterUpload: false` becomes `delete: false`. `delete: true` removes more than `deleteSourcemapsAfterUpload: true`: for source maps you turned on yourself, the old option only removed the maps of the chunks that were uploaded. `delete: true` removes every source map of the build, also CSS source maps and the maps of chunks that the upload leaves out, and it does so also when nothing is uploaded. In `@sentry/nextjs`, both options only apply to the client source maps. + +When `sourcemaps.delete` is unset, Sentry already removes the source maps it turned on itself, and `delete: true` removes all of them. If you used `filesToDeleteAfterUpload` to delete other files, delete them with a script after the build. + +Some SDKs turned on source maps for `disable: 'disable-upload'`, so that you could upload them yourself. With `upload: false`, they only do so when you also set `delete: false`. + +In `@sentry/astro`, `@sentry/nuxt` and `@sentry/solidstart`, `sourcemaps.disable: true` also leaves out the Sentry plugin, so no release is injected or created. In `@sentry/nitro`, it skips the release creation. The new options keep these release steps. To turn them off too, set: + +```js +sourcemaps: { upload: false, injectDebugIds: false }, +release: { inject: false, create: false, finalize: false, setCommits: false, deploy: false }, +``` + ### `@sentry/nextjs` **Tracing removed from generated templates:** Tracing was removed from the generated Pages Router API handler, Edge API handler, and Middleware wrapper templates. Route handlers and middleware are still instrumented automatically, so no action is required for most users. @@ -1482,7 +1509,7 @@ Affected SDKs: `@sentry/remix`. The plugin now also applies the build-time instrumentation transform. If you added `sentryOrchestrionPlugin()` from `@sentry/server-utils/orchestrion/vite` to your Vite config manually, remove it. Opt out with `sentryRemixVitePlugin({ buildTimeInstrumentation: false })`. -It also injects debug IDs and uploads source maps once you pass `org`, `project` and `authToken` — opt out with `sentryRemixVitePlugin({ sourcemaps: { disable: true } })`. +It also injects debug IDs and uploads source maps once you pass `org`, `project` and `authToken` — opt out with `sentryRemixVitePlugin({ sourcemaps: { upload: false, injectDebugIds: false } })`. ### React: Simpler React Router setup via `@sentry/react/react-router` @@ -1815,7 +1842,7 @@ tracing loaders and actions. instead of wrapping them individually. - The deprecated `sentryHandleRequest` export was removed. Use `wrapSentryHandleRequest` instead. -The deprecated `sourceMapsUploadOptions` option was removed from `sentryReactRouter()`. Move its fields to the root level of the `sentryConfig` passed to `sentryReactRouter()`. Note that `enabled` was replaced by `sourcemaps.disable` (inverted: `enabled: false` becomes `sourcemaps: { disable: true }`). +The deprecated `sourceMapsUploadOptions` option was removed from `sentryReactRouter()`. Move its fields to the root level of the `sentryConfig` passed to `sentryReactRouter()`. Note that `enabled: false` becomes `sourcemaps: { upload: false, injectDebugIds: false }`. ### Browser and Node profiling @@ -1922,7 +1949,7 @@ remains available on the React-based SDKs (`@sentry/nextjs`, `@sentry/react-rout The following bundler plugin options have no first-class equivalent and are no longer reachable: `release.uploadLegacySourcemaps`, `_experiments`, and the whole-plugin `disable` flag (use -`sourcemaps.disable` instead). +`sourcemaps: { upload: false, injectDebugIds: false }` instead). ### `@sentry/nuxt` @@ -1938,7 +1965,7 @@ sentry.server.config.ts After the rename, the SDK bundles the file into the Nitro server build and initializes itself at server startup. See ["the server config is bundled"](#sentrynuxt-the-server-config-is-bundled---import-is-no-longer-needed) above: the `--import` preload is no longer needed. -The deprecated `sourceMapsUploadOptions` module option was removed. Move its fields to the root level of the `sentry` module options. Note that `url` was renamed to `sentryUrl`, and `enabled` was replaced by `sourcemaps.disable` (inverted: `enabled: false` becomes `sourcemaps: { disable: true }`). +The deprecated `sourceMapsUploadOptions` module option was removed. Move its fields to the root level of the `sentry` module options. Note that `url` was renamed to `sentryUrl`, and `enabled: false` becomes `sourcemaps: { upload: false, injectDebugIds: false }`. To also turn off the release steps, as `enabled: false` did, see [the deprecated source map options](#sourcemapsdisable-deletesourcemapsafterupload-and-filestodeleteafterupload-are-deprecated). ```ts // nuxt.config.ts @@ -2011,7 +2038,7 @@ export default defineConfig({ ### `@sentry/astro` -The deprecated `sourceMapsUploadOptions` option was removed from `sentryAstro()`. Move its fields to the top level of the `sentryAstro()` options. Note that `assets` and `filesToDeleteAfterUpload` moved into `sourcemaps`, and `enabled` was replaced by `sourcemaps.disable` (inverted: `enabled: false` becomes `sourcemaps: { disable: true }`). +The deprecated `sourceMapsUploadOptions` option was removed from `sentryAstro()`. Move its fields to the top level of the `sentryAstro()` options. Note that `assets` moved into `sourcemaps`, `filesToDeleteAfterUpload` is replaced by `sourcemaps.delete`, and `enabled: false` becomes `sourcemaps: { upload: false, injectDebugIds: false }`. To also turn off the release steps, as `enabled: false` did, see [the deprecated source map options](#sourcemapsdisable-deletesourcemapsafterupload-and-filestodeleteafterupload-are-deprecated). ```js // astro.config.mjs @@ -2091,8 +2118,9 @@ Sentry.init({ ### `@sentry/solidstart` The `sourceMapsUploadOptions` build option was removed. Move its fields to the top level, matching every -other meta-framework SDK. Note that `enabled` was replaced by `sourcemaps.disable` (inverted: -`enabled: false` becomes `sourcemaps: { disable: true }`). +other meta-framework SDK. Note that `enabled: false` becomes `sourcemaps: { upload: false, injectDebugIds: false }`, +and `filesToDeleteAfterUpload` is replaced by `sourcemaps.delete`. To also turn off the release steps, as +`enabled: false` did, see [the deprecated source map options](#sourcemapsdisable-deletesourcemapsafterupload-and-filestodeleteafterupload-are-deprecated). This only affects SolidStart 1 setups using `withSentry()` / `sentrySolidStartVite()`. SolidStart 2's `sentrySolidStart()` already took its options at the top level. @@ -2113,8 +2141,7 @@ export default defineConfig( // after telemetry: false, sourcemaps: { - disable: false, - filesToDeleteAfterUpload: ['./dist/**/*.map'], + delete: true, }, }, ), diff --git a/packages/astro/src/integration/index.ts b/packages/astro/src/integration/index.ts index 839bf661b36f..1744008df633 100644 --- a/packages/astro/src/integration/index.ts +++ b/packages/astro/src/integration/index.ts @@ -1,5 +1,5 @@ import { sentryVitePlugin } from '@sentry/bundler-plugins/vite'; -import { resolveSourceMapsFeatures, warnOnRemovedBuildOptions } from '@sentry/core'; +import { resolveSourceMapsFeatures, warnOnConflictingSourceMapOptions, warnOnRemovedBuildOptions } from '@sentry/core'; import { sentryOrchestrionPlugin } from '@sentry/server-utils/orchestrion/vite'; import type { AstroConfig, AstroIntegration } from 'astro'; import * as fs from 'fs'; @@ -59,6 +59,8 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => { warnOnRemovedBuildOptions(options, ['unstable_sentryVitePluginOptions', 'sourceMapsUploadOptions'], message => logger.warn(message), ); + // The Sentry plugin is not added with `sourcemaps.disable: true`. + warnOnConflictingSourceMapOptions(sourcemaps, message => logger.warn(message)); const sdkEnabled = { client: typeof enabled === 'boolean' ? enabled : (enabled?.client ?? true), @@ -81,6 +83,7 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => { // A user's own glob replaces the SDK's deletion. Maps in a Cloudflare `_worker.js` folder // stay, so that wrangler can read them for `upload_source_maps`. const sdkDeleteSourceMaps = + // oxlint-disable-next-line typescript/no-deprecated sourcemaps?.delete === undefined && sourcemaps?.filesToDeleteAfterUpload === undefined ? (environment?: string) => sdkEnabledSourceMaps(environment) && !buildState.writesCloudflareWorker ? true : undefined diff --git a/packages/bundler-plugins/src/core/types.ts b/packages/bundler-plugins/src/core/types.ts index 227d4955b108..1dd0480156c4 100644 --- a/packages/bundler-plugins/src/core/types.ts +++ b/packages/bundler-plugins/src/core/types.ts @@ -155,6 +155,9 @@ export interface Options { // TODO(v12): Remove `disable`. `upload` and `injectDebugIds` replace it. /** + * @deprecated Use `sourcemaps.upload` and `sourcemaps.injectDebugIds` instead. `upload: false` replaces + * `"disable-upload"`, and `upload: false, injectDebugIds: false` replaces `true`. + * * Disables all functionality related to sourcemaps if set to `true`. * * If set to `"disable-upload"`, the plugin will not upload sourcemaps to Sentry, but will still inject debug IDs @@ -223,39 +226,24 @@ export interface Options { */ resolveSourceMap?: ResolveSourceMapHook; + // TODO(v12): Remove. /** - * 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. - * - * Note: If you pass in a Promise that resolves to a string or array, the plugin will await the Promise and use - * the resolved value globs. This is useful if you need to dynamically determine the files to delete. Some - * higher-level Sentry SDKs or options use this feature (e.g., SvelteKit). + * @deprecated Use `sourcemaps.delete` instead. When it is unset, Sentry already removes the source maps it + * turned on, and `delete: true` removes all of them. To delete other files, run a script after the build. * - * The globbing patterns must follow the implementation of the `glob` package: https://www.npmjs.com/package/glob#glob-primer - * - * Use the `debug` option to print information about which files end up being deleted. + * A glob or an array of globs, or a promise of them, that specifies the build artifacts to delete after the + * upload to Sentry. The globbing patterns must follow the implementation of the `glob` package. */ filesToDeleteAfterUpload?: string | string[] | Promise; + // TODO(v12): Remove. /** - * Whether source maps are removed from the build output after they are uploaded to Sentry. - * - * When unset, the plugin removes only the source maps it turned on itself, that is, when the bundler's source map - * setting was not set. `true` also removes source maps you enabled yourself. `false` never removes them; the plugin - * still turns on hidden source maps when the setting is not set, so they can be uploaded. + * @deprecated Use `sourcemaps.delete` instead. For source maps you turned on, `delete: true` removes every + * source map of the build, also those of chunks that were not uploaded, and also when nothing is uploaded. * - * When the plugin turned source maps on, none of them reach the build output, not even those of chunks that - * `sourcemaps.assets` or `sourcemaps.ignore` keep out of the upload. Source maps you enabled yourself are only - * removed for the JavaScript chunks that were uploaded; excluded chunks keep theirs. - * - * `true` removes source maps you enabled yourself even when no upload runs, for example without an auth token. - * With `sourcemaps.disable` set, the plugin keeps them for a manual upload and warns. The plugin does not turn - * source maps on when it cannot upload them. - * - * With webpack's array form of `devtool`, `true` replaces the array with one hidden source map setting for - * all asset types, because webpack hides the array from plugins. - * - * With Rollup, Vite and webpack the removed source maps are never written to the output directory. With esbuild - * they are deleted after the upload. + * Whether source maps are removed from the build output after they are uploaded to Sentry. When unset, the + * plugin removes only the source maps it turned on itself. `true` also removes the source maps you turned on + * for the JavaScript chunks that were uploaded. `false` never removes them. */ deleteSourcemapsAfterUpload?: boolean; }; diff --git a/packages/bundler-plugins/test/core/option-mappings.test.ts b/packages/bundler-plugins/test/core/option-mappings.test.ts index ef56d9117d9d..890e27ef152d 100644 --- a/packages/bundler-plugins/test/core/option-mappings.test.ts +++ b/packages/bundler-plugins/test/core/option-mappings.test.ts @@ -425,12 +425,12 @@ describe('validateOptions', () => { }); it.each([undefined, 'disable-upload'] as const)( - 'does not warn when `deleteSourcemapsAfterUpload` is set and `sourcemaps.disable` is `%s`', + 'does not warn about a conflict when `deleteSourcemapsAfterUpload` is set and `sourcemaps.disable` is `%s`', disable => { const options = normalizeUserOptions({ sourcemaps: { disable, deleteSourcemapsAfterUpload: true } }); expect(validateOptions(options, mockedLogger)).toBe(true); - expect(mockedLogger.warn).not.toHaveBeenCalled(); + expect(mockedLogger.warn).not.toHaveBeenCalledWith(expect.stringMatching(/ is ignored | still | is set, but /)); }, ); diff --git a/packages/core/src/build-time-plugins/buildTimeOptionsBase.ts b/packages/core/src/build-time-plugins/buildTimeOptionsBase.ts index e75ad50c97c2..15f9fd98cada 100644 --- a/packages/core/src/build-time-plugins/buildTimeOptionsBase.ts +++ b/packages/core/src/build-time-plugins/buildTimeOptionsBase.ts @@ -247,6 +247,9 @@ interface SourceMapsOptions { // TODO(v12): Remove `disable`. `upload` and `injectDebugIds` replace it. /** + * @deprecated Use `sourcemaps.upload` and `sourcemaps.injectDebugIds` instead. `upload: false` replaces + * `"disable-upload"`, and `upload: false, injectDebugIds: false` replaces `true`. + * * If this flag is `true`, any functionality related to source maps will be disabled. This includes the automatic upload of source maps. * * By default (`false`), the plugin automatically uploads source maps during a production build if a Sentry auth token is detected. @@ -280,31 +283,25 @@ interface SourceMapsOptions { */ ignore?: string | string[]; + // TODO(v12): Remove. /** - * 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. + * @deprecated Use `sourcemaps.delete` instead. When it is unset, Sentry already removes the source maps it + * turned on, and `delete: true` removes all of them. To delete other files, run a script after the build. + * + * A glob or an array of globs that specifies the build artifacts to delete after the upload to Sentry. * * The globbing patterns must follow the implementation of the `glob` package: https://www.npmjs.com/package/glob#glob-primer */ filesToDeleteAfterUpload?: string | Array; + // TODO(v12): Remove. /** - * Whether source maps are removed from the build output after they are uploaded to Sentry. - * - * When unset, the plugin removes only the source maps it turned on itself, that is, when the bundler's source map - * setting was not set. `true` also removes source maps you enabled yourself. `false` never removes them; the plugin - * still turns on hidden source maps when the setting is not set, so they can be uploaded. - * - * When the plugin turned source maps on, none of them reach the build output, not even those of chunks that - * `sourcemaps.assets` or `sourcemaps.ignore` keep out of the upload. Source maps you enabled yourself are only - * removed for the JavaScript chunks that were uploaded; excluded chunks keep theirs. - * - * `true` removes source maps you enabled yourself even when no upload runs, for example without an auth token. - * With `sourcemaps.disable` set, the plugin keeps them for a manual upload and warns. The plugin does not turn - * source maps on when it cannot upload them. + * @deprecated Use `sourcemaps.delete` instead. For source maps you turned on, `delete: true` removes every + * source map of the build, also those of chunks that were not uploaded, and also when nothing is uploaded. * - * With webpack's array form of `devtool`, `true` replaces the array with one hidden source map setting for - * all asset types, because webpack hides the array from plugins. + * Whether source maps are removed from the build output after they are uploaded to Sentry. When unset, Sentry + * removes only the source maps it turned on itself. `true` also removes the source maps you turned on for the + * JavaScript chunks that were uploaded. `false` never removes them. */ deleteSourcemapsAfterUpload?: boolean; diff --git a/packages/core/src/build-time-plugins/warnOnConflictingSourceMapOptions.ts b/packages/core/src/build-time-plugins/warnOnConflictingSourceMapOptions.ts index c49e841583dd..60aa357d5039 100644 --- a/packages/core/src/build-time-plugins/warnOnConflictingSourceMapOptions.ts +++ b/packages/core/src/build-time-plugins/warnOnConflictingSourceMapOptions.ts @@ -1,6 +1,6 @@ import { consoleSandbox } from '../utils/debug-logger'; -/** The source map options that can conflict with each other. */ +/** The source map options that can conflict with each other or are deprecated. */ export interface ConflictingSourceMapOptions { disable?: boolean | 'disable-upload'; upload?: boolean; @@ -14,8 +14,8 @@ export interface ConflictingSourceMapOptions { const loggedWarnings = new Set(); /** - * Warns about `sourcemaps` options that conflict with each other. It logs - * each warning once per process. + * Warns about deprecated `sourcemaps` options and about options that conflict with each other. It + * logs each warning once per process. * * The bundler plugin calls this for the options it gets. SDKs that apply some of the options * themselves call it with the user's options, because the plugin does not see them all. @@ -46,6 +46,23 @@ export function warnOnConflictingSourceMapOptions( } }; + // TODO(v12): Remove along with the deprecated options. + if (sourcemaps.disable !== undefined) { + warn( + "`sourcemaps.disable` is deprecated and will be removed in the next major version. Use `sourcemaps.upload: false` instead of `'disable-upload'`, and `sourcemaps: { upload: false, injectDebugIds: false }` instead of `true`.", + ); + } + if (sourcemaps.deleteSourcemapsAfterUpload !== undefined) { + warn( + '`sourcemaps.deleteSourcemapsAfterUpload` is deprecated and will be removed in the next major version. Use `sourcemaps.delete` instead.', + ); + } + if (sourcemaps.filesToDeleteAfterUpload !== undefined) { + warn( + '`sourcemaps.filesToDeleteAfterUpload` is deprecated and will be removed in the next major version. Use `sourcemaps.delete` instead. To delete other files, run a script after the build.', + ); + } + const usesFeatureOptions = sourcemaps.upload !== undefined || sourcemaps.injectDebugIds !== undefined; // TODO(v12): Remove along with `sourcemaps.disable`. if (usesFeatureOptions && sourcemaps.disable !== undefined) { diff --git a/packages/core/test/lib/build-time-plugins/warnOnConflictingSourceMapOptions.test.ts b/packages/core/test/lib/build-time-plugins/warnOnConflictingSourceMapOptions.test.ts index ab51787fd492..9bf912c5a002 100644 --- a/packages/core/test/lib/build-time-plugins/warnOnConflictingSourceMapOptions.test.ts +++ b/packages/core/test/lib/build-time-plugins/warnOnConflictingSourceMapOptions.test.ts @@ -15,18 +15,40 @@ describe('warnOnConflictingSourceMapOptions', () => { vi.restoreAllMocks(); }); + it.each([ + [{ disable: true }, /^`sourcemaps\.disable` is deprecated.*`sourcemaps\.upload: false`/], + [{ disable: 'disable-upload' }, /^`sourcemaps\.disable` is deprecated/], + [{ disable: false }, /^`sourcemaps\.disable` is deprecated/], + [ + { deleteSourcemapsAfterUpload: true }, + /^`sourcemaps\.deleteSourcemapsAfterUpload` is deprecated.*`sourcemaps\.delete`/, + ], + [{ deleteSourcemapsAfterUpload: false }, /^`sourcemaps\.deleteSourcemapsAfterUpload` is deprecated/], + [ + { filesToDeleteAfterUpload: ['dist/**/*.map'] }, + /^`sourcemaps\.filesToDeleteAfterUpload` is deprecated.*`sourcemaps\.delete`/, + ], + [{ delete: true, filesToDeleteAfterUpload: [] }, /^`sourcemaps\.filesToDeleteAfterUpload` is deprecated/], + ] as const)('warns once that an option in %j is deprecated', (sourcemaps, message) => { + const logWarning = vi.fn(); + + warnOnConflictingSourceMapOptions(sourcemaps, logWarning); + + expect(logWarning).toHaveBeenCalledTimes(1); + expect(logWarning).toHaveBeenCalledWith(expect.stringMatching(message)); + }); + it.each([ [{ upload: false, disable: true }, /`sourcemaps\.disable` is ignored/], [{ injectDebugIds: false, disable: 'disable-upload' }, /`sourcemaps\.disable` is ignored/], [{ upload: true, injectDebugIds: false }, /`sourcemaps\.injectDebugIds` is `false`/], [{ delete: true, deleteSourcemapsAfterUpload: false }, /`sourcemaps\.deleteSourcemapsAfterUpload` is ignored/], [{ delete: false, filesToDeleteAfterUpload: ['dist/**/*.map'] }, /`sourcemaps\.filesToDeleteAfterUpload` still/], - ] as const)('warns once about %j', (sourcemaps, message) => { + ] as const)('warns about the conflict in %j', (sourcemaps, message) => { const logWarning = vi.fn(); warnOnConflictingSourceMapOptions(sourcemaps, logWarning); - expect(logWarning).toHaveBeenCalledTimes(1); expect(logWarning).toHaveBeenCalledWith(expect.stringMatching(message)); }); @@ -37,19 +59,30 @@ describe('warnOnConflictingSourceMapOptions', () => { { injectDebugIds: false }, { upload: false, injectDebugIds: false }, { delete: false }, + { delete: true }, + { disable: undefined, deleteSourcemapsAfterUpload: undefined, filesToDeleteAfterUpload: undefined }, + ] as const)('does not warn about %j', sourcemaps => { + const logWarning = vi.fn(); + + warnOnConflictingSourceMapOptions(sourcemaps, logWarning); + + expect(logWarning).not.toHaveBeenCalled(); + }); + + it.each([ { disable: true, deleteSourcemapsAfterUpload: true }, { disable: true, delete: true }, { delete: true, filesToDeleteAfterUpload: ['extra/**'] }, - { filesToDeleteAfterUpload: ['dist/**/*.map'] }, - ] as const)('does not warn about %j', sourcemaps => { + ] as const)('only warns about the deprecated options in %j', sourcemaps => { const logWarning = vi.fn(); warnOnConflictingSourceMapOptions(sourcemaps, logWarning); - expect(logWarning).not.toHaveBeenCalled(); + expect(logWarning).toHaveBeenCalledWith(expect.stringMatching(/ is deprecated /)); + expect(logWarning).not.toHaveBeenCalledWith(expect.stringMatching(/ is ignored | still | is set, but /)); }); - it('warns about each conflict', () => { + it('warns about each deprecated option and each conflict', () => { const logWarning = vi.fn(); warnOnConflictingSourceMapOptions( @@ -57,7 +90,7 @@ describe('warnOnConflictingSourceMapOptions', () => { logWarning, ); - expect(logWarning).toHaveBeenCalledTimes(3); + expect(logWarning).toHaveBeenCalledTimes(5); }); it('logs each warning once, also for later calls', () => { @@ -65,10 +98,12 @@ describe('warnOnConflictingSourceMapOptions', () => { warnOnConflictingSourceMapOptions({ upload: true, injectDebugIds: false }, logWarning); warnOnConflictingSourceMapOptions({ upload: true, injectDebugIds: false, disable: true }, logWarning); + warnOnConflictingSourceMapOptions({ disable: 'disable-upload' }, logWarning); - expect(logWarning).toHaveBeenCalledTimes(2); + expect(logWarning).toHaveBeenCalledTimes(3); expect(logWarning).toHaveBeenNthCalledWith(1, expect.stringMatching(/`sourcemaps\.injectDebugIds` is `false`/)); - expect(logWarning).toHaveBeenNthCalledWith(2, expect.stringMatching(/`sourcemaps\.disable` is ignored/)); + expect(logWarning).toHaveBeenNthCalledWith(2, expect.stringMatching(/`sourcemaps\.disable` is deprecated/)); + expect(logWarning).toHaveBeenNthCalledWith(3, expect.stringMatching(/`sourcemaps\.disable` is ignored/)); }); it('logs with a `[Sentry]` prefix by default', () => { diff --git a/packages/gatsby/gatsby-node.js b/packages/gatsby/gatsby-node.js index 9834e87fdafb..1aff974bedf9 100644 --- a/packages/gatsby/gatsby-node.js +++ b/packages/gatsby/gatsby-node.js @@ -2,18 +2,39 @@ const fs = require('fs'); const { hasSourceMapUploadCredentials } = require('@sentry/bundler-plugins/core'); const { sentryWebpackPlugin } = require('@sentry/bundler-plugins/webpack'); -const { consoleSandbox, resolveSourceMapsFeatures } = require('@sentry/core'); +const { consoleSandbox, resolveSourceMapsFeatures, warnOnConflictingSourceMapOptions } = require('@sentry/core'); const SENTRY_USER_CONFIG = ['./sentry.config.js', './sentry.config.ts']; // Gatsby calls `onCreateWebpackConfig` once per build stage. let warnedAboutDeleteOptions = false; +let warnedAboutFlatDeleteOption = false; exports.onCreateWebpackConfig = ({ getConfig, actions, stage }, options) => { const enableClientWebpackPlugin = options.enableClientWebpackPlugin !== false; if (process.env.NODE_ENV === 'production' && enableClientWebpackPlugin) { const prevSourceMapSetting = getConfig() && 'devtool' in getConfig() ? getConfig().devtool : undefined; const { injectDebugIds, upload } = resolveSourceMapsFeatures(options.sourcemaps); + const sourcemaps = options.sourcemaps; + // Gatsby reads no other `sourcemaps` options. + warnOnConflictingSourceMapOptions( + sourcemaps && { + disable: sourcemaps.disable, + upload: sourcemaps.upload, + injectDebugIds: sourcemaps.injectDebugIds, + delete: sourcemaps.delete, + }, + ); + // TODO(v12): Remove along with the flat `deleteSourcemapsAfterUpload`. + if (options.deleteSourcemapsAfterUpload !== undefined && !warnedAboutFlatDeleteOption) { + warnedAboutFlatDeleteOption = true; + consoleSandbox(() => { + // eslint-disable-next-line no-console + console.warn( + '[Sentry] `deleteSourcemapsAfterUpload` is deprecated and will be removed in the next major version. Use `sourcemaps.delete` instead.', + ); + }); + } // `sourcemaps.delete` replaces the flat `deleteSourcemapsAfterUpload`. const deleteOption = options.sourcemaps?.delete ?? options.deleteSourcemapsAfterUpload; if ( diff --git a/packages/gatsby/test/gatsby-node.test.ts b/packages/gatsby/test/gatsby-node.test.ts index ca7d37dae041..4d96f48115ba 100644 --- a/packages/gatsby/test/gatsby-node.test.ts +++ b/packages/gatsby/test/gatsby-node.test.ts @@ -22,6 +22,12 @@ async function mock(mockedUri: string, stub: any) { }; } +// `gatsby-node.js` remembers the warnings it logged. +async function loadFreshGatsbyNode(): Promise { + vi.resetModules(); + return (await import('../gatsby-node')).onCreateWebpackConfig; +} + describe('onCreateWebpackConfig', () => { // eslint-disable-next-line @typescript-eslint/no-var-requires const { sentryWebpackPlugin } = require('@sentry/bundler-plugins/webpack'); @@ -290,19 +296,53 @@ describe('onCreateWebpackConfig', () => { logSpy.mockRestore(); }); - it('warns once when `sourcemaps.delete` and the flat option are both set', () => { + it('warns once when `sourcemaps.delete` and the flat option are both set', async () => { + const freshOnCreateWebpackConfig = await loadFreshGatsbyNode(); const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}); const getConfig = vi.fn().mockReturnValue({ devtool: 'source-map' }); const options = { deleteSourcemapsAfterUpload: true, sourcemaps: { delete: false } }; for (const stage of ['build-javascript', 'build-html']) { - onCreateWebpackConfig({ actions: { setWebpackConfig: vi.fn() }, getConfig, stage }, options); + freshOnCreateWebpackConfig({ actions: { setWebpackConfig: vi.fn() }, getConfig, stage }, options); } - expect(warnSpy).toHaveBeenCalledTimes(1); + expect(warnSpy).toHaveBeenCalledTimes(2); expect(warnSpy).toHaveBeenCalledWith( expect.stringContaining('`deleteSourcemapsAfterUpload` is ignored because `sourcemaps.delete` is set'), ); + expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('`deleteSourcemapsAfterUpload` is deprecated')); + warnSpy.mockRestore(); + }); + + it('warns once that the flat `deleteSourcemapsAfterUpload` is deprecated', async () => { + const freshOnCreateWebpackConfig = await loadFreshGatsbyNode(); + const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}); + const getConfig = vi.fn().mockReturnValue({ devtool: 'source-map' }); + + for (const stage of ['build-javascript', 'build-html']) { + freshOnCreateWebpackConfig( + { actions: { setWebpackConfig: vi.fn() }, getConfig, stage }, + { deleteSourcemapsAfterUpload: false }, + ); + } + + expect(warnSpy).toHaveBeenCalledTimes(1); + expect(warnSpy).toHaveBeenCalledWith( + '[Sentry] `deleteSourcemapsAfterUpload` is deprecated and will be removed in the next major version. Use `sourcemaps.delete` instead.', + ); + warnSpy.mockRestore(); + }); + + it('warns that `sourcemaps.disable` is deprecated', () => { + const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}); + const getConfig = vi.fn().mockReturnValue({ devtool: 'source-map' }); + + onCreateWebpackConfig( + { actions: { setWebpackConfig: vi.fn() }, getConfig, stage: 'build-javascript' }, + { sourcemaps: { disable: 'disable-upload' } }, + ); + + expect(warnSpy).toHaveBeenCalledWith(expect.stringMatching(/^\[Sentry\] `sourcemaps\.disable` is deprecated/)); warnSpy.mockRestore(); }); diff --git a/packages/nextjs/src/config/getBuildPluginOptions.ts b/packages/nextjs/src/config/getBuildPluginOptions.ts index bf431d02647d..5e32ac2bc035 100644 --- a/packages/nextjs/src/config/getBuildPluginOptions.ts +++ b/packages/nextjs/src/config/getBuildPluginOptions.ts @@ -316,6 +316,7 @@ export function getBuildPluginOptions({ const finalIgnorePatterns = mergeIgnorePatterns(sourcemapUploadIgnore, sentryBuildOptions.sourcemaps?.ignore); + // oxlint-disable-next-line typescript/no-deprecated const userFilesToDeleteAfterUpload = sentryBuildOptions.sourcemaps?.filesToDeleteAfterUpload; if (sentryBuildOptions.debug && userFilesToDeleteAfterUpload !== undefined && userFilesReplaceDeletion) { diff --git a/packages/nextjs/src/config/sourceMapOptions.ts b/packages/nextjs/src/config/sourceMapOptions.ts index 27b096e5cfb9..cedc94062b06 100644 --- a/packages/nextjs/src/config/sourceMapOptions.ts +++ b/packages/nextjs/src/config/sourceMapOptions.ts @@ -36,6 +36,7 @@ export function setSdkDeletesSourceMaps(options: SentryBuildOptions): void { export function getDeleteSourceMapsOption(options: SentryBuildOptions): boolean | undefined { const { sourcemaps } = options; return ( + // oxlint-disable-next-line typescript/no-deprecated sourcemaps?.delete ?? sourcemaps?.deleteSourcemapsAfterUpload ?? (sdkDeletesSourceMaps.has(options) || undefined) ); } @@ -68,6 +69,8 @@ export function getSourceMapFeatureOptions( return { upload: false, injectDebugIds: false }; } + // oxlint-disable-next-line typescript/no-deprecated const { disable, upload, injectDebugIds } = userSourcemaps ?? {}; + // oxlint-disable-next-line typescript/no-deprecated return { disable, upload, injectDebugIds }; } diff --git a/packages/nextjs/src/config/types.ts b/packages/nextjs/src/config/types.ts index e8d1489172ec..8dfef2efd201 100644 --- a/packages/nextjs/src/config/types.ts +++ b/packages/nextjs/src/config/types.ts @@ -467,33 +467,22 @@ type SentryBuildSourceMapsOptions = Omit< */ ignore?: string | string[]; + // TODO(v12): Remove. /** - * A glob or an array of globs that specifies which source map files should be deleted after being uploaded to Sentry. + * @deprecated Use `sourcemaps.delete` instead. `delete: true` removes all client source maps. To delete other + * files, run a script after the build. * - * When set, this overrides the default deletion behavior of `deleteSourcemapsAfterUpload`. - * - * Use this option when you need fine-grained control over which source maps are deleted. - * - * @example - * ```javascript - * withSentryConfig(nextConfig, { - * sourcemaps: { - * filesToDeleteAfterUpload: ['.next/static/**\/*.map'], - * }, - * }); - * ``` + * A glob or an array of globs that specifies the files to delete after the upload to Sentry. When set, it replaces + * the files that Sentry deletes by default. */ filesToDeleteAfterUpload?: string | string[]; + // TODO(v12): Remove. /** - * Toggle whether the client source maps within your Next.js build folder should be automatically deleted after - * being uploaded to Sentry. Server source maps are kept. - * - * When `true`, all client source maps are deleted, also those you turned on yourself (for example with - * `productionBrowserSourceMaps`) and those that were not uploaded. + * @deprecated Use `sourcemaps.delete` instead. * - * Defaults to `true` for webpack builds and for Turbopack builds in which the SDK turns on the client source maps. - * With `disable` set to `true` or `"disable-upload"`, nothing is deleted unless you set this option to `true`. + * Whether the client source maps within your Next.js build folder are deleted after the upload to Sentry. Server + * source maps are kept. `true` deletes all client source maps. */ deleteSourcemapsAfterUpload?: boolean; diff --git a/packages/nitro/src/sourceMaps.ts b/packages/nitro/src/sourceMaps.ts index 9d57495b78b2..8d84c2db9620 100644 --- a/packages/nitro/src/sourceMaps.ts +++ b/packages/nitro/src/sourceMaps.ts @@ -107,6 +107,7 @@ export function getPluginOptions( outputDir?: string, ): BundlerPluginOptions { const deleteOption = options?.sourcemaps?.delete; + // oxlint-disable-next-line typescript/no-deprecated const userFilesToDelete = options?.sourcemaps?.filesToDeleteAfterUpload; // `sourcemaps.delete` replaces the rule that only the source maps Sentry enabled are deleted. const defaultFilesToDelete = @@ -135,6 +136,7 @@ export function getPluginOptions( silent: options?.silent ?? false, errorHandler: options?.errorHandler, sourcemaps: { + // oxlint-disable-next-line typescript/no-deprecated disable: options?.sourcemaps?.disable, upload: options?.sourcemaps?.upload, injectDebugIds: options?.sourcemaps?.injectDebugIds, diff --git a/packages/nuxt/src/vite/sourceMapDeletion.ts b/packages/nuxt/src/vite/sourceMapDeletion.ts index 92cf4b67a6ca..a39269e358ed 100644 --- a/packages/nuxt/src/vite/sourceMapDeletion.ts +++ b/packages/nuxt/src/vite/sourceMapDeletion.ts @@ -126,9 +126,11 @@ export function withClientSourceMapDeletion( ...options, sourcemaps: { ...options.sourcemaps, + // oxlint-disable-next-line typescript/no-deprecated filesToDeleteAfterUpload: undefined, sdkFilesToDeleteAfterUpload: undefined, delete: undefined, + // oxlint-disable-next-line typescript/no-deprecated deleteSourcemapsAfterUpload: undefined, // The Vite plugin reads this in its `config` hook, after `modules:done` set the fallback. sdkDeleteSourceMaps: environment => { @@ -139,6 +141,7 @@ export function withClientSourceMapDeletion( if (userSourcemaps?.delete !== undefined) { return userSourcemaps.delete; } + // oxlint-disable-next-line typescript/no-deprecated return fallback[side] && userSourcemaps?.filesToDeleteAfterUpload === undefined ? true : undefined; }, }, @@ -158,9 +161,11 @@ export function withoutSourceMapDeletion(options: InternalOptions): InternalOpti ...options, sourcemaps: { ...options.sourcemaps, + // oxlint-disable-next-line typescript/no-deprecated filesToDeleteAfterUpload: undefined, sdkFilesToDeleteAfterUpload: undefined, delete: undefined, + // oxlint-disable-next-line typescript/no-deprecated deleteSourcemapsAfterUpload: undefined, sdkDeleteSourceMaps: false, }, diff --git a/packages/nuxt/src/vite/sourceMaps.ts b/packages/nuxt/src/vite/sourceMaps.ts index 619b25910c09..cd6a9155d5be 100644 --- a/packages/nuxt/src/vite/sourceMaps.ts +++ b/packages/nuxt/src/vite/sourceMaps.ts @@ -239,6 +239,7 @@ export function getPluginOptions( }, sourcemaps: { + // oxlint-disable-next-line typescript/no-deprecated disable: moduleOptions.sourcemaps?.disable, upload: sourcemapsOptions.upload, injectDebugIds: sourcemapsOptions.injectDebugIds, @@ -275,6 +276,7 @@ function resolveFilesToDeleteAfterUpload( const fallbackFilesToDelete = getFallbackFilesToDelete(shouldDeleteFilesFallback, deleteOption); const shouldDeleteFilesAfterUpload = fallbackFilesToDelete.length > 0; + // oxlint-disable-next-line typescript/no-deprecated const filesToDeleteAfterUpload = moduleOptions.sourcemaps?.filesToDeleteAfterUpload; if (deleteOption === true) { diff --git a/packages/react-router/src/vite/buildEnd/handleOnBuildEnd.ts b/packages/react-router/src/vite/buildEnd/handleOnBuildEnd.ts index 265da9c130c3..c11b41d22545 100644 --- a/packages/react-router/src/vite/buildEnd/handleOnBuildEnd.ts +++ b/packages/react-router/src/vite/buildEnd/handleOnBuildEnd.ts @@ -47,6 +47,7 @@ export const sentryOnBuildEnd: BuildEndHook = async ({ reactRouterConfig, viteCo project, release, sentryUrl, + // oxlint-disable-next-line typescript/no-deprecated sourcemaps = { disable: false }, debug = false, }: Omit & @@ -123,6 +124,7 @@ export const sentryOnBuildEnd: BuildEndHook = async ({ reactRouterConfig, viteCo return; } + // oxlint-disable-next-line typescript/no-deprecated const userFilesToDeleteAfterUpload = await sourcemaps?.filesToDeleteAfterUpload; const defaultFilesToDelete = [`${toGlobPath(reactRouterConfig.buildDirectory)}/**/*.map`]; let updatedFilesToDeleteAfterUpload: string | string[] | undefined; diff --git a/packages/react-router/src/vite/makeCustomSentryVitePlugins.ts b/packages/react-router/src/vite/makeCustomSentryVitePlugins.ts index 0522109ed041..4899ff3fe37a 100644 --- a/packages/react-router/src/vite/makeCustomSentryVitePlugins.ts +++ b/packages/react-router/src/vite/makeCustomSentryVitePlugins.ts @@ -60,6 +60,7 @@ export async function makeCustomSentryVitePlugins(options: SentryReactRouterBuil injectDebugIds: false, // The plugin deletes these in a `finally` block that runs regardless of the options above, which // would remove the maps before `sentryOnBuildEnd` gets to upload them. Deletion happens there instead. + // oxlint-disable-next-line typescript/no-deprecated filesToDeleteAfterUpload: undefined, }, }) as Plugin[]; diff --git a/packages/remix/src/vite/index.ts b/packages/remix/src/vite/index.ts index a32c17561b6c..4cc4ca02bb22 100644 --- a/packages/remix/src/vite/index.ts +++ b/packages/remix/src/vite/index.ts @@ -1,4 +1,4 @@ -import { resolveSourceMapsFeatures } from '@sentry/core'; +import { resolveSourceMapsFeatures, warnOnConflictingSourceMapOptions } from '@sentry/core'; import type { Plugin } from 'vite'; import { makeOrchestrionPlugin } from './orchestrionPlugin'; import { makeReleasePlugin } from './releasePlugin'; @@ -46,6 +46,9 @@ export function sentryRemixVitePlugin(options: SentryRemixVitePluginOptions = {} return plugins; } + // The bundler plugin does not get `sourcemaps.deleteSourcemapsAfterUpload`. + warnOnConflictingSourceMapOptions(options.sourcemaps); + const sourceMapState: SourceMapState = { sdkEnabledSourceMaps: false }; // `'disable-upload'` still generates them - debug IDs are injected and the user uploads by hand. diff --git a/packages/remix/src/vite/sourceMaps.ts b/packages/remix/src/vite/sourceMaps.ts index cd3cafc76f6e..3720af38eb67 100644 --- a/packages/remix/src/vite/sourceMaps.ts +++ b/packages/remix/src/vite/sourceMaps.ts @@ -48,6 +48,7 @@ export function makeAddSentryVitePlugin( silent, sourcemaps: { assets: sourcemaps?.assets, + // oxlint-disable-next-line typescript/no-deprecated disable: sourcemaps?.disable, upload: sourcemaps?.upload, injectDebugIds: sourcemaps?.injectDebugIds, @@ -55,12 +56,14 @@ export function makeAddSentryVitePlugin( ignore: sourcemaps?.ignore, rewriteSources: sourcemaps?.rewriteSources, resolveSourceMap: sourcemaps?.resolveSourceMap, + // oxlint-disable-next-line typescript/no-deprecated filesToDeleteAfterUpload: sourcemaps?.filesToDeleteAfterUpload, // Called when the bundler plugin decides, after `makeEnableSourceMapsPlugin` ran. // Without an upload the user uploads the maps by hand, so they stay. // The SDK never read the user's `deleteSourcemapsAfterUpload`. `delete` replaces it. // A user's own `filesToDeleteAfterUpload` replaces the SDK's deletion. sdkDeleteSourceMaps: + // oxlint-disable-next-line typescript/no-deprecated sourcemaps?.delete === undefined && sourcemaps?.filesToDeleteAfterUpload === undefined ? () => (state.sdkEnabledSourceMaps && resolveSourceMapsFeatures(sourcemaps).upload ? true : undefined) : undefined, diff --git a/packages/solidstart/src/vite/release.ts b/packages/solidstart/src/vite/release.ts index 4fdd04975686..1c7f3dd0a152 100644 --- a/packages/solidstart/src/vite/release.ts +++ b/packages/solidstart/src/vite/release.ts @@ -11,6 +11,7 @@ import type { BuildTimeOptionsBase } from '@sentry/core'; export function getRuntimeRelease(options: Pick): string | undefined { if ( process.env.NODE_ENV === 'development' || + // oxlint-disable-next-line typescript/no-deprecated options.sourcemaps?.disable === true || options.release?.inject === false ) { diff --git a/packages/solidstart/src/vite/sentrySolidStartVite.ts b/packages/solidstart/src/vite/sentrySolidStartVite.ts index 5f0d26b6ddb8..26aada3e3da9 100644 --- a/packages/solidstart/src/vite/sentrySolidStartVite.ts +++ b/packages/solidstart/src/vite/sentrySolidStartVite.ts @@ -1,4 +1,9 @@ -import { resolveSourceMapsFeatures, stringifyForCodeInjection, warnOnRemovedBuildOptions } from '@sentry/core'; +import { + resolveSourceMapsFeatures, + stringifyForCodeInjection, + warnOnConflictingSourceMapOptions, + warnOnRemovedBuildOptions, +} from '@sentry/core'; import type { Plugin, UserConfig } from 'vite'; import { makeBuildInstrumentationFilePlugin } from './buildInstrumentationFile'; import type { SourceMapState } from './sourceMaps'; @@ -14,6 +19,8 @@ export const sentrySolidStartVite = ( runtimeRelease?: string, ): Plugin[] => { warnOnRemovedBuildOptions(options, ['unstable_sentryVitePluginOptions']); + // The Sentry plugin is not added with `sourcemaps.disable: true`. + warnOnConflictingSourceMapOptions(options.sourcemaps); const sentryPlugins: Plugin[] = [ { diff --git a/packages/solidstart/src/vite/sourceMaps.ts b/packages/solidstart/src/vite/sourceMaps.ts index d57460ecf249..e0a3b0ce16e5 100644 --- a/packages/solidstart/src/vite/sourceMaps.ts +++ b/packages/solidstart/src/vite/sourceMaps.ts @@ -48,12 +48,14 @@ function makeSourceMapDeletionOptions( const keepSdkEnabledSourceMaps = keepWhenUploadDisabled && !!resolveSourceMapsFeatures(sourcemaps).legacyDisable; return { + // oxlint-disable-next-line typescript/no-deprecated deleteSourcemapsAfterUpload: sourcemaps?.deleteSourcemapsAfterUpload, sdkDeleteSourceMaps: sourcemaps?.delete === undefined ? environment => sdkEnabledSourceMaps(environment) && !keepSdkEnabledSourceMaps && + // oxlint-disable-next-line typescript/no-deprecated sourcemaps?.filesToDeleteAfterUpload === undefined ? true : undefined diff --git a/packages/sveltekit/src/vite/sourceMaps.ts b/packages/sveltekit/src/vite/sourceMaps.ts index dcbef0f208ab..ed18cd66ab09 100644 --- a/packages/sveltekit/src/vite/sourceMaps.ts +++ b/packages/sveltekit/src/vite/sourceMaps.ts @@ -165,6 +165,7 @@ export async function makeCustomSentryVitePlugins( // output - see the note on the adapter output dir in `sentrySvelteKit()`. const adapterOutputDir = await getAdapterOutputDir(); + // oxlint-disable-next-line typescript/no-deprecated const originalFilesToDeleteAfterUpload = options?.sourcemaps?.filesToDeleteAfterUpload; // Without `sourcemaps.delete`, the SDK only removes the source maps it turned on itself, and a diff --git a/packages/tanstackstart-react/src/vite/sentryTanstackStart.ts b/packages/tanstackstart-react/src/vite/sentryTanstackStart.ts index 730ac94ee39f..87b30ee7983a 100644 --- a/packages/tanstackstart-react/src/vite/sentryTanstackStart.ts +++ b/packages/tanstackstart-react/src/vite/sentryTanstackStart.ts @@ -1,5 +1,5 @@ import type { BuildTimeOptionsBase, ReactComponentAnnotationOptions } from '@sentry/core'; -import { resolveSourceMapsFeatures } from '@sentry/core'; +import { resolveSourceMapsFeatures, warnOnConflictingSourceMapOptions } from '@sentry/core'; import { sentryOrchestrionPlugin } from '@sentry/server-utils/orchestrion/vite'; import type { Plugin } from 'vite'; import { makeAutoInstrumentMiddlewarePlugin } from './autoInstrumentMiddleware'; @@ -113,6 +113,9 @@ export function sentryTanstackStart(options: SentryTanstackStartOptions = {}): P return plugins; } + // The bundler plugin does not get `sourcemaps.deleteSourcemapsAfterUpload`. + warnOnConflictingSourceMapOptions(options.sourcemaps); + plugins.push(makeServerInstrumentationPlugin({ debug: options.debug, release })); // Runs the orchestrion code transform over the server bundle so instrumented DB drivers get diff --git a/packages/tanstackstart-react/src/vite/sourceMaps.ts b/packages/tanstackstart-react/src/vite/sourceMaps.ts index 821747431589..c18d77b7b660 100644 --- a/packages/tanstackstart-react/src/vite/sourceMaps.ts +++ b/packages/tanstackstart-react/src/vite/sourceMaps.ts @@ -98,6 +98,7 @@ export function makeAddSentryVitePlugin( silent, sourcemaps: { assets: sourcemaps?.assets, + // oxlint-disable-next-line typescript/no-deprecated disable: sourcemaps?.disable, upload: sourcemaps?.upload, injectDebugIds: sourcemaps?.injectDebugIds, @@ -105,11 +106,13 @@ export function makeAddSentryVitePlugin( ignore: sourcemaps?.ignore, rewriteSources: sourcemaps?.rewriteSources ?? rewriteTanstackStartSource, resolveSourceMap: sourcemaps?.resolveSourceMap, + // oxlint-disable-next-line typescript/no-deprecated filesToDeleteAfterUpload: sourcemaps?.filesToDeleteAfterUpload, // Called when the bundler plugin decides, after the SDK's enable plugins ran. // The SDK never read the user's `deleteSourcemapsAfterUpload`. `delete` replaces it. // A user's own `filesToDeleteAfterUpload` replaces the SDK's deletion. sdkDeleteSourceMaps: + // oxlint-disable-next-line typescript/no-deprecated sourcemaps?.delete === undefined && sourcemaps?.filesToDeleteAfterUpload === undefined ? environment => hasSdkEnabledSourceMaps(state, environment) || undefined : undefined, diff --git a/packages/tanstackstart-react/test/vite/sentryTanstackStart.test.ts b/packages/tanstackstart-react/test/vite/sentryTanstackStart.test.ts index f2676730f560..bed5fff45551 100644 --- a/packages/tanstackstart-react/test/vite/sentryTanstackStart.test.ts +++ b/packages/tanstackstart-react/test/vite/sentryTanstackStart.test.ts @@ -379,11 +379,11 @@ describe('sentryTanstackStart()', () => { const { sentryTanstackStart: freshSentryTanstackStart } = await import('../../src/vite/sentryTanstackStart'); const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => undefined); - freshSentryTanstackStart({ sourcemaps: { disable: true } }); + freshSentryTanstackStart({ sourcemaps: { upload: false, injectDebugIds: false } }); expect(warnSpy).not.toHaveBeenCalledWith(expect.stringContaining('`tunnelRoute` option is deprecated')); - freshSentryTanstackStart({ tunnelRoute: true, sourcemaps: { disable: true } }); - freshSentryTanstackStart({ tunnelRoute: '/monitor', sourcemaps: { disable: true } }); + freshSentryTanstackStart({ tunnelRoute: true, sourcemaps: { upload: false, injectDebugIds: false } }); + freshSentryTanstackStart({ tunnelRoute: '/monitor', sourcemaps: { upload: false, injectDebugIds: false } }); expect(warnSpy).toHaveBeenCalledOnce(); expect(warnSpy).toHaveBeenCalledWith( From 8fc5c0e5511d962ac92f026f78aee17a1d2a74f5 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Thu, 26 Nov 2026 12:43:07 +0000 Subject: [PATCH 2/2] fix(gatsby): Pass `sourcemaps.disable` to the bundler plugin Gatsby read the option for its `devtool` decision only, so the plugin still injected debug IDs and uploaded the source maps that existed. --- packages/gatsby/gatsby-node.js | 3 +++ packages/gatsby/test/gatsby-node.test.ts | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/packages/gatsby/gatsby-node.js b/packages/gatsby/gatsby-node.js index 1aff974bedf9..e267d0871732 100644 --- a/packages/gatsby/gatsby-node.js +++ b/packages/gatsby/gatsby-node.js @@ -83,6 +83,9 @@ exports.onCreateWebpackConfig = ({ getConfig, actions, stage }, options) => { sourcemaps: { // Only include files from the build output directory assets: ['./public/**'], + // TODO(v12): Remove along with `sourcemaps.disable`. + // oxlint-disable-next-line typescript/no-deprecated + disable: options.sourcemaps?.disable, upload: options.sourcemaps?.upload, injectDebugIds: options.sourcemaps?.injectDebugIds, sdkDeleteSourceMaps: deleteSourcemapsAfterUpload, diff --git a/packages/gatsby/test/gatsby-node.test.ts b/packages/gatsby/test/gatsby-node.test.ts index 4d96f48115ba..cacd11328eec 100644 --- a/packages/gatsby/test/gatsby-node.test.ts +++ b/packages/gatsby/test/gatsby-node.test.ts @@ -346,6 +346,21 @@ describe('onCreateWebpackConfig', () => { warnSpy.mockRestore(); }); + it.each([true, 'disable-upload'] as const)('passes `sourcemaps.disable: %j` to the plugin', disable => { + const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}); + const getConfig = vi.fn().mockReturnValue({ devtool: 'source-map' }); + + onCreateWebpackConfig( + { actions: { setWebpackConfig: vi.fn() }, getConfig, stage: 'build-javascript' }, + { sourcemaps: { disable } }, + ); + + expect(sentryWebpackPlugin).toHaveBeenCalledWith( + expect.objectContaining({ sourcemaps: expect.objectContaining({ disable }) }), + ); + warnSpy.mockRestore(); + }); + it.each([ [{ delete: false }, { deleteSourcemapsAfterUpload: true }, undefined], [{ delete: true }, { deleteSourcemapsAfterUpload: false }, true],