coderaiser / minify

Minifier of js, css, html and img
https://coderaiser.github.io/minify
MIT License
228 stars 29 forks source link

Incorrect javascript produced for nested single line if..else statements. v10.3.0-v11.0.1 #118

Closed Aglartur closed 8 months ago

Aglartur commented 9 months ago

I encountered an error where incorrect javascript is produced when minifed. Surprisingly it works in 9.2.0 Original code:

let a;
let b;

if (a) {
  if (b) {
    console.log("a and b are truthy");
  } else {
    console.log("a is truthy, b is falsy");
  }
}

Incorrect code (v10.3.0-v11.0.1). If a is falsy, then console.log("a is truthy, b is falsy")' gets triggered incorrectly.

let a;
let b;
a && b
  ? console.log("a and b are truthy")
  : console.log("a is truthy, b is falsy");

Correct code (v9.2.0)

let a, b;
a &&
  (b
    ? console.log("a and b are truthy")
    : console.log("a is truthy, b is falsy"));
coderaiser commented 9 months ago

Just fixed in @putout/minify@3.7.0, please re-install Minify, is it works for you?