babel / minify

:scissors: An ES6+ aware minifier based on the Babel toolchain (beta)
https://babeljs.io/repl
MIT License
4.39k stars 225 forks source link

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

Open conartist6 opened 5 years ago

conartist6 commented 5 years ago

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:

function unused() {
}
class Unused {}
let notReferenced;

expected:

// [empty]