Skip to content

Commit 47928a4

Browse files
committed
[loose parser] Consume semicolons after export-all statements
FIX: Fix a bug that caused semicolons after `export *` statements to be parsed as empty statements. Closes #1082
1 parent 25b99ba commit 47928a4

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

acorn-loose/src/statement.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ lp.parseExport = function() {
461461
}
462462
}
463463
node.source = this.eatContextual("from") ? this.parseExprAtom() : this.dummyString()
464+
this.semicolon()
464465
return this.finishNode(node, "ExportAllDeclaration")
465466
}
466467
if (this.eat(tt._default)) {

test/tests-export-all-as-ns-from-source.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,19 @@ test("export * from \"source\"", {
8585
"sourceType": "module"
8686
}, { sourceType: "module", ecmaVersion: 11 })
8787

88+
test("export * from 'a';", {
89+
type: "Program",
90+
body: [
91+
{
92+
type: "ExportAllDeclaration",
93+
exported: null,
94+
source: {
95+
type: "Literal",
96+
}
97+
}
98+
]
99+
}, {sourceType: "module", ecmaVersion: 11})
100+
88101
testFail("export * as ns from \"source\"", "'import' and 'export' may appear only with 'sourceType: module' (1:0)", { sourceType: "script", ecmaVersion: 11 })
89102
testFail("export * as ns from \"source\"", "Unexpected token (1:9)", { sourceType: "module", ecmaVersion: 10 })
90103
testFail("export * as ns", "Unexpected token (1:14)", { sourceType: "module", ecmaVersion: 11 })

0 commit comments

Comments
 (0)