2023-12-18 13:12:25 +08:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
value: true
|
|
|
|
});
|
|
|
|
exports.default = annotateAsPure;
|
2024-01-16 21:26:16 +08:00
|
|
|
var _t = require("@babel/types");
|
|
|
|
const {
|
|
|
|
addComment
|
|
|
|
} = _t;
|
2023-12-18 13:12:25 +08:00
|
|
|
const PURE_ANNOTATION = "#__PURE__";
|
|
|
|
const isPureAnnotated = ({
|
|
|
|
leadingComments
|
|
|
|
}) => !!leadingComments && leadingComments.some(comment => /[@#]__PURE__/.test(comment.value));
|
|
|
|
function annotateAsPure(pathOrNode) {
|
2024-01-16 21:26:16 +08:00
|
|
|
const node = pathOrNode["node"] || pathOrNode;
|
2023-12-18 13:12:25 +08:00
|
|
|
if (isPureAnnotated(node)) {
|
|
|
|
return;
|
|
|
|
}
|
2024-01-16 21:26:16 +08:00
|
|
|
addComment(node, "leading", PURE_ANNOTATION);
|
|
|
|
}
|
2023-12-18 13:12:25 +08:00
|
|
|
|
2024-01-16 21:26:16 +08:00
|
|
|
//# sourceMappingURL=index.js.map
|