index.js 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _helperPluginUtils = require("@babel/helper-plugin-utils");
  7. var _default = exports.default = (0, _helperPluginUtils.declare)(api => {
  8. api.assertVersion(7);
  9. const isPlugin = (plugin, name) => name === "plugin" || Array.isArray(plugin) && plugin[0] === "plugin";
  10. const options = plugin => Array.isArray(plugin) && plugin.length > 1 ? plugin[1] : {};
  11. return {
  12. name: "syntax-import-assertions",
  13. manipulateOptions(opts, {
  14. plugins
  15. }) {
  16. for (let i = 0; i < plugins.length; i++) {
  17. const plugin = plugins[i];
  18. if (isPlugin(plugin, "deprecatedImportAssert")) return;
  19. if (isPlugin(plugin, "importAttributes")) {
  20. plugins.splice(i, 1, "deprecatedImportAssert", ["importAttributes", Object.assign({}, options(plugin), {
  21. deprecatedAssertSyntax: true
  22. })]);
  23. return;
  24. }
  25. }
  26. plugins.push("importAssertions");
  27. }
  28. };
  29. });
  30. //# sourceMappingURL=index.js.map