framework
framework copied to clipboard
Import attributes
We should support import assertions. This may require the acorn-import-assertions plugin.
Static imports with assertions look like this:
import data from "./data.json" assert {type: "json"};
Dynamic imports with assertions look like this:
const data = await import("./data.json", {assert: {type: "json"}});
Both of these currently generate syntax errors with Acorn, but are supported by most browsers.
Maybe worth mentioning that ESLint won't add support for import attributes until they become Stage 4 and fails to parse a file that contains them.
These are now called “import attributes” and use with
instead of assert
. Still not widely supported though.