fix(build): use tsc --build to respect dependency order in monorepo#187
fix(build): use tsc --build to respect dependency order in monorepo#187
Conversation
The previous build script used 'npm run build --workspaces' which runs workspace builds in parallel without respecting TypeScript project references. This caused dependent packages to fail compilation when @tinyclaw/core had not finished building yet. Using 'tsc --build' respects the project references and builds packages in the correct dependency order. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Greptile SummaryThis PR replaces the parallel However, one blocking issue was found:
Confidence Score: 2/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["tsc --build\n(root tsconfig.json)"] --> B[packages/core]
B --> C[packages/teams]
B --> D[packages/channels]
B --> E[packages/server]
C --> E
B --> F[packages/main]
C --> F
E --> F
A --> G[packages/visualizer]
style G fill:#f55,color:#fff
G:::broken
classDef broken stroke:#c00,stroke-width:2px
G --> H["❌ TS6306: composite: true missing\ndeclaration: false is incompatible"]
Last reviewed commit: cbb552f |
| ], | ||
| "scripts": { | ||
| "build": "npm run build --workspaces", | ||
| "build": "tsc --build", |
There was a problem hiding this comment.
tsc --build will fail for the visualizer package
packages/visualizer/tsconfig.json is not compatible with TypeScript composite project references, which tsc --build requires for every entry listed under references in the root tsconfig.json.
Two problems with the visualizer's config:
- It does not extend
../../tsconfig.base.json, so it does not inherit"composite": true. - It explicitly sets
"declaration": false— which is incompatible withcomposite: true(TypeScript requires declarations to be emitted for composite projects so downstream packages can consume them).
When tsc --build reaches packages/visualizer, it will throw:
error TS6306: Referenced project 'packages/visualizer' must have setting 'composite': true.
All other package tsconfigs extend tsconfig.base.json (which provides composite: true and declaration: true), so only the visualizer is affected. The fix is to bring it in line with the rest of the packages:
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src",
"jsx": "react-jsx"
},
"include": ["src/**/*"]
}Note that isolatedModules can be dropped (it's a bundler-oriented option and not meaningful for tsc output), and declaration: false must be removed so the composite build can emit .d.ts files.
Description
Fix build failures after the monorepo refactoring by respecting TypeScript project reference dependencies. The previous build script used
npm run build --workspaceswhich runs all workspace builds in parallel, causing dependent packages to fail when@tinyclaw/corehadn't finished building yet.Changes
npm run build --workspacestotsc --buildtsconfig.jsonTesting
🤖 Generated with Claude Code