UNPKG

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

Version:

Transform the Import Attributes proposal (`import ... from '...' with { ... }`) to the previous version known as Import Assertions (`import ... from '...' assert { ... }`).

33 lines (30 loc) 939 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _helperPluginUtils = require("@babel/helper-plugin-utils"); var _pluginSyntaxImportAttributes = require("@babel/plugin-syntax-import-attributes"); var _default = exports.default = (0, _helperPluginUtils.declare)(api => { api.assertVersion("^7.0.0-0 || >8.0.0-alpha <8.0.0-beta"); return { name: "proposal-import-attributes-to-assertions", inherits: _pluginSyntaxImportAttributes.default, manipulateOptions({ generatorOpts }) { generatorOpts.importAttributesKeyword = "assert"; }, visitor: { "ImportDeclaration|ExportNamedDeclaration|ExportAllDeclaration"(path) { const { node } = path; if (!node.attributes) return; node.assertions = node.attributes; node.attributes = null; } } }; }); //# sourceMappingURL=index.js.map