From a5c24d9479b758565783edd44c9ca240c694ee5a Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 24 Nov 2026 23:16:31 +0000 Subject: [PATCH 1/6] docs(js): Document automatic source maps and the new sourcemaps options --- .../common/best-practices/micro-frontends.mdx | 1 - .../sourcemaps/uploading/angular-nx.mdx | 29 ++--- .../sourcemaps/uploading/angular-webpack.mdx | 16 +-- .../uploading/bundler-plugin-options.mdx | 104 ++++++++++++++++-- .../common/sourcemaps/uploading/esbuild.mdx | 22 +--- .../common/sourcemaps/uploading/rollup.mdx | 24 +--- .../common/sourcemaps/uploading/vite.mdx | 26 +---- .../common/sourcemaps/uploading/webpack.mdx | 61 ++++------ .../common/troubleshooting/index.mdx | 4 +- .../cordova/sourcemaps/uploading/esbuild.mdx | 15 +-- .../cordova/sourcemaps/uploading/rollup.mdx | 16 +-- .../cordova/sourcemaps/uploading/vite.mdx | 17 +-- .../cordova/sourcemaps/uploading/webpack.mdx | 15 +-- .../guides/nextjs/capturing-errors/index.mdx | 2 +- .../nextjs/configuration/build/index.mdx | 88 +++++++++++---- .../nextjs/manual-setup/webpack-setup.mdx | 2 + .../guides/react-router/hydrogen.mdx | 2 + .../sveltekit/configuration/build/index.mdx | 58 +++++++++- .../features/sentryTanstackStart.mdx | 2 +- .../enable-readable-stack-traces.mdx | 5 +- .../bundler-plugin-source-maps/esbuild.mdx | 9 ++ .../bundler-plugin-source-maps/rollup.mdx | 9 ++ includes/bundler-plugin-source-maps/vite.mdx | 9 ++ .../bundler-plugin-source-maps/webpack.mdx | 9 ++ includes/react-router/source-maps-upload.mdx | 14 +++ .../javascript.nuxt.mdx | 4 + .../javascript.remix.mdx | 2 +- .../javascript.nuxt.mdx | 4 + .../javascript.remix.mdx | 2 +- .../sourcemaps/overview/javascript.astro.mdx | 21 +++- .../sourcemaps/overview/javascript.nextjs.mdx | 4 +- .../sourcemaps/overview/javascript.nitro.mdx | 21 ++-- .../sourcemaps/overview/javascript.nuxt.mdx | 16 +-- .../sourcemaps/overview/javascript.remix.mdx | 18 ++- .../overview/javascript.solidstart.mdx | 14 ++- .../sourcemaps/overview/javascript.svelte.mdx | 17 +-- .../overview/javascript.sveltekit.mdx | 9 +- .../javascript.tanstackstart-react.mdx | 19 ++-- .../sourcemaps/overview/javascript.vue.mdx | 17 +-- .../sourcemaps/primer/javascript.nuxt.mdx | 20 ++-- .../upload/primer/javascript.sveltekit.mdx | 4 + 41 files changed, 426 insertions(+), 325 deletions(-) create mode 100644 includes/bundler-plugin-source-maps/esbuild.mdx create mode 100644 includes/bundler-plugin-source-maps/rollup.mdx create mode 100644 includes/bundler-plugin-source-maps/vite.mdx create mode 100644 includes/bundler-plugin-source-maps/webpack.mdx diff --git a/docs/platforms/javascript/common/best-practices/micro-frontends.mdx b/docs/platforms/javascript/common/best-practices/micro-frontends.mdx index 36a8eecc493df..0766ba74d11a4 100644 --- a/docs/platforms/javascript/common/best-practices/micro-frontends.mdx +++ b/docs/platforms/javascript/common/best-practices/micro-frontends.mdx @@ -83,7 +83,6 @@ below is for Webpack, but this is also supported in Vite, Rollup, and esbuild. const { sentryWebpackPlugin } = require("@sentry/bundler-plugins/webpack"); module.exports = { - devtool: "hidden-source-map", // Source map generation must be turned on ("hidden-source-map", "source-map", etc.) plugins: [ sentryWebpackPlugin({ moduleMetadata: ({ release }) => ({ dsn: "__MODULE_DSN__", release }), diff --git a/docs/platforms/javascript/common/sourcemaps/uploading/angular-nx.mdx b/docs/platforms/javascript/common/sourcemaps/uploading/angular-nx.mdx index 3b190aed99d08..12493e9510d05 100644 --- a/docs/platforms/javascript/common/sourcemaps/uploading/angular-nx.mdx +++ b/docs/platforms/javascript/common/sourcemaps/uploading/angular-nx.mdx @@ -90,30 +90,20 @@ const { sentryWebpackPlugin } = require("@sentry/bundler-plugins/webpack"); module.exports = { // ... other config above ... - devtool: "hidden-source-map", // Source map generation must be turned on ("hidden-source-map", "source-map", etc.) plugins: [ sentryWebpackPlugin({ org: "___ORG_SLUG___", project: "___PROJECT_SLUG___", authToken: process.env.SENTRY_AUTH_TOKEN, - sourcemaps: { - // As you're enabling client source maps, you probably want to delete them after they're uploaded to Sentry. - // Set the appropriate glob pattern for your output folder - some glob examples below: - filesToDeleteAfterUpload: ["./**/*.map", ".*/**/public/**/*.map", "./dist/**/client/**/*.map"] - } + delete: true, + }, }), ], }; ``` - - Generating source maps **may expose them to the public**, potentially causing your - source code to be leaked. You can prevent this by configuring your server to - deny access to `.js.map` files, or by using Sentry Webpack Plugin's - `sourcemaps.filesToDeleteAfterUpload` - option to delete source maps after they've been uploaded to Sentry. - +Angular turns on the source maps, so the plugin keeps them in the build output by default. `sourcemaps.delete: true` removes them after the upload, so your users can't download them. With a version before `11.15.0`, remove them with `sourcemaps.filesToDeleteAfterUpload`. Learn more about configuring the plugin in our Sentry webpack plugin documentation. @@ -147,7 +137,10 @@ Then, follow the [official Nx documentation](https://nx.dev/nx-api/angular/execu "options": { "org": "___ORG_SLUG___", "project": "___PROJECT_SLUG___", - "authToken": "___SENTRY_AUTH_TOKEN___" + "authToken": "___SENTRY_AUTH_TOKEN___", + "sourcemaps": { + "delete": true + } } } ] @@ -157,13 +150,7 @@ Then, follow the [official Nx documentation](https://nx.dev/nx-api/angular/execu } ``` - - Generating source maps **may expose them to the public**, potentially causing your - source code to be leaked. You can prevent this by configuring your server to - deny access to `.js.map` files, or by using Sentry Esbuild Plugin's - `sourcemaps.filesToDeleteAfterUpload` - option to delete source maps after they've been uploaded to Sentry. - +Angular turns on the source maps, so the plugin keeps them in the build output by default. `sourcemaps.delete: true` removes them after the upload, so your users can't download them. With a version before `11.15.0`, remove them with `sourcemaps.filesToDeleteAfterUpload`. ## 3. Upload diff --git a/docs/platforms/javascript/common/sourcemaps/uploading/angular-webpack.mdx b/docs/platforms/javascript/common/sourcemaps/uploading/angular-webpack.mdx index 0d748d55e5439..3303ae9434693 100644 --- a/docs/platforms/javascript/common/sourcemaps/uploading/angular-webpack.mdx +++ b/docs/platforms/javascript/common/sourcemaps/uploading/angular-webpack.mdx @@ -102,18 +102,14 @@ const { sentryWebpackPlugin } = require("@sentry/bundler-plugins/webpack"); module.exports = { // ... other config above ... - devtool: "hidden-source-map", // Source map generation must be turned on ("hidden-source-map", "source-map", etc.) plugins: [ sentryWebpackPlugin({ org: "___ORG_SLUG___", project: "___PROJECT_SLUG___", authToken: process.env.SENTRY_AUTH_TOKEN, - sourcemaps: { - // As you're enabling client source maps, you probably want to delete them after they're uploaded to Sentry. - // Set the appropriate glob pattern for your output folder - some glob examples below: - filesToDeleteAfterUpload: ["./**/*.map", ".*/**/public/**/*.map", "./dist/**/client/**/*.map"] - } + delete: true, + }, }), ], }; @@ -136,10 +132,4 @@ We recommend running a production build to test your implementation. - - Generating source maps **may expose them to the public**, potentially causing your - source code to be leaked. You can prevent this by configuring your server to - deny access to `.js.map` files, or by using Sentry Webpack Plugin's - `sourcemaps.filesToDeleteAfterUpload` - option to delete source maps after they've been uploaded to Sentry. - +Angular turns on the source maps, so the plugin keeps them in the build output by default. `sourcemaps.delete: true` removes them after the upload, so your users can't download them. With a version before `11.15.0`, remove them with `sourcemaps.filesToDeleteAfterUpload`. diff --git a/docs/platforms/javascript/common/sourcemaps/uploading/bundler-plugin-options.mdx b/docs/platforms/javascript/common/sourcemaps/uploading/bundler-plugin-options.mdx index 631e695c64f60..5af831b67ce08 100644 --- a/docs/platforms/javascript/common/sourcemaps/uploading/bundler-plugin-options.mdx +++ b/docs/platforms/javascript/common/sourcemaps/uploading/bundler-plugin-options.mdx @@ -48,9 +48,6 @@ sentryVitePlugin({ org: "___ORG_SLUG___", project: "___PROJECT_SLUG___", authToken: process.env.SENTRY_AUTH_TOKEN, - sourcemaps: { - filesToDeleteAfterUpload: ["./dist/**/*.map"], - }, }); ``` @@ -157,6 +154,62 @@ Completely disables all functionality of the plugin. Options related to source maps upload and processing. +When your bundler's source map setting isn't set, the plugin turns on hidden source maps, uploads them, and removes them from the build output. It does this only when it can upload, that is, when it has an auth token, an organization, and a project. Source maps that you turn on yourself are uploaded and stay in the build output. + + + +Whether the plugin uploads source maps to Sentry. + +With `false`, the plugin uploads nothing, but it still injects debug IDs: the bundles get the debug ID snippet and a `//# debugId=` comment, and the emitted source maps get the matching `debug_id` field. This happens inside the bundler's build pipeline, so hashes computed by later build steps (for example, for subresource integrity) include the debug IDs. + +Use this to upload the source maps yourself later, for example with `sentry-cli sourcemaps upload`. The files already have their debug IDs, so you don't need an `inject` step. + +With `false`, the plugin turns on source maps only when `sourcemaps.delete` is `false`. + +```javascript +sentryVitePlugin({ + sourcemaps: { + // Upload only in CI + upload: process.env.CI === "true", + }, +}); +``` + + + + + +Whether the plugin injects debug IDs into the bundles and their source maps. + +With `false`, the plugin adds no debug IDs and uploads no source maps, because the upload matches files by debug ID. Use this when another tool injects the debug IDs and uploads the source maps, for example the Sentry CLI. + + + + + +Whether the plugin removes source maps from the build output. + +- Not set: the plugin removes the source maps it turned on itself, that is, when your bundler's source map setting wasn't set. Source maps that you turned on stay. +- `true`: the plugin removes all source maps of the build, also the ones you turned on, and also the ones of files that `sourcemaps.assets` or `sourcemaps.ignore` keep out of the upload. The plugin switches visible source maps to hidden ones, so that no `sourceMappingURL` comment points to a removed file. +- `false`: the plugin removes no source maps. When your bundler's source map setting isn't set, the plugin turns on hidden source maps, and they stay in the build output. + +`true` and `false` don't depend on an upload. They also apply when the upload is turned off, when it can't run (for example, without an auth token), and when it fails. + +With Rollup, Vite, and webpack, the plugin never writes the removed source maps to the output directory. With esbuild, it deletes them after the build. + +To keep the source maps for a manual upload later, set `upload: false` and `delete: false`: + +```javascript +sentryVitePlugin({ + sourcemaps: { + upload: false, + delete: false, + }, +}); +``` + + + A glob or an array of globs that specify the build artifacts and source maps that will be uploaded to Sentry. @@ -207,7 +260,9 @@ Use the `debug` option to print information about source map resolution. A glob, an array of globs or a promise resolving a glob or 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). +To remove source maps, use [`sourcemaps.delete`](#sourcemaps.delete). It removes the source maps the build writes, while globs can miss source maps or match files that you want to keep. The plugin deletes the files that `filesToDeleteAfterUpload` matches also when `sourcemaps.delete` is `false`. + +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. The globbing patterns must follow the implementation of the [`glob`](https://www.npmjs.com/package/glob#glob-primer) package. @@ -215,13 +270,30 @@ Use the `debug` option to print information about which files end up being delet + + +Use [`sourcemaps.delete`](#sourcemaps.delete) instead. When you set both, the plugin ignores `deleteSourcemapsAfterUpload`. + +Whether the plugin removes source maps from the build output after the upload. When not set, the plugin removes only the source maps it turned on itself. `true` also removes the source maps you turned on. `false` keeps all source maps. + +Unlike `sourcemaps.delete`, this option depends on the upload. When you turn off the upload, `true` keeps the source maps you turned on, and `false` turns on no source maps. + + + -If this flag is `true`, any functionality related to source maps will be disabled. +Use [`sourcemaps.upload`](#sourcemaps.upload) and [`sourcemaps.injectDebugIds`](#sourcemaps.injectDebugIds) instead: + +| `sourcemaps.disable` | Replacement | +| -------------------- | ---------------------------------- | +| `"disable-upload"` | `sourcemaps.upload: false` | +| `true` | `sourcemaps.injectDebugIds: false` | -If set to `"disable-upload"`, the plugin will not upload source maps to Sentry, but will still inject debug IDs into the build artifacts: the bundles receive the runtime debug ID snippet and a `//# debugId=` comment, and the emitted source maps receive the matching `debug_id` field. This happens inside the bundler's build pipeline, so hashes computed by later build steps (for example, for subresource integrity) include the debug IDs. +When you set `upload` or `injectDebugIds`, the plugin ignores `disable`. + +If this flag is `true`, any functionality related to source maps will be disabled. -This is useful if you want to manually upload source maps to Sentry at a later point in time, for example with `sentry-cli sourcemaps upload`. The artifacts already carry their debug IDs, so no `inject` step is needed. +If set to `"disable-upload"`, the plugin will not upload source maps to Sentry, but will still inject debug IDs into the build artifacts, like `sourcemaps.upload: false`. @@ -241,7 +313,7 @@ If no `name` is provided and the plugin can't automatically detect one, no relea - + Whether the plugin should inject release information into the build for the SDK to pick it up when sending events. (recommended) @@ -249,7 +321,21 @@ Whether the plugin should inject release information into the build for the SDK The plugin injects the release into the chunks that load at startup. The release name usually changes on every commit, so these chunks get new content hashes, and new file names, on every release, even when their code didn't change. The chunks that import them get new file names too, so returning visitors download all of them again instead of using their browser cache. -To keep these file names stable, turn off injection and pass the release to `Sentry.init` at runtime, from a value that isn't part of your bundled code, for example from your HTML page: +To keep these file names stable, set `inject: "html"`. The plugin then adds the release to the `` of each emitted HTML page in an inline `