Keep track of file-size changes in Pull Requests

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:

  1. Compare the size with the previous size and show that in the PR.
  2. Make the tests fail if the size of the scripts increase. Then, allow for easy update of the size after review.
  3. Increased bundle size should be exposed to the PR reviewer, not only to the assignee.
  4. 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:

  1. 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.
  2. 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.
  3. Increased bundle size is exposed to the reviewer because there is a change in a file (budget.js) in that PR.
  4. 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:

  1. It compares the previous size and shows it in the PR.
  2. 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.
  3. Increased bundle size is exposed to the reviewer because it is a change in a file.
  4. It doesn’t test external scripts.

We could reuse this Preact GitHub action. Here you can find an example of the result.

Goals:

  1. It compares the previous size and show it in the PR.
  2. It doesn’t fail when size increases.
  3. 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.
  4. It doesn’t test external scripts.

I have edited the OP to turn it into a proper Feature Discussion.