babel / babel/minify

Unused class declaration is not removed

Open
#650 5 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
4.4k
Forks
217
PR merge metrics
No merged PRs in 30d

Description

If you minify the following functions only one of the unused class declarations is removed.

```js
function fn(base) {
class foo extends base {}
}
function fn2(base) {
class bar extends base.prop {}
}
```
Becomes:
```js
function fn(a){}
function fn2(a){class b extends a.prop{}}
```

Obviously this is a contrived example but in my application this is causing a large tree of unused classes to make it into the client bundle.

I'm just testing on the command line with `babel`:
```
cat example.js | babel --presets=babili
```

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.