Extracted babel-helper-annotate-as-pure (#6267)

This commit is contained in:
Mateusz Burzyński
2017-09-25 17:40:51 +02:00
committed by GitHub
parent 2374062bbd
commit 413ffe6639
8 changed files with 119 additions and 26 deletions

View File

@@ -6,6 +6,7 @@
"license": "MIT",
"main": "lib/index.js",
"dependencies": {
"babel-helper-annotate-as-pure": "7.0.0-beta.1",
"babel-helper-define-map": "7.0.0-beta.1",
"babel-helper-function-name": "7.0.0-beta.1",
"babel-helper-optimise-call-expression": "7.0.0-beta.1",

View File

@@ -1,9 +1,8 @@
import LooseTransformer from "./loose";
import VanillaTransformer from "./vanilla";
import annotateAsPure from "babel-helper-annotate-as-pure";
import nameFunction from "babel-helper-function-name";
const PURE_ANNOTATION = "#__PURE__";
export default function({ types: t }) {
// todo: investigate traversal requeueing
const VISITED = Symbol();
@@ -57,7 +56,7 @@ export default function({ types: t }) {
path.replaceWith(new Constructor(path, state.file).run());
if (path.isCallExpression()) {
path.addComment("leading", PURE_ANNOTATION);
annotateAsPure(path);
if (path.get("callee").isArrowFunctionExpression()) {
path.get("callee").arrowFunctionToExpression();
}