A GitHub action that compares the real cost of your JavaScript in every pull request
This action uses Size Limit (performance budget tool for JavaScript) to calculate the real cost of your JavaScript for end-users. The main features of this action are:
Commenting pull requests with the comparison of Size Limit output.
Rejecting a pull request if the cost exceeds the limit.
By default this action will try to build your PR by running buildnpm script located in your package.json. If something need to be done after dependencies are installed but before building postinstall npm script could be used. For example, using lerna:
"scripts": {
"postinstall": "lerna bootstrap",
"build": "lerna run build"
},
Define Size limit configuration. For example (inside package.json):
You can optionally specify a custom npm script to run instead of the default build adding a build_script option to the yml workflow shown above. Additionally, providing a skip_step option will tell the action to skip either the install or build phase.
By default, the action will attempt to autodetect which package manager to use, but in some cases
like those who are using a monorepo and the directory option, this may not detect the correct
manager. You can manually specify the package manager with the package_manager option.
A GitHub action that compares the real cost of your JavaScript in every pull request
This action uses Size Limit (performance budget tool for JavaScript) to calculate the real cost of your JavaScript for end-users. The main features of this action are:
Usage
buildnpm script located in yourpackage.json. If something need to be done after dependencies are installed but before buildingpostinstallnpm script could be used. For example, using lerna:package.json):.github/workflows/size-limit.ymlYou can optionally specify a custom npm script to run instead of the defaultbuildadding abuild_scriptoption to the yml workflow shown above. Additionally, providing askip_stepoption will tell the action to skip either theinstallorbuildphase.Add
clean_scriptoption to specify npm script to run after size-limit results are collected. This is useful to clean up leftover assets.Customizing size-limit script
Use
scriptoption to customize the size-limit execution script (the output should always be ajson), which defaults tonpx size-limit --json.Customizing working directory
The
directoryoption allow to run all the tasks in a subfolder. It’s only convenient if all your stuff is in a subdirectory of your git repository.For instance, if
package.jsonis in the subfolderclient/:Customizing the Package Manager
By default, the action will attempt to autodetect which package manager to use, but in some cases like those who are using a monorepo and the directory option, this may not detect the correct manager. You can manually specify the package manager with the
package_manageroption.Feedback
Pull requests, feature ideas and bug reports are very welcome. We highly appreciate any feedback.