index.js 574 B

1234567891011121314151617181920212223
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = annotateAsPure;
  6. var _t = require("@babel/types");
  7. const {
  8. addComment
  9. } = _t;
  10. const PURE_ANNOTATION = "#__PURE__";
  11. const isPureAnnotated = ({
  12. leadingComments
  13. }) => !!leadingComments && leadingComments.some(comment => /[@#]__PURE__/.test(comment.value));
  14. function annotateAsPure(pathOrNode) {
  15. const node = pathOrNode["node"] || pathOrNode;
  16. if (isPureAnnotated(node)) {
  17. return;
  18. }
  19. addComment(node, "leading", PURE_ANNOTATION);
  20. }
  21. //# sourceMappingURL=index.js.map