make export { foo as default }; trigger common interop
This commit is contained in:
parent
7f985fe08a
commit
07c7b5b419
@ -27,7 +27,7 @@ function DefaultFormatter(file) {
|
||||
}
|
||||
|
||||
DefaultFormatter.prototype.doDefaultExportInterop = function (node) {
|
||||
return node.default && !this.noInteropRequireExport && !this.hasNonDefaultExports;
|
||||
return t.isSpecifierDefault(node) && !this.noInteropRequireExport && !this.hasNonDefaultExports;
|
||||
};
|
||||
|
||||
DefaultFormatter.prototype.bumpImportOccurences = function (node) {
|
||||
|
||||
@ -64,6 +64,17 @@ CommonJSFormatter.prototype.importDeclaration = function (node, nodes) {
|
||||
}, true));
|
||||
};
|
||||
|
||||
CommonJSFormatter.prototype.exportSpecifier = function (specifier, node, nodes) {
|
||||
if (this.doDefaultExportInterop(node)) {
|
||||
nodes.push(util.template("exports-default-assign", {
|
||||
VALUE: t.getSpecifierId(specifier)
|
||||
}, true));
|
||||
return;
|
||||
}
|
||||
|
||||
DefaultFormatter.prototype.exportSpecifier.apply(this, arguments);
|
||||
};
|
||||
|
||||
CommonJSFormatter.prototype.exportDeclaration = function (node, nodes) {
|
||||
if (this.doDefaultExportInterop(node)) {
|
||||
var declar = node.declaration;
|
||||
|
||||
@ -760,7 +760,7 @@ t.getSpecifierId = function (specifier) {
|
||||
*/
|
||||
|
||||
t.isSpecifierDefault = function (specifier) {
|
||||
return specifier.default || t.isIdentifier(specifier.id) && specifier.id.name === "default";
|
||||
return specifier.default || t.isIdentifier(specifier.id, { name: "default" });
|
||||
};
|
||||
|
||||
toFastProperties(t);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user