Skip to content

Commit

Permalink
Don't overwrite node type when parsing import.meta
Browse files Browse the repository at this point in the history
FIX: Make sure `onToken` get an `import` keyword token when parsing
`import.meta`.

Closes #1256
  • Loading branch information
marijnh committed Nov 1, 2023
1 parent 6369777 commit c3ec702
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions acorn/src/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,12 +519,14 @@ pp.parseExprImport = function(forNew) {
// Consume `import` as an identifier for `import.meta`.
// Because `this.parseIdent(true)` doesn't check escape sequences, it needs the check of `this.containsEsc`.
if (this.containsEsc) this.raiseRecoverable(this.start, "Escape sequence in keyword import")
const meta = this.parseIdent(true)
this.next()

if (this.type === tt.parenL && !forNew) {
return this.parseDynamicImport(node)
} else if (this.type === tt.dot) {
node.meta = meta
let meta = this.startNodeAt(node.start, node.loc)
meta.name = "import"
node.meta = this.finishNode(meta, "Identifier")
return this.parseImportMeta(node)
} else {
this.unexpected()
Expand Down

0 comments on commit c3ec702

Please sign in to comment.