add extra note to minification dead code elimination transformer

This commit is contained in:
Sebastian McKenzie 2015-02-13 15:09:17 +11:00
parent 0a4fc16ca0
commit 6be2a6e02a

View File

@ -4,6 +4,7 @@ exports.optional = true;
exports.ExpressionStatement = function (node) {
// remove consequenceless expressions such as local variables and literals
// note: will remove directives
//
// var foo = true; foo; -> var foo = true;
// "foo"; ->
@ -66,8 +67,7 @@ exports.IfStatement = {
// if (foo) {} else { bar; } -> if (!foo) { bar; }
//
if (t.blockStatement(consequent) && !consequent.body.length &&
t.isBlockStatement(alternate) && alternate.body.length) {
if (t.blockStatement(consequent) && !consequent.body.length && t.isBlockStatement(alternate) && alternate.body.length) {
node.consequent = node.alternate;
node.alternate = null;
node.test = t.unaryExpression("!", test, true);