Skip to main content

Overview

T3 Code uses Turbo for orchestrated builds across the monorepo. The build process produces optimized bundles for web, server, and desktop distributions.

Quick Build Commands

Build Process

Build Order

Turbo builds packages in dependency order:
1

Packages (Parallel)

  • packages/contracts (Effect/Schema → ESM/CJS)
  • packages/shared (Runtime utilities)
2

Apps (Sequential)

  • apps/web (React + Vite → static assets)
  • apps/server (Node.js → bundled ESM)
3

Desktop (Final)

  • apps/desktop (Electron → platform binaries)

Build Outputs

Building Components

Contracts Package

Builds Effect/Schema definitions to distributable format:
Build Tool: tsdown (TypeScript bundler) Output:
  • dist/index.mjs - ESM bundle
  • dist/index.cjs - CommonJS bundle
  • dist/index.d.ts - TypeScript declarations
Configuration:
package.json

Web App

Builds React application to static assets:
Build Tool: Vite 8 Output: dist/ directory with:
  • index.html - HTML entry point
  • assets/*.js - Code-split JavaScript bundles
  • assets/*.css - Extracted stylesheets
  • assets/* - Images, fonts, other assets
Optimizations:
  • React Compiler (automatic memoization)
  • Code splitting (route-based)
  • Tree shaking (unused code elimination)
  • Minification (Terser)
  • CSS optimization (Lightning CSS)
Configuration:
vite.config.ts

Server Package

Builds Node.js backend to bundled ESM:
Build Tool: Custom bundler (scripts/cli.ts build) Output: dist/index.mjs (single bundle including web assets) Process:
  1. Builds web app (if not already built)
  2. Bundles server code with tsdown
  3. Embeds web assets in server bundle
  4. Generates CLI entry point
Configuration:
scripts/cli.ts
The server build includes the web app for production serving.

Desktop App

Builds Electron application:
Build Tool: tsdown + Electron Output: dist-electron/ directory with:
  • main.js - Electron main process
  • preload.js - Preload scripts
For distribution, see Desktop Distribution below.

Production Build

Full Production Build

Build everything for production:

Start Production Server

Run the built server:
This runs node dist/index.mjs which:
  • Starts WebSocket server
  • Serves built web app as static files
  • Opens browser to the app
Production Configuration:

Desktop Distribution

Build Desktop Artifacts

Create platform-specific installers:
Output: release/T3 Code (Alpha)-0.0.3-arm64.dmg

Custom Platform/Architecture

Build for specific targets:
Available Options:

DMG Packaging Options

For debugging package contents:
Staging files remain in .stage/ directory.
Enable code signing (requires certificates in CI/secrets):
macOS: Uses Apple Developer IDWindows: Uses Azure Trusted Signing with these environment variables:
  • AZURE_TRUSTED_SIGNING_ENDPOINT
  • AZURE_TRUSTED_SIGNING_ACCOUNT_NAME
  • AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME
  • AZURE_TRUSTED_SIGNING_PUBLISHER_NAME
  • AZURE_TENANT_ID
  • AZURE_CLIENT_ID
  • AZURE_CLIENT_SECRET

Desktop Package Contents

The desktop package includes:
  • Electron shell (dist-electron/)
  • Web UI (bundled from apps/web/dist)
  • Backend server (apps/server/dist as t3 CLI)
  • App icon (from assets/macos-icon-1024.png)
How it works:
apps/desktop/src/main/backend.ts

Build Optimization

Turbo Caching

Turbo caches build outputs for faster rebuilds:
Cache Configuration:
turbo.json

Parallel Builds

Turbo runs independent builds in parallel:

Incremental Builds

Development builds support incremental compilation:

CI/CD Integration

GitHub Actions Example

.github/workflows/build.yml

Desktop Release Workflow

.github/workflows/release.yml

Troubleshooting

Ensure all dependencies are installed:
Clear the Turbo cache:
Check that you’ve built the dependencies first:
Force rebuild the web app:

Pre-Commit Checks

Both bun lint and bun typecheck must pass before tasks are considered complete.
Run all checks before committing:

Automated Checks

Add to .husky/pre-commit:

Next Steps

Testing

Learn about testing strategies

Setup

Review development setup