TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Tiny Treeshaker: JavaScript tree shaking in 200 lines of code

62 pointsby markl42almost 4 years ago

8 comments

Waterluvianalmost 4 years ago
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 未加载
barbazooalmost 4 years ago
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 未加载
geokonalmost 4 years ago
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 未加载
esperentalmost 4 years ago
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 未加载
tonyedgecombealmost 4 years ago
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>
tyingqalmost 4 years ago
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 未加载
Tade0almost 4 years ago
I love the function and variable names - straight to the point, without trying hard to be too precise.
somehnacct3757almost 4 years ago
Will the need for bundling and tree-shaking still be so great with HTTP&#x2F;2 and js module support in browsers?
评论 #27673775 未加载