facebook / hermes

A JavaScript engine optimized for running React Native.
https://hermesengine.dev/
MIT License
9.68k stars 618 forks source link

[hermes-parser] Support Import Attributes #1458

Open ojj1123 opened 2 months ago

ojj1123 commented 2 months ago

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

avp commented 1 month ago

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.