-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
I was trying to get tree shaking working. Here are a few notes about the tree shaking and production guides:
The article explains what tree shaking is (really well), but it doesn't really cover how to achieve it.
--optimize-minimize
will do it, but that also throws in uglify, which can make it difficult to confirm if treeshaking has worked, and will throw errors if you're using ES2016+.
One of the guides should cover how to enable tree shaking without enabling other optimisations. This will help users confirm that code is being removed, without having to read minified code.
The production guide should cover how to avoid errors when using ES2016+, either by using the uglify harmony branch, or BabiliWebpackPlugin. None of the docs I've seen cover how to use BabiliWebpackPlugin instead of uglify while retaining tree shaking.
Tree shaking will break if using babel + the es2015 preset, as it transpiles the imports. I've filed babel/babel-loader#477, but it may be worth mentioning in the guide too.