xtuc / acorn-import-attributes

Support for import assertions in acorn

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parsing error when parsing reexport statement that exports a specifier that is not a valid identifier

Andarist opened this issue · comments

Originally reported here but then I realized that the error was only thrown when this plugin was used

Repro

const { Parser } = require('acorn')
const { importAssertions } = require('acorn-import-assertions')

Parser
  .extend(importAssertions)
  .parse(`export * as '🙈' from 'external'`, { sourceType: 'module', ecmaVersion: 'latest' })

Actual

Uncaught [SyntaxError: Unexpected token (1:12)
] {
  pos: 12,
  loc: Position { line: 1, column: 12 },
  raisedAt: 15
}

Expected

It should parse this input correctly

There's an alternative with support.

https://github.com/bojavou/acorn-import-attributes