Skip to content

Simplify buildNamespaceReexport #9109

Closed

Description

@mathiasbynens

This code is meant to prevent __esModule from being overwritten:

if (key === "default" || key === "__esModule") return;

It’s helpful in loose mode, but for non-loose mode the key === "__esModule" is redundant, since the __esModule property is then added as follows:

Object.defineProperty(exports, '__esModule', {
  value: true
});

Note that enumerable: false is implied here, and so __esModule won’t show up in Object.keys(exports).

Your mission, should you choose to accept it, is to remove this redundant check from the non-loose mode code path!

Ref. tc39/ecma262#1320 (comment).

Activity

  1. babel-bot commented on Dec 1, 2018

    @babel-bot
    Collaborator

    Hey @mathiasbynens! We really appreciate you taking the time to report an issue. The collaborators
    on this project attempt to help as many people as possible, but we're a limited number of volunteers,
    so it's possible this won't be addressed swiftly.

    If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
    community that typically always has someone willing to help. You can sign-up here
    for an invite.

  2. loganfsmyth commented on Dec 1, 2018

    @loganfsmyth
    Member

    I don't think we can do that safely because it's not a question of if the current file is running in loose mode, but rather if the module namespace that is being re-exported is in loose mode.

  3. mathiasbynens commented on Dec 1, 2018

    @mathiasbynens
    ContributorAuthor

    In that case we should close this issue :)

  4. added
    outdatedA closed issue/PR that is archived due to age. Recommended to make a new issue
    on Mar 2, 2019
  5. locked as resolved and limited conversation to collaborators on Mar 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions