Repository navigation
Commit 85dd351
fix: resolve altimate-core platform packages via createRequire
M3 from PR #820 review. The old locatePlatformPackageDir walked the
filesystem hand-checking three different prefix shapes for bun's flat
`.bun/<scope>+<name>@<version>/node_modules/<scope>/<name>` layout and
interpolated `altimateCoreVersion` (read from packages/opencode/package.json
dependencies) into the path literally. Both fragile:
- pkg.dependencies values can carry semver prefixes (`^0.3.1`, `~0.3.1`,
`>=0.3.1`) — the literal interpolation would miss the on-disk dir,
which is keyed by the exact resolved version.
- bun could change its flat-layout dir name format at any time; we'd
silently start failing to find the prebuild.
Replace with `createRequire(path.join(loaderDir, "index.js"))` then
`req.resolve(`${pkgName}/package.json`)`. Node's resolver walks parent
node_modules from the require base, which (in this project's bun-hoisted
layout) finds the prebuild via the loader's `.bun/@AltimateAI+altimate-core@.../node_modules/@altimateai/altimate-core-<platform>`
sibling entries without us having to know what the surrounding store
looks like.
Verified all 5 platform packages resolve to the same `.bun` paths the
old function returned:
darwin-arm64 -> .../node_modules/.bun/@AltimateAI[email protected]/node_modules/@altimateai/altimate-core-darwin-arm64
darwin-x64 -> .../node_modules/.bun/@AltimateAI[email protected]/node_modules/@altimateai/altimate-core-darwin-x64
linux-arm64 -> .../node_modules/.bun/@AltimateAI[email protected]/node_modules/@altimateai/altimate-core-linux-arm64-gnu
linux-x64 -> .../node_modules/.bun/@AltimateAI[email protected]/node_modules/@altimateai/altimate-core-linux-x64-gnu
win32-x64 -> .../node_modules/.bun/@AltimateAI[email protected]/node_modules/@altimateai/altimate-core-win32-x64-msvc
Build still succeeds, binary still starts hermetically:
$ rm -rf packages/opencode/dist && \
bun run packages/opencode/script/build.ts --single --skip-install
building @altimateai/altimate-code-darwin-arm64
$ cd /tmp && env -u NODE_PATH .../bin/altimate --version
0.0.0-fix/curl-install-bundle-altimate-core-202605181341
$ bun test test/install/ test/branding/
401 pass / 0 fail
altimateCoreVersion is no longer used and is dropped.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>1 parent 2564abf commit 85dd351
1 file changed
Lines changed: 14 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
246 | 247 | | |
247 | 248 | | |
248 | 249 | | |
249 | | - | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
250 | 257 | | |
251 | 258 | | |
252 | 259 | | |
| |||
265 | 272 | | |
266 | 273 | | |
267 | 274 | | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
272 | 279 | | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
| 280 | + | |
| 281 | + | |
294 | 282 | | |
295 | 283 | | |
296 | 284 | | |
| |||
0 commit comments