babel-plugin-vdux-transform
Advanced tools
Comparing version 1.0.5 to 1.1.0
@@ -23,2 +23,6 @@ 'use strict'; | ||
function isVduxLikeComponent(node) { | ||
return t.isCallExpression(node) && node.callee.name === 'component' && isVduxLikeComponentObject(node.arguments[0]); | ||
} | ||
function isHocComponent(node, hoc) { | ||
@@ -116,3 +120,3 @@ if (t.isCallExpression(node)) { | ||
CallExpression: function CallExpression(path) { | ||
if (path.node[VISITED_KEY] || !isHocComponent(path.node, this.options.hoc)) { | ||
if (path.node[VISITED_KEY] || !isHocComponent(path.node, this.options.hoc) && !isVduxLikeComponent(path.node)) { | ||
return; | ||
@@ -134,23 +138,25 @@ } | ||
path.replaceWith(wrapComponent(path.node, componentId, this.wrapperFunctionId)); | ||
}, | ||
ObjectExpression: function ObjectExpression(path) { | ||
if (path.node[VISITED_KEY] || !isVduxLikeComponentObject(path.node)) { | ||
return; | ||
} | ||
} | ||
path.node[VISITED_KEY] = true; | ||
// ObjectExpression (path) { | ||
// if (path.node[VISITED_KEY] || !isVduxLikeComponentObject(path.node)) { | ||
// return | ||
// } | ||
// `foo({ displayName: 'NAME' })` => 'NAME' | ||
var componentName = getDisplayName(path.node); | ||
var componentId = componentName || path.scope.generateUid('component'); | ||
var isInFunction = hasParentFunction(path); | ||
// path.node[VISITED_KEY] = true | ||
this.components.push({ | ||
id: componentId, | ||
name: componentName, | ||
isInFunction: isInFunction | ||
}); | ||
// // `foo({ displayName: 'NAME' })` => 'NAME' | ||
// const componentName = getDisplayName(path.node) | ||
// const componentId = componentName || path.scope.generateUid('component') | ||
// const isInFunction = hasParentFunction(path) | ||
path.replaceWith(wrapComponent(path.node, componentId, this.wrapperFunctionId)); | ||
} | ||
// this.components.push({ | ||
// id: componentId, | ||
// name: componentName, | ||
// isInFunction: isInFunction | ||
// }) | ||
// path.replaceWith(wrapComponent(path.node, componentId, this.wrapperFunctionId)) | ||
// } | ||
}; | ||
@@ -157,0 +163,0 @@ |
{ | ||
"name": "babel-plugin-vdux-transform", | ||
"version": "1.0.5", | ||
"version": "1.1.0", | ||
"description": "Babel plugin to instrument vdux components with custom transforms", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
32261
774