Skip to content

Commit 57fd515

Browse files
committed
Parse asterisk within import statement
1 parent b70fb59 commit 57fd515

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

src/grammar.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ grammar =
364364
ImportSpecifier: [
365365
o 'Identifier'
366366
o 'Identifier IMPORT_AS Identifier', -> new ImportSpecifier $1, $3
367-
o '* IMPORT_AS Identifier', -> new ImportSpecifier {value: '*'}, $3
367+
o 'IMPORT_ALL IMPORT_AS Identifier', -> new ImportSpecifier null, $3
368368
]
369369

370370
NamedImports: [

src/lexer.coffee

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,8 @@ exports.Lexer = class Lexer
448448
if value is ';'
449449
@seenFor = @seenImport = @seenExport = no
450450
tag = 'TERMINATOR'
451+
else if value is '*' and (@seenImport or @seenExport)
452+
tag = 'IMPORT_ALL'
451453
else if value in MATH then tag = 'MATH'
452454
else if value in COMPARE then tag = 'COMPARE'
453455
else if value in COMPOUND_ASSIGN then tag = 'COMPOUND_ASSIGN'

src/nodes.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ exports.ImportSpecifier = class ImportSpecifier extends Base
12851285
children: ['original', 'alias']
12861286

12871287
compileNode: (o) ->
1288-
return [@makeCode("#{@original.value} as #{@alias.value}")]
1288+
return [@makeCode("#{if @original? then @original.value else '*'} as #{@alias.value}")]
12891289

12901290
#### Assign
12911291

0 commit comments

Comments
 (0)