babel / babel/minify

Eliminate if statements when condition is provably true/false

Open
#930 2 comments 4 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.