Repository navigation
chore(deps): upgrade tailwindcss 3 → 4, which is also the exit from the unpatched braces advisory - #247
Conversation
…246) `scripts/audit-baseline.json` was empty, so `check-audit.mjs` exited 1 on `main` and turned every PR red on Dependency Audit. GHSA-vfj7-8cjw-p6xm has no published fix, so there is nothing to update to within 3.x. Booked against this ticket rather than waived: the upgrade to tailwindcss 4 later in this PR removes the package that carries the edge, and deletes this entry in the same breath. The weekly `--strict` run fails on a booked advisory that no longer reports, so both halves have to land together. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Replaces `tailwind.config.js` with CSS-first `@theme`, and takes `braces` out of the production graph on the way: `[email protected]` declares zero dependencies, so `pnpm audit --prod` now reports 0 high and 0 critical. Staying on 3.x was not an exit — `3.4.19` still declares `chokidar`, `fast-glob` and `micromatch`. Two invariants this repo already held would have broken by default, and both are mechanical consequences of v4 rather than judgement calls. **v4 emits real cascade layers, which inverts #156.** An author layer loses to a host page's unlayered rules, so layering our sheet would hand a host's `button {}` an automatic win over every utility we ship. Tailwind's parts are therefore imported without a `layer()` clause, and the scoping pass flattens the one `@layer properties` block v4 still emits for its `@property` fallback. `dist/` carries no `@layer` at all. **v4's default theme is rem, and `assert:css` fails on one (#238).** Every scale is re-pinned in px under `@theme`, with `*: initial` clearing each namespace first — the v3 config replaced these scales rather than extending them, so without the clear v4's own rem defaults survive alongside ours. `--spacing: 4px` re-pins all 37 spacing entries by itself. Breakpoints are pinned too, for parity rather than because they were a bug: a media query's rem resolves against the browser's initial font size, not the root's. Three things the ticket did not anticipate, each measured: - **The reset had to move to its own sheet.** v4's entry is `@import`, and an `@import` must lead the file, so a rule can no longer be written above it. The reset's `all: revert` is (0,0,0) — exactly tying Preflight's own `*` rule — so source order is the only thing separating them. Same reason for `base.css`, which holds v3's `@layer base` and must keep losing to the utilities. - **`@apply` needed two fixes.** v4 applies utilities only, so the `.bg-panel` family becomes `@utility` (which is what makes `@apply bg-panel` resolve at all), and importance moves onto each utility as a trailing `!`. - **lightningcss hands the scoping pass optimised selectors.** It elides the universal selector before a pseudo-element, emitting `.x>*+:before` for the List molecule's `[&>*+*]:before:` variants. Peeling the pseudo-element off left a body ending in a combinator, and the pass refused it. It restores the `*` now. `prettier-plugin-tailwindcss` goes to 0.7.4, not 0.8.1: 0.8.1 crashes against this repo's pinned `[email protected]`. `tailwindStylesheet` points it at the stylesheet, since there is no config file left to find — the sweep it produced is class-order only, and it sorts our own `@utility` names. `tailwind-merge` becomes a direct dependency at 3.x because `tailwind-variants@3` declares it as a peer, and v1's conflict tables do not know v4's class names, so `tv()` would resolve conflicts wrongly. The size budget goes 308 → 318 KiB. Both graphs grew 5.9 KiB against origin/main built the same way; the loader did not move. About 4.3 KiB of that is the stylesheet (v4's per-property `@property` blocks and the `color-mix` plus `@supports` pair behind every `/NN` modifier) and 1.7 KiB is `tailwind-merge`. Numbers recorded beside the budget. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…it (#246) Phase 1 booked GHSA-vfj7-8cjw-p6xm so the Dependency Audit gate would stop failing every PR. The tailwindcss 4 upgrade removed the package that carried it, so `pnpm audit --prod` no longer reports it at all. Both halves have to land in one PR. `audit.yml` adds `--strict`, which fails on a booked advisory that no longer reports — verified: exit 1 with the entry left behind, exit 0 without it. Leaving the line would have turned the weekly ratchet red instead of a PR, which is the slower way to find out. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Tailwind 4 builds its utilities on `@property` and `color-mix()`, which Firefox shipped in 128. Chrome 111 and Safari 16.4 already met v4's own floors, so Firefox is the only row that moves. The failure mode is worth stating, because it is not graceful: `@property` is what registers the custom properties the utilities read, so a Firefox between 114 and 127 gets the markup with no working utility behind it — unstyled, not partly styled. `docs/embedding.md` and `CHANGELOG.md` are the only documentation an embedding site reads, so both carry it. No CSP row changes and no new origin. Also corrects the guidance that would now mislead: `src/AGENTS.md` still said Tailwind was 3.4.3 and pointed at `TAILWIND_REM_TO_PX` in a deleted file, and `src/styles/fonts.ts` pointed `fontFamily.sans` at the same. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Deploying sahajatlas with
|
| Latest commit: |
763e06e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://53ddd3b5.sahajatlas.pages.dev |
| Branch Preview URL: | https://claude-chore-246-tailwind-4.sahajatlas.pages.dev |
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The diff is the size of its ticket, and the additions the ticket called unnecessary earn their place: a probe through @tailwindcss/[email protected] shows v4 still emits @layer properties with unlayered imports, so flattenCascadeLayers is load-bearing.
One gap the diff opens and nothing closes. v4 registers 18 document-global @property names into the host page — a third global namespace beside @keyframes and @font-face, which this repo namespaces and allowlists. assertScoped walks rules only, so it never reaches them.
Findings
- should-fix —
@propertyreaches the host page unscoped and ungated —scripts/postcss-scope-widget.mjs:397 - should-fix — the published Firefox degradation is backwards —
docs/embedding.md:926 - consider —
text-3xlstays inert, now documented as intended —src/styles/globals.css:133
What was checked
Ticket #246 against the diff. Read whole: globals.css, host-reset.css, base.css, both CSS scripts. Both host-facing files updated. The sweep is class order.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
Tailwind 4 composes its utilities through registered `--tw-*` custom properties, and `@property` registers a name rather than a selector. So the scoping pass cannot touch one and `assertScoped`, which walks rules, cannot see one: 62 registrations reached the host document with nothing gating them. That is the same hole a bare `@keyframes` or an unnamespaced `@font-face` opens, and it arrived with this upgrade. They cannot be namespaced, since Tailwind writes the `var()` references itself, so the gate allows the one prefix by name — the `@font-face` precedent — and fails on anything else. Finding none at all also fails, because a walk that stops matching would otherwise pass vacuously. Both new assertions were verified by reintroducing the defect. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PRPmyE9hgcsWJ43uzFiUck
Both host-facing files said the widget renders unstyled below 128. It does not. Tailwind emits an `@supports` block guarded on `(-moz-orient: inline) and (not (color: rgb(from red r g b)))`, which matches Firefox under 128 exactly, setting every `--tw-*` to its initial value; the scoping pass flattens the layer but keeps the block. Measured in the shipped CSS: layout, spacing, colour and radius utilities emit plain declarations, no declaration uses relative colour syntax, the `color-mix()` ones carry their own `@supports`, and nothing animates a registered property. So 128 is the version Tailwind declares support for, which is where the three published numbers come from, not the version below which the widget stops rendering. The JavaScript target is unchanged, and its own Baseline floor is still Firefox 114 — worth saying, since the table now reads 128. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PRPmyE9hgcsWJ43uzFiUck
`text-3xl` generated nothing: the `--text-*` scale stops at `2xl`, so the story's mock host-page title has always rendered at the inherited 15px. `--text-2xl` is 30px, which is the size stock Tailwind's `text-3xl` would have given it, so the class the scale does define is also the one that renders it as written. The scale itself is left alone. Adding `--text-3xl` would invent a type step no design token defines, and this story's mock host page was its only call site. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PRPmyE9hgcsWJ43uzFiUck
The scoping section covered `@keyframes` only, so the gate's two allowlists read as arbitrary. A developer adding a `@property` of our own would meet a red build with no guide explaining it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PRPmyE9hgcsWJ43uzFiUck
Deploying sahajatlas-design with
|
| Latest commit: |
763e06e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://15150c8d.sahajatlas-design.pages.dev |
| Branch Preview URL: | https://claude-chore-246-tailwind-4.sahajatlas-design.pages.dev |
|
Addressed all three adversarial-review threads. Lean gate green, Adopted
Partly adopted, left open
🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
The cause breakdown and the headroom restatement both duplicated what the paragraph above the budget already says, and the PR body carries the breakdown. The measured before/after numbers are what a later reader cannot re-derive, so they stay. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KGbJYnhF68ZkXCFdVrGV7x
The header restated globals.css's import comment and its own body comment. What a reader cannot re-derive is the two-sided position — after preflight, before the utilities — so that stays. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KGbJYnhF68ZkXCFdVrGV7x
The specificity tie with Preflight is already the body comment's second numbered point, so the header only needs to name the position and why the rules are a file rather than a block in globals.css. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KGbJYnhF68ZkXCFdVrGV7x
|
Addressed all three threads. Lean gate green — 1632 tests, 128 files. The push is comments only: Adopted
Answered, left open for you
Both headers are trimmed to that one constraint now. Docs checked, nothing stale. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
#247 landed first, which is the order this PR's body warned about. Its one conflict is `scripts/audit-baseline.json`, and the resolution takes main's side whole: the booking this branch added for GHSA-vfj7-8cjw-p6xm is dead. #247 upgraded tailwindcss 3 → 4, and tailwindcss 4 declares zero dependencies, so all six paths to `braces` left the production graph. A baseline entry for an advisory no longer reported is the single state the weekly `audit.yml --strict` run fails on. Keeping this branch's side would have re-armed exactly that. Measured on the merge result: `pnpm audit:check` reports 0 critical, 0 high, 0 new, and `check-audit.mjs --strict` is green as well. Main's own note text already carries the braces chapter and names #246 as the exit, so nothing in the dropped prose survives unrecorded. The conflict was confined to that file. The other four the branch touches (.github/workflows/production-smoke.yml, scripts/ci-workflows.test.ts, docs/testing.md, AGENTS.md) merged clean and are unchanged by this commit. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WyV8BqCadb5ceVGrfN9Cab
#247 moved the stylesheet to Tailwind 4 CSS-first config and split the #156 defensive reset out into src/styles/host-reset.css. This branch retires that reset, because the shadow root is the boundary now. Both intents are kept: globals.css takes main's v4 part-imports, @source and @theme wholesale, and #236's retirement lands in host-reset.css, where the reset now lives — the `all: revert` rule is gone, the retirement note and the inherited `.sy-atlas` baseline stay, still unlayered and still ahead of preflight. - package.json: both of this branch's pinned patch targets stay, main's @tailwindcss/postcss stays, and `autoprefixer` goes — v4 prefixes through lightningcss, and postcss.config.js no longer loads it. - pnpm-lock.yaml: regenerated from main's lockfile by `pnpm install`. - scripts/audit-baseline.json: main's side. This branch had booked the braces advisory against tailwindcss 3; #247's v4 upgrade took all six paths to it out of the graph, so the list is empty rather than waived. - scripts/postcss-scope-widget.test.ts: this branch's assertions, aimed at host-reset.css, which is where the reset it pins against moved. - CHANGELOG.md and docs/embedding.md: both sides' entries. The exception list is six now — the live region and the @Property registrations are separate facts a host can observe. Gates: lean gate ✓ (135 files, 1665 tests), build ✓ with assert:css (1176 rules, 3 sheets, 62 @Property allowlisted) and assert:maps ✓, `pnpm size` ✓ (standalone 308.2/318, loader 2.7/3.5, embed 310.0/318 KiB), `pnpm audit:check` ✓ (0 new high or critical). Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0117YshqyPTLWEVcZ65d7DHa
Summary
tailwindcss3.4.3 → 4.3.3, replacingtailwind.config.jswith CSS-first@theme.braces(GHSA-vfj7-8cjw-p6xm, high, no published fix) out of the production graph:pnpm audit --prodreports 0 high, 0 critical.docs/embedding.mdandCHANGELOG.md: the published Firefox floor moves 114 → 128, and the stylesheet registers 62 document-global@propertynames. No CSP row moves.Changes
src/styles/host-reset.css,src/styles/base.css— new, extracted fromglobals.css. v4's entry is@import, and an@importmust lead the file, so the two rule blocks whose cascade position is load-bearing could no longer be written above it. Order is nowhost-reset → theme → preflight → base → utilities, which is what v3's layers gave for free.src/styles/globals.css— the@themeblock, the unlayered part-by-part import,@custom-variant dark, and the@utilityconversions.scripts/postcss-scope-widget.mjs— flattens@layer; restores a universal selector lightningcss elides.scripts/assert-css-scoped.mjs— gates@property, the third document-global namespace. The--tw-prefix is allowlisted by name, the way a font family is; anything else fails the build, and finding none fails too.scripts/check-bundle-size.mjs— budget 308 → 318 KiB, with the measured numbers.Test results
pnpm lint && pnpm typecheck && pnpm test:run— 1632 tests, 128 filesscripts/postcss-scope-widget.test.ts; 3 existing updated for the moved files. Each new assertion was verified by reintroducing its defect and watching it fail.pnpm build—assert:cssconfirms 1177 rules confined to.sy-atlasand 62@propertyregistrations allowlisted, with noremoutside the calendar chunk;assert:mapscleanpnpm size: ✓ standalone 307.9 / embed 309.6 / loader 2.7, all inside the raised budgetpnpm ladle:build: ✓pnpm audit:check: ✓ exit 0, and--strictexit 0 (the ratchet)grep -ro '@layer' dist/: 0Manual verification
Two checks from the ticket could not run here — neither is reachable from a headless runner, and both are the gates the automated lane cannot be.
pnpm ladle, light and dark. A wrong@themevalue compiles cleanly and simply looks wrong. Worth most attention: every/NNopacity utility now emitscolor-mix()in oklab instead of HSL alpha, which is a real visual delta on every one of them, androunded-sm(2px) vs v4's own default naming.pnpm review:embedafterpnpm build— the feat(widget): de-brand the widget and keep host CSS out of it #156 direction specifically: a host rule onbutton,a,div,letter-spacingandline-heightmust still lose to our utilities. This PR moves that reset into its own file, so its position is exactly what wants confirming.Notes for reviewer
The cascade is the whole risk in this PR, and two of its three mechanisms are new here rather than from the ticket.
@layer propertiesfor its@propertyfallback, so the scoping pass flattens any@layer. That is belt-and-braces on purpose — a future Tailwind that layers something cascade-relevant then cannot reachdist/unnoticed.all: revertis(0,0,0), which exactly ties Preflight's own*, ::before, ::afterrule. Source order is the only thing separating them. That is whyhost-reset.cssexists as a file, and the single most load-bearing line in the diff is its@importsitting abovepreflight.css.scripts/postcss-scope-widget.mjsis the pass that keeps our CSS out of host pages, so changing it is the security-relevant part of this diff. The build's ownassertScopedbackstop ran over all 1177 emitted rules and passed, which is a build-time proof rather than a judgement.@propertyis a third document-global namespace, and it arrived with this upgrade. It registers a name rather than a selector, so the scoping pass cannot touch one andassertScoped, which walks rules, could not see one — 62 registrations reached the host document ungated. The gate now covers them,src/components/AGENTS.mdnames all three namespaces, anddocs/embedding.mdcarries a fifth honest exception beside@font-face.One review lens still has not run. The configured
/security-reviewis triggered by this diff (src/styles/,postcss.config.js,package.json,pnpm-lock.yaml,scripts/*css*), and/simplifyand/code-review highdid not fit either run's lease. What did run: the adversarial review, whose three findings are all answered in-thread;comment-lint(clean, 28 files); and the sink check for thecontentPattern(nodangerouslySetInnerHTML,DOMPurifyor.innerHTMLadded).The
text-3xlcall site is fixed; the silence behind it is not.CompactEmbedView.stories.tsx:70rendered its mock host-page heading at the inherited size, because the--text-*scale stops at2xl— v3 declaredfontSizetwice and the second block won. It now usestext-2xl, which is 30px, the size stock Tailwind'stext-3xlwould have given it. The scale itself is unchanged: adding--text-3xlwould invent a type step no design token defines. So a futuretext-3xlstill generates nothing, whichsrc/AGENTS.mddocuments as the silent-failure trap, and a gate on ungenerated classes wants its own ticket.Detail
Deviations from the ticket, each measured rather than assumed.
prettier-plugin-tailwindcssis 0.7.4, not 0.8.1. 0.8.1 throwsTypeError: e.charAt is not a functioninside prettier's own TypeScript parser against this repo's pinned[email protected], despite declaringprettier: ^3.0. 0.7.4 sorts v4 classes against the same prettier.tailwindStylesheetin.prettierrcpoints it atglobals.css, since there is no config left to find — without it the plugin cannot see our@utilitynames. The sweep it produced is 24 files of class-order only; no props moved, so thejsx-sort-propscomment-displacement trap did not fire.@sourcepaths are stylesheet-relative, not project-root-relative (../../src, not./src), confirmed by the resolver error. The ticket's snippet would not have resolved.@importposition, notsource(none), was the first build failure. The ticket placed the imports where the@tailwinddirectives were — after ~100 lines of rules. Those imports are not inlined there, so the theme never registered and every@applyfailed on an "unknown utility class". Probes confirmedsource(none)itself is fine.@applyneeded two fixes the ticket did not list. v4 applies utilities only, so.bg-panelmust be@utilityfor@apply bg-panelto resolve at all; and importance moves onto each utility (text-primary!), since a trailing!importantis parsed as a utility name.40remetc., and 73 responsive utilities depend on them — but a media query'sremresolves against the browser's initial font size, not the root's, so they were never a fix(ui): a host's root font size shrinks the side panel #238 exposure.assert-css-scoped.mjsis declarations-only for the same reason.@tailwindcss/postcssis a devDependency. It is build-time only, and keeping it out of the production graph keepsaudit --prodhonest.tailwindcssitself stays independencies, satisfyingtailwind-variants' peer; harmless now that it declares no dependencies of its own.What a Firefox between 114 and 127 actually gets, measured in the shipped CSS. Not an unstyled widget, which both host-facing files claimed until e8c8e79. Tailwind emits an
@supports ((-moz-orient: inline) and (not (color: rgb(from red r g b))))block setting every--tw-*to its initial value, matching exactly the versions below the floor, and the scoping pass flattens the layer but keeps the block. Layout, spacing, colour and radius utilities emit plain declarations; no declaration uses relative colour syntax (its only occurrence indist/is that feature test); thecolor-mix()ones carry their own@supportsand use oklab, which Firefox has had since 113; and nothing in the bundle animates a registered property. So 128 is the version Tailwind declares support for — which is where all three published numbers come from — not the version below which the widget stops rendering.build.targetis untouched, and Baseline's own Firefox leg is still 114.The size budget, measured against
origin/mainat 5c85fda built the same uncredentialed way.+6.0 KiB on standalone and +5.9 on embed, loader flat, so the loader/embed seam is intact. About 4.3 KiB is the stylesheet, even though the rule count barely moved (1172 → 1177): v4 emits an
@propertyblock per custom property, a--tw-*: initialfallback set, and acolor-mix()plus@supportspair for every/NNmodifier v3 wrote as plainhsl(… / x). The remaining 1.7 KiB istailwind-merge1 → 3. Both numbers are recorded beside the budget, with the credentialed gap.Residual advisories, unchanged by this PR and ungated:
payloadandfast-uri(moderate),dompurify(low) — exactly what the ticket predicted would remain.The baseline entry nets to zero in this diff, deliberately. Phase 1 books the advisory so the commits before the upgrade are not red; the last commit deletes it.
audit.yml --strictfails on a booked advisory that no longer reports — verified both ways, exit 1 with the line, exit 0 without.Closes #246
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code