Skip to content

[BUG] Babel 7 with es2015 preset incorrectly destructures from imported module. #6373

Closed

Description

@alloy

Input Code

Cloneable/runnable example can be found here.

Given a module that exports an object:

export const NestedObjects = {
  Foo: "whatevs",
  Bar: "whatevs",
}

And a module that imports the object and then destructures it into multiple objects:

import { NestedObjects } from "./some-module"
const { Foo, Bar } = NestedObjects

Babel Configuration

{
  "presets": ["es2015"]
}

Expected Behavior

I would expect both Foo and Bar to be taken from _someModule.NestedObjects.

Current Behavior

Only the first destructured object is resolved correctly _someModule.NestedObjects.Foo, the following object loses the module reference NestedObjects.Bar.

Possible Solution

I have not had the time yet to drill it down to the specific plugin in the es2015 preset that causes this, so that should probably be the first avenue to explore. I will update this ticket if I do find time to debug more before someone else has had the opportunity to do so.

Context

Our React Native project tries to use this library, which currently fails the build.

Your Environment

software version(s)
Babel 7.0.0-beta.2
node 8.4.0
npm 5.3.0
Operating System Mac OS X 10.12.5

Activity

  1. babel-bot commented on Oct 3, 2017

    @babel-bot
    Collaborator

    Hey @alloy! 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. orta commented on Oct 3, 2017

    @orta
    Contributor

    Nice response @babel-bot, I should steal this and get it on CocoaPods' peril.

  3. hzoo commented on Oct 3, 2017

    @hzoo
    Member

    REPL on master (you can use /repl/build/master to test what the current state of master is)

    screen shot 2017-10-03 at 9 29 32 am

  4. added
    outdated
    on May 4, 2018
  5. locked as resolved and limited conversation to collaborators on May 4, 2018
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

    7.x: regressionoutdated

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions