Report npm package size changes on your pull-requests using pkg-size.
If you like this project, please star it & follow me to see what other cool projects I'm working on! ❤️
- 🎩 Auto-detect distribution assets Only tracks distribution files by using the same logic as
npm publish
! - 🙌 Supports npm, yarn, and pnpm Auto CI/frozen-lock installs across module installers!
- 🔥 Fully customizable report comment Configure the default template or bring your own!
-
Create the following file in your repo:
.github/workflows/package-size-report.yml
:name: Package Size Report on: pull_request: branches: [ master, develop ] # ⬅ Add other branches you want size checks on jobs: pkg-size-report: name: Package Size Report runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Package size report uses: privatenumber/pkg-size-action@develop env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
Try making a PR against one of the designated branches! You'll see a comment on your PR reporting the difference package size. This comment will be automatically updated as you push changes to your PR.
Set a custom build command to produce distribution assets
By default, pkg-size-action detects whether npm run build
works. If not, it assumes your repo doesn't have a build step and won't even install dependencies.
If your repo has a different build script, specify one via build-command
. Disable producing a build by passing in false
.
name: Package Size Report
on:
pull_request:
branches: [ master, develop ]
jobs:
pkg-size-report:
name: Package Size Report
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Package size report
uses: privatenumber/pkg-size-action@develop
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
build-command: npm run prod-build # ⬅ Set a different build script here
Hiding source-map changes from report
Source-maps can be a negligible when considering distribution size. Hide them from your report to reduce the noise using a glob.
name: Package Size Report
on:
pull_request:
branches: [ master, develop ]
jobs:
pkg-size-report:
name: Package Size Report
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Package size report
uses: privatenumber/pkg-size-action@develop
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
hide-files: '*.{js,css}.map' # Set a glob to filter out irrelevant files
Show unchanged & changed files in the same table
name: Package Size Report
on:
pull_request:
branches: [ master, develop ]
jobs:
pkg-size-report:
name: Package Size Report
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Package size report
uses: privatenumber/pkg-size-action@develop
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
unchanged-files: show # ⬅ Make unchanged files appear in the same table
Default: npm run build
if exists in package.json
Command to build the package and produce distribution files with. Pass in false
to disable attempting to produce a build.
Default: true
Possible values: true
, false
Whether to comment the build size report on the PR or not.
Default: regression
Possible values: regression
, head-only
Sets the size report mode:
regression
: Builds bothhead
andbase
branch and compares difference.head-only
: Only builds and reports onhead
branch.
Default: uncompressed
Possible values: uncompressed
, gzip
, brotli
Which size to show. Pass in a comma-separated list for multiple.
Default: collapse
Possible values: show
, collapse
, hide
Whether to show unchanged files.
Default: delta
Possible values: delta
, headSize
, baseSize
, path
Which property to sort the files list by. delta
is the size difference.
Default: desc
Possible values: desc
, asc
Files list sort order.
Glob pattern to hide files. For example, if you want to hide source-maps:
hide-files: '*.{js,css}.map'
MIT © Hiroki Osame
Logo made by Freepik