Description
We want to have a solid way of checking out how much KBs is the file size increasing when a Pull Request is done. We have two main goals here:
- Compare the size with the previous size and show that in the PR.
- Make the tests fail if the size of the scripts increase. Then, allow for easy update of the size after review.
- Increased bundle size should be exposed to the PR reviewer, not only to the assignee.
- Tests external scripts as well as internal scripts.
Current solution
Right now, we have the budget.json
file of the LightHouse CI to limit the size of the scripts. If it’s higher than the value defined there, the tests won’t pass.
Regarding the goals:
- It doesn’t compare with the previous size (although if the
budget.json
contains the previous size, it fails if the size was increased). It doesn’t show that info in the PR. - It makes tests fail if size increases. The way to allow for an increased size is to update the budget file, which is not super hard but not super easy either.
- Increased bundle size is exposed to the reviewer because there is a change in a file (budget.js) in that PR.
- It tests externals scripts.
User Stories
As a Frontity core developer
I want to know when I have increased the bundle size
so that I can take the necessary action
Possible solution
Add bundlewatch: @mmczaplinski created some time ago a Pull Request to implement this.
Goals:
- It compares the previous size and shows it in the PR.
- It fails if size increases. The way to allow for an increased size is to update the budget file, similar to what we have now.
- Increased bundle size is exposed to the reviewer because it is a change in a file.
- It doesn’t test external scripts.
We could reuse this Preact GitHub action. Here you can find an example of the result.
Goals:
- It compares the previous size and show it in the PR.
- It doesn’t fail when size increases.
- Increased bundle size is exposed to the reviewr in the PR, although it may not pay attention to it because it’s in a comment.
- It doesn’t test external scripts.