-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
add babel-plugin-transform-block-scoping #30807
add babel-plugin-transform-block-scoping #30807
Conversation
A discussion in evanw/esbuild#478 has shown that using let and class in same enclosing level has a signigicant performance impact on the Safari browser. To alleviate this problem we transform the let and class constructs into var when it is 'easily' possible. Co-authored-by: Justin Ridgewell <jridgewell@google.com> Co-authored-by: erwin mombay <erwinm@google.com>
Hey @jridgewell! These files were changed:
|
Agree with @jridgewell feedback that we'll need to turn on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mangle will be needed to rename the variable references.
size before this change: size after this change: |
This reverts commit 9799f73.
* add babel-plugin-transform-block-scoping A discussion in evanw/esbuild#478 has shown that using let and class in same enclosing level has a signigicant performance impact on the Safari browser. To alleviate this problem we transform the let and class constructs into var when it is 'easily' possible. Co-authored-by: Justin Ridgewell <jridgewell@google.com> Co-authored-by: erwin mombay <erwinm@google.com> * turn on mangle on terser * Comments and test cases Co-authored-by: Justin Ridgewell <jridgewell@google.com>
A discussion in evanw/esbuild#478 has shown that using let and class in the same enclosing/block level has a significant performance impact on the Safari browser when there is a large number of instances of the block scoped variables to track (such as a large bundle with a large number of let/const/class declarations). To alleviate this problem we transform the let and class constructs into var when it is 'easily' possible (ex. we bail on the for loop block scoping to not complicate the transform).
this should only be turned on for esm/sxg in post closure transforms
We do not do this transform to
const
as we do aconst
tolet
transformer prior to this transform. As a follow up PR i will combine this with thelet
toconst
transformerCo-authored-by: Justin Ridgewell jridgewell@google.com
Co-authored-by: erwin mombay erwinm@google.com