Describe the bug
Minification produces output where a variable is only minified sometimes within a function. Thanks for your help!
To Reproduce
Minimal code to reproduce the bug
function foo() {
let varName = [];
while (false) {}
varName;
}
Actual Output
"use strict";
function foo(){
for(var a=[];false;);
varName
}
Expected Output
I'm not sure if it's expected to pull the varName variable into the loop in this circumstance, so the expected output is one of the following:
"use strict";
function foo(){
for(var a=[];false;);
a
}
or
"use strict";
function foo(){
var a=[];
for(;false;);
a
}
Configuration
Turning off all minify plugins except for mangle and simplify (bug requires both).
npx babel ./src --out-dir ./lib
babel-minify version: 0.5.1
babel core : 7.11.6
babel-minify-config:
{
"mangle": true,
"simplify": true,
"evaluate": false,
"replace": false,
"booleans": false,
"builtIns": false,
"consecutiveAdds": false,
"deadcode": false,
"flipComparisons": false,
"guards": false,
"infinity": false,
"memberExpressions": false,
"mergeVars": false,
"numericLiterals": false,
"propertyLiterals": false,
"regexpConstructors": false,
"removeConsole": false,
"removeDebugger": false,
"removeUndefined": false,
"simplifyComparisons": false,
"typeConstructors": false,
"undefinedToVoid": false
}
babelrc:
module.exports = {
presets: [
'@babel/preset-env',
['minify', {
"mangle": true,
"simplify": true,
"evaluate": false,
"replace": false,
"booleans": false,
"builtIns": false,
"consecutiveAdds": false,
"deadcode": false,
"flipComparisons": false,
"guards": false,
"infinity": false,
"memberExpressions": false,
"mergeVars": false,
"numericLiterals": false,
"propertyLiterals": false,
"regexpConstructors": false,
"removeConsole": false,
"removeDebugger": false,
"removeUndefined": false,
"simplifyComparisons": false,
"typeConstructors": false,
"undefinedToVoid": false
}]
],
plugins: [
],
}
Possible solution
Not sure. But it appears the logic in this region may need to be improved, when it decides if a variable is referenced outside the loop.
Describe the bug
Minification produces output where a variable is only minified sometimes within a function. Thanks for your help!
To Reproduce
Minimal code to reproduce the bug
Actual Output
Expected Output
I'm not sure if it's expected to pull the
varNamevariable into the loop in this circumstance, so the expected output is one of the following:or
Configuration
Turning off all minify plugins except for
mangleandsimplify(bug requires both).babel-minify version:
0.5.1babel core :
7.11.6babel-minify-config:
babelrc:
Possible solution
Not sure. But it appears the logic in this region may need to be improved, when it decides if a variable is referenced outside the loop.