Repository navigation
feat(solid-router): delegate lazyRouteComponent to Solid 2's lazy() - #8081
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]>
Route components now render through solid-js lazy(): the importer wrapper selects the configured export and forwards the module's $$moduleUrl (the bundler's SSR transform appends it), so SSR'd route chunks get client asset resolution — stylesheet links, modulepreload hints, and hydration gating — through the same client-assets manifest seam as any other lazy() component, with positional hydration as the fallback. Carries an interim pnpm patch for solid-js 2.0.0-rc.0 (to be upstreamed, same play as the vite-plugin-solid isEntry patch): lazy() no longer caches a rejected module promise, so a failed chunk download is retried by the next preload or render instead of being sealed in for the page's lifetime — this is what lets TanStack's download-retry contract ride on lazy() directly instead of wrapping it in a retry state machine. The patch also fixes an unhandled-rejection leak (lazy's internal .then had no rejection handler) and, on the server, stops a transient import failure from poisoning every later SSR request. Retry semantics improve: a failed hover-preload is retried at render (previously the recorded error was thrown without re-attempting the import); the error boundary + route-reload retry flow is unchanged when the render-time attempt also fails. preload() keeps its contract — a memoized Promise<void> that never rejects, cleared on failure so a later preload retries, one import per server. The module-not-found reload-once dance is unchanged. 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 58301aa
☁️ 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: |
…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]>
Merging this PR will degrade performance by 5.47%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Memory | mem server error-paths unmatched (vue) |
582.2 KB | 1,026.8 KB | -43.3% |
| ❌ | Memory | mem server error-paths redirect (react) |
294.7 KB | 348.4 KB | -15.41% |
| ❌ | Memory | mem server error-paths redirect (solid) |
424 KB | 485.7 KB | -12.69% |
| ❌ | Memory | mem server error-paths not-found (react) |
384.7 KB | 428.3 KB | -10.2% |
| ❌ | Simulation | ssr assets inline-css cdn (solid) |
416.2 ms | 449.7 ms | -7.45% |
| ❌ | Simulation | ssr rewrite localized (solid) |
482 ms | 518.4 ms | -7.02% |
| ❌ | Memory | mem server error-paths redirect (vue) |
401.6 KB | 429.8 KB | -6.57% |
| ❌ | Memory | mem server server-fn-churn (vue) |
332.8 KB | 353.4 KB | -5.81% |
| ❌ | Memory | mem client interrupted-navigations (vue) |
451.6 KB | 479.1 KB | -5.75% |
| ❌ | Simulation | client-side navigation loop (solid) |
114 ms | 120.9 ms | -5.72% |
| ❌ | Simulation | ssr assets linked-css control (solid) |
548.7 ms | 579.8 ms | -5.37% |
| ❌ | Simulation | ssr before-load chain (solid) |
399.6 ms | 417.8 ms | -4.36% |
| ❌ | Simulation | ssr control-flow error 500 (solid) |
382.1 ms | 399.3 ms | -4.31% |
| ❌ | Simulation | ssr global-mw document (solid) |
727.5 ms | 759 ms | -4.16% |
| ❌ | Simulation | ssr dehydrate plain control (solid) |
504.6 ms | 526.4 ms | -4.13% |
| ❌ | Memory | mem server aborted-requests (react) |
861.5 KB | 898.5 KB | -4.12% |
| ❌ | Simulation | ssr loaders (solid) |
339.2 ms | 351.4 ms | -3.46% |
| ⚡ | Memory | mem client preload-churn (vue) |
881 KB | 770.4 KB | +14.35% |
| ⚡ | Memory | mem server request-churn (react) |
701.7 KB | 653.3 KB | +7.41% |
| ⚡ | Memory | mem server error-paths unmatched (react) |
424.4 KB | 401.6 KB | +5.69% |
| ... | ... | ... | ... | ... | ... |
ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing solid-lazy-route-components (58301aa) with solid-usehead-head-management (5278494)
…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]>
…te assets to TanStack's manifest Extends the interim solid-js patch with two hydration-critical fixes (both upstream candidates, same play as the retry fix it already carries): - lazy()'s preloaded-module hydration shortcut (_$HY.modules) now only applies when the callsite has a bundler-injected moduleUrl. The shortcut assumes the registered chunk's default export is the component; for wrappers selecting a named export it silently rendered undefined, never claimed the SSR'd DOM, and navigation later couldn't dispose it — 20 basic-suite e2e failures (orphaned route content stacking up across navigations). - $$moduleUrl: null on a lazy()-resolved module is an explicit opt-out of per-module asset registration, without the server warning that undefined draws. lazyRouteComponent uses that opt-out: route chunks bundle many routes, so registering the chunk emitted the union of their CSS on every route and broke per-route stylesheet isolation (4 start-manifest e2e failures). Route assets stay on TanStack's route-keyed manifest, which is per-route precise; hydration is synchronous because preload() warms lazy()'s component cache before the router renders. User-level lazy() components inside routes remain fully registered — the opt-out is scoped to the route-component wrapper. Verified: solid-start basic e2e 80 passed (was 60/20); start-manifest 10 passed (including the previously failing lazy-to-static shared-CSS navigation); unit suites green apart from the four pre-existing failures fixed on the useHead branch. Co-Authored-By: Claude Fable 5 <[email protected]>
e2e verification + two hydration fixes (747a786)The initial e2e sweep surfaced two real defects, both now fixed: 1. Orphaned SSR DOM on client navigation (20 2. Per-route CSS isolation broken (4 Both patch hunks are upstream candidates alongside the rejection-retry fix. The longer-term convergence (making route chunks safely registrable) is per-component default-export split chunks in the router plugin — follow-up territory. Results: solid-start 🤖 Generated with Claude Code |
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 identified 4 pre-existing test failures unrelated to this PR: 3 in remountDeps.test.tsx caused by Solid 2.0.0-rc.0 removing the onMount API, and 1 in issue-7986-retained-pending.test.tsx which is a pre-existing behavioral issue. These failures are confirmed by the PR author to occur identically without these commits, so no action is needed on this PR.
No code changes were suggested for this issue.
Trigger a rerun:
🎓 Learn more about Self-Healing CI on nx.dev
…fest With the head registry (useHead branch) underneath, lazyRouteComponent forwards the module's real $$moduleUrl: split route modules have per-module client-manifest entries (the query is part of the module identity), so server-side lazy() registers exactly the route's own CSS and modulepreload hints, and the registry's URL-keyed resource dedupe absorbs the overlap with TanStack's route-keyed manifest links — the duplicate-stylesheet failures that forced the earlier $$moduleUrl null opt-out were double emission between Solid's channel and TanStack's in-tree links, which the registry now reconciles. The now-unused null opt-out hunk is dropped from the solid-js patch, leaving exactly the two upstream-tracked fixes (rejection retry: solidjs/solid#2999, fixed on next in 3c68ab21; hydration-shortcut moduleUrl gate: solidjs/solid#3011). Verified on the stack: unit 59 files / 865 tests all green (first fully green combination), solid-start basic e2e 80 passed, start-manifest 12 passed including the ported modulepreload-hint and hydration asset-map tests. Co-Authored-By: Claude Fable 5 <[email protected]>
Restacked on #8080 — route chunks now opt in to the client-assets manifest (cffa310)Retargeted this PR onto the useHead branch, which changes the asset story for the better:
Verification on the stack: unit 59 files / 865 tests fully green (first configuration where everything passes, including the CatchBoundary fixes from #8080); solid-start 🤖 Generated with Claude Code |
…kport Upstream resolved solidjs/solid#3011 with first-class named-export support instead of the fallback gate this patch carried: lazy(fn, { export }, moduleUrl?) names which export of the resolved module is the component, as a call-site literal available on both runtimes — so hydration claims the component synchronously from the preloaded module namespace, and runtime wrappers that pick an export inside the import thunk fail loudly in dev instead of silently orphaning SSR'd DOM. The solid-js patch is now a faithful backport of solidjs/solid@56ca6470 (which also carries the #2999 rejection-retry fix in its final load-inside-memo shape) onto the rc.0 dists, plus one deliberate deviation: lazy() still accepts the legacy string second argument (moduleUrl) that rc.0's bundler transform injects, normalizing it to the third position, until the updated transform (dom-expressions 0856717a) ships. Type declarations carry the new overloads. lazyRouteComponent takes its final upstream-aligned shape: the module namespace passes through untouched ($$moduleUrl included, so route chunks keep registering their real client assets), { export } selects the component, and only the module-not-found reload dance and the memoized never-rejecting preload contract remain as wrapper logic. When an rc ships with both upstream commits, the migration is deleting the patch. Verified: unit 59 files / 865 tests green; solid-start basic e2e 80 passed; start-manifest 12 passed. Co-Authored-By: Claude Fable 5 <[email protected]>
rc.1 ships everything the interim patch carried: the lazy() rejection retry fix (solidjs/solid#2999, 3c68ab21) and the { export } option with its loud-in-dev hydration guard (solidjs/solid#3011, 56ca6470 + dom-expressions 0856717a — the updated transform arrives through babel-preset-solid 2.0.0-rc.1 via @solidjs/vite-plugin 3.0.0-next.30). patches/ and the patchedDependencies entry are deleted; lazyRouteComponent is unchanged, already in its final shape against the real API. Monorepo-wide range bump: solid-js and @solidjs/web ^2.0.0-rc.0 → ^2.0.0-rc.1, @solidjs/vite-plugin ^3.0.0-next.28 → ^3.0.0-next.30. Verified on vanilla rc.1: unit 59 files / 865 tests green; solid-start basic e2e 80 passed; start-manifest 12 passed. Co-Authored-By: Claude Fable 5 <[email protected]>
Patch retired — now on vanilla solid-js 2.0.0-rc.1rc.1 (released today) ships both halves of what the pnpm patch carried: the This PR now contains no patches — Verification on vanilla rc.1: unit 59 files / 865 tests green · solid-start 🤖 Generated with Claude Code |
Problem
lazyRouteComponentpredates Solid 2'slazy()and hand-rolls what it nowprovides: a load state machine over
Dynamic, with documented hydrationcaveats (a conditional
createMemoin the render path) and none of theSSR asset story — route chunks rendered on the server got no per-module
client asset resolution through Solid's client-assets manifest, relying
solely on TanStack's route-keyed manifest.
Mechanism
lazyRouteComponentnow delegates to solid-jslazy()(~60 lines, mostof them comments):
module's
$$moduleUrl(appended by@solidjs/vite-plugin's SSRtransform), so server-side
lazy()resolves the route chunk's clientassets — stylesheet links, modulepreload hints, and hydration gating —
through the same manifest seam as any other
lazy()component.Positional hydration remains the fallback. Duplicate emission against
TanStack's route-keyed manifest is absorbed by the renderer's resource
dedupe (by identity/URL).
sessionStorage-gated refresh) is unchanged, living in the importer
wrapper's rejection handler.
preload()keeps its contract: a memoizedPromise<void>that neverrejects, cleared on failure so a later preload retries, one import per
server.
Interim solid-js patch (to be upstreamed)
Solid's
lazy()caches its module promise permanently — rejectionsincluded — which would seal in a failed chunk download for the page's
lifetime and make TanStack's download-retry contract (error boundary →
retry → re-import) impossible without wrapping
lazy()in a retry statemachine. This PR carries a pnpm patch for solid-js 2.0.0-rc.0 (same play
as the earlier vite-plugin-solid
isEntrypatch, removed once upstreamshipped) that:
the next preload or render retries the import — matching how browsers
treat failed dynamic imports;
lazy()'s internal.thenhad norejection handler);
subsequent SSR request (the shared rejected promise previously threw
for the rest of the process lifetime).
Retry semantics improve with it: a failed hover-preload is retried at
render (previously the recorded error was thrown without re-attempting),
and the error-boundary retry flow is unchanged when the render-time
attempt also fails.
tests/component-preload-retry.test.tsxpins the newshape.
Note: until the fix ships in a solid-js release, the retry behavior only
holds inside this repo (the patch applies to the workspace, not to
published consumers) — one more reason to upstream promptly.
Verification
All on
solid-router-v2-pre(solid-js2.0.0-rc.0+ patch,@solidjs/vite-plugin3.0.0-next.28):@tanstack/solid-routerunit (client + server modes): pass, includingthe updated
component-preload-retrysuite — except the 4 pre-existingbranch failures unrelated to this change (
remountDeps×3 from theSolid 2
onMountremoval;issue-7986×1), which fail identicallywithout these commits.
basic-file-based-code-splitting,solid-start/basic,start-manifest): running, results to follow in a comment.🤖 Generated with Claude Code