Fix object rest params for exports.
This commit is contained in:
parent
45b41740d8
commit
c82b084927
@ -129,6 +129,10 @@ export default function () {
|
||||
return {
|
||||
inherits: require("babel-plugin-transform-strict-mode"),
|
||||
|
||||
manipulateOptions(opts, parserOpts) {
|
||||
parserOpts.plugins.push("objectRestSpread");
|
||||
},
|
||||
|
||||
visitor: {
|
||||
ThisExpression(path, state) {
|
||||
// If other plugins run after this plugin's Program#exit handler, we allow them to
|
||||
@ -311,14 +315,14 @@ export default function () {
|
||||
for (let i = 0; i < id.node.properties.length; i++) {
|
||||
const prop = id.node.properties[i];
|
||||
let propValue = prop.value;
|
||||
if (!t.isRestProperty(prop)) {
|
||||
if (t.isAssignmentPattern(propValue)) {
|
||||
propValue = propValue.left;
|
||||
}
|
||||
addTo(exports, propValue.name, propValue);
|
||||
exportsToInsert.push(buildExportsAssignment(propValue, propValue));
|
||||
nonHoistedExportNames[propValue.name] = true;
|
||||
if (t.isAssignmentPattern(propValue)) {
|
||||
propValue = propValue.left;
|
||||
} else if (t.isRestProperty(prop)) {
|
||||
propValue = prop.argument;
|
||||
}
|
||||
addTo(exports, propValue.name, propValue);
|
||||
exportsToInsert.push(buildExportsAssignment(propValue, propValue));
|
||||
nonHoistedExportNames[propValue.name] = true;
|
||||
}
|
||||
} else if (id.isArrayPattern() && id.node.elements) {
|
||||
for (let i = 0; i < id.node.elements.length; i++) {
|
||||
|
||||
@ -0,0 +1 @@
|
||||
export const { foo, ...bar } = {};
|
||||
@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
const { foo, ...bar } = {};
|
||||
exports.foo = foo;
|
||||
exports.bar = bar;
|
||||
Loading…
x
Reference in New Issue
Block a user