Skip to content

Compile UI Tailwind once per verification (#230) - #238

Merged
jimhoyd merged 1 commit into
mainfrom
fix/ui-styles-once-per-verify
Sep 20, 2026
Merged

jimhoyd merged 1 commit into
mainfrom
fix/ui-styles-once-per-verify

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator

Closes #230.

What changed

packages/ui ran verify as typecheck then build, and both of those run styles, so scripts/build-styles.mjs compiled the same minified Tailwind CSS twice per verification.

-    "typecheck": "npm run styles && tsc --noEmit",
-    "build": "npm run styles && tsc -p tsconfig.build.json",
-    "verify": "npm run typecheck && npm run build && npm test",
+    "typecheck": "npm run styles && npm run typecheck:tsc",
+    "typecheck:tsc": "tsc --noEmit",
+    "build": "npm run styles && npm run build:tsc",
+    "build:tsc": "tsc -p tsconfig.build.json",
+    "verify": "npm run styles && npm run typecheck:tsc && npm run build:tsc && npm test",

typecheck and build keep their old meaning — each still runs styles first — so either works alone on a fresh checkout. Every external caller (scripts/pack-sources.mjs, scripts/prepare-extension-release.sh, .github/workflows/ci.yml) invokes only styles, typecheck, build and verify, all of which are preserved. No workflow file changed, so required checks are untouched.

No caching and no up-to-date check were added. The single styles run is unconditional; there is no "skip if the file exists" path, so no stale output can survive a source change.

Docs updated: packages/ui/README.md, packages/ui/CONTRIBUTING.md, packages/ui/AGENTS.md, plus a changeset.

Measured

macOS 15, Node 26, local. Before each run: packages/ui/dist and packages/ui/src/styles.generated.ts removed. Paired A/B alternating the old and new script sets in the same session, 8 pairs:

median mean min max
before 2.85s 3.03s 2.81s 4.33s
after 2.63s 2.71s 2.59s 3.23s

Median paired saving 0.21s, mean 0.32s; per-pair deltas [0.22, -0.37, 1.74, 0.19, 0.22, 0.13, 0.21, 0.22] — the 1.74s and -0.37s pairs are machine noise.

Honest reading: that is roughly 7% of a ~2.9s run. The styles step alone takes under a second on this machine, so the wall-clock saving is small. The issue's own CI timings describe one run rather than a controlled benchmark, and CI (cold cache, slower runners) was not measured, so no larger claim is made here. The change is worth making because the double compilation is a real redundancy that can be removed without adding a cache, not because it is a meaningful speedup.

Verified

  • Exactly one styles invocation in verify's output, down from two.
  • src/styles.generated.ts is byte-identical (sha256 2f7e3ad4…) from typecheck alone, build alone, or verify.
  • Invalidation: adding an unused utility class to src/components.ts changed the generated hash and emitted the class in the CSS; reverting restored the original hash.
  • From a clean state, build alone emits the stylesheet plus dist/index.d.ts, and typecheck alone passes.
  • npm run lint, npm run check, npm test (581 pass, 1 skipped), npm run verify:workspaces (ui 59, auth 196, admin 63, workspace integration 1 — all pass).

Not established

  • No true fresh clone with npm ci was run. Each measurement reset packages/ui to its unbuilt state instead, and the root dist/ that packages/ui/test/scaffold.test.ts requires was built once beforehand, as CI does.
  • CI wall-clock effect is unmeasured; only local timings are reported.
  • Only packages/ui was touched. auth and admin still run typecheck then build in their own verify, which duplicates tsc work but not style compilation.

🤖 Generated with Claude Code

packages/ui ran verify as typecheck then build, and both of those run
styles, so scripts/build-styles.mjs compiled the same minified CSS twice
per verification. verify now runs styles once and then the compiler-only
typecheck:tsc and build:tsc scripts. typecheck and build keep their old
meaning -- each still runs styles first -- so either works alone on a
fresh checkout, and every external caller (scripts/pack-sources.mjs,
scripts/prepare-extension-release.sh, .github/workflows/ci.yml) still
invokes only styles, typecheck, build and verify. No CI workflow changed.

No caching and no up-to-date check were added. The single styles run is
unconditional, so no stale output can survive a source change.

Verified locally on macOS 15 / Node 26, from a state with no
packages/ui/dist and no src/styles.generated.ts:

- Paired A/B, alternating old and new scripts, 8 pairs each: verify
  median 2.85s before, 2.63s after; median paired saving 0.21s, mean
  0.32s (one outlier pair at 1.74s, one at -0.37s). That is about 7% of
  a ~2.9s run, and the styles step alone is under a second here. The
  redundancy is real but the wall-clock saving is small; the issue's own
  CI timings describe one run, not a benchmark, so no larger claim is
  made. CI, where the run is cold, was not measured.
- Exactly one styles invocation in verify's output, down from two.
- src/styles.generated.ts is byte-identical (sha256 2f7e3ad4...) whether
  produced by typecheck alone, build alone, or verify.
- Invalidation: adding an unused utility class to src/components.ts
  changed the generated hash and emitted the class; reverting restored
  the original hash.
- build alone and typecheck alone each still emit the stylesheet and
  dist/index.d.ts from a clean state.

Gates run: npm run lint, npm run check, npm test (581 pass, 1 skipped),
npm run verify:workspaces (ui 59, auth 196, admin 63, integration 1, all
pass). A true fresh clone plus npm ci was not run; the ui package was
reset to its unbuilt state before every measurement, and the root
dist/ that packages/ui/test/scaffold.test.ts requires was built once
first, as CI does.

Co-Authored-By: Claude Opus 5 <[email protected]>
@jimhoyd
jimhoyd force-pushed the fix/ui-styles-once-per-verify branch from 2e42cf0 to 8ae2033 Compare September 20, 2026 05:19
@jimhoyd
jimhoyd merged commit 1080f4b into main Sep 20, 2026
20 checks passed
@jimhoyd
jimhoyd deleted the fix/ui-styles-once-per-verify branch September 20, 2026 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Request]: Generate UI styles once during workspace verification

1 participant