Why is my ES6 webpack bundle larger when using default imports instead of named imports?

Tree shaking, is part of the minification process. In dev bundles this process is not applied.

Try to run in "production" mode, and compare the results.


No, it shouldn't. It very depends on how internal libs are organized.

  • If it uses require inside, the lib will not be shaked
  • If it uses import * inside and uses this package, the whole * will be included
  • Even! if it uses import {name} from './names' it still might not be tree-shaked

There is a good starting article about how tree shaking works and how to help it: https://webpack.js.org/guides/tree-shaking/