Skip to content

fix(build): use tsc --build to respect dependency order in monorepo#187

Merged
jlia0 merged 1 commit intomainfrom
jlia0/fix-build-after-refactor
Mar 10, 2026
Merged

fix(build): use tsc --build to respect dependency order in monorepo#187
jlia0 merged 1 commit intomainfrom
jlia0/fix-build-after-refactor

Conversation

@jlia0
Copy link
Collaborator

@jlia0 jlia0 commented Mar 10, 2026

Description

Fix build failures after the monorepo refactoring by respecting TypeScript project reference dependencies. The previous build script used npm run build --workspaces which runs all workspace builds in parallel, causing dependent packages to fail when @tinyclaw/core hadn't finished building yet.

Changes

  • Changed root build script from npm run build --workspaces to tsc --build
  • This respects the project references already configured in each package's tsconfig.json
  • Builds packages in correct dependency order: core → teams → channels/server → main

Testing

  • ✅ Build completes successfully
  • ✅ All TypeScript compilation errors resolved

🤖 Generated with Claude Code

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>
@jlia0 jlia0 merged commit ee46b31 into main Mar 10, 2026
1 check passed
@jlia0 jlia0 deleted the jlia0/fix-build-after-refactor branch March 10, 2026 21:30
@greptile-apps
Copy link

greptile-apps bot commented Mar 10, 2026

Greptile Summary

This PR replaces the parallel npm run build --workspaces root build script with tsc --build to leverage TypeScript project references and enforce correct dependency ordering across the monorepo. The approach is sound — the root tsconfig.json is already properly configured as a solution-style file ("files": [] + "references") and tsconfig.base.json provides "composite": true for all packages that extend it.

However, one blocking issue was found:

  • packages/visualizer/tsconfig.json is incompatible with composite project references. Unlike every other package, it does not extend ../../tsconfig.base.json, missing the required "composite": true. It also explicitly sets "declaration": false, which TypeScript forbids in a composite project. Since the root tsconfig.json includes packages/visualizer in its references array, tsc --build will error with TS6306: Referenced project must have setting 'composite': true when it reaches the visualizer package.

Confidence Score: 2/5

  • Not safe to merge as-is — tsc --build will fail on the visualizer package due to missing composite: true.
  • The fix correctly identifies the problem (parallel workspace builds racing) and the solution (tsc --build with project references) is the right approach. The root tsconfig.json and all package configs except one are properly set up. However, packages/visualizer/tsconfig.json lacks composite: true and sets declaration: false, which will cause a hard TypeScript error when tsc --build processes it, blocking the build entirely.
  • packages/visualizer/tsconfig.json — must be updated to extend tsconfig.base.json and remove declaration: false before this PR can work end-to-end.

Important Files Changed

Filename Overview
package.json Root build script changed from npm run build --workspaces to tsc --build. The intent is correct and the root tsconfig.json is properly configured with "files": [] and references for all packages. However, packages/visualizer/tsconfig.json lacks composite: true and sets declaration: false, which will cause tsc --build to fail when it processes the visualizer reference.

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"]
Loading

Last reviewed commit: cbb552f

],
"scripts": {
"build": "npm run build --workspaces",
"build": "tsc --build",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. It does not extend ../../tsconfig.base.json, so it does not inherit "composite": true.
  2. It explicitly sets "declaration": false — which is incompatible with composite: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant