Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-minify-dead-code-elimination

Package Overview
Dependencies
Maintainers
5
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-minify-dead-code-elimination - npm Package Compare versions

Comparing version 0.5.0-alpha.540d75e7 to 0.5.0-alpha.5a128fd5

39

lib/index.js

@@ -278,6 +278,10 @@ "use strict";

if (p.isAssignmentExpression() && !p.get("right").isPure()) {
mutations.push(() => p.replaceWith(p.get("right")));
} else {
mutations.push(() => removeOrVoid(p));
if (p.isAssignmentExpression()) {
if (t.isArrayPattern(p.node.left) || t.isObjectPattern(p.node.left)) {
bail = true;
} else if (p.get("right").isPure()) {
mutations.push(() => removeOrVoid(p));
} else {
mutations.push(() => p.replaceWith(p.get("right")));
}
}

@@ -609,6 +613,27 @@ });

exit(path) {
const evaluated = evaluate(path.get("discriminant"), {
const discriminantPath = path.get("discriminant");
const evaluated = evaluate(discriminantPath, {
tdz: this.tdz
});
if (!evaluated.confident) return;
if (!evaluated.confident) return; // the simplify transformation might have brought in the previous
// expressions into the switch's test expression and instead of
// bailing out of impure path, we collect the impurities of it's
// a sequence expression and bail out if the primary test itself
// is impure
let beforeTest = [];
if (t.isSequenceExpression(discriminantPath.node)) {
const expressions = discriminantPath.get("expressions");
const lastExpression = expressions[expressions.length - 1];
if (!lastExpression.isPure()) {
return;
}
beforeTest = [t.expressionStatement(t.sequenceExpression(expressions.slice(0, expressions.length - 1).map(path => path.node)))];
} else if (!discriminantPath.isPure()) {
return;
}
const discriminant = evaluated.value;

@@ -658,3 +683,3 @@ const cases = path.get("cases");

replaceSwitch([...extractVars(path), ...result.statements]);
replaceSwitch([...extractVars(path), ...beforeTest, ...result.statements]);

@@ -661,0 +686,0 @@ function getStatementsUntilBreak(start) {

8

package.json
{
"name": "babel-plugin-minify-dead-code-elimination",
"version": "0.5.0-alpha.540d75e7",
"version": "0.5.0-alpha.5a128fd5",
"description": "",

@@ -15,7 +15,7 @@ "keywords": [

"dependencies": {
"babel-helper-evaluate-path": "^0.5.0-alpha.540d75e7",
"babel-helper-mark-eval-scopes": "^0.5.0-alpha.540d75e7",
"babel-helper-remove-or-void": "^0.5.0-alpha.540d75e7",
"babel-helper-evaluate-path": "^0.5.0-alpha.5a128fd5",
"babel-helper-mark-eval-scopes": "^0.5.0-alpha.5a128fd5",
"babel-helper-remove-or-void": "^0.5.0-alpha.5a128fd5",
"lodash.some": "^4.6.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc