Skip to content

chore(deps): upgrade tailwindcss 3 → 4, which is also the exit from the unpatched braces advisory #246

Closed

Description

@sydevs-bot

Summary

Upgrade tailwindcss 3.4.3 → 4.3.3. That is the deliverable now, not the fallback.

The upgrade is also the exit from the unpatched braces DoS advisory
(GHSA-vfj7-8cjw-p6xm, high, CVSS 7.5,
CVE-2026-93687, vulnerable <=3.0.3, no published fix). [email protected] has zero
dependencies
, so the six paths that reach braces leave the production graph with it.

Measured, not assumed. A scratch lockfile resolved with [email protected],
[email protected], tailwind-merge@^3.7.0 and @tailwindcss/[email protected], with
autoprefixer dropped, gives pnpm audit --prod → 0 high, 0 critical. braces is gone from
--prod entirely. What remains is what remains today and is ungated: payload and fast-uri
(moderate), dompurify (low).

[email protected] (today) [email protected]
own dependencies 23 0
pnpm audit --prod high 1 (braces) 0
PostCSS entry tailwindcss @tailwindcss/postcss
config tailwind.config.js CSS-first @theme in globals.css

Staying on 3.x is not an exit

[email protected] is published on the v3-lts dist-tag, so "upgrade within 3" looks like a
cheap third option. It is not: 3.4.19 still declares chokidar, fast-glob and micromatch,
which are three of the six paths. Measured off the registry metadata. The braces edge survives
every 3.x.

Approach

Three phases, one PR, in this order. Phase 1 is independent and unblocks everyone; phases 2 and 3
are the upgrade.

Phase 1 — book the advisory, so CI goes green

scripts/audit-baseline.json:29 is "advisories": {}, so node scripts/check-audit.mjs exits 1
on main today and every PR here is red on Dependency Audit. Confirmed by running it:
New high/critical advisories (1): GHSA-vfj7-8cjw-p6xm (braces).

Add the one entry keyed by the GHSA id, with a one-line reason naming this ticket.
scripts/check-audit.mjs:188 compares the audit's gated ids against those keys, and
.github/workflows/ci.yml:76 runs it on every PR. The lean gate
(.claude/skills/pr-prep/check.sh) does not include audit:check, so this failure is
invisible locally and shows up only in CI.

Phase 3 deletes the entry again. Both halves belong in this ticket: the weekly
audit.yml --strict run fails on a baseline entry whose advisory no longer reports, so leaving
the line behind turns the ratchet red.

Phase 2 — the cascade and the units. This is the hard part.

Two invariants this repo already holds break by default under v4. Both were measured by compiling
a probe sheet through @tailwindcss/[email protected], not read off the migration guide.

1. v4 emits real cascade layers, and that inverts #156. v3 strips its own @layer and emits
flat rules. v4 emits @layer theme, base, components, utilities; and wraps everything in them.
src/styles/globals.css:45 already states the trap, aimed at the opposite direction: unlayered
author styles outrank every author layer, so layering our sheet hands a host page's
button { … } an automatic win over our utilities. v4 does that to us by default, for the whole
utility set — a host-visible regression in the defensive reset, not a cosmetic one.

Mitigation, measured: import the parts without a layer() clause and the output carries zero
@layer at-rules, matching v3's cascade position exactly.

@import 'tailwindcss/theme.css' source(none);
@import 'tailwindcss/preflight.css';
@import 'tailwindcss/utilities.css' source(none);
@source './index.html';
@source './src';
@source './.ladle';

This replaces @tailwind base; @tailwind components; @tailwind utilities;
(src/styles/globals.css:134). source(none) plus explicit @source lines keep the deliberate
content behaviour from tailwind.config.js:157 — scan all of src, so a directory rename never
silently drops a utility.

2. v4's default theme is rem, and pnpm assert:css fails the build on one. The probe emitted
--spacing: 0.25rem, --text-sm: 0.875rem, --radius-lg: 0.5rem from a handful of utilities.
scripts/assert-css-scoped.mjs:65 allows rem only in the lazy CalendarView-* chunk (#238), so
every one of these fails the build.

TAILWIND_REM_TO_PX (tailwind.config.js:24) is the v3 answer and has to be re-expressed as
@theme. It gets shorter: v4 derives the spacing scale from one variable, so

@theme { --spacing: 4px; }

re-pins all 37 entries — .p-4 compiles to padding: calc(var(--spacing) * 4). Measured: with
that one line the probe output contains zero rem. preflight.css ships no rem of its own, so
the theme variables are the entire surface.

Re-pin in px, each against the table it replaces: --spacing (one line), --radius-*
(borderRadius, tailwind.config.js:25), --text-* (fontSize, both the TAILWIND_REM_TO_PX
block and the overriding one at tailwind.config.js:200), --leading-* (lineHeight),
--container-* (maxWidth plus columns). maxWidth is a function taking { theme, breakpoints }
(tailwind.config.js:95); v4 has no breakpoints() helper, so those keys get written out.

Phase 3 — the mechanical migration

Each item below is a known call site, not a sweep.

  1. postcss.config.js:13 — swap tailwindcss() for @tailwindcss/postcss, drop
    autoprefixer (v4 prefixes through lightningcss). Keep the PostCSS entry point; do not take
    @tailwindcss/vite.
    scopeWidgetCss has to run last over the finished sheet, Tailwind's
    generated output included. The Vite plugin does Tailwind's work outside the PostCSS chain, so
    the scoping pass would stop seeing the utilities it exists to confine — and pnpm assert:css
    is a post-build gate, so the leak would reach dist/ before anything complained.
  2. darkMode: 'class' (tailwind.config.js:258) → @custom-variant dark (&:where(.dark, .dark *));.
    Measured: dark:bg-primary compiles to .dark\:bg-primary:where(.dark, .dark *), which keeps
    working with src/hooks/use-theme.ts:23 and Ladle's theme addon (.ladle/config.mjs) unchanged.
  3. <alpha-value> is gone — 4 call sites, tailwind.config.js:10, :12, :13, :188.
    v4 handles the /50 modifier itself: measured, bg-primary/50 emits
    color-mix(in srgb, hsl(var(--primary-9)) 50%, transparent) with an @supports upgrade to
    in oklab. So brandScale becomes plain --color-primary-*: hsl(var(--primary-N)) entries and
    the opacity modifiers keep working. ⚠ The blend moves from HSL alpha to color-mix in oklab —
    a real visual delta on every /NN utility, which is part of what the browser pass checks.
  4. radixScale (tailwind.config.js:19) needs no change in substance — solid var(--gray-N)
    values become --color-gray-* entries.
  5. theme.extend.opacity (tailwind.config.js:195) → @theme { --opacity-hover: 0.8; --opacity-disabled: 0.5; }. Measured: opacity-hover still generates, which keeps
    src/styles/globals.css:358 (@apply text-primary hover:opacity-hover !important) compiling.
  6. fontFamily (tailwind.config.js:239) → --font-sans etc. defaultTheme.fontFamily.* has
    no v4 equivalent import, so the fallback stacks get written out. The
    var(--sy-font-sans, "Atlas Rethink Sans") indirection and the fix(ui): scope widget css so it cannot restyle the host page #91 reasoning above it carry
    over verbatim; src/styles/fonts.test.ts covers the family name.
  7. backgroundImage (tailwind.config.js:254) → --background-image-circle-pattern.
  8. tailwind-variants 0.1.20 → 3.3.1, and tailwind-merge becomes a direct dependency.
    0.1.20 bundles tailwind-merge@^1.14.0 as a dependency; 3.3.1 declares it as a peer at
    >=3.0.0. v1's merge tables do not know v4's class names, so this upgrade is not optional —
    it is what makes tv()'s conflict resolution correct. tailwind-variants keeps its
    tailwindcss: '*' peer, which is now harmless: the edge resolves to a package with no
    dependencies.
  9. prettier-plugin-tailwindcss 0.6.14 → 0.8.1 for v4 class sorting. A full
    pnpm lint:fix pass will reorder class strings across src/. ⚠ jsx-sort-props autofix moves
    props and leaves comments where they sat (docs/rules/code-comments.md) — re-read every JSX
    opening element the sweep touched.
  10. The scoping pass itself needs no change. isNested()
    (scripts/postcss-scope-widget.mjs:426) skips only rules with a rule-type ancestor, and
    @layer is an at-rule — so had we kept the layers, rules inside them would still be scoped and
    still asserted. Phase 2 removes the layers anyway. v4 does emit nested @supports inside
    rules, which the pass sees more of than before, so scripts/postcss-scope-widget.test.ts is
    the spec to extend.
  11. tailwind.config.js can be deleted once @theme carries everything. ⚠ Do not keep it
    alive through @config: that is the v3 compatibility path, and <alpha-value> and the
    breakpoints() helper are exactly what it exists to preserve — a half-migrated config is a
    second source of truth for the token set.

Acceptance criteria

  • scripts/audit-baseline.json books GHSA-vfj7-8cjw-p6xm against this ticket in Phase 1, and
    pnpm audit:check exits 0.
  • [email protected] and @tailwindcss/[email protected] installed; autoprefixer removed;
    tailwind-variants@^3.3.1 and tailwind-merge@^3.7.0 installed.
  • GHSA-vfj7-8cjw-p6xm no longer reported by pnpm audit --prod, and its baseline entry is
    deleted in the same PR.
  • The emitted CSS carries no @layer at-rule, so the feat(widget): de-brand the widget and keep host CSS out of it #156 reset keeps its cascade position.
  • pnpm build passes, assert:css included — no rem outside the CalendarView-* chunk.
  • tailwind.config.js is deleted, and no @config directive replaces it.
  • docs/embedding.md's Browser support table and CHANGELOG.md both state the Firefox floor
    this moves (see Downstream impact).

Verification checklist

  • node scripts/check-audit.mjs exits 0 after Phase 1.
  • pnpm audit --prod --json | grep GHSA-vfj7-8cjw-p6xm — matches after Phase 1, no match
    after Phase 3.
  • node scripts/check-audit.mjs --strict exits 0 after the baseline entry is deleted. It exits
    1 if the entry is left behind, which is the ratchet.
  • pnpm build succeeds. Then grep -c '@layer' dist/**/*.js → 0, and pnpm assert:css passes.
  • pnpm size stays inside budget. Record the new numbers beside the budget in
    scripts/check-bundle-size.mjs — the eager payload changes, and the loader/embed graphs must
    still share no chunk.
  • pnpm lint && pnpm typecheck && pnpm test:run (the lean gate) and pnpm ladle:build.
  • A browser pass over all 50 stories in both themes — pnpm ladle, light and dark. This is
    the gate the automated lane cannot be: a wrong @theme value compiles cleanly and just looks
    wrong. The /NN opacity utilities (now color-mix) and every TAILWIND_REM_TO_PX scale are
    what to look at.
  • pnpm review:embed after pnpm build — a real host-page embed, checking the feat(widget): de-brand the widget and keep host CSS out of it #156 direction
    specifically: a host rule on button, a, div, letter-spacing and line-height must
    still lose to our utilities.
  • Spot-check the three @layer components / @layer utilities blocks in
    src/styles/globals.css:320-360 still compile their @apply lines, bg-panel,
    flex-center and colored-links included.

Open questions

  • Which Firefox floor ships? v4 needs 128; docs/embedding.md publishes 114.
    Raise the documented floor, or hold the upgrade? Chrome 111 and Safari 16.4 already match
    v4's own floor, so Firefox is the only gap.
  • Which exit — wait for [email protected], or upgrade? Upgrade. Decided in the thread.
  • Is an availability-only advisory worth a major CSS upgrade? Yes. Decided in the thread.

Downstream impact

docs/embedding.md and CHANGELOG.md, in this PR. The Browser support table publishes
Firefox 114; Tailwind 4 requires 128. That is a host-observable contract change, and those two
files are the only documentation an embedding site reads.

No CSP row changes: v4 adds no origin, and the stylesheet still injects through
vite-plugin-css-injected-by-js. No SahajCloud or SahajAtlasWordpress change — the atlas URL
contract and the CMS types are untouched.

Notes

  • A pnpm.patchedDependencies patch of braces would not clear the gate. pnpm audit matches
    installed versions against the advisory range, not patched content, so the finding survives the
    fix. It is not a third exit.
  • pnpm.auditConfig.ignoreGhsas is closed off on purpose. scripts/check-audit.mjs treats its
    presence as a failure rather than a waiver, and turns the PR red.
  • Moving tailwindcss to devDependencies does not work, measured. Entry moved, lockfile
    rebuilt with pnpm install --lockfile-only, node scripts/check-audit.mjs still exits 1 on the
    same GHSA, because tailwind-variants keeps the peer edge in the production graph. Recorded
    because it is the obvious shortcut and it is a dead end. Phase 3 makes it moot either way.
  • Two non-gated findings sit beside this one, out of scope here: fast-uri (moderate, patched
    >=3.1.8) and dompurify (low, patched >=3.4.16). Both are fixable in range.
  • Every measurement above came from [email protected] / @tailwindcss/[email protected] compiled
    through PostCSS 8.5.26, and from a scratch lockfile resolved with pnpm 9.15.0.

🤖 Written by the sydevs autonomous loop — see what this is

Activity

  1. added
    proposal
    bot:working
    on Oct 3, 2026
  2. sydevs-bot commented on Oct 3, 2026

    @sydevs-bot
    ContributorAuthor

    🤖 no session running

    recent dispatches
    • 19:54Z implement · attempt 1 · session · done
    • 19:54Z implement · attempt 1 · session
    • 18:36Z revise · attempt 1 · session · done
    • 18:36Z revise · attempt 1 · session
    • 02:29Z revise · attempt 1 · session · done

    Written by the sydevs dispatcher. Sessions never edit this comment.

  3. added theissue type on Oct 3, 2026
  4. sydevs-bot commented on Oct 3, 2026

    @sydevs-bot
    ContributorAuthor

    Revised from the code. One claim in the body was false, and it matters.

    • The advisory is not booked. scripts/audit-baseline.json:29 is "advisories": {}, so node scripts/check-audit.mjs exits 1 on main today. Every PR here is red on Dependency Audit until that entry lands. The booking is now Phase 1 of ## Approach.
    • Two root edges, not one. [email protected] declares tailwindcss: '*' as a peer, and pnpm resolves it into the production graph. Six distinct paths reach braces, not three.
    • Moving tailwindcss to devDependencies does not even silence the gate. Measured: entry moved, pnpm install --lockfile-only, pnpm audit:check still exits 1 on the same GHSA. The refusal stands, for a better reason.
    • Not parked. A Hold Until would block Phase 1, which is live work.

    Priority High — the red gate blocks other work. Effort Easy. No tailwindcss 4 ticket filed; that is an open question for you.

    @sydevs-bot implement starts the work.

    🤖 Written by the sydevs autonomous loop — see what this is


    Generated by Claude Code

  5. added and removed
    bot:working
    on Oct 3, 2026
  6. moved this from Proposed to Revising in SYDevelopers Technical Roadmapon Oct 3, 2026
  7. Ardnived commented on Oct 3, 2026

    @Ardnived
    Contributor

    @sydevs-bot Revise this ticket as an upgrade to tailwindcss 4

  8. added
    bot:working
    and removed
    proposal
    on Oct 3, 2026
  9. changed the title [-]chore(deps): braces DoS advisory has no patch — tailwindcss 3 is its only path in[/-] [+]chore(deps): upgrade tailwindcss 3 → 4, which is also the exit from the unpatched braces advisory[/+] on Oct 3, 2026
  10. sydevs-bot commented on Oct 3, 2026

    @sydevs-bot
    ContributorAuthor

    Reshaped as the tailwindcss 4 upgrade. Title changed — it named the advisory, now it names the deliverable.

    Every claim below is measured:

    Phase 1 (book the advisory, green CI) stays. Phase 3 deletes the entry — the --strict ratchet needs both halves in one PR.

    Effort Easy → Hard. One open question for you: v4 needs Firefox 128, docs/embedding.md publishes 114.

    @sydevs-bot implement starts the work.

    🤖 Written by the sydevs autonomous loop — see what this is


    Generated by Claude Code

  11. added and removed
    bot:working
    on Oct 3, 2026
  12. Ardnived commented on Oct 3, 2026

    @Ardnived
    Contributor

    @sydevs-bot implement and raise the documented browser floor as needed

  13. added
    bot:working
    and removed
    bot:working
    on Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    High

    Hold Until

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions