Skip to content

Preserve original identifier names from input sourcemaps#17992

Merged
nicolo-ribaudo merged 3 commits into
mainfrom
fix/source-map-propagation
May 13, 2026
Merged

Preserve original identifier names from input sourcemaps#17992
nicolo-ribaudo merged 3 commits into
mainfrom
fix/source-map-propagation

Conversation

@Andarist
Copy link
Copy Markdown
Member

Fixes the issue that caused the original names from the input source map to be ignored by Babel. This caused incorrect mappings to be generated (generating name entries for identifiers coming from the already partially transformed input) and ultimately leading to issues in devtools, such as this:
image

Notice how root (from the original source code) can't be evaluated properly here. That's because Babel generated root2 at this position (that came from the B in A_original -> B -> C_babel_output).

I think it might be helpful to review the diff between current and new behavior here: https://github.com/babel/babel/compare/3b6c1f87be19ab3f823fe9c0074006d97c677d32..ea7fa30d663f7d646d3be7cffab50caed3bf84dc

@babel-bot
Copy link
Copy Markdown
Collaborator

babel-bot commented May 11, 2026

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/61524

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 11, 2026

Open in StackBlitz

commit: fb8bcd3

Copy link
Copy Markdown
Contributor

@JLHwung JLHwung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated source map makes more sense, thank you!

@Andarist Andarist requested a review from nicolo-ribaudo May 12, 2026 19:27
Copy link
Copy Markdown
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! If you also need this in Babel 7, please open a PR backporting the commit targeting the 7.x branch.

@nicolo-ribaudo nicolo-ribaudo added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label May 13, 2026
@nicolo-ribaudo nicolo-ribaudo merged commit d9d9a0c into main May 13, 2026
102 checks passed
@nicolo-ribaudo nicolo-ribaudo deleted the fix/source-map-propagation branch May 13, 2026 21:00
JLHwung pushed a commit that referenced this pull request May 14, 2026
…7998)

* Add failing test case

* Preserve original identifier names from input sourcemaps

* fix stuff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Bug Fix 🐛 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants