Repository navigation
test(bundler-plugins): Add integration tests for sourcemaps.assets and sourcemaps.ignore - #25916
Conversation
…and `sourcemaps.ignore` The bundler plugin integration tests had no fixture that set either option, and the unit tests only check that the globs reach the glob call. Nothing asserted which chunks end up uploaded. Each of the Rollup, Rolldown, Vite, webpack and esbuild fixtures gets a two-entry build with source maps on. One test ignores `entry2.js`, the other restricts `assets` to `entry1.js`. The `sentry` CLI stub can now record the `sources` of every map in the upload directory, opt-in through `SENTRY_TEST_RECORD_UPLOADED_SOURCES`, so the snapshots show which chunks were uploaded and that every map stays in the output.
size-limit report 📦Compared: 7061d1d (PR test merge using develop at 30cfb4c) Against: 30cfb4c (develop) · base run #64245 ✅ Baseline matches: this diff contains only this PR's changes.
|
isaacs
left a comment
There was a problem hiding this comment.
Just a comment, going to pivot and review the stack first. Re-requesting from myself so that it stays on my queue 👍
| output: { | ||
| dir: "out/sourcemaps-ignore", | ||
| chunkFileNames: "[name].js", | ||
| sourcemap: true, |
There was a problem hiding this comment.
I was going to raise that the fixtures never take the staged upload path, but I think that's covered by your stack? If this PR is meant only as a baseline before the stack, then we should maybe say that in the description, and make sure each stack PR adds the staged variant.
There was a problem hiding this comment.
I was going to raise that the fixtures never take the staged upload path, but I think that's covered by your stack?
The staged upload path will be covered in the stack but I haven't got that far yet. I've added a ref. to this in the description.
I think eventually It would be good to move Roll{up,down}, Vite and webpack to only use the staged path, but that's a behavioural change because we would stop picking up maps that weren't in the build. I would say that's desirable, but it is a change. It looks like esbuild, Turbopack, SvelteKit and Nuxt will not be able to go this route though 🤔
…r upload in the Rollup plugin (#25645) Part of the stack for #25609. When the Rollup or Rolldown output has no `sourcemap` setting and an upload can run, the plugin switches the output to hidden source maps, copies each chunk and its map into the upload staging folder from a `generateBundle` hook that runs last, and drops the map asset so it is never written. A map the plugin turned on never reaches the output, not even for chunks that `sourcemaps.assets` or `sourcemaps.ignore` keep out of the upload or that the plugin cannot prepare. `deleteSourcemapsAfterUpload: true` also removes maps the user enabled, but only for chunks that were uploaded; the rest stay, with a warning for a chunk the plugin cannot prepare. `generate()` drops the maps the plugin turned on, so callers that write the result themselves get what they configured. Decisions and stagings are recorded per output, told apart by `format`, `entryFileNames`, `chunkFileNames` and `file`, because several outputs can write into one directory at once with different settings. Staging applies `sourcemaps.assets` and `sourcemaps.ignore` through the matcher that `glob` exports for its own `ignore` option, with the same dot-file rules as the upload from disk: `assets` skips dot files and folders unless a pattern names them, and `ignore` matches them. SvelteKit and Nuxt pass `deleteSourcemapsAfterUpload: false` because they need the map files on disk after the Vite build; the other framework SDKs set the bundler's source map option themselves, which the plugin never deletes, so their builds do not change until each one migrates in its own PR. Integration fixtures cover `ignore` and `assets` on the staged path and mixed outputs into one directory; the CLI stub change comes from #25916 and drops out when that merges.
The bundler plugin integration tests had no fixture that set
sourcemaps.assetsorsourcemaps.ignore, and the unit tests only check that the globs reach the glob call. Nothing asserted which chunks end up uploaded, which let a gap in the staged upload work go unnoticed.Each of the Rollup, Rolldown, Vite, webpack and esbuild fixtures gets a two-entry build with source maps on. One test ignores
entry2.js, the other restrictsassetstoentry1.js. ThesentryCLI stub can now record thesourcesof every map in the upload directory, opt-in throughSENTRY_TEST_RECORD_UPLOADED_SOURCES, so the snapshots show which chunks were uploaded and that every map stays in the output.These stacked PRs will need their own tests to cover the staged upload route.