index.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. deprecatedAssertSyntax
  9. }) => {
  10. api.assertVersion("^7.22.0 || >8.0.0-alpha <8.0.0-beta");
  11. if (deprecatedAssertSyntax != null && typeof deprecatedAssertSyntax !== "boolean") {
  12. throw new Error("'deprecatedAssertSyntax' must be a boolean, if specified.");
  13. }
  14. return {
  15. name: "syntax-import-attributes",
  16. manipulateOptions({
  17. parserOpts,
  18. generatorOpts
  19. }) {
  20. var _generatorOpts$import;
  21. (_generatorOpts$import = generatorOpts.importAttributesKeyword) != null ? _generatorOpts$import : generatorOpts.importAttributesKeyword = "with";
  22. const importAssertionsPluginIndex = parserOpts.plugins.indexOf("importAssertions");
  23. if (importAssertionsPluginIndex !== -1) {
  24. parserOpts.plugins.splice(importAssertionsPluginIndex, 1);
  25. deprecatedAssertSyntax = true;
  26. }
  27. if (deprecatedAssertSyntax) {
  28. parserOpts.plugins.push("deprecatedImportAssert", ["importAttributes", {
  29. deprecatedAssertSyntax: true
  30. }]);
  31. } else {
  32. parserOpts.plugins.push("importAttributes");
  33. }
  34. }
  35. };
  36. });
  37. //# sourceMappingURL=index.js.map