index.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  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. parserOpts.plugins.push(["importAttributes", {
  28. deprecatedAssertSyntax: Boolean(deprecatedAssertSyntax)
  29. }]);
  30. }
  31. };
  32. });
  33. //# sourceMappingURL=index.js.map