Skip to content

Commit

Permalink
Respect ES Version, fixes #745
Browse files Browse the repository at this point in the history
  • Loading branch information
VastBlast committed Sep 13, 2024
1 parent 400c636 commit d10da8a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions js/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d10da8a

Please sign in to comment.