doesdev / rollup-plugin-analyzer

Mad metrics for your rollup bundles, know all the things
http://rollup-plugin-analyzer.doesdev.com
MIT License
242 stars 4 forks source link

"limit" results in incorrect bundle size report #24

Closed arctica closed 3 years ago

arctica commented 3 years ago

When using "limit", the reported stats are incorrect because they exclude all modules that are beyond the cutoff point. Limit should probably only affect the list of modules in the output, not the calculations.

A simple way to showcase the issue is to set "limit: 0" which will result in something like the following:

-----------------------------
Rollup File Analysis
-----------------------------
bundle size:    0 Byte
original size:  0 Byte
code reduction: 0 %
module count:   236
arctica commented 3 years ago

As a workaround I just figured that one can use the "filter" option with a function like the following to achieve what I wanted since by default the filter will not affect the summary.

const limiter = (limit) => {
    let nth = 0;

    return (m) => nth++ < limit;
}

And then analyze({ filter: limiter(5) } ).

Thanks btw for such a great plugin.

doesdev commented 3 years ago

Thanks for the report, just released version 4.0.0 with this behavior changed to not affect the summary (unless filterSummary === true).