diff --git a/lib/output.js b/lib/output.js index c51fb7dc..4bf4c19b 100644 --- a/lib/output.js +++ b/lib/output.js @@ -1233,7 +1233,7 @@ function OutputStream(options) { output.space(); } if (self.imported_names) { - if (self.imported_names.length === 1 && self.imported_names[0].name.name === "*") { + if (self.imported_names.length === 1 && self.imported_names[0].foreign_name.name === "*") { self.imported_names[0].print(output); } else { output.print("{"); diff --git a/lib/parse.js b/lib/parse.js index eced9ff2..45021b3c 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -2176,7 +2176,7 @@ function parse($TEXT, options) { next(); } - imported_names = import_names(); + imported_names = import_names(true); if (imported_names || imported_name) { expect_token("name", "from"); @@ -2227,16 +2227,14 @@ function parse($TEXT, options) { }) } - function import_nameAsterisk() { + function import_nameAsterisk(name) { var start = S.token; var foreign_name; - var name; - next(); var end = prev(); - name = new AST_SymbolImport({ + name = name || new AST_SymbolImport({ name: '*', start: start, end: end, @@ -2256,7 +2254,7 @@ function parse($TEXT, options) { }) } - function import_names() { + function import_names(allow_as) { var names; if (is("punc", "{")) { next(); @@ -2269,8 +2267,13 @@ function parse($TEXT, options) { } next(); } else if (is("operator", "*")) { - var st = prev(); - names = [import_nameAsterisk()]; + var name; + next(); + if (allow_as && is("name", "as")) { + next(); // The "as" word + name = as_symbol(AST_SymbolImportForeign); + } + names = [import_nameAsterisk(name)]; } return names; } @@ -2286,7 +2289,7 @@ function parse($TEXT, options) { next(); } - exported_names = import_names(); + exported_names = import_names(false); if (exported_names) { expect_token("name", "from"); diff --git a/test/compress/harmony.js b/test/compress/harmony.js index 721383c9..ebb31954 100644 --- a/test/compress/harmony.js +++ b/test/compress/harmony.js @@ -183,9 +183,16 @@ import_statement: { import { Bar, Baz } from 'lel'; import Bar, { Foo } from 'lel'; import { Bar as kex, Baz as food } from 'lel'; - import * from 'lel'; } - expect_exact: 'import"mod-name";import Foo from"bar";import{Bar,Baz}from"lel";import Bar,{Foo}from"lel";import{Bar as kex,Baz as food}from"lel";import*from"lel";' + expect_exact: 'import"mod-name";import Foo from"bar";import{Bar,Baz}from"lel";import Bar,{Foo}from"lel";import{Bar as kex,Baz as food}from"lel";' +} + +import_all_statement: { + input: { + import * from 'lel'; + import * as Lel from 'lel'; + } + expect_exact: 'import*from"lel";import*as Lel from"lel";' } export_statement: {