Skip to content

Commit b834e6d

Browse files
committed
bugfix es2018 import()
1 parent 0911ad8 commit b834e6d

12 files changed

+940
-1776
lines changed

src/nodes.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,10 @@ export class IfStatement {
485485

486486
export class Import {
487487
readonly type: string;
488-
constructor() {
488+
readonly source: Literal;
489+
constructor(source) {
489490
this.type = Syntax.Import;
491+
this.source = source;
490492
}
491493
}
492494

src/parser.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,18 @@ export class Parser {
12821282
parseImportCall(): Node.Import {
12831283
const node = this.createNode();
12841284
this.expectKeyword('import');
1285-
return this.finalize(node, new Node.Import());
1285+
this.expect("(");
1286+
1287+
const source = this.parseAssignmentExpression();
1288+
if (!this.match(")") && this.config.tolerant) {
1289+
this.tolerateUnexpectedToken(this.nextToken());
1290+
} else {
1291+
this.expect(")");
1292+
if (this.match(";")) {
1293+
this.nextToken();
1294+
}
1295+
}
1296+
return this.finalize(node, new Node.Import(source));
12861297
}
12871298

12881299
parseLeftHandSideExpressionAllowCall(): Node.Expression {

0 commit comments

Comments
 (0)