Skip to content

fix(sourcemap): preserve names through collapse_sourcemaps - #9486

Merged
IWANABETHATGUY merged 3 commits into
rolldown:mainfrom
eoin:fix-collapse-sourcemaps-preserve-names
Sep 24, 2026
Merged

IWANABETHATGUY merged 3 commits into
rolldown:mainfrom
eoin:fix-collapse-sourcemaps-preserve-names

Conversation

@eoin

@eoin eoin commented May 20, 2026 •

Copy link
Copy Markdown

This change results in collapse_sourcemaps more closely mirroring the original rollup implementation, fixing an issue with sourcemap generation. collapse_sourcemaps previously kept only first_map.names, silently dropping any identifier the minifier (or an intermediate transform) renamed. As a result, Vite 8 bundles emit near-empty names arrays, breaking downstream consumers (e.g. Sentry) that rely on the names array to recover original identifier names from minified positions. This seems to be a version 8 regression.

@codspeed

codspeed Bot commented May 20, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 3.09%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 1 regressed benchmark
✅ 6 untouched benchmarks
⏩ 10 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ collapse_codegen_chain 30.7 ms 31.7 ms -3.09%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing eoin:fix-collapse-sourcemaps-preserve-names (82957f0) with main (7869925)2

Open in CodSpeed

Footnotes

  1. 10 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (81f238f) during the generation of this report, so 7869925 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@eoin

eoin commented May 21, 2026 •

Copy link
Copy Markdown
Author

It looks like this fixes a regression introduced in vitejs/vite@47a4d5069.

Commit Bundler with-define-object-*.js.map names
aa4739ab3 rollup ["main", "mainInner", "define_testDefineObject_default"]
47a4d5069 rolldown 1.0.0-beta.7 []
main []
This branch ["main", "mainInner", "\"hello\""]

This change results in names getting populated again, triggering a snapshot failure in js-sourcemap.spec.ts.

I'm not sure why \"hello\" replaces define_testDefineObject_default, but I suspect that's a separate issue.

@netlify

netlify Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 82957f0
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6ab4e16d4138f60008e934c4

@IWANABETHATGUY
IWANABETHATGUY force-pushed the fix-collapse-sourcemaps-preserve-names branch from 646704c to 1e33b22 Compare September 24, 2026 08:05
@IWANABETHATGUY

Copy link
Copy Markdown
Member

I’ll make a few small changes directly on your branch to avoid unnecessary back-and-forth and help move this forward more efficiently.

  1. Reduce allocations.
  2. Improve performance.

@IWANABETHATGUY
IWANABETHATGUY force-pushed the fix-collapse-sourcemaps-preserve-names branch from 477bbaf to 63d2a9d Compare September 24, 2026 08:27
eoin and others added 3 commits September 24, 2026 16:38
`collapse_sourcemaps` previously kept only `first_map.names`, silently
dropping any identifier the minifier (or an intermediate transform)
renamed. As a result, Vite 8 bundles emit near-empty `names` arrays
where Vite 7 (Rollup + esbuild) populated them, breaking downstream
consumers that rely on the names array to recover original identifier
names from minified positions.

Match the linked upstream (rollup/src/utils/collapseSourcemaps.ts):
concatenate every map's names into a merged pool, then for each
token walk the chain and prefer the name closest to the original
source, falling back through later maps when none is set. Adds tests
for last-map, middle-map, and first-vs-last name resolution.
Compute each map's name offset while building the lookup chain, so the
collapse keeps its allocation count (tasks/track_memory_allocations).
…earlier map has names

When every map before the last one has no names, no traced token can
carry a name, so the remap loop runs without the per-step name work.
This recovers the `collapse_codegen_chain` regression.
@IWANABETHATGUY
IWANABETHATGUY force-pushed the fix-collapse-sourcemaps-preserve-names branch from 63d2a9d to 82957f0 Compare September 24, 2026 08:38
@IWANABETHATGUY
IWANABETHATGUY merged commit ca66f9c into rolldown:main Sep 24, 2026
58 of 59 checks passed
@rolldown-guard rolldown-guard Bot mentioned this pull request Sep 24, 2026
shulaoda added a commit that referenced this pull request Sep 24, 2026
## [1.2.11] - 2026-09-24

### 🚀 Features

- watch: report only file events (#10974) by @shulaoda

### 🐛 Bug Fixes

- sourcemap: preserve names through `collapse_sourcemaps` (#9486) by @eoin
- watch: map metadata events by kind and missing paths as deleted (#10973) by @shulaoda

### 🚜 Refactor

- rolldown_fs_watcher: hand the handler file events instead of notify results (#10980) by @shulaoda
- rolldown_fs_watcher: share one event handler adapter between the notify watchers (#10979) by @shulaoda
- rolldown_fs_watcher: register every path with one watch mode (#10978) by @shulaoda
- rolldown_fs_watcher: tweak the backend traits and the event mapping (#10977) by @shulaoda
- watch: translate notify events inside FsWatcher (#10972) by @shulaoda

### 📚 Documentation

- watch: update the fs watcher layout and the dev coordinator message (#10981) by @shulaoda
- watch: document the event translation in FsWatcher (#10975) by @shulaoda

### ◀️ Revert

- "perf(dev/lazy): fetch a lazy route in one request" (#10789) (#10982) by @h-a-n-a

### ❤️ New Contributors

* @eoin made their first contribution in [#9486](#9486)

Co-authored-by: shulaoda <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: minify sourcemap has an empty names array — original identifiers unrecoverable

2 participants