Elffuss BraidHub

kikocis/continue public

main · 2.4 KiBRenderedRawPermalink
1# Build Process Documentation
2
3## Overview
4
5The Continue CLI uses esbuild to bundle the application along with local packages (`@continuedev/config-yaml` and `@continuedev/openai-adapters`) into a single distributable file. This ensures that users who install the CLI from npm don't need to worry about local file references.
6
7## Build Steps
8
91. **Install dependencies**: `npm install`
102. **Build**: `npm run build`
11 - This first builds the local packages
12 - Then bundles everything with esbuild
13
14## How it Works
15
16### Bundling Strategy
17
18The `build.mjs` script uses esbuild to:
19
20- Bundle all TypeScript/JavaScript code into a single ES module
21- Include local packages (`@continuedev/config-yaml`, `@continuedev/openai-adapters`) directly in the bundle
22- Keep problematic or native dependencies external (e.g., `@sentry/profiling-node`, `winston`, `express`)
23- Create a wrapper script (`dist/cn.js`) with the proper shebang for CLI execution
24
25### Key Features
26
27- **Local Package Bundling**: Local packages are bundled directly, avoiding `file:` reference issues
28- **Stub for Optional Dependencies**: `react-devtools-core` is stubbed to prevent runtime errors
29- **CommonJS Compatibility**: Adds `createRequire` to support packages that use dynamic requires
30- **Source Maps**: Generates source maps for debugging
31- **Metadata**: Creates `dist/meta.json` with bundle analysis information
32
33## Testing
34
35### Smoke Tests
36
37Run smoke tests to verify the build:
38
39```bash
40npm run test:smoke
41```
42
43The smoke tests verify:
44
45- Bundle files exist
46- CLI commands work (--version, --help)
47- Bundle size is reasonable (<20MB)
48- Local packages are properly bundled
49- No missing runtime dependencies
50
51## Troubleshooting
52
53### Common Issues
54
551. **Module not found errors**: Check if the module needs to be added to the external list in `build.mjs`
562. **Native module issues**: Native modules should be marked as external
573. **Bundle too large**: Review bundled packages in `dist/meta.json` and consider marking large packages as external
58
59### Analyzing the Bundle
60
61After building, check `dist/meta.json` to see:
62
63- What packages were bundled
64- Bundle size breakdown
65- Input/output file mappings
66
67## Publishing
68
69When publishing to npm:
70
711. The bundled files in `dist/` are included
722. Users install via `npm install -g @continuedev/cli`
733. The `cn` command becomes available globally
744. No local file references or missing dependencies