index.js 919 B

123456789101112131415161718192021222324252627282930313233
  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 = exports.default = (0, _helperPluginUtils.declare)(api => {
  8. api.assertVersion(7);
  9. const regex = /(\\*)([\u2028\u2029])/g;
  10. function replace(match, escapes, separator) {
  11. const isEscaped = escapes.length % 2 === 1;
  12. if (isEscaped) return match;
  13. return `${escapes}\\u${separator.charCodeAt(0).toString(16)}`;
  14. }
  15. return {
  16. name: "transform-json-strings",
  17. inherits: require("@babel/plugin-syntax-json-strings").default,
  18. visitor: {
  19. "DirectiveLiteral|StringLiteral"({
  20. node
  21. }) {
  22. const {
  23. extra
  24. } = node;
  25. if (!(extra != null && extra.raw)) return;
  26. extra.raw = extra.raw.replace(regex, replace);
  27. }
  28. }
  29. };
  30. });
  31. //# sourceMappingURL=index.js.map