Skip to content

Commit

Permalink
bugfix es2018 import()
Browse files Browse the repository at this point in the history
  • Loading branch information
jogibear9988 committed Apr 28, 2021
1 parent 0911ad8 commit b834e6d
Show file tree
Hide file tree
Showing 12 changed files with 940 additions and 1,776 deletions.
4 changes: 3 additions & 1 deletion src/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,10 @@ export class IfStatement {

export class Import {
readonly type: string;
constructor() {
readonly source: Literal;
constructor(source) {
this.type = Syntax.Import;
this.source = source;
}
}

Expand Down
13 changes: 12 additions & 1 deletion src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,18 @@ export class Parser {
parseImportCall(): Node.Import {
const node = this.createNode();
this.expectKeyword('import');
return this.finalize(node, new Node.Import());
this.expect("(");

const source = this.parseAssignmentExpression();
if (!this.match(")") && this.config.tolerant) {
this.tolerateUnexpectedToken(this.nextToken());
} else {
this.expect(")");
if (this.match(";")) {
this.nextToken();
}
}
return this.finalize(node, new Node.Import(source));
}

parseLeftHandSideExpressionAllowCall(): Node.Expression {
Expand Down

0 comments on commit b834e6d

Please sign in to comment.