Last change
on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
516 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | "use strict";
|
---|
| 2 |
|
---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
---|
| 4 | value: true
|
---|
| 5 | });
|
---|
| 6 | exports.default = annotateAsPure;
|
---|
| 7 |
|
---|
| 8 | var t = require("@babel/types");
|
---|
| 9 |
|
---|
| 10 | const PURE_ANNOTATION = "#__PURE__";
|
---|
| 11 |
|
---|
| 12 | const isPureAnnotated = ({
|
---|
| 13 | leadingComments
|
---|
| 14 | }) => !!leadingComments && leadingComments.some(comment => /[@#]__PURE__/.test(comment.value));
|
---|
| 15 |
|
---|
| 16 | function annotateAsPure(pathOrNode) {
|
---|
| 17 | const node = pathOrNode["node"] || pathOrNode;
|
---|
| 18 |
|
---|
| 19 | if (isPureAnnotated(node)) {
|
---|
| 20 | return;
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | t.addComment(node, "leading", PURE_ANNOTATION);
|
---|
| 24 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.