|
| 1 | +# Copilot Instructions for build-tools |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +This is the **build-tools** release group for the Fluid Framework monorepo. It contains CLI tools and libraries for building, testing, releasing, and managing Fluid Framework repositories. |
| 6 | + |
| 7 | +**Runtime**: Node.js >=20.15.1, pnpm 10.18.3 |
| 8 | +**Language**: TypeScript ~5.4.5 |
| 9 | +**Module system**: Mix of CommonJS and ESM (see DEV.md for constraints) |
| 10 | + |
| 11 | +## Packages |
| 12 | + |
| 13 | +| Package | Description | Output Dir | Module Type | |
| 14 | +|---------|-------------|------------|-------------| |
| 15 | +| `@fluid-tools/build-cli` (flub) | Main CLI for build/release operations | `lib/` | ESM | |
| 16 | +| `@fluidframework/build-tools` | Core build infrastructure, `fluid-build` CLI | `dist/` | CommonJS | |
| 17 | +| `@fluid-tools/build-infrastructure` | Workspace and release group abstractions | `lib/` (ESM), `dist/` (CJS) | Dual | |
| 18 | +| `@fluid-tools/version-tools` (fluv) | Semantic versioning utilities CLI | `lib/` | CommonJS | |
| 19 | +| `@fluidframework/bundle-size-tools` | Bundle size analysis utilities | `dist/` | CommonJS | |
| 20 | + |
| 21 | +## Build Commands |
| 22 | + |
| 23 | +**Always run from `build-tools/` directory. Install dependencies first if `node_modules/` doesn't exist.** |
| 24 | + |
| 25 | +```bash |
| 26 | +# Install dependencies (required first time or after package.json changes) |
| 27 | +pnpm install |
| 28 | + |
| 29 | +# Full build (compile + lint + docs) |
| 30 | +pnpm build |
| 31 | + |
| 32 | +# Fast incremental build (compile only) |
| 33 | +pnpm build:fast |
| 34 | + |
| 35 | +# TypeScript compilation only |
| 36 | +pnpm tsc |
| 37 | + |
| 38 | +# Run tests |
| 39 | +pnpm test:mocha |
| 40 | + |
| 41 | +# Lint code |
| 42 | +pnpm lint |
| 43 | + |
| 44 | +# Format code |
| 45 | +pnpm format |
| 46 | + |
| 47 | +# Clean build artifacts |
| 48 | +pnpm clean |
| 49 | +``` |
| 50 | + |
| 51 | +## Build Order |
| 52 | + |
| 53 | +Packages have workspace dependencies and must build in order: |
| 54 | +1. `version-tools` (no internal deps) |
| 55 | +2. `build-tools` (depends on version-tools) |
| 56 | +3. `build-infrastructure` (depends on version-tools) |
| 57 | +4. `bundle-size-tools` (no internal deps) |
| 58 | +5. `build-cli` (depends on all above) |
| 59 | + |
| 60 | +The `fluid-build` task scheduler handles this automatically via `pnpm build`. |
| 61 | + |
| 62 | +## Validation Checklist |
| 63 | + |
| 64 | +Before submitting changes, verify: |
| 65 | + |
| 66 | +1. **TypeScript compiles**: `pnpm tsc` |
| 67 | +2. **Tests pass**: `pnpm test:mocha` |
| 68 | +3. **Lint passes**: `pnpm lint` (runs ESLint + syncpack) |
| 69 | +4. **Format is correct**: `pnpm check:format` (uses Biome) |
| 70 | + |
| 71 | +## Key Configuration Files |
| 72 | + |
| 73 | +| File | Purpose | |
| 74 | +|------|---------| |
| 75 | +| `package.json` | Root workspace config, scripts, dependencies | |
| 76 | +| `pnpm-workspace.yaml` | Workspace package locations | |
| 77 | +| `syncpack.config.cjs` | Dependency version synchronization rules | |
| 78 | +| `biome.jsonc` | Code formatting and organization (extends root) | |
| 79 | +| `commitlint.config.cjs` | Commit message format (conventional commits, sentence-case) | |
| 80 | +| `api-extractor-base.json` | Shared API Extractor configuration | |
| 81 | + |
| 82 | +Each package has: |
| 83 | +- `package.json` - Package config and scripts |
| 84 | +- `tsconfig.json` - TypeScript configuration |
| 85 | +- `.eslintrc.cjs` - ESLint rules (extends `@fluidframework/eslint-config-fluid`) |
| 86 | +- `api-extractor.json` - API report generation (most packages) |
| 87 | + |
| 88 | +## Dependency Constraints |
| 89 | + |
| 90 | +**Critical**: Many dependencies are pinned to older versions due to ESM/CommonJS compatibility. See `DEV.md` for the full list. Do not upgrade: |
| 91 | + |
| 92 | +- `execa` (max ^5.x) |
| 93 | +- `globby` (max ^11.x) |
| 94 | +- `type-fest` (max ^2.x) |
| 95 | +- `eslint` (max ~8.57.0) |
| 96 | +- `typescript` (pinned ~5.4.5) |
| 97 | + |
| 98 | +## Testing |
| 99 | + |
| 100 | +Tests use Mocha. Test files are in `src/test/` and compile to `lib/test/` or `dist/test/`. |
| 101 | + |
| 102 | +```bash |
| 103 | +# Run all tests |
| 104 | +pnpm test:mocha |
| 105 | + |
| 106 | +# Run tests with coverage |
| 107 | +pnpm test:coverage |
| 108 | + |
| 109 | +# Run tests for a specific package |
| 110 | +cd packages/build-cli && pnpm test:mocha |
| 111 | +``` |
| 112 | + |
| 113 | +## Common Tasks |
| 114 | + |
| 115 | +### Adding a new flub command |
| 116 | + |
| 117 | +1. Create command file in `packages/build-cli/src/commands/` |
| 118 | +2. Commands use oclif framework - extend `BaseCommand` |
| 119 | +3. Run `pnpm build:manifest` to update oclif manifest |
| 120 | +4. Add tests in `src/test/commands/` |
| 121 | + |
| 122 | +### Modifying build tasks |
| 123 | + |
| 124 | +Task definitions are in the repository root (`../fluidBuild.config.cjs`) and can be augmented per-package in `package.json` under `fluidBuild.tasks`. |
| 125 | + |
| 126 | +### Policy checks |
| 127 | + |
| 128 | +```bash |
| 129 | +# Check repo policy |
| 130 | +pnpm policy-check |
| 131 | + |
| 132 | +# Fix auto-fixable policy issues |
| 133 | +pnpm policy-check:fix |
| 134 | +``` |
| 135 | + |
| 136 | +## File Structure |
| 137 | + |
| 138 | +``` |
| 139 | +build-tools/ |
| 140 | +├── packages/ |
| 141 | +│ ├── build-cli/ # flub CLI (ESM) |
| 142 | +│ ├── build-infrastructure/ # Workspace abstractions (dual ESM/CJS) |
| 143 | +│ ├── build-tools/ # fluid-build CLI (CommonJS) |
| 144 | +│ ├── bundle-size-tools/ # Bundle analysis (CommonJS) |
| 145 | +│ └── version-tools/ # fluv CLI (CommonJS) |
| 146 | +├── biome.jsonc # Formatter config |
| 147 | +├── syncpack.config.cjs # Dep version rules |
| 148 | +├── DEV.md # Dependency upgrade blockers |
| 149 | +└── pnpm-workspace.yaml # Workspace definition |
| 150 | +``` |
| 151 | + |
| 152 | +## Troubleshooting |
| 153 | + |
| 154 | +- **"Cannot find module" errors**: Run `pnpm install` then `pnpm build` |
| 155 | +- **Type errors after dependency changes**: Run `pnpm clean && pnpm build` |
| 156 | +- **Lockfile conflicts**: Use `pnpm install --no-frozen-lockfile` only for local testing |
| 157 | +- **ESM import errors**: Check DEV.md - many packages are pinned to CommonJS-compatible versions |
| 158 | + |
| 159 | +Trust these instructions. Only search the codebase if information here is incomplete or found to be incorrect. |
0 commit comments