babel-plugin-debug-macros
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -115,20 +115,26 @@ 'use strict'; | ||
Object.keys(svelteMap[source]).forEach(function (flag) { | ||
path.scope.getBinding(flag).referencePaths.forEach(function (p) { | ||
if (envFlags.DEBUG) { | ||
if (!svelteMap[source][flag]) { | ||
var t = builder.t; | ||
var binding = path.scope.getBinding(flag); | ||
if (binding !== undefined) { | ||
binding.referencePaths.forEach(function (p) { | ||
if (envFlags.DEBUG) { | ||
if (svelteMap[source][flag] === false) { | ||
var t = builder.t; | ||
var consequent = p.parentPath.get('consequent'); | ||
consequent.unshiftContainer('body', builder.t.throwStatement(t.newExpression(t.identifier('Error'), [t.stringLiteral(`You indicated you don't have any deprecations, however you are relying on ${flag}.`)]))); | ||
if (!p.parentPath.isIfStatement()) { | ||
return; | ||
} | ||
var consequent = p.parentPath.get('consequent'); | ||
consequent.unshiftContainer('body', builder.t.throwStatement(t.newExpression(t.identifier('Error'), [t.stringLiteral(`You indicated you don't have any deprecations, however you are relying on ${flag}.`)]))); | ||
} | ||
} else { | ||
if (p.parentPath.isIfStatement()) { | ||
p.replaceWith(builder.t.booleanLiteral(svelteMap[source][flag])); | ||
} | ||
} | ||
} else { | ||
var binding = path.scope.getBinding(flag); | ||
if (binding) { | ||
binding.referencePaths.forEach(function (p) { | ||
return p.replaceWith(builder.t.booleanLiteral(svelteMap[source][flag])); | ||
}); | ||
binding.path.remove(); | ||
} | ||
}); | ||
if (!envFlags.DEBUG && binding) { | ||
binding.path.remove(); | ||
} | ||
}); | ||
} | ||
}); | ||
@@ -135,0 +141,0 @@ }); |
@@ -13,3 +13,3 @@ { | ||
"name": "babel-plugin-debug-macros", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"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
25283
573