FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

perf: Only extract source map comments at the end of the file by liuxingbaoyu · Pull Request #18039 · babel/babel · GitHub

/ babel Public

perf: Only extract source map comments at the end of the file - #18039

Merged
nicolo-ribaudo merged 2 commits into
babel:mainfrom
liuxingbaoyu:perf-input-map
Jun 16, 2026
Merged

perf: Only extract source map comments at the end of the file#18039
nicolo-ribaudo merged 2 commits into
babel:mainfrom
liuxingbaoyu:perf-input-map

Conversation

liuxingbaoyu commented May 31, 2026
edited
Loading

Copy link
Copy Markdown
Member
Q                       A
Fixed Issues? Fixes #1, Fixes #2
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT
  1. Only search for the input source map when source maps are needed.
  2. Only search the top-level source map.
  3. Print an error log when loading fails.

Potential impact:
Currently, if users do not enable sourceMaps, source map comments in the code will be retained.
If some tools directly concatenate the source code and map within functions, they will no longer be loaded. (However, we only load one source map anyway.)

This greatly improves core performance: ~20%

PS F:\babel\benchmark\babel-core\real-case-preset-env-typescript> node .\babel-parser-tokenizer-index.mjs         
current: 86.54 ops/sec ±1.7% (12ms)
PS F:\babel\benchmark\babel-core\real-case-preset-env-typescript> node .\babel-parser-tokenizer-index.mjs
current: 104 ops/sec ±1.38% (9.587ms)

Closes #16874

liuxingbaoyu added PR: Performance 🏃‍♀️ A type of pull request used for our changelog categories pkg: core area: sourcemaps labels May 31, 2026

babel-bot commented May 31, 2026
edited
Loading

Copy link
Copy Markdown
Collaborator

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

chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9980eb58c5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

pkg-pr-new Bot commented May 31, 2026
edited
Loading

Copy link
Copy Markdown

Open in StackBlitz

commit: 022060e

nicolo-ribaudo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Technically if a source map comment is followed by code we should ignore it.

So it should be enough to scan from the end, and only the trailing comments.

Maybe we could even start doing it at the parser level at some point.

https://tc39.es/ecma426/#sec-JavaScriptExtractSourceMapURL

nicolo-ribaudo added PR: Spec Compliance 👓 A type of pull request used for our changelog categories PR: Performance 🏃‍♀️ A type of pull request used for our changelog categories and removed PR: Needs Docs PR: Performance 🏃‍♀️ A type of pull request used for our changelog categories labels Jun 14, 2026
nicolo-ribaudo changed the title perf: Improve the performance of processing source maps perf: Only extract source map comments at the end of the file Jun 14, 2026

Copy link
Copy Markdown
Member

@liuxingbaoyu I pushed a commit to further limit which comments we look at, so that we match the spec :)

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

Labels

area: sourcemaps pkg: core PR: Performance 🏃‍♀️ A type of pull request used for our changelog categories PR: Spec Compliance 👓 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL