Ponder and better educate on the displayed metrics #546
sarahdayan
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey there!
First of all, thank you so much for Bundlephobia. I use it often, and it's an excellent contribution to the JavaScript community. And because it has become so prevalent and used in high-reach tools, I think there are opportunities for improvement to further fulfill its role of educating and informing users.
Distinguishing between all build formats
Right now, the result page for a package shows the bundle size of what's listed as the
main
module. This doesn't always reflect what users would end up using in their projects.For example, someone using Vue.js in a Webpack 2+ or Vite-powered project will import the ESM build (listed under
module
), while someone importing it from jsDelivr will import the UMD build (listed underjsdelivr
). The CommonJS build (listed undermain
) is only useful for older bundlers such as Browserify and Webpack 1, so it's hardly representative of any actual usage.Suggested solutions
main
one.<script>
tag, without a build step", "CJS—If you're using this with Node.js or with older module bundlers", etc.Emphasize tree-shakeability
When a package is both exported as an ECMAScript module and is marked as side-effect free, Bundlephobia displays it and provides a useful Exports Analysis section that shows the breakdown of each individual module. This information is crucial, because such packages usually heavily promote modularity—that is, you rarely use the whole thing, and your bundle size will be dramatically impacted by this. Unfortunately, the result page doesn't emphasize it enough.
A good example are
date-fns
anddayjs
. The wholedate-fns
package weights 19.3 KB minified + gzipped, but it's entirely modular and designed to be used that way. Most of its functions don't exceed half a kilobyte. In contrast,dayjs
is 2.8 KB minified + gzipped, but it isn't modular (it does have concerns split into plugins, but it's not as atomic). So on paper,dayjs
is smaller thandate-fns
, but in reality,dayjs
will always cost you at least 2.8 KB whiledate-fns
will cost you just what you consume, which might very well be a lot smaller. Yet, Bundlephobia showsdayjs
as a 86% smaller alternative todate-fns
. This is misleading because it doesn't at all take into account how both projects are architected, yet provides a number that may direct users to a solution that might not be in their best interest.Suggested solutions
Provide educative content
Not everyone is familiar with certain terms such as "tree-shakeable" or "side-effect free", and these pieces of information are discreet on the result page while the full bundle size is highly visible. Since Bundlephobia is about finding the cost of adding an npm package to one's bundle, with today's JavaScript tooling, it seems crucial to emphasize and educate on such features which are among the most important aspects that a user should consider.
Suggested solutions
Afterword
Please be assured that I'm not shooting at Bundlephobia, only providing constructive criticism and possible solutions because I think it's a great project that could be even better. I'm also down to participate in finding and implementing the solutions, as I'm well aware that everyone is doing that on their own time.
Looking forward to discussing this all further!
Beta Was this translation helpful? Give feedback.
All reactions