babel / babel/minify

dead-code-elimiation doesn't remove unused top level code

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

Description

For unused top level statements and expressions in module sources, dead-code-elimination does nothing, while in fact it is safe to remove them.

actual:
```js
function unused() {
}
class Unused {}
let notReferenced;
```

expected:
```js
// [empty]
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with the provided module-source example and inspect the dead-code-elimination entry point for how it handles top-level statements and expressions. Done means unused top-level functions, classes, and variables are removed while the example produces an empty output.

Written by the indexing model from the issue text.

Assessment

Tech stack
babel, javascript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.