fix default import generation
This commit is contained in:
parent
8ffd2e843f
commit
01934b6960
@ -1,7 +1,14 @@
|
||||
var t = require("../../types");
|
||||
var _ = require("lodash");
|
||||
|
||||
exports.ImportSpecifier =
|
||||
exports.ImportSpecifier = function (node, print) {
|
||||
if (node.id && node.id.name === "default") {
|
||||
print(node.name);
|
||||
} else {
|
||||
return exports.ExportSpecifier.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
exports.ExportSpecifier = function (node, print) {
|
||||
print(node.id);
|
||||
if (node.name) {
|
||||
@ -62,7 +69,9 @@ exports.ImportDeclaration = function (node, print) {
|
||||
self.push(", ");
|
||||
}
|
||||
|
||||
if (!spec.default && spec.type !== "ImportBatchSpecifier" && !foundImportSpecifier) {
|
||||
var isDefault = spec.id && spec.id.name === "default";
|
||||
|
||||
if (!isDefault && spec.type !== "ImportBatchSpecifier" && !foundImportSpecifier) {
|
||||
foundImportSpecifier = true;
|
||||
self.push("{ ");
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import "foo";
|
||||
import foo from "foo";
|
||||
import { default as foo } from "foo";
|
||||
import foo from "foo";
|
||||
import * as foo from "foo";
|
||||
import foo, { baz as xyz } from "foo";
|
||||
import { bar } from "foo";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user