Skip to content

perf: Improve transform performance a bit#16874

Closed
liuxingbaoyu wants to merge 1 commit into
babel:mainfrom
liuxingbaoyu:perf-core
Closed

perf: Improve transform performance a bit#16874
liuxingbaoyu wants to merge 1 commit into
babel:mainfrom
liuxingbaoyu:perf-core

Conversation

@liuxingbaoyu

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

https://babeljs.io/docs/options#inputsourcemap
I don't know why inputSourceMap is true by default even though sourceMaps is false.
This PR improves performance when the input does not contain source maps, avoiding traverseFast twice.

@babel-bot

babel-bot commented Sep 30, 2024

Copy link
Copy Markdown
Collaborator

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

);
} else {
debug("discarding unknown inline input sourcemap");
if (process.env.BABEL_8_BREAKING || !fromAst) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Discussion welcome here.
I'm not sure if source map comments are included in program.comments when transformFromAst, and maybe we shouldn't use the fast path in Babel 8 either.

@liuxingbaoyu

Copy link
Copy Markdown
Member Author

There is also a potential optimization of only traversing top-level statements, but I'm not sure if that is sufficient.
Also, we can consider changing the default value of inputSourceMap in Babel 8.

@liuxingbaoyu liuxingbaoyu added pkg: core PR: Performance 🏃‍♀️ A type of pull request used for our changelog categories labels Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: core PR: Performance 🏃‍♀️ A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants