Repository navigation
fix: preserve scoped classes in production SSR spreads - #974
Merged
trueadm merged 1 commit intoSep 6, 2026
Merged
Conversation
domgan-oai
marked this pull request as ready for review
September 6, 2026 21:37
14 of 21 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix production server rendering dropping synthesized scoped CSS classes on elements with spread attributes. The canonical-attribute fast path returned before applying pending class merges; it now runs only when no class merges are pending.
The ordinary canonical-attribute path remains unchanged. Merge-bearing calls use the existing normalization and class-composition path, preserving authored-class precedence. No compiler, client runtime, or Strong-mode changes.
Validation
pnpm install --frozen-lockfilecompleted with the unchanged lockfile; the earlier registry cooldown no longer blocks installation.octaneandoctane-prod(10 failures);classNameremained the unaffected control. Restoring the guard passed all six variants in both projects.pnpm exec vitest run packages/octane/tests/ssr-production-bundle.test.ts packages/octane/tests/ssr.test.ts packages/octane/tests/style-map.test.ts packages/octane/tests/streaming-ssr.test.ts --project octane --project octane-prod --reporter=dot: 300 test executions passed across eight suite executions.pnpm exec tsgo --noEmit -p packages/octane/tsconfig.json.pnpm format:files:check packages/octane/tests/ssr-production-bundle.test.ts packages/octane/src/runtime.server.ts .changeset/ssr-scoped-spread-classes.mdandgit diff --check.pnpm synccompleted without generated changes; the worktree is clean.6cf95d710a8715be5cc49ac7a679987493a19223: all four test shards, React parity, website/browser integration, package validation, examples, lint, typechecking, and provenance. Cursor Bugbot also passed with no review threads. The PR is ready for review.pnpm format:check,pnpm typecheck, andpnpm testwere not rerun locally; the CI workflow covers the full repository checks.Performance validation
Compared production SSR fixture bundles with and without the guard using the same installed dependencies on Node 24.18.0, macOS 26.6.2, arm64. Ran the existing harness in baseline/candidate/candidate/baseline order, with 0.2 seconds warmup, 2 seconds timing per case, and 1,000 memory-phase renders:
pnpm exec vite build benchmarks/ssr-throughput/fixtures --ssr src/entry-server.ts --outDir ../dist/fixtures --emptyOutDir CONFIGS=deopt-page,escape-heavy BENCH_JSON=/tmp/ssr-sample.json node benchmarks/ssr-throughput/run.mjs 2 --no-buildMedian render scores (baseline → candidate): compiled cards 1.300 → 1.297 ms (-0.22%); descriptor control 3.458 → 3.461 ms (+0.08%); escaping 3.275 → 3.292 ms (+0.53%). All benchmark gates passed. These small deltas do not establish a throughput change. Full HTML/CSS results matched for both card variants, escaping, and hydratable/static control-flow fixtures. The unminified fixture bundle grew by 24 bytes (178,800 → 178,824).
Risk / follow-ups
This is a one-condition runtime fix with a patch changeset. The measured controls protect ordinary SSR paths; they do not quantify the corrected scoped-class merge path, because the old version omits required output there. Merge-bearing calls use the existing normalization/composition path and its allocations. No throughput improvement is claimed. Self-review confirmed canonical calls without pending class merges retain their fast path and the regression covers empty/null/false/array/className inputs plus authored-class precedence.
Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Low Risk
Single guard on an existing production fast path in SSR attribute serialization; scope is limited to class handling with spreads, with targeted regression tests.
Overview
Fixes production SSR dropping scoped CSS classes on elements that use attribute spreads (
{...props}).In
ssrAttrs, the production-only canonical-attribute fast path could return before pending class merges (including synthesized scope-hash classes) were applied. That path now runs only whenclassMerges === null, so spread/class/classNamecases go through the full normalization and class-composition logic. Authored-class vs spread precedence behavior is unchanged.Adds a patch changeset and production-bundle tests (six spread variants) that assert rendered nodes still match emitted scoped selectors and that
classbefore/after spread ordering stays correct.Reviewed by Cursor Bugbot for commit 6cf95d7. Bugbot is set up for automated code reviews on this repo. Configure here.