Implementation:Cypress io Cypress Lerna Nx Build
| Knowledge Sources | |
|---|---|
| Domains | Build, Monorepo |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
Concrete tool for building all monorepo packages in dependency order using Lerna with Nx task orchestration.
Description
The lerna run build --stream command (triggered by yarn build in root package.json:L17) uses Nx to analyze the dependency graph and execute per-package build scripts in topological order. The nx.json configuration (L1-51) defines task dependencies, and lerna.json (L1-13) defines workspace package paths.
Usage
Run yarn build from the repository root to compile all packages. Individual packages can be built with lerna run build --scope=@packages/config.
Code Reference
Source Location
- Repository: cypress-io/cypress
- Files:
- package.json:L17 (build script)
- nx.json:L1-51 (task orchestration)
- lerna.json:L1-13 (workspace config)
Signature
// nx.json
{
"targetDefaults": {
"build": {
"dependsOn": ["^build"]
}
}
}
// lerna.json
{
"packages": ["cli", "packages/*", "npm/*", "tooling/*", "system-tests", "scripts"],
"useNx": true
}
Import
# Build all packages
yarn build
# or: npx lerna run build --stream
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| TypeScript sources | .ts files | Yes | Source files across all packages |
| Package dependencies | package.json | Yes | Inter-package dependency declarations |
Outputs
| Name | Type | Description |
|---|---|---|
| Compiled JS | dist/ directories | JavaScript output per package |
| Type declarations | .d.ts files | TypeScript declaration files |
| Bundled assets | various | Webpack/Vite bundled assets |
Usage Examples
Development Build
# Full build
yarn build
# Build specific package
npx lerna run build --scope=@packages/config
# Build with streaming output
npx lerna run build --stream