index.js 696 B

1234567891011121314151617181920212223242526272829
  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 _core = require("@babel/core");
  8. var _default = (0, _helperPluginUtils.declare)(api => {
  9. api.assertVersion(7);
  10. return {
  11. name: "transform-sticky-regex",
  12. visitor: {
  13. RegExpLiteral(path) {
  14. const {
  15. node
  16. } = path;
  17. if (!node.flags.includes("y")) return;
  18. path.replaceWith(_core.types.newExpression(_core.types.identifier("RegExp"), [_core.types.stringLiteral(node.pattern), _core.types.stringLiteral(node.flags)]));
  19. }
  20. }
  21. };
  22. });
  23. exports.default = _default;