Build System Overview
The build system uses different tools for different parts:| Component | Tool | Purpose |
|---|---|---|
| Shared package | TypeScript | Compile to JS + type definitions |
| Core package | TypeScript | Compile to JS + type definitions |
| Main process | TypeScript + esbuild | Compile then bundle to single file |
| Renderer | Vite | Bundle React app |
| Packaging | Electron Forge | Create distributable app |
Package manager: pnpm is required for the
workspace:* protocol used in the monorepo.Development Build
Quick Start
Available Scripts
Build Order
Packages must be built in dependency order:Why This Order?
Each package depends on type definitions from upstream packages:Main Process Bundle
The main process uses a two-stage build:Stage 1: TypeScript Compilation
src/ to intermediate JavaScript with:
- Target: ES2022
- Module: ESNext
- Type definitions: Generated
Stage 2: esbuild Bundling
Thebundle.mjs script bundles everything into a single file:
Why bundle? pnpm uses symlinks for workspace packages. Electron Forge’s dependency walker can’t follow these symlinks. Bundling creates a single file with all code, eliminating the need for
node_modules in the packaged app.Renderer Bundle
The renderer uses Vite for both development and production:Development
- Hot module replacement (HMR)
- React Fast Refresh
- Instant updates
Production
- Minified JavaScript
- Code splitting
- Hashed filenames for caching
Production Packaging
Electron Forge creates distributable packages.Package (No Installer)
Creates an application bundle:Make (With Installer)
Creates installers for distribution:Forge Configuration
Packaging is configured inapps/main/forge.config.cjs:
Code Signing (macOS)
For production builds with code signing, set these environment variables:Generating App-Specific Password
Sign in to Apple ID
Go to appleid.apple.com
Build Troubleshooting
Workspace Dependencies Not Found
Main Process Not Updating
Problem: Changes to main process don’t appear in the app. Solution: Main process doesn’t hot-reload. Restart the dev server:Preload Script Not Loading
Problem: Preload APIs not available in renderer. Solution: Rebuild preload scripts:TypeScript Errors
Problem: Type errors in IDE but code runs. Solution: Rebuild packages to regenerate type definitions:Clean Build
If you encounter persistent issues, try a clean build:Build Performance
Development
- Cold start: ~15-30 seconds (includes
npm run deps) - Hot reload (renderer): Instant with Vite HMR
- Rebuild after changes: Depends on what changed
- Renderer only: Instant (HMR)
- Preload/shared/core: ~5-10 seconds + restart
- Main process: ~5-10 seconds + restart
Production
- Package (no installer): ~30-60 seconds
- Make (with installer): ~60-120 seconds
- Code signing: Adds ~30-60 seconds
Build times vary based on hardware and platform. Apple Silicon Macs are generally faster than Intel.