doesdev / rollup-plugin-analyzer

Mad metrics for your rollup bundles, know all the things

Home Page:http://rollup-plugin-analyzer.doesdev.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

skip analysis on demand

FND opened this issue · comments

commented

As I understand it, rollup-plugin-analyzer's analysis is performed anew whenever rollup.rollup is invoked - which might be expensive if the bundle is continually being recompiled in watch mode. (This is mostly an assumption though, so feel free to disabuse me of that notion.)

Thus it might be helpful to have a switch to temporarily suppress that analysis altogether, e.g. like this:

import { plugin as analyze } from 'rollup-plugin-analyzer'

    plugins: [analyze({
        skip: params => Math.random() > 0.5
    })]

Generally speaking there shouldn't be an impact on the bundling performance from this plugin as we return a promise that resolves immediately in the hooks. Presumably what should happen is rollup will invoke the hook and then immediately start processing the then, once the event loop is free then the analysis will run. That being said I'll still look into adding that option. Additionally, I probably need some tooling or options around watch to suppress when building in watch mode specifically.

I added a test to check for overhead related to the plugin. The test itself looks for a threshold of a 50ms difference between bundling without the plugin vs. with. It passes that, but in reality on a per bundle basis they are run within a couple ms of each other. Actually the with plugin runs faster but I'm sure that's due to Rollup being warmed up (no cache is used though).

On the watching I'm not sure if there would be a good way within the plugin to suppress the output selectively when watched. As you pointed out passing in a function to an option that would skip would do that, but I think in that case it might be better done within the build script itself. That's how I do it myself for dev building.

All that to say I think we can close this on the basis of performance but feel free to comment if you have any other thoughts on this and we can re-open and explore it further.

commented

there shouldn't be an impact on the bundling performance

I was concerned with performance in general, including battery drain.

However, you're absolutely correct: A switch within rollup-plugin-analyzer itself isn't necessary because we can just choose to omit this plugin altogether when invoking rollup.rollup({ plugins, cache, … }) (which is our entry point even in watch mode, as recompiling is just compiling with a primed cache).

So yes, all good - thanks for looking into this and sorry for the distraction.