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

[cjs] Skip duplicate reexported bindings in namespace reexports #11739

Merged
merged 4 commits into from Sep 28, 2020

Conversation

mischnic
Copy link
Contributor

@mischnic mischnic commented Jun 22, 2020

Q                       A
Fixed Issues? Fixes #11710
Patch: Bug Fix? 👍
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes (I think)
Documentation PR Link -
Any Dependency Changes? 👎
License MIT

Namespace reexports: skip already added reexports on the exports object if they are strictly equal (as suggested in #11710 (comment)).

Questions:

  1. Not sure if this change could cause other side effects?
    • Currently, loose mode wouldn't throw any errors on duplicate bindings (in non-loose Object.defineProperty does this automatically). However, the order of the objects should be the same (because both skip if already set).
  2. I don't think there are any (integration) tests which aren't snapshot tests?

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 22, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 87938ed:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@babel-bot
Copy link
Collaborator

babel-bot commented Jun 22, 2020

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

@@ -236,6 +236,7 @@ function buildNamespaceReexport(metadata, namespace, loose) {
Object.keys(NAMESPACE).forEach(function(key) {
if (key === "default" || key === "__esModule") return;
VERIFY_NAME_LIST;
if (key in EXPORTS && EXPORTS[key] === NAMESPACE[key]) return;
Copy link
Member

Choose a reason for hiding this comment

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

Since this is technically not spec compliant, could you add a comment explaining the reason to do it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done (directly above the template string)

@nicolo-ribaudo nicolo-ribaudo added area: modules PR: Bug Fix 🐛 A type of pull request used for our changelog categories labels Jun 22, 2020
@mischnic mischnic force-pushed the reexports-duplicate-symbols branch from fa8bd25 to d7f8014 Compare June 23, 2020 12:42
Copy link
Contributor

@JLHwung JLHwung left a comment

Choose a reason for hiding this comment

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

Can you update the test fixtures?

@mischnic mischnic force-pushed the reexports-duplicate-symbols branch from d7f8014 to 199055a Compare July 19, 2020 17:24
@mischnic
Copy link
Contributor Author

Can you update the test fixtures?

Done

@nicolo-ribaudo nicolo-ribaudo changed the title plugin-transform-modules-commonjs: Skip duplicate reexported bindings in namespace reexports [cjs] Skip duplicate reexported bindings in namespace reexports Sep 28, 2020
@nicolo-ribaudo nicolo-ribaudo merged commit a080c82 into babel:main Sep 28, 2020
@nicolo-ribaudo
Copy link
Member

Thanks!

@mischnic mischnic deleted the reexports-duplicate-symbols branch September 28, 2020 14:42
@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 Dec 29, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: modules outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transpiling (non-conflicting) namespace reexports emits invalid code
4 participants