Skip to main content

@babel/plugin-syntax-import-attributes

note

Syntax only

This plugin only enables Babel to parse this syntax. Babel does not support transforming this syntax

This plugin enables Babel to parse import attributes:

JavaScript
import foo from "./foo.json" with { type: "json" };

Installation

npm install --save-dev @babel/plugin-syntax-import-attributes

Usage

babel.config.json
{
"plugins": ["@babel/plugin-syntax-import-attributes"]
}

Via CLI

Shell
babel --plugins @babel/plugin-syntax-import-attributes script.js

Via Node API

JavaScript
require("@babel/core").transformSync("code", {
plugins: ["@babel/plugin-syntax-import-attributes"]
});

Options

deprecatedAssertSyntax

boolean, defaults to false.

If enabled, support parsing import attributes using the deprecated assert keyword:

JavaScript
import foo from "./foo.json" assert { type: "json" };

This syntax is only supported in V8-based engines, and its removal from the web is being investigated.