2 ms·
I really don't understand the difference. Please enlighten me.
by Kiro 5y ago
I really don't understand the difference. Please enlighten me.
- bschlenk1 5y agoAll tree shaking is dead code elimination, but not all dead code elimination is tree shaking (in webpack at least). Tree shaking happens at the import level. If I say `import { abc } from 'some-lib'`, tree shaking won’t include any other objects some-lib may export. Removing a branch that can never be true, like `if ('production' === 'production') { … } else { /* dead code */ }` is dead code elimination, but webpack wouldn’t consider that tree shaking.