Search code examples
javascriptember.jsdead-codetree-shaking

Ember and Dead Code elimination / Tree shaking


I have an app that has a dependency on a few bigger libraries and ember addons. From those dependencies, I use a very small subset of functions and components so I was surprised that in the final output is everything. I would like to stripp off everything that's not used.

Looking over the internet, I wasn't able to find any useful resource about this topic. What's the recommended setup for dead code elimination or tree shaking for Ember app in 2017?

PS: I know that Tree shaking is a bit different than dead code elimination, but the purpose is basically the same.


Solution

  • At the moment there is not an easy way to do so if the addon you use doesn't help with it. The Ember-CLI folks are working on making it easy to swap in any bundle step you want (to experiment with Webpack, Rollup, etc), but at the moment Ember-CLI does a fairly simplistic concatenation/minification.

    More information about the work in progress can be found here: https://github.com/ember-cli/rfcs/pull/110