Nested if blocks with true conditions are not minified correctly, not even close!
To Reproduce
Minimal code to reproduce the bug
(function () {
let x = 1;
console.log(x);
if (true) {
let x = 2;
if (true) {
let x = 3;
console.log(x);
if (true) {
let x = 4;
console.log(x);
}
}
}
console.log(x);
})();
Console output:
1
3
4
1
Actual Output
"use strict";
(function() {
var a = 1;
console.log(4);
console.log(a);
})();
Console output:
4
1
Expected Output
I don't really care much for what code would be outputted so, take this output with a pinch of salt.
What matters is that the console logs would give the same result.
"use strict";
(function() {
var a = 1;
console.log(a);
console.log(3);
console.log(4);
console.log(a);
})();
Describe the bug
Nested if blocks with true conditions are not minified correctly, not even close!
To Reproduce
Minimal code to reproduce the bug
Console output:
Actual Output
Console output:
Expected Output
I don't really care much for what code would be outputted so, take this output with a pinch of salt. What matters is that the console logs would give the same result.
Configuration
How are you using babel-minify?
I was using the Babel REPL and this bug appeared: https://babeljs.io/en/repl#?babili=true&browsers=&build=&builtIns=false&spec=false&loose=false&code_lz=BQMwrgdgxgLglgewgAmASmQbwFDL8gGwFMZkAPZAXmQEYBuXfKJAZwWIDoCEBzYMtA3zI4IVDABOYIhhzC8xUhWoAmIfNHipMrI2EBIReSrIAzOrz7mENp258BFjWOCTpsvfn2GSx6gBYnb2tbIi5efkFPfQBfTzwY-WRPOOEQ9jD7SPUYtHQ6IA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=script&lineWrap=true&presets=es2015%2Cbabili&prettier=true&targets=&version=6.26.0&envVersion=