Fix T6953,T2541 export-from statement renamed default issue
- Use `interopRequireDefault` helper if local name is default. Via 59naga/babel-plugin-add-module-exports#20
This commit is contained in:
@@ -295,7 +295,11 @@ export default function () {
|
||||
} else if (specifier.isExportDefaultSpecifier()) {
|
||||
// todo
|
||||
} else if (specifier.isExportSpecifier()) {
|
||||
topNodes.push(buildExportsFrom(t.stringLiteral(specifier.node.exported.name), t.memberExpression(ref, specifier.node.local)));
|
||||
if (specifier.node.local.name === "default") {
|
||||
topNodes.push(buildExportsFrom(t.stringLiteral(specifier.node.exported.name), t.memberExpression(t.callExpression(this.addHelper("interopRequireDefault"), [ref]), specifier.node.local)));
|
||||
} else {
|
||||
topNodes.push(buildExportsFrom(t.stringLiteral(specifier.node.exported.name), t.memberExpression(ref, specifier.node.local)));
|
||||
}
|
||||
nonHoistedExportNames[specifier.node.exported.name] = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,3 +4,4 @@ export {foo, bar} from "foo";
|
||||
export {foo as bar} from "foo";
|
||||
export {foo as default} from "foo";
|
||||
export {foo as default, bar} from "foo";
|
||||
export {default as foo} from "foo";
|
||||
|
||||
@@ -57,4 +57,10 @@ Object.defineProperty(exports, "bar", {
|
||||
get: function () {
|
||||
return _foo.bar;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "foo", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return babelHelpers.interopRequireDefault(_foo).default;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user