Do not use lookahead when parsing dynamic import or import.meta (#9983)
This commit is contained in:
parent
9febf63882
commit
47eb1ddfe0
@ -875,19 +875,19 @@ export default class ExpressionParser extends LValParser {
|
|||||||
return this.finishNode(node, "Super");
|
return this.finishNode(node, "Super");
|
||||||
|
|
||||||
case tt._import:
|
case tt._import:
|
||||||
if (this.lookahead().type === tt.dot) {
|
|
||||||
return this.parseImportMetaProperty();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.expectPlugin("dynamicImport");
|
|
||||||
|
|
||||||
node = this.startNode();
|
node = this.startNode();
|
||||||
this.next();
|
this.next();
|
||||||
|
|
||||||
|
if (this.match(tt.dot)) {
|
||||||
|
return this.parseImportMetaProperty(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.expectPlugin("dynamicImport", node.start);
|
||||||
|
|
||||||
if (!this.match(tt.parenL)) {
|
if (!this.match(tt.parenL)) {
|
||||||
this.unexpected(null, tt.parenL);
|
this.unexpected(null, tt.parenL);
|
||||||
}
|
}
|
||||||
return this.finishNode(node, "Import");
|
return this.finishNode(node, "Import");
|
||||||
|
|
||||||
case tt._this:
|
case tt._this:
|
||||||
node = this.startNode();
|
node = this.startNode();
|
||||||
this.next();
|
this.next();
|
||||||
@ -1125,12 +1125,10 @@ export default class ExpressionParser extends LValParser {
|
|||||||
return this.finishNode(node, "MetaProperty");
|
return this.finishNode(node, "MetaProperty");
|
||||||
}
|
}
|
||||||
|
|
||||||
parseImportMetaProperty(): N.MetaProperty {
|
parseImportMetaProperty(node: N.MetaProperty): N.MetaProperty {
|
||||||
const node = this.startNode();
|
const id = this.createIdentifier(this.startNodeAtNode(node), "import");
|
||||||
const id = this.parseIdentifier(true);
|
|
||||||
this.expect(tt.dot);
|
this.expect(tt.dot);
|
||||||
|
|
||||||
if (id.name === "import") {
|
|
||||||
if (this.isContextual("meta")) {
|
if (this.isContextual("meta")) {
|
||||||
this.expectPlugin("importMeta");
|
this.expectPlugin("importMeta");
|
||||||
} else if (!this.hasPlugin("importMeta")) {
|
} else if (!this.hasPlugin("importMeta")) {
|
||||||
@ -1139,7 +1137,6 @@ export default class ExpressionParser extends LValParser {
|
|||||||
`Dynamic imports require a parameter: import('a.js')`,
|
`Dynamic imports require a parameter: import('a.js')`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.inModule) {
|
if (!this.inModule) {
|
||||||
this.raise(
|
this.raise(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user