文章预览
在本文开始之前需要郑重的感谢下开源前辈 Farm ,Mako 的 tree shaking 算法大量的参考( 抄 )了 Farm 的实现。在 Mako 实现 tree shaking 之初,我们一头雾水毫无头绪,有前辈的无私的领路才让 Mako 成为可能。感恩,感谢! 什么是 tree shaking 先看下 Wiki 上的定义 。 In computing, tree shaking is a dead code elimination technique that is applied when optimizing code. Often contrasted with traditional single-library dead code elimination techniques common to minifiers, tree shaking eliminates unused functions from** across** the bundle by starting at the entry point and only including functions that may be executed. It is succinctly described as "live code inclusion". 简单总结下。 tree shaking 是一种死代码删除 (dead code elimination) 技术 tree shaking 根据模块间(across)的信息来完成死代码的删除的 Tree shaking 利用的是模块间的信息,进行的 dead code 删除。dea
………………………………