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

Created on 3 Oct 2017  路  3Comments  路  Source: babel/babel

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

regression outdated

All 3 comments

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.

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

EmpireWorld picture EmpireWorld  路  3Comments

babel-bot picture babel-bot  路  3Comments

tleunen picture tleunen  路  3Comments

nicolo-ribaudo picture nicolo-ribaudo  路  3Comments

mathiasbynens picture mathiasbynens  路  3Comments