index.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 = (0, _helperPluginUtils.declare)((api, options) => {
  8. api.assertVersion(7);
  9. const {
  10. legacy = false
  11. } = options;
  12. if (typeof legacy !== "boolean") {
  13. throw new Error("'legacy' must be a boolean.");
  14. }
  15. const {
  16. decoratorsBeforeExport
  17. } = options;
  18. if (decoratorsBeforeExport === undefined) {
  19. if (!legacy) {
  20. 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.");
  21. }
  22. } else {
  23. if (legacy) {
  24. throw new Error("'decoratorsBeforeExport' can't be used with legacy decorators.");
  25. }
  26. if (typeof decoratorsBeforeExport !== "boolean") {
  27. throw new Error("'decoratorsBeforeExport' must be a boolean.");
  28. }
  29. }
  30. return {
  31. name: "syntax-decorators",
  32. manipulateOptions(opts, parserOpts) {
  33. parserOpts.plugins.push(legacy ? "decorators-legacy" : ["decorators", {
  34. decoratorsBeforeExport
  35. }]);
  36. }
  37. };
  38. });
  39. exports.default = _default;