Bundler plugins should handle source maps without any user configuration
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- node.js, rollup, typescript, vite, webpack
- Ambito
- build-system, devtools
Direzione di ricerca
Start by reading the bundler plugin hooks named in the issue: generateBundle for Rollup, Rolldown and Vite, and processAssets for webpack and Rspack; check esbuild's metafile handling separately. Trace how each plugin currently stages and uploads source maps, then compare behavior across the listed bundlers and credential conditions. Done means maps are uploaded without user configuration and are not emitted by default, while the documented opt-out and existing glob behavior remain intact.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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";
import { sentryVitePlugin } from "@sentry/vite-plugin";
export default defineConfig({
build: {
sourcemap: "hidden", // Source map generation must be turned on ("hidden", true, etc.)
},
plugins: [
sentryVitePlugin({
org: "example-org",
project: "example-project",
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"],
},
}),
],
});
Users 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.
The 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.
Proposal
Add one option, sourcemaps.deleteSourcemapsAfterUpload?: boolean, default undefined ("auto"), and make the plugin handle the source map setting itself:
| Bundler source map setting | deleteSourcemapsAfterUpload |
Behaviour |
|---|---|---|
| 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. |
| unset | false |
Unchanged: setting untouched, no maps generated. |
hidden or true |
auto | Unchanged: upload from disk, maps stay in the output, filesToDeleteAfterUpload still works. |
hidden or true |
true |
true is coerced to hidden. Maps are removed before write. |
inline |
any | Warn. Nothing to delete. |
false |
any | Warn that source maps are off. |
Rules:
- The plugin only turns maps on when it will also remove them.
falsenever adds maps to anyone's output. - The plugin only turns maps on when an upload can run (not
NODE_ENV=development,sourcemaps.disableunset, auth token, org and project present). Builds without credentials behave as today. - For Rollup, Rolldown, Vite, webpack and Rspack the
.mapfile is never written to the output directory. For esbuild, which has no pre-write hook, the plugin deletes the exact.mappaths from esbuild's metafile after a successful upload. - Existing
filesToDeleteAfterUploadglobs keep working and are still useful for files the bundler did not produce.
What the docs become
import { defineConfig } from "vite";
import { sentryVitePlugin } from "@sentry/vite-plugin";
export default defineConfig({
plugins: [
sentryVitePlugin({
org: "example-org",
project: "example-project",
authToken: process.env.SENTRY_AUTH_TOKEN,
}),
],
});
No 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.
Backwards compatibility
- Anyone who set
hiddenortruetoday sees no change. - Anyone with
sourcemapunset and credentials configured gets maps uploaded where they got a "no source maps found" warning before. Their emitted JavaScript does not change and no.mapfile appears in their output. - The framework SDKs (Next.js, Nuxt, SvelteKit, Astro, Remix, SolidStart, TanStack Start, Gatsby) pass
deleteSourcemapsAfterUpload: falsein 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.
Implementation notes
- 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.
- Rollup and Rolldown: an
outputOptionshook setssourcemap: 'hidden'when unset; a second plugin object withgenerateBundleatorder: 'post'stages the chunk and map and deletes the.mapasset. Rolldown syncs asset deletion back to Rust. - Vite: a
confighook setsbuild.sourcemap: 'hidden'when unset; the existingenforce: 'post'plugin does the staging aftervite:build-import-analysishas rewritten the maps. - webpack and Rspack:
apply()setsdevtool: 'hidden-source-map'when unset;processAssetsatPROCESS_ASSETS_STAGE_REPORT + 1stages the asset and itsrelated.sourceMapand callscompilation.deleteAsset. Content hashes are unaffected because they are final by then. - Rollup 4.64.8 now includes the
sourceMappingURLcomment in chunk hashes, so the plugin must use thehiddenmode rather than strip the comment itself. - 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.
- Lingua principale
- TypeScript
- Stelle
- 8.8k
- Fork
- 1.9k
- Merge medio
- 1g 8h
- PR unite (30g)
- 744
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di getsentry/sentry-javascript
-
AWS Lambda Waiting for: Product Owner
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
getsentry/sentry-javascript#26910 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Only create Nuxt database and storage spans when there is a parent spanForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. ApertaImprovement Nuxt
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
getsentry/sentry-javascript#25805 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Only create Cloudflare storage and D1 db spans when there is a parent spanForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. ApertaCloudflare Workers Improvement Spans
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
getsentry/sentry-javascript#25804 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Core Feature: Typescript Meta: Breaking
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
getsentry/sentry-javascript#25286 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
javascript
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
getsentry/sentry-javascript#24200 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di getsentry/sentry-javascript
Issue simili
-
Postgres upgrade golden leaves fixture URL query parameters in the expected output comparisonAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
garrytan/gbrain#10437 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Bedrock "Too many tokens" throttle is not auto-retried, unlike "Too many requests"Forse già presa @acmerfight l’ha presa oggi. Apertauntriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
earendil-works/pi#12573 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
agentes-chat/agentes-chat#1506 ·
I maintainer di solito rispondono entro 1 giorno
-
comp/desktop desktop/files os/windows P2 type/perf
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
NousResearch/hermes-agent#160359 ·
I maintainer di solito rispondono entro 1 giorno
-
Missing repro Platform: Android
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
software-mansion/react-native-reanimated#11554 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno