DEV Community

Cover image for Your Bundle is Lying to You: Hidden Costs of Tree-Shaking

Your Bundle is Lying to You: Hidden Costs of Tree-Shaking

Abhinav Shinoy on June 06, 2025

We’ve all heard it: “It’s fine, unused code gets tree-shaken out.” But here’s the truth… Your bundle is lying to you. And tree-shaking isn't t...
Collapse
 
nevodavid profile image
Nevo David

yeah this is honestly spot on, every time i think the build is clean something sneaks in - you think there's a way to really trust your bundle or is it just endless checking?

Collapse
 
abhinavshinoy90 profile image
Abhinav Shinoy

Right? It always feels like a game of whack-a-mole 😅
I don’t think it ever gets to set-it-and-forget-it — but setting up a visualizer in your CI (like source-map-explorer or vite-plugin-visualizer) helps catch sneaky changes early.
Not perfect, but way better than chasing surprises after deploy.

Collapse
 
fstrube profile image
Franklin Strube

Great article. Thanks for sharing!

Collapse
 
abhinavshinoy90 profile image
Abhinav Shinoy

Thanks @fstrube !

Collapse
 
javascriptwizzard profile image
Pradeep

Great post @abhinavshinoy90 !

Collapse
 
abhinavshinoy90 profile image
Abhinav Shinoy
Collapse
 
dotallio profile image
Dotallio

So true about side effects sneaking into bundles, even when you think you’ve done everything right. What’s the sneakiest thing you’ve found lurking in your own builds?

Collapse
 
abhinavshinoy90 profile image
Abhinav Shinoy

One time it was a datepicker that pulled in all of Moment.js, just from one import 😬
We thought we were safe, but it added 200KB+ until we caught it in the analyzer!

Collapse
 
nathan_tarbert profile image
Nathan Tarbert

Pretty cool, honestly makes me second guess how much I rely on my build tools without actually checking what's in there

Collapse
 
abhinavshinoy90 profile image
Abhinav Shinoy

Totally get that — build tools are powerful, but they can lull you into a false sense of security. A quick peek at the bundle now and then can be super eye-opening!

Collapse
 
vetriselvan_11 profile image
vetriselvan Panneerselvam

Great article

Collapse
 
abhinavshinoy90 profile image
Abhinav Shinoy