babel-plugin-conditional-compile
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -40,5 +40,5 @@ 'use strict'; | ||
//not a block | ||
path.replaceWith(node || types.emptyStatement()); | ||
node ? path.replaceWith(node) : path.remove(); | ||
} else if (Object.getOwnPropertyNames(scope.bindings).length != 0) { | ||
path.replaceWith(node || types.emptyStatement()); | ||
node ? path.replaceWith(node) : path.remove(); | ||
} else { | ||
@@ -50,2 +50,15 @@ //no declaration in scope | ||
} | ||
}, | ||
LogicalExpression: { | ||
exit: function exit(path) { | ||
var operator = path.node.operator; | ||
var left = path.get('left'); | ||
var right = path.get('right'); | ||
var leftVal = left.evaluate(); | ||
if (operator == '||' && leftVal.confident) { | ||
path.replaceWith(leftVal.value ? left : right); | ||
} else if (operator == '&&' && leftVal.confident) { | ||
path.replaceWith(leftVal.value ? right : left); | ||
} | ||
} | ||
} | ||
@@ -82,4 +95,4 @@ } | ||
default: | ||
throw Error('not support:' + type); | ||
throw Error('not support:' + type + ' as conditional variable'); | ||
} | ||
} |
{ | ||
"name": "babel-plugin-conditional-compile", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "babel plugin for conditional compile", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52450
16
117
1