Rich-Harris / butternut

The fast, future-friendly minifier
https://butternut.now.sh
MIT License
1.17k stars 17 forks source link

Remove dead code blocks #70

Open darsain opened 7 years ago

darsain commented 7 years ago

In this example:

let foo = false;
if (foo) console.log('ohno');

The whole if block should get removed. This is very useful for removing development only code blocks from production builds. Example:

if (process.env.NODE_ENV === 'development') {
  // do stuff
}

// before minification this gets transformed into
if ('production' === 'development') {
  // do stuff
}
Rich-Harris commented 7 years ago

Funny you should raise this, it's what I'm currently working on 😀

Rich-Harris commented 7 years ago

Actually, I take it back — the initial case, where foo isn't replaced inline, isn't handled yet. It's planned though!