Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/size.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Bundle-size check for pull requests.
#
# Runs size-limit from local node_modules (avoids npx version mismatch).
# Posts a PR comment with current sizes and fails if any budget is exceeded.

name: Size

on:
pull_request:
types: [opened, synchronize, reopened]
branches: [main]

permissions:
contents: read
pull-requests: write

jobs:
size:
name: Bundle size
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
persist-credentials: false

- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: "22"
cache: npm

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Check bundle size
id: size
run: |
./node_modules/.bin/size-limit --json > size-output.json
cat size-output.json

- name: Post size comment
if: always() && steps.size.conclusion != 'skipped'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
if (!fs.existsSync('size-output.json')) return;
let results;
try { results = JSON.parse(fs.readFileSync('size-output.json', 'utf8')); }
catch { return; }
const rows = results.map(r => {
const status = r.exceeded ? '❌' : '✅';
const size = r.size != null ? `${(r.size / 1024).toFixed(1)} kB` : 'n/a';
const limit = r.sizeLimit || 'none';
return `| ${r.name || r.path} | ${size} | ${limit} | ${status} |`;
}).join('\n');
const body = `## Bundle size\n\n| Entry | Size | Budget | Status |\n|-------|------|--------|--------|\n${rows}`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body
});
10 changes: 10 additions & 0 deletions .size-limit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default [
{
path: "dist/index.js",
limit: "160 kB",
modifyEsbuildConfig(config) {
config.platform = "node";
return config;
},
},
];
Loading
Loading