TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Tiny Treeshaker: JavaScript tree shaking in 200 lines of code

62 点作者 markl42将近 4 年前

8 条评论

Waterluvian将近 4 年前
Something that drives me bonkers about current tree shaking is that there’s no good way to see what got shaken.<p>I want a graph that shows me all the branches that got culled.<p>Even better would be a dependency graph that shows me what is causing things not to be culled.<p>I had an issue where Antd was pulling in 200KB of icons and I couldn’t figure out why until I spent hours bisecting it by commenting out entire sections of my application.
评论 #27673838 未加载
评论 #27672632 未加载
barbazoo将近 4 年前
TIL about tree shaking and that that&#x27;s a thing in JS. Is that applicable to other languages? Why not Python?
评论 #27672503 未加载
评论 #27672636 未加载
评论 #27672792 未加载
评论 #27674111 未加载
评论 #27672826 未加载
geokon将近 4 年前
Anyone have any experience using a Java treeshaker? I have a Clojure GUI&#x2F;JFX App that&#x27;s bloated and I&#x27;ve only managed to slim it down with manual package pruning.<p>I couldn&#x27;t get Proguard to work with Clojure. Granted proguard is quite baroque so I probably did something wrong. But maybe there is some simpler solution out there for the JVM? Or would this simply be impossible b&#x2F;c Clojure uses reflection? Though so does Javascript from what I understand..
评论 #27672762 未加载
评论 #27673813 未加载
esperent将近 4 年前
I suspect (although I haven&#x27;t checked the code) that this is actually a &quot;dead code elimination&quot; algorithm which is easier to write than a tree shaking algorithm.<p>Tree-shaking is actually &quot;live code inclusion&quot;, the opposite side of dead code elimination.<p><a href="https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Tree_shaking" rel="nofollow">https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Tree_shaking</a>
评论 #27675635 未加载
评论 #27673340 未加载
tonyedgecombe将近 4 年前
The interesting stuff seems to be going on in <a href="https:&#x2F;&#x2F;github.com&#x2F;facebook&#x2F;jscodeshift" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;facebook&#x2F;jscodeshift</a>
tyingq将近 4 年前
How does treeshaking deal with error paths (or other uncommonly used code paths) that aren&#x27;t often used, but are important not to throw out?
评论 #27675476 未加载
Tade0将近 4 年前
I love the function and variable names - straight to the point, without trying hard to be too precise.
somehnacct3757将近 4 年前
Will the need for bundling and tree-shaking still be so great with HTTP&#x2F;2 and js module support in browsers?
评论 #27673775 未加载