index.js 1.1 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. function _core() {
  14. const data = require("@babel/core");
  15. _core = function () {
  16. return data;
  17. };
  18. return data;
  19. }
  20. var _default = (0, _helperPluginUtils().declare)(api => {
  21. api.assertVersion(7);
  22. return {
  23. name: "transform-shorthand-properties",
  24. visitor: {
  25. ObjectMethod(path) {
  26. const {
  27. node
  28. } = path;
  29. if (node.kind === "method") {
  30. const func = _core().types.functionExpression(null, node.params, node.body, node.generator, node.async);
  31. func.returnType = node.returnType;
  32. path.replaceWith(_core().types.objectProperty(node.key, func, node.computed));
  33. }
  34. },
  35. ObjectProperty({
  36. node
  37. }) {
  38. if (node.shorthand) {
  39. node.shorthand = false;
  40. }
  41. }
  42. }
  43. };
  44. });
  45. exports.default = _default;