minify-js
minify-js copied to clipboard
minimization invents variables, undefined
minimize this code
for(let n=0;n<0;n++){Z((5+n)*8,5*8)}
with this code
fn main() {
let mut o = vec![];
minify_js::minify(
&Session::new(),
minify_js::TopLevelMode::Global,
b"for(let n=0;n<0;n++){Z((5+n)*8,5*8)}",
&mut o,
)
.unwrap();
dbg!(String::from_utf8(o).unwrap());
}
and you get
for(let a=b;a<b;a++){Z((c+ a)*d,c*d)}
which fails with
Uncaught ReferenceError: b is not defined
I am having the same issue. I use minify-js via minify-html. I have a function
function convertCtoF(val) {
return Math.round((val * 1.8 + 32) * 10) / 10;
}
and it gets minified to
var convertCtoF = (a => Math.round((a * 1.8 + 32) * b) / b);
and I am having Uncaught ReferenceError: b is not defined
Running into the same problem, turning
const getOpposite = (language) => language == "teal" ? "lua" : "teal"
into
const getOpposite = (a) => (a == b ? `lua` : b);