Skip to content

perf: unified CSS preprocessor, snapshot audit fixes#5721

Merged
quantizor merged 4 commits into
mainfrom
next
Apr 5, 2026
Merged

perf: unified CSS preprocessor, snapshot audit fixes#5721
quantizor merged 4 commits into
mainfrom
next

Conversation

@quantizor

Copy link
Copy Markdown
Contributor

Summary

  • Unified CSS preprocessor: Replace stripLineComments + sanitizeCSS with single-pass preprocessCSS. General paren-depth tracking protects // inside any function call (url, calc, image-set, etc.) without maintaining a function name list. -0.28kB gzip production bundle (8.49→8.21kB).
  • Fix parseCSSDeclarations brace-depth off-by-one (native): declarations after @supports and other nested at-rule blocks were silently lost due to double-counting the first {.
  • Fix isEscaped detection: single-lookback charCodeAt(i-1) !== BACKSLASH fails on \\" (escaped backslash + closing quote). New isEscaped() counts consecutive backslashes, exported and shared by preprocessCSS and stylisPluginRSC.
  • stylisPluginRSC: merge findAdjacentCombinators into expandAdjacentSibling (one loop, no intermediate array).
  • Snapshot audit: 592 snapshots across 35 files reviewed and traced to producing functions. Fixed 8 misleading test names, 1 orphaned test block, keyframes object CSS :hover&:hover, added single-attrs mutation edge case test.
  • Bench dedup: shared bench() utility and COLORS array, new preprocessCSS isolated + pipeline benchmark.

Replace stripLineComments + sanitizeCSS with single-pass preprocessCSS.
Paren-depth tracking protects // inside any function call (url, calc,
image-set, etc.) without maintaining a function name list. sanitizeBraces
collapsed from two loops to one with imbalanced flag.

Fix escape detection: isEscaped() counts consecutive backslashes instead
of single-lookback check. Exported for reuse by stylisPluginRSC.

stylisPluginRSC: merge findAdjacentCombinators into expandAdjacentSibling
(one loop instead of two + intermediate array). Use shared isEscaped().
Brace-depth scan for at-rule/selector skip now covers both prop and
value ranges. Old code started depth=1 and scanned only the value,
double-counting the first {. Declarations after @supports and other
nested at-rule blocks are now correctly recovered.
Fix keyframes object CSS ':hover' → '&:hover' (was producing descendant
selector instead of pseudo-class). Move orphaned flatten test inside its
describe block. Correct 5 stale/wrong test names. Add single-attrs
mutation edge case documenting needsCopy behavior.
Extract bench() and COLORS to bench-utils.ts, replacing 4 copies of
the bench function and 3 copies of the COLORS array. Add preprocessCSS
isolated + full-pipeline benchmark at 5 CSS scale levels.
@changeset-bot

changeset-bot Bot commented Apr 5, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 484a8c2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@quantizor quantizor merged commit 248edc3 into main Apr 5, 2026
5 checks passed
@quantizor quantizor deleted the next branch April 5, 2026 18:22
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.

1 participant