diff --git a/packages/babel-plugin-transform-es2015-destructuring/src/index.js b/packages/babel-plugin-transform-es2015-destructuring/src/index.js index c0d4bfc3bb..0930e860fb 100644 --- a/packages/babel-plugin-transform-es2015-destructuring/src/index.js +++ b/packages/babel-plugin-transform-es2015-destructuring/src/index.js @@ -211,7 +211,7 @@ export default function({ types: t }) { if (t.isRestElement(prop)) { this.pushObjectRest(pattern, objRef, prop, i); } else { - this.pushObjectProperty(prop, objRef); + this.pushObjectProperty(prop, t.clone(objRef)); } } } diff --git a/packages/babel-plugin-transform-es2015-destructuring/test/fixtures/destructuring/issue-6373/actual.js b/packages/babel-plugin-transform-es2015-destructuring/test/fixtures/destructuring/issue-6373/actual.js new file mode 100644 index 0000000000..2ff9926bee --- /dev/null +++ b/packages/babel-plugin-transform-es2015-destructuring/test/fixtures/destructuring/issue-6373/actual.js @@ -0,0 +1,3 @@ +import { NestedObjects } from "./some-module" + +const { Foo, Bar } = NestedObjects diff --git a/packages/babel-plugin-transform-es2015-destructuring/test/fixtures/destructuring/issue-6373/expected.js b/packages/babel-plugin-transform-es2015-destructuring/test/fixtures/destructuring/issue-6373/expected.js new file mode 100644 index 0000000000..69b8f9b7fe --- /dev/null +++ b/packages/babel-plugin-transform-es2015-destructuring/test/fixtures/destructuring/issue-6373/expected.js @@ -0,0 +1,6 @@ +"use strict"; + +var _someModule = require("./some-module"); + +const Foo = _someModule.NestedObjects.Foo, + Bar = _someModule.NestedObjects.Bar; diff --git a/packages/babel-plugin-transform-es2015-destructuring/test/fixtures/destructuring/issue-6373/options.json b/packages/babel-plugin-transform-es2015-destructuring/test/fixtures/destructuring/issue-6373/options.json new file mode 100644 index 0000000000..7ac4ca3c1f --- /dev/null +++ b/packages/babel-plugin-transform-es2015-destructuring/test/fixtures/destructuring/issue-6373/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["transform-es2015-destructuring", "transform-es2015-modules-commonjs"] +}