Annotating transformed classes with #__PURE__ comment (#6209)
This commit is contained in:
committed by
Henry Zhu
parent
c4f6a7a06f
commit
c47258d68c
@@ -2,6 +2,8 @@ import LooseTransformer from "./loose";
|
||||
import VanillaTransformer from "./vanilla";
|
||||
import nameFunction from "babel-helper-function-name";
|
||||
|
||||
const PURE_ANNOTATION = "#__PURE__";
|
||||
|
||||
export default function({ types: t }) {
|
||||
// todo: investigate traversal requeueing
|
||||
const VISITED = Symbol();
|
||||
@@ -51,11 +53,11 @@ export default function({ types: t }) {
|
||||
|
||||
path.replaceWith(new Constructor(path, state.file).run());
|
||||
|
||||
if (
|
||||
path.isCallExpression() &&
|
||||
path.get("callee").isArrowFunctionExpression()
|
||||
) {
|
||||
path.get("callee").arrowFunctionToExpression();
|
||||
if (path.isCallExpression()) {
|
||||
path.addComment("leading", PURE_ANNOTATION);
|
||||
if (path.get("callee").isArrowFunctionExpression()) {
|
||||
path.get("callee").arrowFunctionToExpression();
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user