Skip to content

Commit 98be6b0

Browse files
authored
chore(skills): Add bump-size-limit skill (#19715)
As a "manual but less manual than editing `.size-limit.js`" alternative to #19690, this PR adds a skill that takes care of bumping size limits. I also added a `test:size-limit` script for convenience since we didn't document elsewhere how to manually run the `size-limit` CLI.
1 parent cdee7a9 commit 98be6b0

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
name: bump-size-limit
3+
description: Bump size limits in .size-limit.js when the size-limit CI check is failing. Use when the user mentions size limit failures, bundle size checks failing, CI size check errors, or needs to update size-limit thresholds. Also use when the user says "bumpSizeLimit", "fix size limit", "size check failing", or "update bundle size limits".
4+
---
5+
6+
# Bump Size Limit
7+
8+
When the size-limit GitHub Action fails, it means one or more bundle scenarios exceed their configured byte thresholds in `.size-limit.js`. This skill walks through building, measuring, and bumping only the limits that need it.
9+
10+
## Workflow
11+
12+
### Step 1: Build all packages (including CDN bundles)
13+
14+
A full build is required because size-limit measures the actual compiled artifacts.
15+
16+
```bash
17+
yarn build
18+
```
19+
20+
This takes a few minutes. CDN bundles in `packages/browser/build/bundles/` must be up to date — a dev build is not sufficient.
21+
22+
### Step 2: Run the size check in JSON mode
23+
24+
```bash
25+
yarn test:size-limit
26+
```
27+
28+
The JSON output is an array of objects. Each object has:
29+
30+
- `name` — the scenario label
31+
- `passed` — whether it's within the limit
32+
- `size` — actual size in bytes
33+
- `sizeLimit` — configured limit in bytes
34+
35+
### Step 3: Identify failed scenarios
36+
37+
Filter for entries where `"passed": false`. These are the only ones that need bumping.
38+
39+
### Step 4: Calculate new limits
40+
41+
For each failed scenario, round the actual size **up to the next full KB** (1 KB = 1000 bytes in this context, matching how size-limit interprets the limits in `.size-limit.js`).
42+
43+
**Example:** If actual size is `129,127` bytes, the new limit is `130 KB` (i.e. 130,000 bytes).
44+
45+
The heuristic is intentionally conservative — it gives just enough headroom without inflating limits unnecessarily.
46+
47+
### Step 5: Update `.size-limit.js`
48+
49+
Open `.size-limit.js` at the repository root and update the `limit` field for each failed scenario. Limits are strings like `'130 KB'`.
50+
51+
Only change limits for scenarios that actually failed. Do not touch passing scenarios.
52+
53+
### Step 6: Verify the fix
54+
55+
Re-run size-limit to confirm everything passes:
56+
57+
```bash
58+
yarn test:size-limit
59+
```
60+
61+
If any scenario still fails (e.g., due to rounding edge cases), bump that specific limit by another 1 KB and re-run.

agents.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ source = "path:.agents/skills/triage-issue"
4242
name = "upgrade-dep"
4343
source = "path:.agents/skills/upgrade-dep"
4444

45+
[[skills]]
46+
name = "bump-size-limit"
47+
source = "path:.agents/skills/bump-size-limit"
48+
4549
[[skills]]
4650
name = "upgrade-otel"
4751
source = "path:.agents/skills/upgrade-otel"

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"test:ci:browser": "UNIT_TEST_ENV=browser ts-node ./scripts/ci-unit-tests.ts",
4444
"test:ci:node": "UNIT_TEST_ENV=node ts-node ./scripts/ci-unit-tests.ts",
4545
"test:ci:bun": "nx run-many -t test -p @sentry/bun",
46+
"test:size-limit": "yarn size-limit --json",
4647
"yalc:publish": "nx run-many -t yalc:publish"
4748
},
4849
"volta": {

0 commit comments

Comments
 (0)