diff --git a/MIGRATION.md b/MIGRATION.md index 85a5c6d6073c..46a56c24321f 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -1482,7 +1482,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: { injectDebugIds: false } })`. ### React: Simpler React Router setup via `@sentry/react/react-router` @@ -1815,7 +1815,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: { injectDebugIds: false }`. ### Browser and Node profiling @@ -1922,7 +1922,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: { injectDebugIds: false }` instead). ### `@sentry/nuxt` @@ -1938,7 +1938,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: { 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 +2011,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: { 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 +2091,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: { 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 +2114,7 @@ export default defineConfig( // after telemetry: false, sourcemaps: { - disable: false, - filesToDeleteAfterUpload: ['./dist/**/*.map'], + delete: true, }, }, ), @@ -2392,6 +2392,31 @@ The main entry re-exported the build plugin statically, which pulled the whole b ); ``` +## 7. Deprecations in 11.x + +### `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: { injectDebugIds: false }` | +| `sourcemaps.deleteSourcemapsAfterUpload` | `sourcemaps.delete` | +| `sourcemaps.filesToDeleteAfterUpload` | `sourcemaps.delete`, or a script that runs after the build | +| `deleteSourcemapsAfterUpload` (Gatsby plugin option) | `sourcemaps.delete` | + +The [bundler plugin options](https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/bundler-plugin-options/#source-maps-options) in the docs describe what `upload`, `injectDebugIds` and `delete` do. + +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: { injectDebugIds: false }, +release: { inject: false, create: false, finalize: false, setCommits: false, deploy: false }, +``` + ## No Version Support Timeline Version support timelines are stressful for everybody using the SDK, so we won't be defining one. 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..89c4dac23935 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 `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..e5264f8f19fa 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 `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 af86f0fd9d98..3e7d050dd9ff 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. @@ -45,6 +45,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.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..20ec40314752 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\.injectDebugIds: false` instead of `true`/], + [{ 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..e267d0871732 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 ( @@ -62,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 ca7d37dae041..cacd11328eec 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,68 @@ 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(); + }); + + 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(); }); 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 8b5b603ab8ec..95ec39bfed14 100644 --- a/packages/nextjs/src/config/sourceMapOptions.ts +++ b/packages/nextjs/src/config/sourceMapOptions.ts @@ -41,6 +41,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) ); } @@ -75,6 +76,8 @@ export function getSourceMapFeatureOptions( return { upload: false, injectDebugIds: resolveSourceMapsFeatures(userSourcemaps).injectDebugIds }; } + // 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 cae6b68a2399..735fef620c00 100644 --- a/packages/nextjs/src/config/types.ts +++ b/packages/nextjs/src/config/types.ts @@ -482,33 +482,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 697510a08927..ca0f0ec1ef99 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 ef66f1202d83..1282cc3303fa 100644 --- a/packages/nuxt/src/vite/sourceMapDeletion.ts +++ b/packages/nuxt/src/vite/sourceMapDeletion.ts @@ -124,9 +124,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 => { @@ -137,6 +139,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; }, }, @@ -156,9 +159,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 9d12da33dbdf..d43a730ed356 100644 --- a/packages/nuxt/src/vite/sourceMaps.ts +++ b/packages/nuxt/src/vite/sourceMaps.ts @@ -238,6 +238,7 @@ export function getPluginOptions( }, sourcemaps: { + // oxlint-disable-next-line typescript/no-deprecated disable: moduleOptions.sourcemaps?.disable, upload: sourcemapsOptions.upload, injectDebugIds: sourcemapsOptions.injectDebugIds, @@ -274,6 +275,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 6cde2ccbcb94..5d08702ec3c7 100644 --- a/packages/react-router/src/vite/buildEnd/handleOnBuildEnd.ts +++ b/packages/react-router/src/vite/buildEnd/handleOnBuildEnd.ts @@ -46,6 +46,7 @@ export const sentryOnBuildEnd: BuildEndHook = async ({ reactRouterConfig, viteCo project, release, sentryUrl, + // oxlint-disable-next-line typescript/no-deprecated sourcemaps = { disable: false }, debug = false, }: Omit & @@ -119,6 +120,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 b5422e327472..0096e10cdc74 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..beaeca4b99b0 100644 --- a/packages/solidstart/src/vite/release.ts +++ b/packages/solidstart/src/vite/release.ts @@ -1,6 +1,6 @@ import { fileURLToPath } from 'node:url'; import { resolveReleaseName } from '@sentry/bundler-plugins/core'; -import type { BuildTimeOptionsBase } from '@sentry/core'; +import { type BuildTimeOptionsBase, resolveSourceMapsFeatures } from '@sentry/core'; /** * The release that the server hands to the browser SDK through the page, instead of the build plugin writing it into @@ -11,7 +11,7 @@ import type { BuildTimeOptionsBase } from '@sentry/core'; export function getRuntimeRelease(options: Pick): string | undefined { if ( process.env.NODE_ENV === 'development' || - options.sourcemaps?.disable === true || + resolveSourceMapsFeatures(options.sourcemaps).legacyDisable === true || options.release?.inject === false ) { return undefined; 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 1861e3cea68d..232f84bf4d97 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/solidstart/test/vite/release.test.ts b/packages/solidstart/test/vite/release.test.ts index 5c29c9acea9b..ce777c02ffe3 100644 --- a/packages/solidstart/test/vite/release.test.ts +++ b/packages/solidstart/test/vite/release.test.ts @@ -29,6 +29,14 @@ describe('getRuntimeRelease', () => { expect(getRuntimeRelease(options)).toBeUndefined(); }); + it.each([ + { disable: true, upload: false }, + { disable: true, injectDebugIds: true }, + { disable: 'disable-upload' }, + ] as const)('resolves the release with %j, which keeps the build plugin', sourcemaps => { + expect(getRuntimeRelease({ sourcemaps })).toBe('detected-release'); + }); + it('returns nothing in development, where the build plugin does not run', () => { process.env.NODE_ENV = 'development'; diff --git a/packages/sveltekit/src/vite/sourceMaps.ts b/packages/sveltekit/src/vite/sourceMaps.ts index 288af99a9b21..2b796ca451b6 100644 --- a/packages/sveltekit/src/vite/sourceMaps.ts +++ b/packages/sveltekit/src/vite/sourceMaps.ts @@ -158,6 +158,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 ed34d625b5bc..c618069e6d15 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'; @@ -112,6 +112,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 8fab3832d724..19285c37e5e7 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(