メインコンテンツへスキップ

@babel/plugin-proposal-import-attributes-to-assertions

注意

このプラグインは、現在のECMAScript仕様または現在提案されている追加事項と互換性のないコードを生成します。ネイティブのESモジュールを発送していて、インポート属性構文(import pkg from "./package.json" with { type: "json" })はサポートしないが、古いインポートアサーション構文(import pkg from "./package.json" assert { type: "json" })はサポートするツール(Chrome 91以降やNode.js 17.2以降)との互換性のみが必要な場合にのみ使用してください。

インストール

npm install --save-dev @babel/plugin-proposal-import-attributes-to-assertions

使用

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

CLI経由

シェル
babel --plugins @babel/plugin-proposal-import-attributes-to-assertions script.js

Node API経由

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