babel-plugin-mobx-observer-on-every-react-component
Advanced tools
Comparing version
@@ -190,3 +190,11 @@ "use strict"; | ||
]); | ||
path.replaceWith(variableDeclaration); | ||
// now check to see if the function declaration is exported. If it is, we need to replace | ||
// the functione with the observer-wrapped function and then export it | ||
// If it's not exported, we can just replace the functoin with the variable declaration | ||
if (path.parentPath.isExportDefaultDeclaration()) { | ||
path.parentPath.replaceWith(t.exportDefaultDeclaration(observerFunction)); | ||
} | ||
else { | ||
path.replaceWith(variableDeclaration); | ||
} | ||
} | ||
@@ -193,0 +201,0 @@ else { |
@@ -165,3 +165,11 @@ import { declare } from "@babel/helper-plugin-utils"; | ||
]); | ||
path.replaceWith(variableDeclaration); | ||
// now check to see if the function declaration is exported. If it is, we need to replace | ||
// the functione with the observer-wrapped function and then export it | ||
// If it's not exported, we can just replace the functoin with the variable declaration | ||
if (path.parentPath.isExportDefaultDeclaration()) { | ||
path.parentPath.replaceWith(t.exportDefaultDeclaration(observerFunction)); | ||
} | ||
else { | ||
path.replaceWith(variableDeclaration); | ||
} | ||
} | ||
@@ -168,0 +176,0 @@ else { |
{ | ||
"name": "babel-plugin-mobx-observer-on-every-react-component", | ||
"version": "0.1.15", | ||
"version": "0.1.16", | ||
"description": "Wrap literally every React component in an MobX observer higher order component.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -248,4 +248,12 @@ import { declare } from "@babel/helper-plugin-utils"; | ||
// now check to see if the function declaration is exported. If it is, we need to replace | ||
// the functione with the observer-wrapped function and then export it | ||
// If it's not exported, we can just replace the functoin with the variable declaration | ||
if (path.parentPath.isExportDefaultDeclaration()) { | ||
path.parentPath.replaceWith(t.exportDefaultDeclaration(observerFunction)); | ||
} else { | ||
path.replaceWith(variableDeclaration); | ||
} else { | ||
} | ||
} else { | ||
// Replace the old function declaration with the new variable declaration | ||
@@ -252,0 +260,0 @@ path.replaceWith(observerFunction); |
60767
2.76%1029
2.29%