diff --git a/lib/6to5/generators/modules.js b/lib/6to5/generators/modules.js index ed6c068b70..14a10e53bb 100644 --- a/lib/6to5/generators/modules.js +++ b/lib/6to5/generators/modules.js @@ -15,38 +15,36 @@ exports.ExportBatchSpecifier = function () { }; exports.ExportDeclaration = function (node, print) { - this.push("export"); + this.push("export "); var specifiers = node.specifiers; if (node.default) { - this.push(" default"); - } else if (specifiers && specifiers.length > 0) { + this.push("default "); + } + + if (node.declaration) { + print(node.declaration); + } else { if (specifiers.length === 1 && t.isExportBatchSpecifier(specifiers[0])) { - this.push(" *"); + this.push("*"); } else { - this.push(" { "); - this.printJoin(print, specifiers, ", "); - this.push(" }"); + this.push("{"); + if (specifiers.length) { + this.push(" "); + this.printJoin(print, specifiers, ", "); + this.push(" "); + } + this.push("}"); } if (node.source) { this.push(" from "); print(node.source); } - - this.semicolon(); - - return; } - if (node.declaration) { - this.push(" "); - print(node.declaration); - } else { - this.push(" { }"); - this.semicolon(); - } + this.ensureSemicolon(); }; exports.ImportDeclaration = function (node, print) { @@ -65,14 +63,14 @@ exports.ImportDeclaration = function (node, print) { if (!spec.default && spec.type !== "ImportBatchSpecifier" && !foundImportSpecifier) { foundImportSpecifier = true; - self.push("{"); + self.push("{ "); } print(spec); }); if (foundImportSpecifier) { - this.push("}"); + this.push(" }"); } this.push(" from ");