The monorepo uses Turborepo for efficient task orchestration and caching across packages and applications.
// turbo.json
{
"$schema": "https://turborepo.com/schema.json",
"ui": "tui",
"tasks": {
"build": {
"dependsOn": ["^build"],
"inputs": ["$TURBO_DEFAULT$", ".env*"],
"outputs": ["dist/**"]
},
"lint": {
"dependsOn": ["^lint"]
},
"check-types": {
"dependsOn": ["^build"]
},
"start": {
"cache": false,
"persistent": true
},
"watch": {
"cache": false,
"persistent": true
},
"test": {
"dependsOn": ["^build"],
"inputs": ["$TURBO_DEFAULT$", ".env*"]
}
}
}- Build Pipeline: Shared packages build before applications
- Type Checking: Depends on built packages for type resolution
- Testing: Requires built dependencies
- Linting: Runs independently with dependency chain
// package.json
{
"workspaces": ["apps/*", "packages/*"],
"packageManager": "yarn@4.9.2"
}lfx-one/
βββ apps/
β βββ lfx-one/ # Angular application
βββ packages/
βββ shared/ # Shared interfaces and constants
# Build all packages and applications
yarn build
# Start development servers
yarn start
# Run linting across all workspaces
yarn lint
# Run tests across all workspaces
yarn test
# Type checking across all workspaces
yarn check-types
# Watch mode for development
yarn watch
# Format code with Prettier
yarn format# Start production server with PM2
yarn start:prod
# Stop production server
yarn stop:prod
# Restart production server
yarn restart:prod
# Zero-downtime reload
yarn reload:prod
# View production logs
yarn logs:prod-
Install Dependencies
yarn install
-
Build Shared Packages
cd packages/shared yarn build -
Start Development Server
yarn start
-
Make Changes and Test
# In separate terminal ./check-headers.sh # Verify license headers yarn lint yarn check-types
When working on shared packages:
# Navigate to shared package
cd packages/shared
# Watch for changes and rebuild
yarn watch
# In another terminal, start the app
cd ../../
yarn startTurborepo runs tasks in parallel when possible:
# These run in parallel across workspaces
yarn lint # Lints all packages simultaneously
yarn test # Tests all packages simultaneously# These respect dependency order
yarn build # Builds shared packages first, then apps
yarn check-types # Type checks after dependencies are built{
"build": {
"outputs": ["dist/**"], // Cache build outputs
"inputs": ["$TURBO_DEFAULT$", ".env*"] // Invalidate on file changes
}
}- Faster Builds: Skip unchanged packages
- CI/CD Optimization: Share cache across environments
- Development Speed: Incremental builds
{
"start": {
"cache": false, // Development server shouldn't be cached
"persistent": true // Long-running process
}
}Projects inherit from shared configuration:
// packages/shared/tsconfig.json
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"declaration": true,
"declarationMap": true,
"outDir": "./dist"
}
}// apps/lfx-one/tsconfig.json
{
"extends": "./tsconfig.app.json",
"compilerOptions": {
"paths": {
"@lfx-one/shared": ["../../packages/shared/src/index.ts"],
"@lfx-one/shared/*": ["../../packages/shared/src/*"]
}
}
}// Root package.json
{
"devDependencies": {
"prettier": "^3.6.2",
"turbo": "^2.5.4",
"typescript": "5.8.3"
},
"engines": {
"node": ">=22"
}
}// apps/lfx-one/package.json
{
"dependencies": {
"@lfx-one/shared": "workspace:*"
}
}- Independent Versioning: Each package has its own version
- Workspace Protocol: Use
workspace:*for local dependencies - Semantic Versioning: Follow semver for all packages
- Update package versions
- Build all packages
- Run tests
- Commit and tag
- Deploy applications
All source code files must include the appropriate license header:
# Check license headers
./check-headers.shRequired Format:
// Copyright The Linux Foundation and each contributor to LFX.
// SPDX-License-Identifier: MITThe repository uses Husky for pre-commit hooks that automatically run:
- License Header Check - Ensures all files have proper headers
- Linting - Runs ESLint and Prettier
- Type Checking - Verifies TypeScript types
- Format Check - Ensures consistent code formatting
# Pre-commit hooks run automatically on commit
git commit -m "your changes"
# To bypass pre-commit hooks (not recommended)
git commit -m "your changes" --no-verify- License Header Check: Automated workflow validates headers on PRs
- Quality Checks: Separate workflow for linting, testing, and building
- Automated Enforcement: PRs cannot be merged without passing all checks
- License Headers: Ensure all new files have proper license headers
- Shared Package First: Build shared packages before applications
- Type Safety: Always run type checking before commits
- Linting: Maintain consistent code style
- Testing: Run tests in affected packages
- Incremental Builds: Leverage Turborepo caching
# Run only affected packages (future feature)
yarn build --filter=...HEAD^
# Parallel execution
yarn build --parallel
# Remote caching (in CI/CD)
yarn build --remote-cache# Clear Turborepo cache
npx turbo prune
# Reinstall dependencies
rm -rf node_modules packages/*/node_modules apps/*/node_modules
yarn install
# Force rebuild shared packages
cd packages/shared
rm -rf dist
yarn build# Check dependency graph
npx turbo build --graph
# Verbose build output
npx turbo build --verbose
# Build specific package
npx turbo build --filter=@lfx-one/sharedTurborepo provides insights into task performance:
# Task timing information
yarn build --profile
# Task dependency visualization
yarn build --graphMonitor cache effectiveness:
- High cache hit rates indicate efficient incremental builds
- Low cache hit rates suggest configuration issues
This development workflow provides efficient monorepo management with fast builds and reliable dependency handling β Turborepo task orchestration, Yarn 4 workspaces, TypeScript path mapping, parallel task execution, and local build caching.