diff --git a/js/util.go b/js/util.go index 005e784b2..1ef4067f9 100644 --- a/js/util.go +++ b/js/util.go @@ -822,10 +822,13 @@ func (m *jsMinifier) optimizeCondExpr(expr *js.CondExpr, prec js.OpPrec) js.IExp } else if isEqualExpr(expr.X, expr.Y) { // if true and false bodies are equal return groupExpr(&js.CommaExpr{[]js.IExpr{expr.Cond, expr.X}}, prec) - } else if nullishExpr, ok := toNullishExpr(expr); ok && m.o.minVersion(2020) { - // no need to check whether left/right need to add groups, as the space saving is always more - return nullishExpr } else { + if m.o.minVersion(2020) { + if nullishExpr, ok := toNullishExpr(expr); ok { + // no need to check whether left/right need to add groups, as the space saving is always more + return nullishExpr + } + } callX, isCallX := expr.X.(*js.CallExpr) callY, isCallY := expr.Y.(*js.CallExpr) if isCallX && isCallY && len(callX.Args.List) == 1 && len(callY.Args.List) == 1 && !callX.Args.List[0].Rest && !callY.Args.List[0].Rest && isEqualExpr(callX.X, callY.X) {