babel-plugin-debug-macros
Advanced tools
Comparing version 0.1.10 to 0.1.11
@@ -26,3 +26,2 @@ 'use strict'; | ||
this.localDebugBindings = []; | ||
this.isImportRemovable = false; | ||
this.envFlagBindings = []; | ||
@@ -84,8 +83,8 @@ this.hasEnvFlags = false; | ||
Object.keys(featuresMap[source]).forEach(function (flag) { | ||
var flagValue = featuresMap[source][flag]; | ||
var binding = path.scope.getBinding(flag); | ||
if (binding && featuresMap[source][flag] !== null) { | ||
binding.referencePaths.forEach(function (p) { | ||
if (p.parentPath.isIfStatement() || p.parentPath.isLogicalExpression() && p.parentPath.parentPath && p.parentPath.parentPath.isIfStatement()) { | ||
p.replaceWith(builder.t.booleanLiteral(featuresMap[source][flag])); | ||
} | ||
if (binding && flagValue !== null) { | ||
binding.referencePaths.forEach(function (referencePath) { | ||
referencePath.replaceWith(builder.t.booleanLiteral(flagValue)); | ||
}); | ||
@@ -165,5 +164,2 @@ | ||
this._collectImportBindings(specifiers, this.localDebugBindings); | ||
if (specifiers.length === this.localDebugBindings.length) { | ||
this.isImportRemovable = true; | ||
} | ||
} | ||
@@ -253,3 +249,9 @@ }, { | ||
if (this.localDebugBindings.length > 0) { | ||
if (this.isImportRemovable) { | ||
this.localDebugBindings[0].parentPath.parentPath; | ||
var importPath = this.localDebugBindings[0].findParent(function (p) { | ||
return p.isImportDeclaration(); | ||
}); | ||
var specifiers = importPath.get('specifiers'); | ||
if (specifiers.length === this.localDebugBindings.length) { | ||
this.localDebugBindings[0].parentPath.parentPath.remove(); | ||
@@ -256,0 +258,0 @@ } else { |
@@ -13,3 +13,3 @@ { | ||
"name": "babel-plugin-debug-macros", | ||
"version": "0.1.10", | ||
"version": "0.1.11", | ||
"description": "Debug macros and feature flag stripping", | ||
@@ -16,0 +16,0 @@ "main": "dist/index.js", |
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
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
27134