index.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 _regeneratorTransform = require("regenerator-transform");
  8. var _default = exports.default = (0, _helperPluginUtils.declare)(({
  9. types: t,
  10. assertVersion
  11. }) => {
  12. assertVersion(7);
  13. return {
  14. name: "transform-regenerator",
  15. inherits: _regeneratorTransform.default,
  16. visitor: {
  17. CallExpression(path) {
  18. {
  19. var _this$availableHelper;
  20. if (!((_this$availableHelper = this.availableHelper) != null && _this$availableHelper.call(this, "regeneratorRuntime"))) {
  21. return;
  22. }
  23. }
  24. const callee = path.get("callee");
  25. if (!callee.isMemberExpression()) return;
  26. const obj = callee.get("object");
  27. if (obj.isIdentifier({
  28. name: "regeneratorRuntime"
  29. })) {
  30. const helper = this.addHelper("regeneratorRuntime");
  31. {
  32. if (t.isArrowFunctionExpression(helper)) {
  33. obj.replaceWith(helper.body);
  34. return;
  35. }
  36. }
  37. obj.replaceWith(t.callExpression(helper, []));
  38. }
  39. }
  40. }
  41. };
  42. });
  43. //# sourceMappingURL=index.js.map