Repository navigation
feat(solid-router): adopt Solid 2's useHead registry for head management - #8080
Conversation
HeadContent now feeds the route-derived tags (useTags output, semantics unchanged) to Solid's head registry as one reactive group instead of rendering <Asset> elements in-tree. The registry owns head emission on both runtimes: SSR splices/streams resolved winners into <head>, the client patches document.head reactively — replacing the manual relocate-into-head, imperative script injection, and document.title syncing that Asset.tsx carried for head tags. The dev-only dev-styles handling (filter DEV_STYLES_ATTR links post hydration) is a no-op in production, so it folds into the single HeadContent — retiring HeadContent.dev.tsx, index.dev.tsx, and the package's development export conditions. Co-Authored-By: Claude Fable 5 <[email protected]>
… asset map The client-assets manifest wiring (99756c0) gives SSR'd lazy() components three observable outputs in the served HTML: modulepreload hints for the lazy chunk and its static imports in the initial <head>, the chunk's stylesheet link, and the serialized boundary→chunk asset map that gates client hydration on those imports. The start-manifest e2e only asserted the stylesheet side, so a silent regression to the route-keyed manifest fallback would keep the suite green while losing hints and hydration gating. Two request-level tests against the built app pin the rest: direct SSR entry to /lazy-css-lazy emits exactly one head modulepreload for the lazy chunk and one for its statically imported widget chunk (and none of them on routes that never render the component), and the hydration payload's _assets map points at the same chunk URL the head hinted. Co-authored-by: Cursor <[email protected]>
Drop the pieces of the head pipeline that existed only for the old in-tree render path: the reference-reuse memo and replaceEqualTags (DOM node stability for a <For> that no longer exists) and the dev-styles post-hydration filtering (HeadContent is now a pure useHead registration). Add the changeset for the useHead adoption. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
View your CI Pipeline Execution ↗ for commit 5278494
☁️ Nx Cloud last updated this comment at |
🚀 Changeset Version Preview6 package(s) bumped directly, 0 bumped as dependents. 🟩 Patch bumps
|
Bundle Size Benchmarks
The following scenarios have bundle-size changes compared with the baseline:
Current gzip tracks all emitted client JS chunks. Initial gzip tracks only the entry/import graph. Trend sparkline is historical current gzip ending with this PR measurement; lower is better. |
More templates
@tanstack/arktype-adapter
@tanstack/eslint-plugin-router
@tanstack/eslint-plugin-start
@tanstack/history
@tanstack/nitro-v2-vite-plugin
@tanstack/react-router
@tanstack/react-router-devtools
@tanstack/react-router-ssr-query
@tanstack/react-start
@tanstack/react-start-client
@tanstack/react-start-rsc
@tanstack/react-start-server
@tanstack/router-cli
@tanstack/router-core
@tanstack/router-devtools
@tanstack/router-devtools-core
@tanstack/router-generator
@tanstack/router-plugin
@tanstack/router-ssr-query-core
@tanstack/router-utils
@tanstack/router-vite-plugin
@tanstack/solid-router
@tanstack/solid-router-devtools
@tanstack/solid-router-ssr-query
@tanstack/solid-start
@tanstack/solid-start-client
@tanstack/solid-start-server
@tanstack/start-client-core
@tanstack/start-fn-stubs
@tanstack/start-plugin-core
@tanstack/start-server-core
@tanstack/start-static-server-functions
@tanstack/start-storage-context
@tanstack/valibot-adapter
@tanstack/virtual-file-routes
@tanstack/vue-router
@tanstack/vue-router-devtools
@tanstack/vue-router-ssr-query
@tanstack/vue-start
@tanstack/vue-start-client
@tanstack/vue-start-server
@tanstack/zod-adapter
commit: |
Hooray! CodSpeed harness just leveled up!The base and head of this comparison were measured with different runner settings, so their benchmark values are not directly comparable. What changed between base and head:
Re-run the base with the same settings to get a valid performance comparison. Comparing Footnotes |
…CI repairs Inline scripts and styles get a stable content-derived key in toHeadTags: the registry otherwise assigns per-runtime unique identities that can never match between server and client, so hydration appended a client copy next to the server-rendered tag (caught by the solid-start basic script-duplication e2e). The ssr head benchmark's sanity assertion now counts name="…" attribute occurrences instead of raw substring hits — the registry writes the identity into data-dh on the same element, which doubled the old count. remountDeps tests migrate onMount to Solid 2's onSettled (pre-existing branch failure; the API was removed in the rc line). Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
Important
At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.
Nx Cloud has identified a possible root cause for your failed CI:
We investigated both CI failures and determined neither is caused by the changes in this PR. The issue-7986-retained-pending unit test failure is explicitly acknowledged by the author as pre-existing, and the e2e CSS assertion failure (~6.6% historical flakiness rate) is also confirmed present in branch 8081 — both failures exist independently of this head-registry refactor.
No code changes were suggested for this issue.
Trigger a rerun:
🎓 Learn more about Self-Healing CI on nx.dev
…background recovery) Two compounding defects kept a captured route error from retrying cleanly on Solid 2: - CatchBoundary's reset effect re-ran on every recompute of the reset key, not only on value changes, so any store write recreated the retried subtree while it settled. The effect is now gated on the key value. The reset handle deliberately stays un-consumed: a reset applied at the wrong moment can no-op (the boundary stays errored and the fallback never re-runs), and only a repeated attempt on a later key change recovers it — consuming the handle at apply time or at children re-render both proved to lose exactly that retry (verified against the background-recovery test). - Match keyed its boundary on the whole matches store, so every unrelated transition fired a premature reset that re-threw the still-stale error and flapped the error UI. The key is now scoped to the guarded match and its descendants (whose errors bubble here when they have no errorComponent), mirroring react-router's per-match keying, as a value string because the store emits fresh objects for content-equal writes. The issue-7986 pending assertion queries fresh under waitFor: the retried subtree renders the pending fallback from two nested slots in quick succession (Show fallback, then the Loading boundary once the child suspends), so a cached element handle can go stale across the swap. First fully green unit run on this branch: 59 files, 864 tests. Co-Authored-By: Claude Fable 5 <[email protected]>
Problem
HeadContentpredates Solid 2's head management: it rendered head tags asin-tree elements and carried a pile of workarounds to make that model work —
manual relocation of rendered nodes into
document.head(forHeadContentrendered in
<body>), imperativedocument.titlesyncing, idempotentimperative script injection for client-side navigation, hydration-id
landmines documented inline in
Asset.tsx, reference-reuse machinery(
replaceEqualTags) so a<For>kept DOM nodes, and a dedicatedindex.deventry whose only job was a dev-styles variant ofHeadContent.Solid 2 (
@solidjs/web2.0.0-rc.0) ships a renderer-owned head registry(
useHead, per the head-management RFC): replaceable tags (title/meta/…)resolve by last-committed group and stream as patches with their suspense
boundary's reveal; resource tags (stylesheets, preloads,
script[src]) emiteagerly and dedupe by identity; the client patches
document.headreactively and adopts server-flushed elements during hydration.
Mechanism
HeadContentis now a pure registration:useTagskeeps computing what the head contains (TanStack'sroute-head model: cross-match merge, child-wins meta dedupe, manifest
CSS/preloads, nonce plumbing) — semantics unchanged. The registry now owns
how tags reach the DOM on both runtimes.
toHeadTagsis a pure data mapping (RouterManagedTag→HeadTag),evaluated inside the registry's flush boundary/effect, so it allocates no
reactive owners (hydration-id safe). Inline-CSS placeholder recovery
(client receives
children === undefinedand reads the server-renderedelement's text) moves into this mapping.
pipeline,
replaceEqualTags+ the reference-reuse memo, andHeadContent.dev.tsx/index.dev.tsx/ thedevelopmentexportconditions (the dev entry existed solely for the dev-styles variant).
HeadContentcan now be rendered anywhere in the tree; keeping it in<head>remains the documented placement (the hydration script belongsearly), so no doc changes.
start-manifeste2e tests from fix(solid-start): harden SSR asset manifest wiring for SSR'd lazy() components #8050(head modulepreload hints + hydration
_assetsmap for SSR'dlazy()components), which pin the seam this change rides on.
Behavior notes
DEV_STYLES_ATTR): the post-hydration removal is gone —the link now persists for the dev session. First paint stays styled (the
blocking link is still SSR'd), edits still apply (Vite's injected style
wins the cascade); the one papercut is that a deleted CSS rule keeps
applying until a full reload. Verified against a live dev server.
of synchronously in-tree (one unit test updated accordingly).
data-dhidentity attributes in SSR output.Verification
All on
solid-router-v2-pre(solid-js2.0.0-rc.0,@solidjs/vite-plugin3.0.0-next.28):@tanstack/solid-routerunit (client + server modes): pass — except 4pre-existing failures unrelated to this change (
remountDeps×3 fails onthe branch from the Solid 2
onMountremoval;issue-7986×1), whichfail identically without these commits.
the pruned exports: pass.
start-manifest: 12 passed (10 pre-existing + the 2 ported tests).basic/csp/selective-ssr: running, results to follow in acomment.
vite dev, solid-start basic app): styled firstpaint (no FOUC), clean hydration, no console errors, registry-patched
title/meta on client navigation, dev-styles endpoint serving.
Served dev SSR
<head>(direct request to/posts— registry-renderedtags carry
data-dhidentities, route title wins):Supersedes the remaining delta of #8050 (its vite-plugin-solid pin bumps
are obsolete — the branch is already on
@solidjs/vite-pluginnext.28; itstest commit is included here).
🤖 Generated with Claude Code