Latest Results
fix(es/minifier): Compress for-if-else-break with a bare loop body
**Description:**
`optimize_for_if_break` handles both `if (t) break;` and `if (t) cons; else
break;`, but only when the loop body is a `BlockStmt`. `merge_for_if_break`
covers the bare-body form, but only for a `break` in the consequent. A bare
body with the `break` in the alternate was the one combination no pass
handled.
An earlier pass unwraps single-statement blocks before either runs, so
`for (; bar();) { if (foo()) baz(); else break; }` reaches them in the bare
form too and was missed as well.
Since the `break` is in the alternate, the test is already the condition for
continuing the loop and is not negated, matching the existing block-body arm.
The consequent becomes the loop body rather than being dropped, so jumps
inside it keep targeting this loop. A declaration is skipped: it is valid as
an `if` branch under Annex B, but never as a bare loop body.
Validation: `cargo test -p swc_ecma_minifier` (3098 passed, 0 failed),
`./scripts/exec.sh` (488 and 2128 passed, 0 failed), `cargo fmt --all`,
`cargo clippy -p swc_ecma_minifier --all-targets -- -D warnings`.
**BREAKING CHANGE:** None
**Related issue (if exists):** Nonebaltasarblanco:fix/minifier-for-if-else-break Latest Branches
0%
JohannesGezachew:fix-12282-array-spread-seq +2%
baltasarblanco:fix/minifier-for-if-else-break +2%
fix/parser-type-string-exports © 2026 CodSpeed Technology