{"id":13553475,"url":"https://github.com/preactjs/compressed-size-action","last_synced_at":"2025-05-14T13:06:04.027Z","repository":{"id":37829640,"uuid":"235609057","full_name":"preactjs/compressed-size-action","owner":"preactjs","description":"GitHub Action that adds compressed size changes to your PRs.","archived":false,"fork":false,"pushed_at":"2025-04-04T04:39:50.000Z","size":707,"stargazers_count":614,"open_issues_count":12,"forks_count":87,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-05-12T04:38:39.703Z","etag":null,"topics":["action","actions","bytes","compressed","prs","size","workflow"],"latest_commit_sha":null,"homepage":"https://github.com/marketplace/actions/compressed-size-action","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/preactjs.png","metadata":{"funding":{"github":["preactjs"],"open_collective":"preact"},"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-01-22T16:00:10.000Z","updated_at":"2025-05-08T01:46:16.000Z","dependencies_parsed_at":"2023-12-19T03:02:53.575Z","dependency_job_id":"8b7e5ac7-04cd-4747-abed-8d9826b8c86c","html_url":"https://github.com/preactjs/compressed-size-action","commit_stats":{"total_commits":124,"total_committers":35,"mean_commits":"3.5428571428571427","dds":0.7258064516129032,"last_synced_commit":"6fa0e7ca017120c754863b31123c5ee2860fd434"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preactjs%2Fcompressed-size-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preactjs%2Fcompressed-size-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preactjs%2Fcompressed-size-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preactjs%2Fcompressed-size-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/preactjs","download_url":"https://codeload.github.com/preactjs/compressed-size-action/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253727349,"owners_count":21954184,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["action","actions","bytes","compressed","prs","size","workflow"],"created_at":"2024-08-01T12:02:25.844Z","updated_at":"2025-05-14T13:06:03.993Z","avatar_url":"https://github.com/preactjs.png","language":"JavaScript","funding_links":["https://github.com/sponsors/preactjs","https://opencollective.com/preact"],"categories":["JavaScript"],"sub_categories":[],"readme":"# compressed-size-action\n\nA GitHub action that reports changes in compressed file sizes on your PRs.\n\n- Automatically uses `yarn`, `pnpm`, `bun`, or `npm ci` when lockfiles are present\n- Builds your PR, then builds the target and compares between the two\n- Doesn't upload anything or rely on centralized storage\n- Supports [custom build scripts](#customizing-the-build) and [file patterns](#customizing-the-list-of-files)\n\n\u003cimg width=\"396\" src=\"https://user-images.githubusercontent.com/105127/73027546-a0176a80-3e01-11ea-887b-7326ee289893.png\"\u003e\n\n\u003cimg width=\"600\" src=\"https://user-images.githubusercontent.com/105127/73027489-8413c900-3e01-11ea-8630-09172b247f82.png\"\u003e\n\n### Usage:\n\nAdd a workflow (`.github/workflows/main.yml`):\n\n```yaml\nname: Compressed Size\n\non: [pull_request]\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n      - uses: actions/checkout@v2\n      - uses: preactjs/compressed-size-action@v2\n```\n\n### Customizing the Installation\n\nBy default, `compressed-size-action` will install dependencies according to which lockfiles are present, if any. However, if you need to run a different installation command, you can pass a custom script to do so. For example, to use `npm ci` with the `--workspace` option:\n\n```diff\nname: Compressed Size\n\non: [pull_request]\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n    - uses: actions/checkout@v2\n    - uses: preactjs/compressed-size-action@v2\n      with:\n+       install-script: \"npm ci --workspace=packages/my-subpackage\"\n```\n\n### Customizing the Build\n\nBy default, `compressed-size-action` will try to build your PR by running the `\"build\"` [npm script](https://docs.npmjs.com/misc/scripts) in your `package.json`.\n\nIf you need to perform some tasks after dependencies are installed but before building, you can use a \"postinstall\" npm script to do so. For example, in Lerna-based monorepo:\n\n```json\n{\n  \"scripts\": {\n    \"postinstall\": \"lerna bootstrap\",\n    \"build\": \"lerna run build\"\n  }\n}\n```\n\nIt is also possible to define a `\"prebuild\"` npm script, which runs after `\"postinstall\"` but before `\"build\"`.\n\nYou can also specify a completely different [npm script](https://docs.npmjs.com/misc/scripts) to run instead of the default (`\"build\"`). To do this, add a **`build-script` option** to your `yml` workflow:\n\n```diff\nname: Compressed Size\n\non: [pull_request]\n\njobs:\n  build:\n\n    runs-on: ubuntu-latest\n\n    steps:\n    - uses: actions/checkout@v2\n    - uses: preactjs/compressed-size-action@v2\n      with:\n+       build-script: \"ci\"\n```\n\n#### Clean up state between builds\n\nFor repositories or custom monorepo setups where files are modified in ways that are not reset by `npm ci \u0026\u0026 npm run build`, it may be necessary to define a custom \"clean\" script. This script resets any file modifications after the upstream (`target`) build ends and your PR code (`HEAD`) is checked out, but before installation of npm dependencies for `HEAD`:\n\n```diff\nname: Compressed Size\non: [pull_request]\njobs:\n  build:\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@v2\n    - uses: preactjs/compressed-size-action@v2\n      with:\n        repo-token: \"${{ secrets.GITHUB_TOKEN }}\"\n+       clean-script: \"clean\"\n```\n\n```jsonc\n// package.json\n{\n  \"scripts\": {\n    // example - a simple nested node_modules setup:\n    \"postinstall\": \"cd packages \u0026\u0026 npm i\",\n    // between the two builds, we need to delete the inner node_modules:\n    \"clean\": \"rm -rf packages/node_modules\"\n  }\n}\n```\n\n### Customizing the list of files\n\n`compressed-size-action` defaults to tracking the size of all JavaScript files within `dist/` directories - anywhere in your repository, not just at the root. You can change the list of files to be tracked and reported using the `pattern` and `exclude` options, both of which are [minimatch patterns](https://github.com/motemen/minimatch-cheat-sheet/blob/master/README.md):\n\n```diff\nname: Compressed Size\non: [pull_request]\njobs:\n  build:\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@v2\n    - uses: preactjs/compressed-size-action@v2\n      with:\n+       pattern: \"./build-output/**/*.{js,css,html,json}\"\n+       exclude: \"{./build-output/manifest.json,**/*.map,**/node_modules/**}\"\n```\n\nFiles are collected by finding matches for `pattern`, then any of those that match `exclude` are ignored. For that reason, most projects don't need to modify `exclude`. The default values for `pattern` and `exclude` are as follows:\n\n```yaml\nwith:\n  # Any JS files anywhere within a dist directory:\n  pattern: \"**/dist/**/*.{js,mjs,cjs}\"\n\n  # Always ignore SourceMaps and node_modules:\n  exclude: \"{**/*.map,**/node_modules/**}\"\n```\n\n### Dealing with hashed filenames\n\nA `strip-hash` option was added in `v2` that allows passing a custom Regular Expression pattern that will be used to remove hashes from filenames. The un-hashed filenames are used both for size comparison and display purposes.\n\nBy default, the characters matched by the regex are removed from filenames.\nIn the example below, a filename `foo.abcde.js` will be converted to `foo.js`:\n\n```yaml\nstrip-hash: \"\\\\b\\\\w{5}\\\\.\"\n```\n\nThis can be customized further using parens to create submatches, which mark where a hash occurs. When a submatch is detected, it will be replaced with asterisks. This is particularly useful when mix of hashed and unhashed filenames are present.\nIn the example below, a filename `foo.abcde.chunk.js` will be converted to `foo.*****.chunk.js`:\n\n```yaml\nstrip-hash: \"\\\\.(\\\\w{5})\\\\.chunk\\\\.js$\"\n```\n\n### Increasing the required threshold\n\nBy default, a file that's been changed by a single byte will be reported as changed. If you'd prefer to require a certain minimum threshold for a file to be changed, you can specify `minimum-change-threshold` in bytes:\n\n```yaml\nminimum-change-threshold: 100\n```\n\nIn the above example, a file with a delta of less than 100 bytes will be reported as unchanged.\n\n### Compression\n\nBy default, files are compared after gzip compression, but it's possible to use other compression algorithms (`gzip/brotli/none`) or disable the compression.\n\n```yaml\ncompression: \"none\"\n```\n\n### Checking multiple bundles\n\nThe action reuses the same comment each time it runs on a PR. In order to run the action multiple times against separate bundles for a single PR, you must provide a `comment-key` option, which the action will use to determine which comment to add or update for the run. The example below demonstrates this for separate \"modern\" and \"legacy\" bundles:\n\n```diff\nname: Compressed Size\non: [pull_request]\njobs:\n  modern-bundle-size-check:\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@v2\n    - uses: preactjs/compressed-size-action@v2\n      with:\n        build-script: \"build:modern\"\n+       comment-key: modern\n\n  legacy-bundle-size-check:\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@v2\n    - uses: preactjs/compressed-size-action@v2\n      with:\n        build-script: \"build:legacy\"\n+       comment-key: legacy\n```\n\nIf you do not provide this key, the action will attempt to use (and therefore replace) the same comment for both bundles, hiding the output for whichever run finished last.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpreactjs%2Fcompressed-size-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpreactjs%2Fcompressed-size-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpreactjs%2Fcompressed-size-action/lists"}