Skip to content

Commit 37d9e1c

Browse files
committed
ci: batch-typecheck examples with tsgo; lighten pre-commit
Replaces 23 per-example `tsc --noEmit` invocations with a single `tsgo -b --noEmit` batch call that checks all 46 tsconfigs (SDK + example client + server configs) in one process. Local (14-core): typecheck 46 configs in ~2s (was ~50s CPU across separate tsc spawns). examples:build: 22s → 15.5s wall, 148s → 82s CPU. CI: expect examples:build ~135s → ~80-90s on Linux (2-core runners were bottlenecked on tsc spawn overhead + contention). Also skips the redundant SDK rebuild inside preexamples:build. Pre-commit: replaces full build:all (all vite bundles) with SDK build + typecheck. CI still does the full build. tsgo pinned to 7.0.0-dev.20260305.1. Used for --noEmit only; .d.ts emission stays on tsc (tsgo declaration emit has known nondeterminism, microsoft/typescript-go#1570). Side fix: 14 examples imported CSS without vite-env.d.ts. tsc 5.9 tolerates this but tsgo enforces TS2882. Added the standard Vite shim.
1 parent 2b0d11e commit 37d9e1c

43 files changed

Lines changed: 231 additions & 26 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,13 @@ jobs:
8383
if: runner.os == 'Linux' && matrix.name == 'Linux x64'
8484
run: npm exec typedoc -- --treatValidationWarningsAsErrors --emit none
8585

86-
- run: npm run examples:build
86+
# Fast-fail typecheck of SDK + all examples (~46 tsconfigs) in one tsgo process.
87+
# Replaces the per-example `tsc --noEmit` that used to run inside examples:build.
88+
- run: npm run typecheck
89+
90+
# examples:build runs `npm run build` again via preexamples:build — skip that
91+
# since we already built the SDK above. Call the runner directly.
92+
- run: npx bun examples/run-all.ts build
8793

8894
- name: Verify generated schemas are up-to-date
8995
shell: bash
@@ -162,7 +168,8 @@ jobs:
162168
run: |
163169
npm ci
164170
npm run build
165-
npm run examples:build
171+
npm run typecheck
172+
npx bun examples/run-all.ts build
166173
npm test
167174
npm run prettier
168175

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ bun.lockb
77
docs/api/
88
tmp/
99
intermediate-findings/
10+
*.tsbuildinfo
1011

1112
# Playwright
1213
playwright-report/

.husky/pre-commit

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ fi
1818
# (avoids sweeping unrelated WIP into the commit)
1919
STAGED=$(git diff --name-only --cached)
2020

21-
npm run build:all
21+
# Build SDK only (regenerates src/generated/, emits dist/ needed by example typecheck)
22+
npm run build
23+
# Fast batch typecheck of SDK + all examples via tsgo (~2s). Replaces the full
24+
# examples:build bundle step — CI still does the full build.
25+
npm run typecheck
2226
npm run prettier:fix
2327

2428
# Re-stage originally-staged files (prettier may have reformatted them)

examples/basic-host/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "1.2.0",
55
"type": "module",
66
"scripts": {
7-
"build": "tsc --noEmit && concurrently \"cross-env INPUT=index.html vite build\" \"cross-env INPUT=sandbox.html vite build\"",
7+
"build": "concurrently \"cross-env INPUT=index.html vite build\" \"cross-env INPUT=sandbox.html vite build\"",
88
"watch": "concurrently \"cross-env INPUT=index.html vite build --watch\" \"cross-env INPUT=sandbox.html vite build --watch\"",
99
"serve": "bun --watch serve.ts",
1010
"start": "cross-env NODE_ENV=development npm run build && npm run serve",

examples/basic-server-preact/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dist"
1515
],
1616
"scripts": {
17-
"build": "tsc --noEmit && cross-env INPUT=mcp-app.html vite build && tsc -p tsconfig.server.json && bun build server.ts --outdir dist --target node && bun build main.ts --outfile dist/index.js --target node --external \"./server.js\" --banner \"#!/usr/bin/env node\"",
17+
"build": "cross-env INPUT=mcp-app.html vite build && tsc -p tsconfig.server.json && bun build server.ts --outdir dist --target node && bun build main.ts --outfile dist/index.js --target node --external \"./server.js\" --banner \"#!/usr/bin/env node\"",
1818
"watch": "cross-env INPUT=mcp-app.html vite build --watch",
1919
"serve": "bun --watch main.ts",
2020
"serve:stdio": "bun main.ts --stdio",

examples/basic-server-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
}
2525
},
2626
"scripts": {
27-
"build": "tsc --noEmit && cross-env INPUT=mcp-app.html vite build && tsc -p tsconfig.server.json && bun build server.ts --outdir dist --target node && bun build main.ts --outfile dist/index.js --target node --external \"./server.js\" --banner \"#!/usr/bin/env node\"",
27+
"build": "cross-env INPUT=mcp-app.html vite build && tsc -p tsconfig.server.json && bun build server.ts --outdir dist --target node && bun build main.ts --outfile dist/index.js --target node --external \"./server.js\" --banner \"#!/usr/bin/env node\"",
2828
"watch": "cross-env INPUT=mcp-app.html vite build --watch",
2929
"serve": "bun --watch main.ts",
3030
"serve:stdio": "bun main.ts --stdio",

examples/basic-server-solid/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dist"
1515
],
1616
"scripts": {
17-
"build": "tsc --noEmit && cross-env INPUT=mcp-app.html vite build && tsc -p tsconfig.server.json && bun build server.ts --outdir dist --target node && bun build main.ts --outfile dist/index.js --target node --external \"./server.js\" --banner \"#!/usr/bin/env node\"",
17+
"build": "cross-env INPUT=mcp-app.html vite build && tsc -p tsconfig.server.json && bun build server.ts --outdir dist --target node && bun build main.ts --outfile dist/index.js --target node --external \"./server.js\" --banner \"#!/usr/bin/env node\"",
1818
"watch": "cross-env INPUT=mcp-app.html vite build --watch",
1919
"serve": "bun --watch main.ts",
2020
"serve:stdio": "bun main.ts --stdio",

examples/basic-server-svelte/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dist"
1515
],
1616
"scripts": {
17-
"build": "tsc --noEmit && cross-env INPUT=mcp-app.html vite build && tsc -p tsconfig.server.json && bun build server.ts --outdir dist --target node && bun build main.ts --outfile dist/index.js --target node --external \"./server.js\" --banner \"#!/usr/bin/env node\"",
17+
"build": "cross-env INPUT=mcp-app.html vite build && tsc -p tsconfig.server.json && bun build server.ts --outdir dist --target node && bun build main.ts --outfile dist/index.js --target node --external \"./server.js\" --banner \"#!/usr/bin/env node\"",
1818
"watch": "cross-env INPUT=mcp-app.html vite build --watch",
1919
"serve": "bun --watch main.ts",
2020
"serve:stdio": "bun main.ts --stdio",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />

examples/basic-server-vanillajs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dist"
1515
],
1616
"scripts": {
17-
"build": "tsc --noEmit && cross-env INPUT=mcp-app.html vite build && tsc -p tsconfig.server.json && bun build server.ts --outdir dist --target node && bun build main.ts --outfile dist/index.js --target node --external \"./server.js\" --banner \"#!/usr/bin/env node\"",
17+
"build": "cross-env INPUT=mcp-app.html vite build && tsc -p tsconfig.server.json && bun build server.ts --outdir dist --target node && bun build main.ts --outfile dist/index.js --target node --external \"./server.js\" --banner \"#!/usr/bin/env node\"",
1818
"watch": "cross-env INPUT=mcp-app.html vite build --watch",
1919
"serve": "bun --watch main.ts",
2020
"serve:stdio": "bun main.ts --stdio",

0 commit comments

Comments
 (0)