rollup-plugin-visualizer icon indicating copy to clipboard operation
rollup-plugin-visualizer copied to clipboard

Assert size increase

Open btd opened this issue 2 years ago • 4 comments

Something to think about. I already have list template that can be used to track sizes and commited to repo. I can add some property that will not allow to override this file in case size increased for example to some percent.

btd avatar Dec 30 '22 10:12 btd

👋 Hi, I just came across this library and found it perfect for diagnosing what's going on – well done!

Actually, I started something a few months back, https://github.com/jycouet/vite-plugin-lib-reporter, to track increases over builds. I use it in my projects to keep track of things, and it's working well. I would be happy to kill my repository if we/i add something similar here 👍 Do you have a specific API in mind?

jycouet avatar Oct 14 '23 12:10 jycouet

Hi, sorry i missed you message. Somehow i messed github notification settings.

I do not have any specific API in mind. What i am trying to follow in this plugin:

  1. Reasonable opinionated way
  2. Minimum settings, ideally 0

Currently plugin allows to add different types of reporters/templates. So most likely we can add one more that will read previous data and compare to provided settings. So i see to new options added - diffLevel to assert, and where to store state. Technically this can be attached to list reporter as it is literally previous state and we only need diffLevel

btd avatar Nov 30 '23 15:11 btd

I would like also to configure as less as possible.

diffLevel, I guess that you have in mind a % (So a number? Maybe defaulting to 0?) The first time, since there is no previous data, you would allow the thing? And later, you would accept x increase? (Failing the build?)

I'm not sure how/where to store the previous build? (or the target branch build?)

jycouet avatar Dec 01 '23 18:12 jycouet

Yes sounds right what you wrote. I created this issue when i added list template (which is just yml content with bundle/file/size entries). Basically this is actual state of bundles reported by rollup/plugin.

  1. On initial build there is no state, pass always.
  2. When file on the same path found, it is possible to start asserting if it is enabled
  3. If assertion enabled we take size of previous builld, new build get diff in % or kb (this need to think) and assert when threshold exceeds

There are moments that i think of:

  1. Assertion should be opt-in, backward compatible - not enabled, not reported
  2. Not sure if we need fail build or warn or any other action. I understand purpose of failing build, warnings are useless
  3. Size difference, % makes sense, does kb difference makes sense?
  4. I was thinking to use specifically list template because it contains what exactly changed - so that we can report this back, like file1, file2 added, file3 increased in size etc.

btd avatar Dec 02 '23 09:12 btd