Repository navigation
fix(sourcemap): preserve names when collapsing sourcemap on minify (#10839) - #10871
Closed
justonemorenight wants to merge 2 commits into
Closed
justonemorenight wants to merge 2 commits into
justonemorenight wants to merge 2 commits into
Conversation
justonemorenight
requested review from
IWANABETHATGUY,
hyfdev and
shulaoda
as code owners
September 14, 2026 07:45
Merging this PR will not alter performance
Comparing Footnotes
|
justonemorenight
force-pushed
the
fix/sourcemap-names-on-minify
branch
from
September 14, 2026 07:57
0f03201 to
554f596
Compare
Member
|
Fixed by #9486 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #10839
When minification and sourcemaps are enabled, oxc's codegen/mangler generates a sourcemap containing mangled identifier mapping names in
last_map.names(e.g.["greet", "personName"]), with the corresponding tokens referencing these names vianame_id.However,
collapse_sourcemapswas only takingfirst_map.get_names()andoriginal_token.get_name_id(). Sincefirst_map(the pre-minification chunk map) had not mangled identifiers, itsnameslist was empty andoriginal_token.get_name_id()wasNone. As a result, the collapsed sourcemap had an emptynamesarray and lost all tokenname_idreferences, preventing DevTools/debuggers from recovering the original symbol names.Solution
rolldown_sourcemap):collapse_sourcemaps, tracenamestarting fromtoken.get_name_id()onlast_map.collapseSourcemapsalgorithm).namestable with any existing names fromfirst_map, and append new unique names encountered during token tracing using a hash map lookup.name_id) to the mapped index in the consolidatednamesarray.OutputAsset.names(rolldown):emit_sourcemap, populateOutputAsset.namesfrommap.get_names()rather than hardcodingvec![].test_collapse_sourcemaps_preserves_names_from_minifierinrolldown_sourcemap.crates/rolldown/tests/rolldown/sourcemap/minify_sourcemap_nameswith node assertions verifying thatsourceMap.namesindist/main.js.mapcontains the renamed identifiers (greet,personName).