index.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 regex() {
  14. const data = _interopRequireWildcard(require("@babel/helper-regex"));
  15. regex = function () {
  16. return data;
  17. };
  18. return data;
  19. }
  20. function _core() {
  21. const data = require("@babel/core");
  22. _core = function () {
  23. return data;
  24. };
  25. return data;
  26. }
  27. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
  28. var _default = (0, _helperPluginUtils().declare)(api => {
  29. api.assertVersion(7);
  30. return {
  31. name: "transform-sticky-regex",
  32. visitor: {
  33. RegExpLiteral(path) {
  34. const {
  35. node
  36. } = path;
  37. if (!regex().is(node, "y")) return;
  38. path.replaceWith(_core().types.newExpression(_core().types.identifier("RegExp"), [_core().types.stringLiteral(node.pattern), _core().types.stringLiteral(node.flags)]));
  39. }
  40. }
  41. };
  42. });
  43. exports.default = _default;