Skip to content

Commit dafad1d

Browse files
ryansolidClaude via Cursorcursoragent
authored
size: add page base + router scenario (#3838)
* chore(size): add page base + router and page live + router scenarios The two server-component page floors carry no router, so the "base case" they gate is a page nobody deploys. Two scenarios add @solidjs/router 2.0 (2.0.0-next.35 — the Solid 2 line, peers solid-js / @solidjs/web ^2.0.0-rc.13 — pinned exactly as a devDependency of scripts/size, resolved from its node_modules; .npmrc's legacy-peer-deps keeps the peers out of the lockfile since the page alias routes them to the dists): createRouter with two routes (one preload, one lazy), the instance as the hydrated root and useNavigate in a route component, so the router's runtime — not just its imports — is retained. Measured locally on next @ 49a8dca: base + router 57,001 B br (184,378 minified) against the base page's 44,864 (145,599), the router's contribution +12,137 br; live + router 58,243 (188,800) against 48,527 (157,562), +9,716 br. The router standalone is 32,430 / 11,216 B. Inline caps at local measured + 10 B rounded up to 0.01 KB (57.02 / 58.26 KB), recorded minified from the same measurement; to be confirmed against CI. Co-authored-by: Claude via Cursor <[email protected]> * size: router pages mount through dynamicComponent; caps re-based on next (#3838) The two router scenarios are the base / live server-component pages plus @solidjs/router; those pages mount through dynamicComponent since #3870 (the documented mount), so the router fixtures do too — with dynamic they measured +2,332 / +2,278 B brotli more (the element runtime dynamic's tag arm keeps). Re-based onto next @ 7233451 (the frames tiers): page base + router 57.02 -> 45.95 KB (45,940 B; 144,082 B min), page live + router 58.26 -> 47.21 KB (47,197 B; 148,526 B min), measured + 10 B rounded up to 0.01 KB. Co-authored-by: Cursor <[email protected]> --------- Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]>
1 parent be82cf3 commit dafad1d

7 files changed

Lines changed: 204 additions & 2 deletions

File tree

‎scripts/size/.npmrc‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# @solidjs/router declares solid-js / @solidjs/web as peers; the scenarios
2+
# alias both to the built dists, so the peers must not be installed here
3+
# (they would pull a published solid-js into this lockfile for nothing).
4+
legacy-peer-deps=true

‎scripts/size/README.md‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ primitives — that keeps the store engine pay-for-use under `hydrate()`, three
77
compiled-template scenarios — a compiled floor and a JSX todo app in CSR and
88
hydrating form — the frames client as a package, two server-component PAGES:
99
base and live, their two compiled counterparts — the same pages as JSX with
10-
the templates a real page has — and two server-entry floors:
11-
`getRequestEvent`/`isServer` and
10+
the templates a real page has — the same two hand-written pages under
11+
`@solidjs/router`, and two server-entry floors: `getRequestEvent`/`isServer` and
1212
`renderToString`) with hard brotli limits on the eager entry chunk. CI fails
1313
when a scenario exceeds its limit and grew more than a small minified
1414
allowance over its base (see [The gate](#the-gate)) — that means tree-shaking regressed, or a deliberate
@@ -123,6 +123,19 @@ switch re-based every cap (Rolldown lands 4–9% lower on the same artifacts;
123123
the table is in the switch PR and each scenario's ledger note in
124124
`scenarios.js`). Ledger deltas must not be read across that line.
125125

126+
## The router scenarios
127+
128+
`page: base + router` and `page: live + router` are the two page scenarios
129+
plus `@solidjs/router` 2.0 — the Solid 2 line (`2.0.0-next.*`), a
130+
devDependency of this directory pinned exactly like Rolldown (a router
131+
upgrade is a re-base, recorded like any other cap change). It resolves from
132+
this directory's `node_modules`; its `solid-js` / `@solidjs/web` imports go
133+
through the page alias to the built dists like everything else, and
134+
`.npmrc`'s `legacy-peer-deps` keeps npm from installing those peers from the
135+
registry for nothing. The router's own modules report as the `other`
136+
package. These are not floors: their caps are inline, and the two page
137+
floors stay the gate on the runtime alone.
138+
126139
## Compiled scenarios
127140

128141
The hand-written `app:` fixtures call the runtime directly and never compile

‎scripts/size/package-lock.json‎

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎scripts/size/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"build": "cd ../.. && pnpm install --frozen-lockfile && pnpm build"
1313
},
1414
"devDependencies": {
15+
"@solidjs/router": "2.0.0-next.35",
1516
"rolldown": "1.2.11"
1617
}
1718
}

‎scripts/size/sc-live-router-app.js‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// The live server-component page under a router: sc-live-app plus the same
2+
// `@solidjs/router` 2.0 composition as sc-router-app (createRouter with two
3+
// routes — one `preload`, one lazy — the instance as the hydrated root,
4+
// `useNavigate` in a route component). See sc-router-app.js for why the
5+
// router's runtime, not just its imports, is retained.
6+
import {
7+
hydrate,
8+
Show,
9+
For,
10+
Loading,
11+
Errored,
12+
dynamicComponent,
13+
createComponent
14+
} from "@solidjs/web";
15+
import { createSignal, createMemo, action, isPending, latest, lazy } from "solid-js";
16+
import { installServerComponents } from "@solidjs/web/frames";
17+
import { createServerReference, live, GET } from "@solidjs/web/server-functions/client";
18+
import { createRouter, useNavigate } from "@solidjs/router";
19+
20+
installServerComponents();
21+
const getStory = live(GET(createServerReference("story", "getStory")));
22+
const Story = dynamicComponent(() => getStory());
23+
const send = action(async () => {});
24+
const [n, setN] = createSignal(0);
25+
const Page = lazy(() => import("./lazy-page.js"));
26+
function Home(props) {
27+
const navigate = useNavigate();
28+
return [props.children, () => navigate("/story/1")];
29+
}
30+
const Router = createRouter({
31+
routes: [
32+
{ path: "/", component: Home, preload: ({ params, intent }) => void (params, intent) },
33+
{ path: "/story/:id", component: Page }
34+
]
35+
});
36+
hydrate(() => {
37+
const d = createMemo(() => n() + (isPending(n) ? 1 : 0) + latest(n));
38+
setN(1);
39+
return [
40+
d(),
41+
Show,
42+
For,
43+
Loading,
44+
Errored,
45+
Story,
46+
send,
47+
createComponent(Router, { children: p => p.children })
48+
];
49+
}, document.body);

‎scripts/size/sc-router-app.js‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// The base server-component page under a router: sc-base-app plus what an
2+
// application page ships to route — `@solidjs/router` 2.0 (the Solid 2 line,
3+
// `2.0.0-next.*`, installed by this directory's own package.json; its
4+
// `solid-js` / `@solidjs/web` imports route to the dists through pageAlias
5+
// like every other import here). `createRouter` with two routes — one with a
6+
// `preload`, one whose component is the page's `lazy()` chunk — rendered as
7+
// the hydrated root through the instance with a render-prop layout, and
8+
// `useNavigate` read in a route component. 2.0 has no `<A>`: anchors are
9+
// plain `<a>`, claimed by the router through `registerElementClaim` and
10+
// intercepted by delegation, so the link runtime is the router's own
11+
// (`setupLinkClaims`, `setupNativeEvents`) and is retained by the instance.
12+
// The instance, its routes and the route components are all reachable from
13+
// the root, so the router's runtime — matching, the integration, the
14+
// context, preloading, link claims — is retained, not just its imports.
15+
import {
16+
hydrate,
17+
Show,
18+
For,
19+
Loading,
20+
Errored,
21+
dynamicComponent,
22+
createComponent
23+
} from "@solidjs/web";
24+
import { createSignal, createMemo, lazy } from "solid-js";
25+
import { installServerComponents } from "@solidjs/web/frames";
26+
import { createServerReference } from "@solidjs/web/server-functions/client";
27+
import { createRouter, useNavigate } from "@solidjs/router";
28+
29+
installServerComponents();
30+
const getStory = createServerReference("story", "getStory");
31+
const Story = dynamicComponent(() => getStory());
32+
const [n, setN] = createSignal(0);
33+
const Page = lazy(() => import("./lazy-page.js"));
34+
function Home(props) {
35+
const navigate = useNavigate();
36+
return [props.children, () => navigate("/story/1")];
37+
}
38+
const Router = createRouter({
39+
routes: [
40+
{ path: "/", component: Home, preload: ({ params, intent }) => void (params, intent) },
41+
{ path: "/story/:id", component: Page }
42+
]
43+
});
44+
hydrate(() => {
45+
const d = createMemo(() => n() + 1);
46+
setN(1);
47+
return [
48+
d(),
49+
Show,
50+
For,
51+
Loading,
52+
Errored,
53+
Story,
54+
createComponent(Router, { children: p => p.children })
55+
];
56+
}, document.body);

‎scripts/size/scenarios.js‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4305,6 +4305,67 @@ module.exports = [
43054305
capMinified: 122779,
43064306
alias: pageAlias
43074307
},
4308+
{
4309+
name: "page: base + router (base page + @solidjs/router: createRouter, two routes, preload, useNavigate)",
4310+
// The base page as an application ships it: with a router. The two page
4311+
// floors above carry no router, so the "base case" they gate is a page
4312+
// nobody deploys; this scenario is the same composition plus
4313+
// `@solidjs/router` 2.0 (`2.0.0-next.35`, pinned exactly in this
4314+
// directory's package.json — the Solid 2 line; a router upgrade is a
4315+
// re-base recorded like a Rolldown upgrade) with `createRouter`, two
4316+
// routes (one `preload`, one lazy), the instance as the hydrated root
4317+
// and `useNavigate` in a route component. Not a floor: an inline cap,
4318+
// and the router's growth is the router's — this scenario attributes it
4319+
// (the `other` package in the report is the router).
4320+
// Landing (2026-10-06, next @ 49a8dca84): measured locally at 57,001 B
4321+
// (184,378 B minified) against the base page's 44,864 (145,599) — the
4322+
// router's contribution +12,137 B br / +38,779 B minified: the router's
4323+
// own 28,008 minified (`createRouterContext`, `setupNativeEvents` incl.
4324+
// the form-action path, `query`'s preload cache, `setupLinkClaims`,
4325+
// scroll restoration, `browserHistory`) plus what it retains of ours —
4326+
// signals +8,583 (`action` and the optimistic lanes: `verdictValue`,
4327+
// `dissolveLane`, `laneRead`, `isPending`/`latest`, `createEffect`,
4328+
// `onSettled`), sf +1,188 (`subscribeFlightData`, `decodeResponsePayload`,
4329+
// the redirect header, `parseServerFunctionAddress`), web +1,137
4330+
// (`takeHydrationValue`, `registerElementClaim`), solid +364
4331+
// (`createContext`, `children`). The router standalone, with solid-js /
4332+
// @solidjs/web external, is 32,430 / 11,216 B.
4333+
// Re-based onto `next` @ 7233451ee (#3838, 2026-10-07), after the frames
4334+
// tiers (#3860): measured at 45,940 B (144,082 B minified) against the
4335+
// base page's 33,908 (105,252) — the router's contribution +12,032 B br
4336+
// / +38,830 B minified, the same as at landing; the page under it is
4337+
// what #3860 cut. The fixture now mounts through `dynamicComponent`, the
4338+
// documented server-component mount the base page uses (#3870); with
4339+
// `dynamic` it measures 48,272 / 151,551 (+2,332 / +7,469: `dynamic`'s
4340+
// tag arm keeps the element runtime). The router does not retain that
4341+
// runtime itself — its `serverRouteComponent` helper mounts with
4342+
// `dynamic`, but this page does not use it. Cap at measured + 10 B
4343+
// rounded up to 0.01 KB; recorded minified 144,082 B (CI-confirmed).
4344+
path: "sc-router-app.js",
4345+
limit: "45.95 KB",
4346+
capMinified: 144082,
4347+
alias: pageAlias
4348+
},
4349+
{
4350+
name: "page: live + router (live page + @solidjs/router: createRouter, two routes, preload, useNavigate)",
4351+
// The live page with the same router (see the base + router note).
4352+
// Landing (2026-10-06, next @ 49a8dca84): measured locally at 58,243 B
4353+
// (188,800 B minified) against the live page's 48,527 (157,562) — the
4354+
// router's contribution +9,716 B br / +31,238 B minified, less than on
4355+
// the base page because the live page already carries `action` and
4356+
// `isPending`/`latest`, which the router retains on every page.
4357+
// Re-based onto `next` @ 7233451ee (#3838, 2026-10-07), after the frames
4358+
// tiers (#3860): measured at 47,197 B (148,526 B minified) against the
4359+
// live page's 37,512 (117,301) — the router's contribution +9,685 B br /
4360+
// +31,225 B minified. Mounted through `dynamicComponent` as the live page
4361+
// is (the base + router note); with `dynamic`: 49,475 / 155,995. Cap at
4362+
// measured + 10 B rounded up to 0.01 KB; recorded minified 148,526 B
4363+
// (CI-confirmed).
4364+
path: "sc-live-router-app.js",
4365+
limit: "47.21 KB",
4366+
capMinified: 148526,
4367+
alias: pageAlias
4368+
},
43084369
{
43094370
name: "server: floor (getRequestEvent + isServer)",
43104371
// What a server module that only asks "am I on the server / which

0 commit comments

Comments
 (0)