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:Packages (Parallel)
packages/contracts(Effect/Schema → ESM/CJS)packages/shared(Runtime utilities)
Build Outputs
| Package | Output Directory | Format |
|---|---|---|
contracts | dist/ | ESM + CJS + types |
web | dist/ | Static HTML/JS/CSS |
server | dist/ | Bundled ESM (index.mjs) |
desktop | dist-electron/ | Electron bundles |
Building Components
Contracts Package
Builds Effect/Schema definitions to distributable format:tsdown (TypeScript bundler)
Output:
dist/index.mjs- ESM bundledist/index.cjs- CommonJS bundledist/index.d.ts- TypeScript declarations
package.json
Web App
Builds React application to static assets:dist/ directory with:
index.html- HTML entry pointassets/*.js- Code-split JavaScript bundlesassets/*.css- Extracted stylesheetsassets/*- Images, fonts, other assets
- React Compiler (automatic memoization)
- Code splitting (route-based)
- Tree shaking (unused code elimination)
- Minification (Terser)
- CSS optimization (Lightning CSS)
vite.config.ts
Server Package
Builds Node.js backend to bundled ESM:scripts/cli.ts build)
Output: dist/index.mjs (single bundle including web assets)
Process:
- Builds web app (if not already built)
- Bundles server code with tsdown
- Embeds web assets in server bundle
- Generates CLI entry point
scripts/cli.ts
The server build includes the web app for production serving.
Desktop App
Builds Electron application:tsdown + Electron
Output: dist-electron/ directory with:
main.js- Electron main processpreload.js- Preload scripts
Production Build
Full Production Build
Build everything for production:Start Production Server
Run the built server:node dist/index.mjs which:
- Starts WebSocket server
- Serves built web app as static files
- Opens browser to the app
Desktop Distribution
Build Desktop Artifacts
Create platform-specific installers:- macOS
- Linux
- Windows
release/T3 Code (Alpha)-0.0.3-arm64.dmgCustom Platform/Architecture
Build for specific targets:| Flag | Values | Description |
|---|---|---|
--platform | mac, linux, win | Target platform |
--target | dmg, AppImage, nsis | Installer format |
--arch | arm64, x64 | CPU architecture |
DMG Packaging Options
Keep staging files
Keep staging files
For debugging package contents:Staging files remain in
.stage/ directory.Code signing
Code signing
Enable code signing (requires certificates in CI/secrets):macOS: Uses Apple Developer IDWindows: Uses Azure Trusted Signing with these environment variables:
AZURE_TRUSTED_SIGNING_ENDPOINTAZURE_TRUSTED_SIGNING_ACCOUNT_NAMEAZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAMEAZURE_TRUSTED_SIGNING_PUBLISHER_NAMEAZURE_TENANT_IDAZURE_CLIENT_IDAZURE_CLIENT_SECRET
Desktop Package Contents
The desktop package includes:- Electron shell (
dist-electron/) - Web UI (bundled from
apps/web/dist) - Backend server (
apps/server/distast3CLI) - App icon (from
assets/macos-icon-1024.png)
apps/desktop/src/main/backend.ts
Build Optimization
Turbo Caching
Turbo caches build outputs for faster rebuilds: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
Build fails with missing dependencies
Build fails with missing dependencies
Ensure all dependencies are installed:
Turbo cache issues
Turbo cache issues
Clear the Turbo cache:
Desktop build fails
Desktop build fails
Check that you’ve built the dependencies first:
Web assets not updating
Web assets not updating
Force rebuild the web app:
Pre-Commit Checks
Run all checks before committing:Automated Checks
Add to.husky/pre-commit:
Next Steps
Testing
Learn about testing strategies
Setup
Review development setup
