babel-plugin-minify-dead-code-elimination
Advanced tools
Comparing version 0.2.0 to 0.3.0-alpha.da60c6b8
@@ -472,2 +472,3 @@ "use strict"; | ||
}; | ||
var isReplacementObj = isObj(replacement) || some(replacement, isObj); | ||
@@ -479,2 +480,31 @@ | ||
// check if it's safe to replace | ||
// To solve https://github.com/babel/minify/issues/691 | ||
// Here we bail for property checks using the "in" operator | ||
// This is because - `in` is a side-effect-free operation but the property | ||
// could be deleted between the replacementPath and referencePath | ||
// It is expensive to compute the delete operation and we bail for | ||
// all the binary "in" operations | ||
var inExpression = replacementPath.isBinaryExpression({ | ||
operator: "in" | ||
}); | ||
if (!inExpression) { | ||
replacementPath.traverse({ | ||
Function(path) { | ||
path.skip(); | ||
}, | ||
BinaryExpression(path) { | ||
if (path.node.operator === "in") { | ||
inExpression = true; | ||
path.stop(); | ||
} | ||
} | ||
}); | ||
} | ||
if (inExpression) { | ||
return "continue"; | ||
} | ||
var replaced = replace(binding.referencePaths[0], { | ||
@@ -1011,3 +1041,7 @@ binding, | ||
declarators.push(t.variableDeclarator(decl.id)); | ||
var bindingIds = Object.keys(t.getBindingIdentifiers(decl.id)); | ||
declarators.push.apply(declarators, _toConsumableArray(bindingIds.map(function (name) { | ||
return t.variableDeclarator(t.identifier(name)); | ||
}))); | ||
} | ||
@@ -1042,3 +1076,6 @@ } catch (err) { | ||
declarators.push(t.variableDeclarator(_decl.id)); | ||
var _bindingIds = Object.keys(t.getBindingIdentifiers(_decl.id)); | ||
declarators.push.apply(declarators, _toConsumableArray(_bindingIds.map(function (name) { | ||
return t.variableDeclarator(t.identifier(name)); | ||
}))); | ||
} | ||
@@ -1045,0 +1082,0 @@ } catch (err) { |
{ | ||
"name": "babel-plugin-minify-dead-code-elimination", | ||
"version": "0.2.0", | ||
"version": "0.3.0-alpha.da60c6b8", | ||
"description": "", | ||
@@ -15,7 +15,7 @@ "keywords": [ | ||
"dependencies": { | ||
"babel-helper-evaluate-path": "^0.2.0", | ||
"babel-helper-mark-eval-scopes": "^0.2.0", | ||
"babel-helper-remove-or-void": "^0.2.0", | ||
"babel-helper-evaluate-path": "^0.3.0-alpha.da60c6b8", | ||
"babel-helper-mark-eval-scopes": "^0.3.0-alpha.da60c6b8", | ||
"babel-helper-remove-or-void": "^0.3.0-alpha.da60c6b8", | ||
"lodash.some": "^4.6.0" | ||
} | ||
} |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
47417
1221
4
1
+ Addedbabel-helper-evaluate-path@0.3.0(transitive)
+ Addedbabel-helper-mark-eval-scopes@0.3.0(transitive)
+ Addedbabel-helper-remove-or-void@0.3.0(transitive)
- Removedbabel-helper-evaluate-path@0.2.0(transitive)
- Removedbabel-helper-mark-eval-scopes@0.2.0(transitive)
- Removedbabel-helper-remove-or-void@0.2.0(transitive)