mishoo/UglifyJS — Issue #284: code folding on dependent constants doesn't work
Author: yodaiken
Created: 2011-12-23 22:25:56+00:00
State: open

Input:

(function(){
var COND = true;
var myfunc = function() {
// do expensive stuff
};
var DEPCOND = (COND) ? true : myfunc(); // will always be true
if (DEPCOND) {
console.log("that was easy.");
} else {
// do lots
// and lots
// and lots
// of stuff
(function(){
console.log("that was hard");
})();
}
})();

Current uglify w/ beautifier output:

(function() {
var a = !0, b = function() {}, c = a ? !0 : b();
c ? console.log("that was easy.") : function() {
console.log("that was hard");
}();
})();

Ideal output:

(function() {
console.log("that was easy");
})();