[Bug] Bundle sizes are incorrect
Describe the bug
I'm testing out benchmarking and found a strange result in the numbers I'm seeing for bundle size.
"size": {
"total": 12857,
"manager": {
"total": 2238,
"main": 0,
"runtime": 4,
"vendors": 2233,
"uiDll": 0
},
It struck me as odd that main would be listed as 0, so I took a look at the file:
(window.webpackJsonp = window.webpackJsonp || []).push([
[2],
{
464: function (module, exports, __webpack_require__) {
__webpack_require__(465),
__webpack_require__(816),
__webpack_require__(802),
__webpack_require__(820),
__webpack_require__(821),
__webpack_require__(817),
__webpack_require__(814),
__webpack_require__(813),
__webpack_require__(815),
__webpack_require__(812),
__webpack_require__(818),
__webpack_require__(819),
(module.exports = __webpack_require__(811));
},
524: function (module, exports) {},
},
[[464, 3, 4]],
]);
It seems like we'd need to actually crawl the require/import tree and count the filesize of any other files/modules that are being required in.
I wonder if it would be simpler and at least more accurate than the current results to total up the filesizes of any file ending in .manager.bundle.js for the manager (and I guess similarly for the webpack preview). The vite preview will have a similar problem, in that multiple chunks can be created. But, this approach may fall short when storyStoreV7 is enabled, since the main bundle won't include all the files. Would we still want to total up all the files? What is the goal of tracking bundle size? Maybe the answer to that last question will help answer some of the others.
I wrote bench before we were bundle splitting, so initially there were just two bundles: one for the preview and one for the manager. Conceptually, we want to measure the bundle size on load -- I'm not sure how to do this. I think it would be fine to measure the total bundle size in manager & preview as well. I'm not sure the best way to do either of these, but open to reviewing a PR for this!