Skip to content

Commit f60c51f

Browse files
committed
refactor(typescript): declare project references and drive typecheck through tsc -b
All 25 workspace packages now declare references derived from the pnpm workspace dependency graph (their manifest workspace:* edges), the root project and examples/sdk reference the packages, and every project points tsBuildInfoFile at its own output directory so one 'tsc -b' pass builds the whole graph. 'pnpm typecheck' becomes 'tsc -b tsconfig.json examples/sdk/tsconfig.json'. Measured on this host (Apple silicon, 12 cores): - cold (package outputs + .tmp wiped): 13.2s -> 9.1s - warm (no edits): 14.2s -> 0.5s - incremental cone: touching packages/host-kit/src/archive.ts rebuilds exactly its 17-project dependent cone; kernel, contracts, xml, ad-script, selectors, session-journal-free branches stay up to date. Root and examples/sdk consume packages through the declaration outputs the graph emits (699 -> 0 package .ts inputs in the root program), so NodeNext resolution errors surface for un-exported subpaths and unknown packages, and composite rootDir fails a package->root relative escape. A missing reference alone does not fail the build (the pnpm link farm resolves the exports-map .ts targets and the program reads sources); that gap stays under R11 and is recorded on #3279.
1 parent 0c1ebb3 commit f60c51f

28 files changed

Lines changed: 517 additions & 52 deletions

File tree

‎examples/sdk/tsconfig.json‎

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
4+
"composite": true,
5+
"noEmit": true,
6+
"tsBuildInfoFile": "../../.tmp/examples-sdk.tsbuildinfo",
47
"paths": {
58
"agent-device": ["../../src/sdk/index.ts"],
69
"agent-device/io": ["../../src/sdk/io.ts"],
@@ -21,5 +24,39 @@
2124
// prior build, workspace link, or publish step. Running an example for real
2225
// still resolves `agent-device` as a self-referencing package (needs
2326
// `pnpm build`), matching how a real consumer would import it.
24-
"include": [".", "../../packages/command-registry/src/global.d.ts"]
27+
//
28+
// Composite under `tsc -b`, so every file its program loads through `paths`
29+
// must be listed here — hence the `../../src/**/*` include with the test and
30+
// fixture exclusions. The workspace packages those sources reach are project
31+
// references: their exports-map `.ts` targets resolve to the `dist-types`
32+
// declarations the graph emits instead of becoming unlisted foreign inputs.
33+
"include": [".", "../../src/**/*", "../../packages/command-registry/src/global.d.ts"],
34+
"exclude": ["../../src/**/*.test.ts", "../../src/**/__tests__/**", "../../src/**/*.fixtures.ts"],
35+
"references": [
36+
{ "path": "../../packages/ad-replay" },
37+
{ "path": "../../packages/ad-script" },
38+
{ "path": "../../packages/capture-kit" },
39+
{ "path": "../../packages/command-registry" },
40+
{ "path": "../../packages/contracts" },
41+
{ "path": "../../packages/device-selection" },
42+
{ "path": "../../packages/host-kit" },
43+
{ "path": "../../packages/kernel" },
44+
{ "path": "../../packages/maestro" },
45+
{ "path": "../../packages/managed-allocation" },
46+
{ "path": "../../packages/platform-android" },
47+
{ "path": "../../packages/platform-apple" },
48+
{ "path": "../../packages/platform-harmonyos" },
49+
{ "path": "../../packages/platform-linux" },
50+
{ "path": "../../packages/platform-vega" },
51+
{ "path": "../../packages/platform-web" },
52+
{ "path": "../../packages/provider-limrun" },
53+
{ "path": "../../packages/provider-webdriver" },
54+
{ "path": "../../packages/provision-kit" },
55+
{ "path": "../../packages/proxy" },
56+
{ "path": "../../packages/replay-port" },
57+
{ "path": "../../packages/replay-test" },
58+
{ "path": "../../packages/selectors" },
59+
{ "path": "../../packages/session-journal" },
60+
{ "path": "../../packages/xml" }
61+
]
2562
}

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179
"check:unit": "pnpm test:unit && pnpm check:tmpdir-leaks && pnpm test:smoke",
180180
"check": "pnpm check:tooling && pnpm check:fallow && pnpm check:unit",
181181
"prepack": "npm_config_dry_run=false pnpm release:prepare",
182-
"typecheck": "tsc -b packages/xml packages/kernel packages/contracts packages/device-selection packages/host-kit packages/capture-kit packages/managed-allocation packages/provision-kit packages/platform-apple packages/platform-android packages/platform-harmonyos packages/platform-vega packages/platform-linux packages/platform-web packages/ad-script packages/selectors packages/command-registry packages/session-journal packages/ad-replay packages/maestro packages/replay-port packages/replay-test packages/provider-webdriver packages/provider-limrun packages/proxy packages/provider-testmu && tsc -p tsconfig.json && tsc -p examples/sdk/tsconfig.json",
182+
"typecheck": "tsc -b tsconfig.json examples/sdk/tsconfig.json",
183183
"test-app:install": "pnpm install --dir examples/test-app",
184184
"test-app:start": "pnpm --dir examples/test-app start",
185185
"test-app:ios": "pnpm --dir examples/test-app ios",

‎packages/ad-replay/tsconfig.json‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,22 @@
66
"emitDeclarationOnly": true,
77
"declaration": true,
88
"declarationDir": "./dist-types",
9-
"rootDir": "./src"
9+
"rootDir": "./src",
10+
"tsBuildInfoFile": "./dist-types/index.tsbuildinfo"
1011
},
11-
"include": ["src"]
12+
"include": ["src"],
13+
"references": [
14+
{
15+
"path": "../ad-script"
16+
},
17+
{
18+
"path": "../contracts"
19+
},
20+
{
21+
"path": "../kernel"
22+
},
23+
{
24+
"path": "../selectors"
25+
}
26+
]
1227
}

‎packages/ad-script/tsconfig.json‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@
66
"emitDeclarationOnly": true,
77
"declaration": true,
88
"declarationDir": "./dist-types",
9-
"rootDir": "./src"
9+
"rootDir": "./src",
10+
"tsBuildInfoFile": "./dist-types/index.tsbuildinfo"
1011
},
11-
"include": ["src"]
12+
"include": ["src"],
13+
"references": [
14+
{
15+
"path": "../contracts"
16+
},
17+
{
18+
"path": "../kernel"
19+
}
20+
]
1221
}

‎packages/capture-kit/tsconfig.json‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,19 @@
66
"emitDeclarationOnly": true,
77
"declaration": true,
88
"declarationDir": "./dist-types",
9-
"rootDir": "./src"
9+
"rootDir": "./src",
10+
"tsBuildInfoFile": "./dist-types/index.tsbuildinfo"
1011
},
11-
"include": ["src"]
12+
"include": ["src"],
13+
"references": [
14+
{
15+
"path": "../contracts"
16+
},
17+
{
18+
"path": "../host-kit"
19+
},
20+
{
21+
"path": "../kernel"
22+
}
23+
]
1224
}

‎packages/command-registry/tsconfig.json‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,19 @@
66
"emitDeclarationOnly": true,
77
"declaration": true,
88
"declarationDir": "./dist-types",
9-
"rootDir": "./src"
9+
"rootDir": "./src",
10+
"tsBuildInfoFile": "./dist-types/index.tsbuildinfo"
1011
},
11-
"include": ["src"]
12+
"include": ["src"],
13+
"references": [
14+
{
15+
"path": "../contracts"
16+
},
17+
{
18+
"path": "../kernel"
19+
},
20+
{
21+
"path": "../selectors"
22+
}
23+
]
1224
}

‎packages/contracts/tsconfig.json‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@
66
"emitDeclarationOnly": true,
77
"declaration": true,
88
"declarationDir": "./dist-types",
9-
"rootDir": "./src"
9+
"rootDir": "./src",
10+
"tsBuildInfoFile": "./dist-types/index.tsbuildinfo"
1011
},
11-
"include": ["src"]
12+
"include": ["src"],
13+
"references": [
14+
{
15+
"path": "../kernel"
16+
}
17+
]
1218
}

‎packages/device-selection/tsconfig.json‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,19 @@
66
"emitDeclarationOnly": true,
77
"declaration": true,
88
"declarationDir": "./dist-types",
9-
"rootDir": "./src"
9+
"rootDir": "./src",
10+
"tsBuildInfoFile": "./dist-types/index.tsbuildinfo"
1011
},
11-
"include": ["src"]
12+
"include": ["src"],
13+
"references": [
14+
{
15+
"path": "../contracts"
16+
},
17+
{
18+
"path": "../host-kit"
19+
},
20+
{
21+
"path": "../kernel"
22+
}
23+
]
1224
}

‎packages/host-kit/tsconfig.json‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@
66
"emitDeclarationOnly": true,
77
"declaration": true,
88
"declarationDir": "./dist-types",
9-
"rootDir": "./src"
9+
"rootDir": "./src",
10+
"tsBuildInfoFile": "./dist-types/index.tsbuildinfo"
1011
},
11-
"include": ["src"]
12+
"include": ["src"],
13+
"references": [
14+
{
15+
"path": "../contracts"
16+
},
17+
{
18+
"path": "../kernel"
19+
}
20+
]
1221
}

‎packages/kernel/tsconfig.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"emitDeclarationOnly": true,
77
"declaration": true,
88
"declarationDir": "./dist-types",
9-
"rootDir": "./src"
9+
"rootDir": "./src",
10+
"tsBuildInfoFile": "./dist-types/index.tsbuildinfo"
1011
},
1112
"include": ["src"]
1213
}

0 commit comments

Comments
 (0)