Suboptimal minification when safe logical assignments are possible
Author: fabiospampinatoCreated Jul 8, 2026Updated Sep 14, 2026
Labelssuboptimal-output
Basically using these flags:
--minify --target=esnextAnd this input code:
let foo;
foo = foo || 1;
export {foo}We get this output code:
let o;o=o||1;export{o as foo};But I think we should really be getting this:
let o;o||=1;export{o as foo};I understand in the presence of setters and proxies this may lead to slightly different execution, but there are some basic cases where we are sure we are not triggering a setter nor a proxy trap, like this one, so presumably the better minification should be emitted.
Source: evanw/esbuild