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

Remove import bindings after rewriting live references #10640

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Nov 4, 2019

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

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).

@nicolo-ribaudo nicolo-ribaudo added PR: Internal 🏠 A type of pull request used for our changelog categories area: modules labels Nov 4, 2019
// redeclared in this scope
if (rootBinding !== localBinding) return;
if (!isSameBinding(scope, path.scope, localName)) return;
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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.

@nicolo-ribaudo nicolo-ribaudo added this to the Babel 8.x milestone Nov 4, 2019
@JLHwung JLHwung changed the base branch from master to next-8-dev June 25, 2020 15:06
@nicolo-ribaudo nicolo-ribaudo force-pushed the internal-rewrite-live-references-before-removing-bindings branch from 4873b24 to 19141ac Compare January 7, 2022 15:19
@babel-bot
Copy link
Collaborator

babel-bot commented Jan 7, 2022

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

@nicolo-ribaudo nicolo-ribaudo changed the base branch from next-8-dev to main January 7, 2022 15:22
@nicolo-ribaudo nicolo-ribaudo marked this pull request as draft January 7, 2022 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: modules 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