Skip to content

Commit ca82433

Browse files
ryansolidclaude
andauthored
ci: track tree-shaken scenario sizes per PR with size-limit (#2883) (#2891)
* ci: track tree-shaken scenario sizes per PR with size-limit (#2883) Five import-cost scenarios (signals floor / +createStore / +isPending, latest; the render+signal simple-app floor; a representative CSR app) with ~5% headroom limits as the tree-shaking regression gate — a re-coupled feature module costs hundreds of bytes against that headroom. The simple-app ceiling is pinned at 10 KB (brotli) deliberately. The size-limit action comments base-vs-head deltas on every PR; the retained-module-graph test in solid-signals stays the precise which-module diagnostic. Co-Authored-By: Claude Fable 5 <[email protected]> * ci: split size workflow into a self-contained gate and best-effort delta comment The size-limit action compares against the base branch, which fails on any PR whose base lacks the size-limit setup (including this bootstrap PR) with 'Unexpected end of JSON input'. The hard gate is now its own job — install, build, pnpm size on the head only — and the base-vs-head comment job is continue-on-error, so it informs when it can and never blocks. Co-Authored-By: Claude Fable 5 <[email protected]> * ci(size): resolve fixtures via esbuild aliases, not root workspace deps Adding solid-js/@solidjs/* as root devDeps re-keyed pnpm's peer graph (vitest and vite-plugin-solid instances gained new peer contexts), relocating the benchmark harness's physical dependencies — which CodSpeed reports as instruction-count regressions despite zero code changes. Aliases in .size-limit.js point bare specifiers at the built browser-prod artifacts instead; the lockfile now only adds size-limit's own isolated tree. Same measured numbers on every scenario. Co-Authored-By: Claude Fable 5 <[email protected]> * ci(size): isolate size tooling in a standalone size/ package Any change to the workspace dependency graph re-keys pnpm peer instances — removing the workspace devDeps still moved @codspeed/vitest-plugin and vite instance keys (vite's optional terser peer context) — and relocating the benchmark harness shows up as phantom CodSpeed regressions. size/ is now a plain npm package outside the pnpm workspace with its own lockfile; the root package.json and pnpm-lock.yaml are byte-identical to next. Fixtures resolve bare specifiers via esbuild aliases to the built browser-prod artifacts. Same measured numbers on every scenario. Co-Authored-By: Claude Fable 5 <[email protected]> * ci(size): relocate to scripts/size Same isolated-from-the-workspace setup, less top-level clutter; README documents why it must stay outside the pnpm workspace graph. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: Claude Fable 5 <[email protected]>
1 parent d0b9c91 commit ca82433

9 files changed

Lines changed: 839 additions & 0 deletions

File tree

‎.github/workflows/size.yml‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Size
2+
3+
# Tracks tree-shaken scenario costs per PR (#2883). scripts/size/ is a
4+
# standalone npm package OUTSIDE the pnpm workspace on purpose: adding its
5+
# tooling to the workspace graph re-keys pnpm peer instances (vitest,
6+
# @codspeed/vitest-plugin), which relocates the benchmark harness and shows
7+
# up as phantom CodSpeed regressions. The limits in size/.size-limit.js are
8+
# the strict tree-shaking gate; the retained-module-graph assertions in
9+
# packages/solid-signals/tests/treeshake.test.ts stay the which-module
10+
# diagnostic underneath.
11+
on:
12+
pull_request:
13+
branches: [main, next]
14+
15+
permissions:
16+
contents: read
17+
pull-requests: write
18+
19+
jobs:
20+
# The hard gate: self-contained on the PR head, fails when any scenario
21+
# exceeds its limit. Never depends on the base branch.
22+
check:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: pnpm/action-setup@v4
27+
- uses: actions/setup-node@v4
28+
with:
29+
node-version-file: ".nvmrc"
30+
cache: pnpm
31+
- run: pnpm install --frozen-lockfile
32+
- run: pnpm build
33+
- run: npm ci --no-audit --no-fund
34+
working-directory: scripts/size
35+
- run: npm run size
36+
working-directory: scripts/size
37+
38+
# Best-effort base-vs-head delta comment. Requires the base branch to also
39+
# carry scripts/size/, so it is informational and never blocks: continue-on-error
40+
# keeps bootstrap PRs (and any action hiccup) green.
41+
compare:
42+
runs-on: ubuntu-latest
43+
continue-on-error: true
44+
steps:
45+
- uses: actions/checkout@v4
46+
- uses: pnpm/action-setup@v4
47+
- uses: actions/setup-node@v4
48+
with:
49+
node-version-file: ".nvmrc"
50+
cache: pnpm
51+
- uses: andresz1/size-limit-action@v1
52+
continue-on-error: true
53+
with:
54+
github_token: ${{ secrets.GITHUB_TOKEN }}
55+
package_manager: npm
56+
directory: scripts/size
57+
build_script: build

‎scripts/size/.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

‎scripts/size/.size-limit.js‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Import-cost scenarios for #2883, measured against the built browser-prod
2+
// artifacts. Bare specifiers resolve via esbuild aliases so nothing here
3+
// touches the workspace dependency graph. Limits carry ~5% headroom over the
4+
// sizes at landing: a breach means tree-shaking regressed (or a deliberate
5+
// feature landed — bump the limit in the same PR and say why). The simple-app
6+
// scenario is pinned at 10 KB on purpose.
7+
const alias = {
8+
"solid-js": "../../packages/solid/dist/solid.js",
9+
"@solidjs/web": "../../packages/solid-web/dist/web.js",
10+
"@solidjs/signals": "../../packages/solid-signals/dist/prod/index.js"
11+
};
12+
const modifyEsbuildConfig = config => ({ ...config, alias });
13+
14+
module.exports = [
15+
{
16+
name: "signals: core floor (createSignal/Memo/Effect/Root/flush)",
17+
path: "../../packages/solid-signals/dist/prod/index.js",
18+
import: "{ createSignal, createMemo, createEffect, createRoot, flush }",
19+
limit: "7.1 KB",
20+
modifyEsbuildConfig
21+
},
22+
{
23+
name: "signals: + createStore",
24+
path: "../../packages/solid-signals/dist/prod/index.js",
25+
import: "{ createSignal, createMemo, createEffect, createRoot, flush, createStore }",
26+
limit: "11.6 KB",
27+
modifyEsbuildConfig
28+
},
29+
{
30+
name: "signals: + isPending/latest",
31+
path: "../../packages/solid-signals/dist/prod/index.js",
32+
import: "{ createSignal, createMemo, createEffect, createRoot, flush, isPending, latest }",
33+
limit: "8.75 KB",
34+
modifyEsbuildConfig
35+
},
36+
{
37+
name: "app: render + one signal (the simple-app floor)",
38+
path: "minimal-app.js",
39+
limit: "10 KB",
40+
modifyEsbuildConfig
41+
},
42+
{
43+
name: "app: CSR with Show/For/Loading/Errored/lazy",
44+
path: "csr-app.js",
45+
limit: "12 KB",
46+
modifyEsbuildConfig
47+
}
48+
];

‎scripts/size/README.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Size scenarios (#2883)
2+
3+
Tree-shaken import-cost tracking: `.size-limit.js` defines scenario entries
4+
(signals floor, +createStore, +isPending/latest, the render+one-signal simple
5+
app, a representative CSR app) with hard gzip-limits. CI fails when a scenario
6+
exceeds its limit — that means tree-shaking regressed, or a deliberate feature
7+
landed and the limit should be bumped in the same PR with a reason. The
8+
simple-app scenario is pinned at 10 KB on purpose.
9+
10+
This directory is deliberately **outside the pnpm workspace**, with its own
11+
npm lockfile. Its tooling must never enter the workspace dependency graph:
12+
changing that graph re-keys pnpm peer instances (vitest,
13+
@codspeed/vitest-plugin), which relocates the benchmark harness and shows up
14+
as phantom CodSpeed regressions. Nothing here is published (`private: true`).
15+
16+
Run locally: `cd scripts/size && npm ci && npm run size` (build the repo
17+
first). The retained-module-graph test in
18+
`packages/solid-signals/tests/treeshake.test.ts` is the companion diagnostic
19+
that names the re-coupled module when shaking breaks.

‎scripts/size/csr-app.js‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// A representative CSR app surface: flow components, boundaries, lazy.
2+
import { render, Show, For, Loading, Errored } from "@solidjs/web";
3+
import { createSignal, createMemo, lazy } from "solid-js";
4+
5+
const [n, setN] = createSignal(0);
6+
const Page = lazy(() => import("./lazy-page.js"));
7+
render(() => {
8+
const d = createMemo(() => n() + 1);
9+
setN(1);
10+
return [d(), Show, For, Loading, Errored, Page];
11+
}, document.body);

‎scripts/size/lazy-page.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default () => "page";

‎scripts/size/minimal-app.js‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// The "simple app" floor: render + one signal. Tracks the tree-shaken cost a
2+
// hello-world CSR app ships (#2883).
3+
import { render } from "@solidjs/web";
4+
import { createSignal } from "solid-js";
5+
6+
const [count, setCount] = createSignal(0);
7+
render(() => {
8+
const el = document.createElement("button");
9+
el.onclick = () => setCount(count() + 1);
10+
return el;
11+
}, document.getElementById("app"));

0 commit comments

Comments
 (0)