Title: Bundler plugins should handle source maps without any user configuration · Issue #25609 · getsentry/sentry-javascript · GitHub
Open Graph Title: Bundler plugins should handle source maps without any user configuration · Issue #25609 · getsentry/sentry-javascript
X Title: Bundler plugins should handle source maps without any user configuration · Issue #25609 · getsentry/sentry-javascript
Description: Problem Setting up source map upload with the Sentry bundler plugins needs too much configuration, and most of it is about source maps that users do not want to ship. The current Vite docs example: import { defineConfig } from "vite"; im...
Open Graph Description: Problem Setting up source map upload with the Sentry bundler plugins needs too much configuration, and most of it is about source maps that users do not want to ship. The current Vite docs example:...
X Description: Problem Setting up source map upload with the Sentry bundler plugins needs too much configuration, and most of it is about source maps that users do not want to ship. The current Vite docs example:...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/25609
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bundler plugins should handle source maps without any user configuration","articleBody":"## Problem\n\nSetting up source map upload with the Sentry bundler plugins needs too much configuration, and most of it is about source maps that users do not want to ship. The current Vite docs example:\n\n```ts\nimport { defineConfig } from \"vite\";\nimport { sentryVitePlugin } from \"@sentry/vite-plugin\";\n\nexport default defineConfig({\n build: {\n sourcemap: \"hidden\", // Source map generation must be turned on (\"hidden\", true, etc.)\n },\n plugins: [\n sentryVitePlugin({\n org: \"example-org\",\n project: \"example-project\",\n authToken: process.env.SENTRY_AUTH_TOKEN,\n sourcemaps: {\n // As you're enabling client source maps, you probably want to delete them after they're uploaded to Sentry.\n // Set the appropriate glob pattern for your output folder - some glob examples below:\n filesToDeleteAfterUpload: [\"./**/*.map\", \".*/**/public/**/*.map\", \"./dist/**/client/**/*.map\"],\n },\n }),\n ],\n});\n```\n\nUsers have to know three things: that source maps must be turned on, that `hidden` is the right mode, and which glob matches their output folder. Wrong globs either leave maps in production or delete files that were never uploaded. \n\nThe plugins upload from disk after the bundler has written its output, then delete files that match the globs. The bundlers all expose the generated map to plugins before the write (`generateBundle` in Rollup, Rolldown and Vite, `processAssets` in webpack and Rspack), so the plugin does not need the map on disk at all.\n\n## Proposal\n\nAdd one option, `sourcemaps.deleteSourcemapsAfterUpload?: boolean`, default `undefined` (\"auto\"), and make the plugin handle the source map setting itself:\n\n| Bundler source map setting | `deleteSourcemapsAfterUpload` | Behaviour |\n|---|---|---|\n| unset | auto or `true` | Plugin turns on hidden maps, copies each chunk and its map from the bundler's pre-write hook into the temp upload folder, removes the `.map` asset so it is never written, uploads the temp folder. |\n| unset | `false` | Unchanged: setting untouched, no maps generated. |\n| `hidden` or `true` | auto | Unchanged: upload from disk, maps stay in the output, `filesToDeleteAfterUpload` still works. |\n| `hidden` or `true` | `true` | `true` is coerced to `hidden`. Maps are removed before write. |\n| `inline` | any | Warn. Nothing to delete. |\n| `false` | any | Warn that source maps are off. |\n\nRules:\n\n- The plugin only turns maps on when it will also remove them. `false` never adds maps to anyone's output.\n- The plugin only turns maps on when an upload can run (not `NODE_ENV=development`, `sourcemaps.disable` unset, auth token, org and project present). Builds without credentials behave as today.\n- For Rollup, Rolldown, Vite, webpack and Rspack the `.map` file is never written to the output directory. For esbuild, which has no pre-write hook, the plugin deletes the exact `.map` paths from esbuild's metafile after a successful upload.\n- Existing `filesToDeleteAfterUpload` globs keep working and are still useful for files the bundler did not produce.\n\n## What the docs become\n\n```ts\nimport { defineConfig } from \"vite\";\nimport { sentryVitePlugin } from \"@sentry/vite-plugin\";\n\nexport default defineConfig({\n plugins: [\n sentryVitePlugin({\n org: \"example-org\",\n project: \"example-project\",\n authToken: process.env.SENTRY_AUTH_TOKEN,\n }),\n ],\n});\n```\n\nNo `build.sourcemap` line, no globs, no comment explaining either. The same applies to the Rollup, webpack, Rspack and esbuild pages. The \"delete source maps after upload\" docs section shrinks to one sentence: maps are uploaded and not shipped by default; set `sourcemaps.deleteSourcemapsAfterUpload: false` to keep them.\n\n## Backwards compatibility\n\n- Anyone who set `hidden` or `true` today sees no change.\n- Anyone with `sourcemap` unset and credentials configured gets maps uploaded where they got a \"no source maps found\" warning before. Their emitted JavaScript does not change and no `.map` file appears in their output.\n- The framework SDKs (Next.js, Nuxt, SvelteKit, Astro, Remix, SolidStart, TanStack Start, Gatsby) pass `deleteSourcemapsAfterUpload: false` in the first PR so their existing behaviour is untouched. Each SDK can then drop its own hidden-map and glob logic in a follow-up PR. Nitro, React Router and Next.js Turbopack upload outside the bundler and keep their current approach.\n\n## Implementation notes\n\n- The upload still goes through the Sentry CLI, which takes a directory, so the temp folder stays. Only the source of the bytes changes, from the output directory to the bundler's hook payload. Memory use does not grow because the bundler already holds every chunk and map for the hook.\n- Rollup and Rolldown: an `outputOptions` hook sets `sourcemap: 'hidden'` when unset; a second plugin object with `generateBundle` at `order: 'post'` stages the chunk and map and deletes the `.map` asset. Rolldown syncs asset deletion back to Rust.\n- Vite: a `config` hook sets `build.sourcemap: 'hidden'` when unset; the existing `enforce: 'post'` plugin does the staging after `vite:build-import-analysis` has rewritten the maps.\n- webpack and Rspack: `apply()` sets `devtool: 'hidden-source-map'` when unset; `processAssets` at `PROCESS_ASSETS_STAGE_REPORT + 1` stages the asset and its `related.sourceMap` and calls `compilation.deleteAsset`. Content hashes are unaffected because they are final by then.\n- Rollup 4.64.8 now includes the `sourceMappingURL` comment in chunk hashes, so the plugin must use the `hidden` mode rather than strip the comment itself.\n- Upstream, a native \"generate but do not emit\" source map mode would remove the need to force `hidden`. Rolldown, webpack and Rspack look receptive and Next.js has an open request for a hidden mode in Turbopack (vercel/next.js#84095). That is separate work and this change does not depend on it.","author":{"url":"https://github.com/timfish","@type":"Person","name":"timfish"},"datePublished":"2026-10-21T11:12:12Z","url":"https://github.com/getsentry/sentry-javascript/issues/25609"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6e2c7cbc-3874-fa75-9556-545b137ba8a0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EC70:1F16DD:1ADF1:23F18:6B043008 |
| html-safe-nonce | 5a9c8a675960063e139637fe5a089f21c454047d726847a38246ec0d2433257c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQzcwOjFGMTZERDoxQURGMToyM0YxODo2QjA0MzAwOCIsInZpc2l0b3JfaWQiOiI4NDkzMzg3MTM0ODkwNDIyMjgwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d8b0ff939f1ed2f0df9f1daa94f5a1ae2bbebd623ab070ed91ac5dd0628f036a |
| hovercard-subject-tag | issue:5959372655 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/25609/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a1c745342cccc91d882945575dfb287d07884fbecafac417c52c55fe552457a7/getsentry/sentry-javascript/issues/25609 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a1c745342cccc91d882945575dfb287d07884fbecafac417c52c55fe552457a7/getsentry/sentry-javascript/issues/25609 |
| og:image:alt | Problem Setting up source map upload with the Sentry bundler plugins needs too much configuration, and most of it is about source maps that users do not want to ship. The current Vite docs example:... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | timfish |
| hostname | github.com |
| expected-hostname | github.com |
| None | b7a1d2b9101496921b08579fbee988d014345aef2f5bd660d1f8c7332d81560e |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c3dd496c3da6ea6b77e69c09279d2b81604654f1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width