RsD0p9BK
6/8/2017 - 12:22 PM

colding__Tree_shaking.md

Tree shaking

Tree shaking is a term commonly used in the JavaScript context for dead-code elimination, or more precisely, live-code import. It relies on ES2015 module import/export for the static structure of its module system. The name and concept have been popularized by the ES2015 module bundler rollup.

webpack 2 comes with a built-in support for ES2015 modules (alias harmony modules) as well as unused module export detection.

https://rollupjs.org/repl?version=0.41.6&shareable=JTdCJTIybW9kdWxlcyUyMiUzQSU1QiU3QiUyMm5hbWUlMjIlM0ElMjJtYWluLmpzJTIyJTJDJTIyY29kZSUyMiUzQSUyMmltcG9ydCUyMCU3QiUyME1hdGglMjAlN0QlMjBmcm9tJTIwJy4lMkZleHBvcnRzLmpzJyUzQiU1Q25jb25zb2xlLmxvZyglMjBNYXRoLmN1YmUoJTIwNSUyMCklMjApJTNCJTIwJTJGJTJGJTIwMTI1JTIyJTdEJTJDJTdCJTIybmFtZSUyMiUzQSUyMmV4cG9ydHMuanMlMjIlMkMlMjJjb2RlJTIyJTNBJTIyaW1wb3J0JTIwKiUyMGFzJTIwTWF0aCUyMGZyb20lMjAnLiUyRm1hdGgtdXRpbHMnJTNCJTVDbmV4cG9ydCUyMCU3Qk1hdGglN0QlM0IlMjIlN0QlMkMlN0IlMjJuYW1lJTIyJTNBJTIybWF0aC11dGlscy5qcyUyMiUyQyUyMmNvZGUlMjIlM0ElMjIlMkYlMkYlMjBUaGlzJTIwZnVuY3Rpb24lMjBpc24ndCUyMHVzZWQlMjBhbnl3aGVyZSUyQyUyMHNvJTVDbiUyRiUyRiUyMFJvbGx1cCUyMGV4Y2x1ZGVzJTIwaXQlMjBmcm9tJTIwdGhlJTIwYnVuZGxlLi4uJTVDbmV4cG9ydCUyMGZ1bmN0aW9uJTIwc3F1YXJlJTIwKCUyMHglMjApJTIwJTdCJTVDbiU1Q3RyZXR1cm4lMjB4JTIwKiUyMHglM0IlNUNuJTdEJTVDbiU1Q24lMkYlMkYlMjBUaGlzJTIwZnVuY3Rpb24lMjBnZXRzJTIwaW5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