Skip to content

Commit 76cd9e1

Browse files
Sheraffclaude
andauthored
ci: keep bundle-size measurement out of the Test workflow (#8669)
The measurement target was named `build`, so `test:pr`/`test:ci` and `build:all` picked it up via `--targets=...,build`. Its cache entry was never reused: the Bundle Size workflow runs with NX_NO_CLOUD and --skipRemoteCache. Rename it to `measure` (with explicit `cache: true`, previously inherited from the `build` target default). Since dependency-only changes no longer reach this target through `nx affected`, add `.nvmrc`, `package.json` and `pnpm-lock.yaml` to the Bundle Size workflow path filters so toolchain bumps are still measured. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 647cb73 commit 76cd9e1

6 files changed

Lines changed: 13 additions & 6 deletions

File tree

‎.github/workflows/bundle-size.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@ on:
99
- 'packages/**'
1010
- 'benchmarks/**'
1111
- 'scripts/benchmarks/bundle-size/**'
12+
- '.nvmrc'
13+
- 'package.json'
14+
- 'pnpm-lock.yaml'
1215
push:
1316
branches: [main]
1417
paths:
1518
- 'packages/**'
1619
- 'benchmarks/**'
1720
- 'scripts/benchmarks/bundle-size/**'
21+
- '.nvmrc'
22+
- 'package.json'
23+
- 'pnpm-lock.yaml'
1824
workflow_dispatch:
1925

2026
concurrency:

‎benchmarks/bundle-size/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pnpm benchmark:bundle-size:run --scenario react-router.minimal,react-router.full
4242
The runner calls `measure.mjs`, which builds the selected package projects through Nx. Full runs build the package projects for all scenarios.
4343
`pnpm benchmark:bundle-size` uses the Nx build cache for the full benchmark, then generates `current.json` with the current commit, branch, dirty status, and report timestamp. CI uses this command as well.
4444

45-
Nx caches the bundles, `measurements.json`, and `benchmark-action.json`. Git metadata does not affect the build cache. The report preserves the original `measuredAt` and build duration when measurements come from cache; `generatedAt` records when the report was generated. Running `pnpm nx run @benchmarks/bundle-size:build` directly produces only the cacheable outputs; run `node scripts/benchmarks/bundle-size/report.mjs` afterward to refresh `current.json`.
45+
Nx caches the bundles, `measurements.json`, and `benchmark-action.json`. Git metadata does not affect the build cache. The report preserves the original `measuredAt` and build duration when measurements come from cache; `generatedAt` records when the report was generated. Running `pnpm nx run @benchmarks/bundle-size:measure` directly produces only the cacheable outputs; run `node scripts/benchmarks/bundle-size/report.mjs` afterward to refresh `current.json`.
4646

4747
If the required packages are already built and unchanged, skip that step:
4848

‎benchmarks/bundle-size/package.json‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
"private": true,
44
"type": "module",
55
"scripts": {
6-
"build": "node ../../scripts/benchmarks/bundle-size/measure.mjs --skip-package-builds --measurements-only",
6+
"measure": "node ../../scripts/benchmarks/bundle-size/measure.mjs --skip-package-builds --measurements-only",
77
"test:unit": "node --test ../../scripts/benchmarks/bundle-size/pr-report.test.mjs ../../scripts/benchmarks/bundle-size/run.test.mjs ../../scripts/benchmarks/bundle-size/report.test.mjs ../../scripts/benchmarks/bundle-size/build.test.mjs ../../scripts/benchmarks/bundle-size/compress.test.mjs ../../scripts/benchmarks/bundle-size/timings.test.mjs"
88
},
99
"nx": {
1010
"targets": {
11-
"build": {
11+
"measure": {
12+
"cache": true,
1213
"inputs": [
1314
"buildProduction",
1415
"^buildProduction",

‎scripts/benchmarks/bundle-size/build.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function build(args, execute = spawnSync) {
2323
...(pnpmPath ? [pnpmPath] : []),
2424
'nx',
2525
'run',
26-
'@benchmarks/bundle-size:build',
26+
'@benchmarks/bundle-size:measure',
2727
...args,
2828
],
2929
options,

‎scripts/benchmarks/bundle-size/build.test.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test('generates a fresh report after a successful Nx run, including cache hits',
2020
assert.deepEqual(calls[0]?.slice(-5), [
2121
'nx',
2222
'run',
23-
'@benchmarks/bundle-size:build',
23+
'@benchmarks/bundle-size:measure',
2424
'--outputStyle=stream',
2525
'--skipRemoteCache',
2626
])

‎skills/bundle-size-optimization/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: Use when working in this repository on JS bundle size, gzip regress
77

88
## Overview
99

10-
Optimize measured client bundles, not source text. The source of truth is `@benchmarks/bundle-size:build`, `benchmarks/bundle-size/results/current.json`, and emitted JS in `benchmarks/bundle-size/dist/`.
10+
Optimize measured client bundles, not source text. The source of truth is `@benchmarks/bundle-size:measure`, `benchmarks/bundle-size/results/current.json`, and emitted JS in `benchmarks/bundle-size/dist/`.
1111
Use `benchmark:bundle-size:run` for local iterations. It uses the same measurement script and builds the selected packages through Nx.
1212

1313
## Commands

0 commit comments

Comments
 (0)