From 76cd9e178d2e2b8c08c9f101dc3e11887dc7d651 Mon Sep 17 00:00:00 2001 From: Flo Date: Sat, 17 Oct 2026 12:35:23 +0200 Subject: [PATCH] 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 --- .github/workflows/bundle-size.yml | 6 ++++++ benchmarks/bundle-size/README.md | 2 +- benchmarks/bundle-size/package.json | 5 +++-- scripts/benchmarks/bundle-size/build.mjs | 2 +- scripts/benchmarks/bundle-size/build.test.mjs | 2 +- skills/bundle-size-optimization/SKILL.md | 2 +- 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/bundle-size.yml b/.github/workflows/bundle-size.yml index 762faa49db..265a632ef5 100644 --- a/.github/workflows/bundle-size.yml +++ b/.github/workflows/bundle-size.yml @@ -9,12 +9,18 @@ on: - 'packages/**' - 'benchmarks/**' - 'scripts/benchmarks/bundle-size/**' + - '.nvmrc' + - 'package.json' + - 'pnpm-lock.yaml' push: branches: [main] paths: - 'packages/**' - 'benchmarks/**' - 'scripts/benchmarks/bundle-size/**' + - '.nvmrc' + - 'package.json' + - 'pnpm-lock.yaml' workflow_dispatch: concurrency: diff --git a/benchmarks/bundle-size/README.md b/benchmarks/bundle-size/README.md index b5f7404480..2185d6b43f 100644 --- a/benchmarks/bundle-size/README.md +++ b/benchmarks/bundle-size/README.md @@ -42,7 +42,7 @@ pnpm benchmark:bundle-size:run --scenario react-router.minimal,react-router.full The runner calls `measure.mjs`, which builds the selected package projects through Nx. Full runs build the package projects for all scenarios. `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. -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`. +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`. If the required packages are already built and unchanged, skip that step: diff --git a/benchmarks/bundle-size/package.json b/benchmarks/bundle-size/package.json index 283f675e44..ed1e7410f7 100644 --- a/benchmarks/bundle-size/package.json +++ b/benchmarks/bundle-size/package.json @@ -3,12 +3,13 @@ "private": true, "type": "module", "scripts": { - "build": "node ../../scripts/benchmarks/bundle-size/measure.mjs --skip-package-builds --measurements-only", + "measure": "node ../../scripts/benchmarks/bundle-size/measure.mjs --skip-package-builds --measurements-only", "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" }, "nx": { "targets": { - "build": { + "measure": { + "cache": true, "inputs": [ "buildProduction", "^buildProduction", diff --git a/scripts/benchmarks/bundle-size/build.mjs b/scripts/benchmarks/bundle-size/build.mjs index df48d53e5c..092087cec7 100644 --- a/scripts/benchmarks/bundle-size/build.mjs +++ b/scripts/benchmarks/bundle-size/build.mjs @@ -23,7 +23,7 @@ export function build(args, execute = spawnSync) { ...(pnpmPath ? [pnpmPath] : []), 'nx', 'run', - '@benchmarks/bundle-size:build', + '@benchmarks/bundle-size:measure', ...args, ], options, diff --git a/scripts/benchmarks/bundle-size/build.test.mjs b/scripts/benchmarks/bundle-size/build.test.mjs index 48717e8b17..74b1649152 100644 --- a/scripts/benchmarks/bundle-size/build.test.mjs +++ b/scripts/benchmarks/bundle-size/build.test.mjs @@ -20,7 +20,7 @@ test('generates a fresh report after a successful Nx run, including cache hits', assert.deepEqual(calls[0]?.slice(-5), [ 'nx', 'run', - '@benchmarks/bundle-size:build', + '@benchmarks/bundle-size:measure', '--outputStyle=stream', '--skipRemoteCache', ]) diff --git a/skills/bundle-size-optimization/SKILL.md b/skills/bundle-size-optimization/SKILL.md index 34f7494efe..1b6b5ebe3a 100644 --- a/skills/bundle-size-optimization/SKILL.md +++ b/skills/bundle-size-optimization/SKILL.md @@ -7,7 +7,7 @@ description: Use when working in this repository on JS bundle size, gzip regress ## Overview -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/`. +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/`. Use `benchmark:bundle-size:run` for local iterations. It uses the same measurement script and builds the selected packages through Nx. ## Commands