nonzzz/vite-bundle-analyzer

Module sizes

TrueCarry opened this issue · 11 comments

Currently all npm packages have same size in UI, while some may be 10kb and others 1mb. Can you please make modules size based on their size in bundle? It works like that in webpack-bundle-analyzer

nonzzz commented

I don't know what you mean, Can you explain what is the all npm pacakges have same size in UI,while some maybe 10kb and otehrs 1mb. But i can promise this plugin provide the size is near than actually size(you maybe notice the README.md) and similar to webpack-bundle-analyzer.

image
My report look like that
Here's 5mb package
image

And here's 18kb side by side
image

I want 5mb package to take a lot more space on the screen.

nonzzz commented

Thanks for your report. This feature will be implemented in the next version.

nonzzz commented

0.7.0 has been released.

Thank you very much! Works like expected. Not sure if related, but for some reason most modules lost their gzip and parsed sizes, only stat tab works.
image

Also for some reason vite outputs ?worker inputs as assets instead of chunks, not sure how can that be fixed, but because of that, we don't have workers in report

@TrueCarry The summary option will only add module information at the end. Like this

image

I've actually meant 2 different issues.
1.
Stat page:
image
Parsed page:
image
Gzipped page:
image

As you see, gzipped and parsed pages are broken. I'm not sure that it's analyzer problem, maybe it's vite thing.

  1. What I meant with ?worker. It is imported as import Worker from '../executorWorker?worker'. As you see on my screenshot from previous comment, I have ExecutorWorker.js that weights 5900kb, but it's not available in chunks list:
    image

I've checked vite output, and worker gets bundled as 'asset', not 'chunk', not sure how can that be addressed, but I don't think there's an easy way.

I don't think both issues could be addressed without too much effort, so I just wanted to let you know about them. Thank you for your work!

In actuality, 'stat sizes' represents the size proximity to your native code (at least, that's my interpretation). However, I've observed that '?worker' does not appear in the 'parsed' or 'gzip' sizes (to be frank, there is currently no effective method to calculate this specific size). Vite is built on Rollup, where each chunk might be missing in the 'sourcemap' (resulting in the remaining chunks being merged by the analyzer). I believe switching to 'rolldown' in Vite might effectively address this issue.

As the documentation suggests, he just tries to analyze it as much as possible.

About doc, I think vite don't put right chunk into bundle context, So I'm trying to get expect behavior from vite repl

Parsed or gzip has no relation to worker. Even packages in index.js not listed there.

@TrueCarry I know, I'm planning resolve them at next version.