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
Remove import bindings after rewriting live references #10640
base: main
Are you sure you want to change the base?
Remove import bindings after rewriting live references #10640
Conversation
// redeclared in this scope | ||
if (rootBinding !== localBinding) return; | ||
if (!isSameBinding(scope, path.scope, localName)) return; |
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.
Consider add it to a scope method, such as
scope.hasSameBinding(localName, otherScope)
because the // redeclared in this scope
check is also used in helper-simple-access
and transform-modules-commonjs
.
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.
Then it wouldn't work with @babel/core
<= 7.6.0. Let's defer this PR to Babel 8 since it's not urgent.
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.
🤔Doesn't uncommenting !!binding
cause it fail with @babel/core
<= 7.6.0?
Let's defer this PR to Babel 8 since it's not urgent.
Yup.
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.
Also relying on scope.hasSameBinding
, since in older versions it's undefined.
4873b24
to
19141ac
Compare
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/50585/ |
Ref: #10628 (comment)
This PR doesn't have any tests because it's just an optimization (before getting the rhs binding, it checks if the lhs one is defined).