Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate helper metadata at build time #16501

Merged
merged 19 commits into from
May 22, 2024

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented May 16, 2024

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

The goal of this PR is to:

  • move as much analysis of helpers as possible to build time rather than runtime
  • make helpers lighter, by working as much as possible with them as an AST rather than a NodePath at runtime
  • get rid of the File class that needs to be injected from @babel/core to @babel/helpers through .ensure(name, FileClass)

This PR reduces the time needed to process a single helper by half (allHelpersNames.map(name => this.addHelper(name)); takes 100ms rather than 190ms on my machine)

@babel-bot
Copy link
Collaborator

babel-bot commented May 16, 2024

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

Copy link
Member

@liuxingbaoyu liuxingbaoyu left a comment

Choose a reason for hiding this comment

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

Great! I like this!

@nicolo-ribaudo nicolo-ribaudo force-pushed the static-helper-metata branch 2 times, most recently from c95ee9a to fc45887 Compare May 18, 2024 12:38
@nicolo-ribaudo nicolo-ribaudo marked this pull request as ready for review May 19, 2024 12:17
@nicolo-ribaudo nicolo-ribaudo added the PR: Internal 🏠 A type of pull request used for our changelog categories label May 19, 2024
this.v = value;
this.k = kind;
}

export { _OverloadYield as default };
Copy link
Member Author

Choose a reason for hiding this comment

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

Support for this is needed in #16510

@nicolo-ribaudo
Copy link
Member Author

nicolo-ribaudo commented May 22, 2024

The helpers-generated.ts size is increased by 50%, and only by 20% when using gzip (it doesn't really matter because it's mostly a Node.js package, but it's still good to know the tradeoff)

**Before ** After
Size 80kB 120kB
gzip 20kB 24kB
minified 74kB 100kB
minified+gzip 19kB 22kB

@nicolo-ribaudo nicolo-ribaudo merged commit 553e433 into babel:main May 22, 2024
51 checks passed
@nicolo-ribaudo nicolo-ribaudo deleted the static-helper-metata branch May 22, 2024 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Internal 🏠 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants