Skip to content

feat(solid-router): delegate lazyRouteComponent to Solid 2's lazy() - #8081

Merged
birkskyum merged 12 commits into
solid-router-v2-prefrom
solid-lazy-route-components
Aug 19, 2026
Merged

birkskyum merged 12 commits into
solid-router-v2-prefrom
solid-lazy-route-components

Conversation

@brenelz

@brenelz brenelz commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Problem

lazyRouteComponent predates Solid 2's lazy() and hand-rolls what it now
provides: a load state machine over Dynamic, with documented hydration
caveats (a conditional createMemo in the render path) and none of the
SSR 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

lazyRouteComponent now delegates to solid-js lazy() (~60 lines, most
of them comments):

  • The importer wrapper selects the configured export and forwards the
    module's $$moduleUrl (appended by @solidjs/vite-plugin's SSR
    transform), so server-side lazy() resolves the route chunk's client
    assets — 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).
  • The module-not-found reload-once dance (stale deploy → one
    sessionStorage-gated refresh) is unchanged, living in the importer
    wrapper's rejection handler.
  • preload() keeps its contract: a memoized Promise<void> that never
    rejects, 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 — rejections
included — 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 state
machine. This PR carries a pnpm patch for solid-js 2.0.0-rc.0 (same play
as the earlier vite-plugin-solid isEntry patch, removed once upstream
shipped) that:

  • clears the cached module promise on rejection (client and server), so
    the next preload or render retries the import — matching how browsers
    treat failed dynamic imports;
  • fixes an unhandled-rejection leak (lazy()'s internal .then had no
    rejection handler);
  • on the server, stops a transient import failure from poisoning every
    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.tsx pins the new
shape.

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-js 2.0.0-rc.0 + patch,
@solidjs/vite-plugin 3.0.0-next.28):

  • @tanstack/solid-router unit (client + server modes): pass, including
    the updated component-preload-retry suite — except the 4 pre-existing
    branch failures unrelated to this change (remountDeps ×3 from the
    Solid 2 onMount removal; issue-7986 ×1), which fail identically
    without these commits.
  • Type tests across ts56–ts70: pass. eslint: 0 errors.
  • e2e (basic-file-based-code-splitting, solid-start/basic,
    start-manifest): running, results to follow in a comment.

🤖 Generated with Claude Code

brenelz and others added 5 commits August 15, 2026 18:46
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]>
@coderabbitai

coderabbitai Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 69ab91e6-30a5-4042-bedf-4b2c203e8a29

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nx-cloud

nx-cloud Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 58301aa

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 11m 31s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 2m 8s View ↗

☁️ Nx Cloud last updated this comment at 2026-08-19 13:33:21 UTC

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

6 package(s) bumped directly, 0 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/solid-router 2.0.0-rc.0 → 2.0.0-rc.1 Changeset
@tanstack/solid-router-devtools 2.0.0-rc.0 → 2.0.0-rc.1 Changeset
@tanstack/solid-router-ssr-query 2.0.0-rc.0 → 2.0.0-rc.1 Changeset
@tanstack/solid-start 2.0.0-rc.0 → 2.0.0-rc.1 Changeset
@tanstack/solid-start-client 2.0.0-rc.0 → 2.0.0-rc.1 Changeset
@tanstack/solid-start-server 2.0.0-rc.0 → 2.0.0-rc.1 Changeset

@github-actions

github-actions Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: 63f0ebaa978c
  • Measured at: 2026-08-19T13:22:50.912Z
  • Baseline source: history:7557415669ca
  • Dashboard: bundle-size history

The following scenarios have bundle-size changes compared with the baseline:

Scenario Current (gzip) Delta vs baseline Initial gzip Raw Brotli Trend
react-router.minimal 83.84 KiB +4 B (+0.00%) 83.70 KiB 262.48 KiB 72.97 KiB █▆▃▃▂▂▁▁▃▃▃▃
react-router.full 87.35 KiB +6 B (+0.01%) 87.22 KiB 274.19 KiB 75.97 KiB █▅▂▂▂▂▁▁▄▄▄▄
solid-router.minimal 39.53 KiB +6.33 KiB (+19.08%) 39.40 KiB 113.09 KiB 35.75 KiB ▁▁▁▁▁▁▁▁▁▁▁█
solid-router.full 47.19 KiB +9.15 KiB (+24.06%) 47.07 KiB 136.73 KiB 42.49 KiB ▁▁▁▁▁▁▁▁▁▁▁█
vue-router.minimal 49.58 KiB +46 B (+0.09%) 49.46 KiB 138.42 KiB 44.75 KiB █▄▁▁▁▁▁▁▄▄▄▇
vue-router.full 55.19 KiB +41 B (+0.07%) 55.07 KiB 156.63 KiB 49.65 KiB █▄▁▁▁▁▁▁▄▄▄▇
react-start.minimal 96.66 KiB -77 B (-0.08%) 96.52 KiB 304.69 KiB 83.79 KiB ▇▄▂▂▁▁▆▆███▃
react-start.deferred-hydration 97.38 KiB -83 B (-0.08%) 96.54 KiB 306.05 KiB 84.51 KiB ▇▅▂▂▁▁▆▆███▃
react-start.full 99.83 KiB -61 B (-0.06%) 99.70 KiB 314.41 KiB 86.53 KiB █▄▁▁▁▁▆▆███▄
react-start.rsbuild.minimal 99.97 KiB -112 B (-0.11%) 99.79 KiB 315.11 KiB 86.19 KiB ▅▅▂▂▁▁▄▄███▁
react-start.rsbuild.minimal-iife 100.37 KiB -112 B (-0.11%) 100.21 KiB 316.05 KiB 86.55 KiB ▅▅▂▂▁▁▄▄███▁
react-start.rsbuild.full 103.29 KiB -110 B (-0.10%) 103.12 KiB 325.20 KiB 88.98 KiB ▅▅▂▂▁▁▄▄███▁
solid-start.minimal 61.10 KiB +15.06 KiB (+32.72%) 60.97 KiB 178.64 KiB 54.79 KiB ▁▁▁▁▁▁▁▁▁▁▁█
solid-start.deferred-hydration 64.77 KiB +15.66 KiB (+31.88%) 61.49 KiB 186.73 KiB 58.13 KiB ▁▁▁▁▁▁▁▁▁▁▁█
solid-start.full 64.89 KiB +13.79 KiB (+26.98%) 64.77 KiB 189.98 KiB 58.06 KiB ▁▁▁▁▁▁▁▁▁▁▁█
vue-start.minimal 65.63 KiB -46 B (-0.07%) 65.51 KiB 189.24 KiB 58.42 KiB ▆▃▁▁▁▁▆▆███▅
vue-start.full 69.44 KiB -69 B (-0.10%) 69.31 KiB 201.55 KiB 61.64 KiB ▅▃▁▁▁▁▆▆███▄

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.

@pkg-pr-new

pkg-pr-new Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@8081

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@8081

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@8081

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@8081

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@8081

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@8081

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@8081

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@8081

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@8081

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@8081

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@8081

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@8081

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@8081

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@8081

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@8081

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@8081

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@8081

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@8081

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@8081

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@8081

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@8081

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@8081

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@8081

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@8081

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@8081

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@8081

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@8081

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@8081

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@8081

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@8081

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@8081

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@8081

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@8081

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@8081

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@8081

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@8081

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@8081

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@8081

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@8081

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@8081

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@8081

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@8081

commit: 58301aa

…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]>
@codspeed

codspeed Bot commented Aug 16, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 5.47%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 6 improved benchmarks
❌ 17 regressed benchmarks
✅ 156 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

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)

Open in CodSpeed

brenelz and others added 2 commits August 15, 2026 20:03
…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]>
@brenelz

brenelz commented Aug 16, 2026

Copy link
Copy Markdown
Contributor Author

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 basic e2e failures). Solid's lazy() preloaded-module hydration shortcut (_$HY.modules[key] → () => cached.default) assumes the registered chunk's default export is the component. For lazyRouteComponent's named-export wrapper the chunk default is undefined, so the boundary silently rendered nothing, never claimed the SSR'd DOM, and navigation couldn't dispose it — old route content stacked up under new routes. The interim solid-js patch now gates the shortcut on a bundler-injected moduleUrl (the transform's marker that the default-export convention holds); un-transformed wrappers fall through to their own import.

2. Per-route CSS isolation broken (4 start-manifest e2e failures). Forwarding the route module's $$moduleUrl registered the whole routes chunk through the renderer's asset channel — and since route chunks bundle many routes, direct SSR of /r2 emitted the union of every route's CSS. Route chunks now opt out explicitly ($$moduleUrl: null, a patch-added semantic that also suppresses the unresolvable-module warning): route assets stay on TanStack's route-keyed manifest, which is per-route precise, and hydration stays synchronous because preload() warms lazy()'s component cache before the router renders. User-level lazy() components inside routes remain fully registered.

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 basic 80 passed (was 60/20) · start-manifest 10 passed including the previously failing lazy→static shared-CSS navigation · unit/type/lint green apart from the four pre-existing failures fixed on the #8080 branch.

🤖 Generated with Claude Code

@nx-cloud nx-cloud Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Rerun CI

Nx Cloud View detailed reasoning on Nx Cloud ↗


🎓 Learn more about Self-Healing CI on nx.dev

brenelz and others added 2 commits August 17, 2026 21:09
…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]>
@brenelz
brenelz changed the base branch from solid-router-v2-pre to solid-usehead-head-management August 18, 2026 02:14
@brenelz

brenelz commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

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 basic e2e 80 passed; start-manifest 12 passed including the modulepreload-hint and hydration asset-map tests.

🤖 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]>
@brenelz
brenelz marked this pull request as draft August 18, 2026 18:46
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]>
@brenelz

brenelz commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

Patch retired — now on vanilla solid-js 2.0.0-rc.1

rc.1 (released today) ships both halves of what the pnpm patch carried: the lazy() rejection-retry fix (solidjs/solid#2999) and the { export } option with its dev-loud hydration guard (solidjs/solid#3011). The updated bundler transform arrives via babel-preset-solid 2.0.0-rc.1 through @solidjs/vite-plugin 3.0.0-next.30.

This PR now contains no patches — patches/ and patchedDependencies are gone, solid pins are bumped monorepo-wide to the rc.1 line, and lazyRouteComponent needed zero changes (the backport had already put it in its final shape against the real API).

Verification on vanilla rc.1: unit 59 files / 865 tests green · solid-start basic e2e 80 passed · start-manifest 12 passed.

🤖 Generated with Claude Code

@brenelz
brenelz marked this pull request as ready for review August 19, 2026 13:34
Base automatically changed from solid-usehead-head-management to solid-router-v2-pre August 19, 2026 15:58
@birkskyum
birkskyum merged commit 252caa8 into solid-router-v2-pre Aug 19, 2026
24 of 25 checks passed
@birkskyum
birkskyum deleted the solid-lazy-route-components branch August 19, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants