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

Avoid IIFE for single-expression class static blocks #14275

Merged

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Feb 15, 2022

Q                       A
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

I noticed that static blocks containing a single expression are quite common, so this PR avoids the IIFE when compiling them. Note that this optimization only affects who is not using a minifier, because minifiers can already easily unwrap IIFEs.

@nicolo-ribaudo nicolo-ribaudo added Spec: Class Static Block PR: Output optimization 🔬 A type of pull request used for our changelog categories labels Feb 15, 2022
@babel-bot
Copy link
Collaborator

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

@nicolo-ribaudo nicolo-ribaudo merged commit 1937284 into babel:main Feb 18, 2022
@nicolo-ribaudo nicolo-ribaudo deleted the no-iife-single-expr-static-block branch February 18, 2022 09:34
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 21, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Output optimization 🔬 A type of pull request used for our changelog categories Spec: Class Static Block
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants