hermes
hermes copied to clipboard
[hermes-parser] Support Import Attributes
Bug Description
Hermes git revision (if applicable): React Native version: OS: Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64):
Steps To Reproduce
- Parse JavaScript code uses Import Attributes with hermes-parser
- Check the result AST.
code example:
const { parse } = require('hermes-parser');
const ast = parse('import json from "./foo.json" with { type: "json" };');
The Expected Behavior
It outputs the correct AST
The Current Behavior
SyntaxError: ';' expected (1:30)
import json from "./foo.json" with { type: "json" };
Reference
- https://github.com/estree/estree/blob/master/stage3/import-attributes.md
- https://github.com/tc39/proposal-import-attributes
- https://github.com/facebook/hermes/issues/607
This feature is at stage 3 and appears to have changed recently, so we still have the old assert keyword. We can update it to have the new with instead.
It seems like it advanced import attributes to stage 4.
https://x.com/robpalmer2/status/1843491103120732585