fix default import generation

This commit is contained in:
Sebastian McKenzie 2014-12-10 23:18:23 +11:00
parent 8ffd2e843f
commit 01934b6960
2 changed files with 12 additions and 3 deletions

View File

@ -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("{ ");
}

View File

@ -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";