|
10 | 10 |
|
11 | 11 | Migrating CORTEX from Node.js + npm to Bun is **low-risk, fully compatible, and meaningfully faster for CI**. Every CI step—install, lint, typecheck, and unit tests—ran correctly under Bun with zero code changes required. The largest single win is the package install step: `bun install` with a warm global cache resolves in **~13 ms** versus npm ci's constant **~7–8 s** regardless of cache. Across all CI steps the end-to-end savings in a cold run sit around 25%; on a warm-cache hit the install alone cuts from 8 s to 0.013 s—a roughly **600×** improvement. |
12 | 12 |
|
13 | | -The migration surface is narrow: two CI workflow lines, two lines in `docs/development.md`, and one `trustedDependencies` field already added to `package.json`. No TypeScript source files need to change. |
| 13 | +The migration surface remains low-risk: CI/workflow setup now uses Bun latest, package scripts invoke Bun directly, and script launchers/shebangs use Bun entrypoints. No TypeScript feature modules required changes. |
14 | 14 |
|
15 | 15 | --- |
16 | 16 |
|
@@ -88,21 +88,21 @@ By default Bun sandboxes lifecycle scripts for security. Two transitive dependen |
88 | 88 | ] |
89 | 89 | ``` |
90 | 90 |
|
91 | | -#### 2. Script shebangs use `#!/usr/bin/env node` |
| 91 | +#### 2. Script shebangs now use `#!/usr/bin/env bun` |
92 | 92 |
|
93 | | -All scripts in `scripts/` declare `#!/usr/bin/env node`. Since Bun exposes a `node` compatibility shim in its `PATH`, these run correctly today. Updating shebangs to `#!/usr/bin/env bun` is optional and can be done incrementally. |
| 93 | +Script entrypoints in `scripts/` were updated to Bun shebangs so direct execution no longer relies on the Node compatibility shim. |
94 | 94 |
|
95 | | -#### 3. Scripts spawn `node` explicitly for subprocesses |
| 95 | +#### 3. Scripts spawn Bun explicitly for subprocesses |
96 | 96 |
|
97 | | -`scripts/run-electron-runtime-smoke.mjs` spawns `node scripts/runtime-harness-server.mjs` as a child process. Under a Bun CI environment `node` is still available (Bun installs its own `node` wrapper), so this works without changes. |
| 97 | +`scripts/run-electron-runtime-smoke.mjs` now spawns `bun scripts/runtime-harness-server.mjs` for child-process consistency. |
98 | 98 |
|
99 | 99 | #### 4. `dev:harness` and `sync:github-project` scripts |
100 | 100 |
|
101 | | -These use `node scripts/...` in the `package.json` `scripts` block. They work with `bun run` today (Bun delegates to the `node` wrapper). Optionally they can be updated to `bun scripts/...` for consistency. |
| 101 | +These now use `bun scripts/...` in the `package.json` `scripts` block. |
102 | 102 |
|
103 | 103 | #### 5. Electron optional dependency version duplication |
104 | 104 |
|
105 | | -`package.json` lists `electron` in both `devDependencies` (^41.0.0) and `optionalDependencies` (^37.2.0). Bun resolves the higher range (^41). npm behaves the same. This pre-existing duplication is unrelated to the migration. |
| 105 | +`package.json` lists `electron` in both `devDependencies` and `optionalDependencies` (both set to `latest`). This duplication remains intentional for current install behavior. |
106 | 106 |
|
107 | 107 | #### 6. `lockfileVersion: 1` in `bun.lock` |
108 | 108 |
|
@@ -142,7 +142,7 @@ Replace Node.js setup + npm with the official Bun GitHub Action. |
142 | 142 | - name: Setup Bun |
143 | 143 | uses: oven-sh/setup-bun@v2 |
144 | 144 | with: |
145 | | - bun-version: "1.3.10" |
| 145 | + bun-version: "latest" |
146 | 146 |
|
147 | 147 | - name: Install dependencies |
148 | 148 | run: bun install --frozen-lockfile |
@@ -175,27 +175,25 @@ Prerequisites updated to list Bun 1.2+ as the supported package manager and show |
175 | 175 |
|
176 | 176 | | Task | Effort | Notes | |
177 | 177 | |---|---|---| |
178 | | -| Replace `node scripts/...` with `bun scripts/...` in `package.json` scripts | Trivial | Works with both today | |
179 | | -| Update `#!/usr/bin/env node` shebangs to `#!/usr/bin/env bun` | Low | Speeds up script cold start slightly | |
180 | 178 | | Remove `package-lock.json` once team fully migrated | Trivial | One `git rm` | |
181 | | -| Pin a specific Bun version in CI instead of `latest` | Done | Already set to `1.3.10`; bump deliberately when upgrading | |
| 179 | +| Keep Bun on `latest` in CI | Done | Current policy tracks newest Bun releases | |
182 | 180 |
|
183 | 181 | --- |
184 | 182 |
|
185 | 183 | ## Risk Assessment |
186 | 184 |
|
187 | 185 | | Risk | Likelihood | Impact | Mitigation | |
188 | 186 | |---|---|---|---| |
189 | | -| Bun release breaks a CI step | Low | Medium | Pin Bun version in CI | |
| 187 | +| Bun release breaks a CI step | Low | Medium | Temporarily pin Bun to a known-good version in CI | |
190 | 188 | | Postinstall sandbox blocks new dep | Low | Low | Add to `trustedDependencies` | |
191 | | -| Electron spawn via `node` wrapper fails | Very Low | Medium | Use explicit `bun` binary path if needed | |
| 189 | +| Bun subprocess path mismatch | Very Low | Medium | Use absolute Bun binary path if needed | |
192 | 190 | | Vitest incompatibility with future Bun version | Very Low | High | Vitest runs on the underlying Bun JavaScriptCore; keep Vitest version pinned | |
193 | 191 |
|
194 | 192 | --- |
195 | 193 |
|
196 | 194 | ## Conclusion |
197 | 195 |
|
198 | | -The CORTEX toolchain is already Bun-compatible with only the config changes included in this PR. No TypeScript source, no tests, no shaders, and no runtime code needed modification. The migration delivers: |
| 196 | +The CORTEX toolchain is Bun-first and uses Bun latest across CI and scripts. No TypeScript source, no tests, and no shaders needed modification; only tooling/config/script invocation surfaces were updated. The migration delivers: |
199 | 197 |
|
200 | 198 | - **~25 % faster** end-to-end cold CI runs |
201 | 199 | - **~75–90 % faster** installs on cached runs (the step that previously dominated CI time) |
|
0 commit comments