Repository navigation
fix: component selectors for memo, function wrappers and Preact, server manager options, prerelease job - #5867
Conversation
🦋 Changeset detectedLatest commit: 8a04c33 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Component selectors for
memoand Preact —flattennow treats any object carryingstyledComponentIdas a selector (which covers amemowrapper with hoisted statics, whose$$typeofstaysreact.memo) and checksisStyledComponentbefore invoking a function carrier, matching Preactcompat'sforwardRefshape. - Server
StyleSheetManageroptions withstylisPlugins={[]}— the RSC path keeps anamespaceorenableVendorPrefixespassed alongside an empty plugin list instead of short-circuiting to the default stylis instance, so server and client now hash the same class names. - Prerelease notes dependencies —
@changesets/readandsemverdeclared at the repo root so the 6.x prerelease job can resolve the script's imports; the lockfile picks up the intendedbabel-plugin-styled-componentspeer refresh alongside. - Also reviewed the
docs/rsc-style-injection.mdupdate and both patch changesets.
Verification on this head: full web suite (1004 tests), native suite (45 tests), and both new RSC manager cases pass; reverting flatten.ts to base fails the memo and both Preact carrier tests, and reverting StyleSheetManager.tsx to base reproduces the dropped namespace with a divergent server class name. The changelog state confirms the empty-plugins bug shipped in 6.6.0, so the separate changesets are appropriate.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No critical issues — one minor test-strengthening suggestion inline.
Reviewed changes
Reviewed the two commits since the last pullfrog review, which consolidated the selector brand check and reworked the server manager's stylis resolution.
- Shared brand check for component selectors —
hasStyledComponentBrandnow backs both the function and object carrier paths inflatten, so preact/compat's function-shaped components and brand-hoisting function HOCs emit.<styledComponentId>instead of being invoked as interpolations, whileisStyledComponentkeeps the$$typeofrequirement that chain folding relies on. - Server manager stylis reuse — the RSC resolution is simplified to inherit / plugins-with-options / options-without-plugins, so a manager with a stable plugins array plus
namespaceorenableVendorPrefixesreuses one cached instance across renders instead of rebuilding it, and a test locks that identity. - Reverted the
isStaticRulesexemption —css()already resolves carriers to class selectors, so the exemption was dead; the net PR change to that module is now a new unit suite only. - Selector test consolidation — the two Preact and memo selector cases became one parameterized test with a
jest.spyOn(React, 'forwardRef')helper, removing two@ts-expect-errormonkey patches, and both changesets were reworded.
Verified on this head: jest -c jest.config.main.js (61 suites / 1010 tests), jest -c jest.config.native.js (45 tests), and the package tsc --noEmit all pass, with pnpm install --frozen-lockfile clean so the prerelease devDependency additions match the lockfile.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the two commits since the prior pullfrog review, which are a formatting pass and the test strengthening that closes the remaining inline suggestion.
- RSC stylis reuse test no longer passes vacuously —
styled.rsc.test.tsxnow importsmainStylisand asserts the instance read throughuseStyleSheetContext()is not the default, so the test fails if the manager never writes its override, not only when it rebuilds the instance. - Formatting reflow — the
withFunctionForwardRefhelper body inbasic.test.tsxwas reflowed by Prettier; no behavior change.
Verified on this head: jest -c jest.config.main.js src/constructors/test/styled.rsc.test.tsx passes 86/86. I also mutation-checked the new assertion — resolving mainStylis from the plugins branch makes both reuse rows fail at that line — so it now guards the failure class it was written for, and the prior thread can stay resolved.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the two commits since the prior pullfrog review, which act on its one inline suggestion and reformat a test file.
- Strengthened the server stylis reuse test — the test now asserts the manager's stylis instance is not the default
mainStylis, so it fails when astylisPlugins+namespace/enableVendorPrefixesmanager drops its override entirely, not only when it rebuilds per request. - Reformatted
basic.test.tsx— no behavior change.
Confirmed the new assertion has teeth: suppressing the manager's override in StyleSheetManager.tsx (so every read is the default instance) fails both reuse cases with the new line and would have passed without it. The full RSC suite (86 tests) and basic.test.tsx (36 tests) pass on this head.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

Three fixes for styles that came out wrong with no useful error, plus a repair to the 6.x prerelease job.
Component selectors
${Box}:hover { ... }producesBox's selector for:preact/compat. The selector came out as[object Object], or the render threw.React.memoor function wrapper that has the styled component's statics hoisted onto it. A memo wrapper's fields were written out as CSS declarations, and a function wrapper was called as an interpolation.A
forwardRefwrapper with hoisted statics is unchanged by this PR:styled()treats it as the styled component itself and skips the wrapper's own render.Server
StyleSheetManagerIn a server component,
<StyleSheetManager stylisPlugins={[]} namespace="#scope">drops the plugins and keeps the namespace, and the same goes forenableVendorPrefixes, matching client components.A server manager with a stable plugins array plus
namespaceorenableVendorPrefixesreuses its compiled stylis instance across renders instead of building a new one each time, andstylisPlugins={[]}on its own no longer builds one at all.Prerelease job
The 6.x Release workflow's prerelease job failed with
Cannot find module 'semver', so no 6.x prerelease has published since the move to pnpm 12. The script's imports are now declared at the repo root. The script runs to completion locally against the pending changesets; the job itself only runs after a merge to 6.x.The lockfile also moves the dev-only
styled-componentspeer ofbabel-plugin-styled-componentsfrom 6.5.3 to 6.6.0, which pnpm refreshes on any lockfile change. Nothing published changes.Cost
Bundle size, gzip -9 bytes:
Render time is unchanged within noise: the geometric mean is 0.998x across 57 server component and client benchmark rows, median of 6 rounds on one machine, run from source. Rows outside ±3% fall on both sides, including a plain React control at 0.92x.
Testing
Web, native, and build suites pass, with new tests for each selector case (unit and rendered), each manager option, instance reuse across requests, and global styles that refer to a component staying static. The
preact/compatcase is tested with a stand-in that givesforwardRefPreact's return shape, not with Preact itself.