Eliminate if statements when condition is provably true/false
Open
- Dominant language
- JavaScript
- Stars
- 4.4k
- Forks
- 217
- PR merge metrics
- No merged PRs in 30d
Description
Assume the following code:
```
function foo() {
if (bar() || true) {
baz();
} else {
NOT_REACHABLE();
}
}
```
Currently, babel-minify transforms this to:
```
function foo(){bar()||!0?baz():NOT_REACHABLE()}foo();
```
UglifyJS3 transforms to:
```
function foo(){bar(),baz()}foo();
```
It would be nice if babel-minify could eliminate the `if` statement entirely.
Contributor guide
Assessment
This issue has not been assessed yet.