hermes icon indicating copy to clipboard operation
hermes copied to clipboard

[hermes-parser] Support Import Attributes

Open ojj1123 opened this issue 1 year ago • 1 comments

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

  1. Parse JavaScript code uses Import Attributes with hermes-parser
  2. 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

ojj1123 avatar Jul 13 '24 09:07 ojj1123

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.

avp avatar Jul 22 '24 18:07 avp

It seems like it advanced import attributes to stage 4.

https://x.com/robpalmer2/status/1843491103120732585

ojj1123 avatar Oct 09 '24 07:10 ojj1123