index.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. function _helperPluginUtils() {
  7. const data = require("@babel/helper-plugin-utils");
  8. _helperPluginUtils = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. var _default = (0, _helperPluginUtils().declare)((api, options) => {
  14. api.assertVersion(7);
  15. const {
  16. legacy = false
  17. } = options;
  18. if (typeof legacy !== "boolean") {
  19. throw new Error("'legacy' must be a boolean.");
  20. }
  21. const {
  22. decoratorsBeforeExport
  23. } = options;
  24. if (decoratorsBeforeExport === undefined) {
  25. if (!legacy) {
  26. throw new Error("The '@babel/plugin-syntax-decorators' plugin requires a" + " 'decoratorsBeforeExport' option, whose value must be a boolean." + " If you want to use the legacy decorators semantics, you can set" + " the 'legacy: true' option.");
  27. }
  28. } else {
  29. if (legacy) {
  30. throw new Error("'decoratorsBeforeExport' can't be used with legacy decorators.");
  31. }
  32. if (typeof decoratorsBeforeExport !== "boolean") {
  33. throw new Error("'decoratorsBeforeExport' must be a boolean.");
  34. }
  35. }
  36. return {
  37. name: "syntax-decorators",
  38. manipulateOptions(opts, parserOpts) {
  39. parserOpts.plugins.push(legacy ? "decorators-legacy" : ["decorators", {
  40. decoratorsBeforeExport
  41. }]);
  42. }
  43. };
  44. });
  45. exports.default = _default;