Anyone have a tool they like for bundle
Anyone have a tool they like for bundle size analysis?
13 Replies
I've gotten close to the limit for my 1MB cap, but I can't find a good tool for helping me shrink that down...
Or rather, finding where I could be shrinking it down.
Is minifying my best bet? I'm hesitant to that from a debugability perspective...
In general, it is always best you minify your code. If you are using esbuild, you can have it generate a source map, which allows for better traces when debugging locally, and in general, that should be enough to debug, since you shouldn’t be manually reading and editing the minified code
Right, I'm doing that, and minifying dropped the pre-gzip size to 600kB, I was really mostyl hoping to figure out where the large bits were that weren't getting tree shaken....
One of my depednencies is turfjs (https://turfjs.org/) which is a beast, but I had assumed that since I imported specific modules only that most of it would get shaken....
Turf.js | Advanced Geospatial Analysis
Turf.js | Advanced geospatial analysis for browsers and Node.js
If you don’t minify your code and use esbuild, there should be comments in the final build highlighting where each block comes from, so you then can work out approximately where most of the bloat comes from
Sure....
Here we go, this is what I was looking for: https://esbuild.github.io/api/#metafile
TIL, thanks!
Ergh, it's not working....wonder if it's CLI only, no js api...
It says it does support CLI, JS, and Go
Never mind, I'm under caffeinated: it's in my top level directory.
Found the issue
Wow. 1.1MB to .3MB with that tool.
Found the culprit...
Building this into the standard esbuild/miniflare/wrangler template would make a lot of sense to me...It's tricky because the building is so decoupled from the serving (which is Miniflare's main thing), and you wouldn't want to make it harder to use different tools...