294d41bd3b
Bun 1.3.14 stopped exposing `--compile` extras through every filesystem-style API: `fs.existsSync`, `Bun.file().exists()`, `Bun.resolveSync`, and `await import()` on `/$bunfs/...` or `file:///$bunfs/...` all fail; only `/$bunfs/root/<binary-name>` itself answers. The pre-existing legacy-pi rewrite emitted `file:///$bunfs/...` URLs that Bun then could not load, so every legacy extension that imported `@oh-my-pi/pi-*` or `@sinclair/typebox` failed on the `omp-darwin-arm64` release binary. `legacy-pi-compat.ts` now keeps a JS-heap reference to every bundled pi-* surface in a lazy-loaded sibling `legacy-pi-bundled-registry.ts` and serves them through an `omp-legacy-pi-bundled:` virtual namespace whose `Bun.plugin().onLoad` synthesizes a re-export module — no bunfs path ever leaves the module in compiled mode. Dev / source-link / installed-package modes keep the historical `file://` rewrite (source files exist on disk). The matching `--compile` extras in `scripts/build-binary.ts` are gone; `BUNFS_PACKAGE_ROOT`, `bunfsPath`, `__computeBunfsPackageRoot`, and `__joinBunfsPath` are deleted as dead code. `scripts/smoke-3423.ts` compiles a tiny binary that loads a fixture extension end-to-end through the new path. Fixes #3423
37 lines
2.0 KiB
TypeScript
37 lines
2.0 KiB
TypeScript
import { describe, expect, it } from "bun:test";
|
|
import * as path from "node:path";
|
|
import { __computeBundledSelfPackageRoot } from "@oh-my-pi/pi-coding-agent/extensibility/plugins/legacy-pi-compat";
|
|
|
|
// Issue #3423 removed the runtime bunfs-path computation (`__computeBunfsPackageRoot`,
|
|
// `__joinBunfsPath`, `bunfsPath`): Bun 1.3.14 stopped exposing `--compile`
|
|
// extras through any filesystem API, so the compat layer now routes the
|
|
// bundled host packages and shims through the `omp-legacy-pi-bundled:`
|
|
// virtual namespace (see `legacy-pi-bundled-virtual.test.ts`). The bunfs
|
|
// path computation is dead and its regression tests (issues #1514, #3329)
|
|
// retired alongside the code.
|
|
//
|
|
// The npm-prebuilt `dist/cli.js` self-package-root computation is still in
|
|
// use by `sourceShimPath` in installed-package mode, so its contract stays
|
|
// pinned below.
|
|
describe("legacy pi compat bundled-self package root computation", () => {
|
|
it("derives the npm prebuilt bundle package root from dist import.meta.dir", () => {
|
|
const winMetaDir = "C:\\Users\\me\\.bun\\install\\global\\node_modules\\@oh-my-pi\\pi-coding-agent\\dist";
|
|
expect(__computeBundledSelfPackageRoot(winMetaDir, path.win32)).toBe(
|
|
"C:\\Users\\me\\.bun\\install\\global\\node_modules\\@oh-my-pi\\pi-coding-agent",
|
|
);
|
|
|
|
const posixMetaDir = "/home/me/.bun/install/global/node_modules/@oh-my-pi/pi-coding-agent/dist";
|
|
expect(__computeBundledSelfPackageRoot(posixMetaDir, path.posix)).toBe(
|
|
"/home/me/.bun/install/global/node_modules/@oh-my-pi/pi-coding-agent",
|
|
);
|
|
});
|
|
|
|
it("derives the source package root when PI_BUNDLED is used outside dist", () => {
|
|
const winMetaDir = "C:\\repo\\packages\\coding-agent\\src\\extensibility\\plugins";
|
|
expect(__computeBundledSelfPackageRoot(winMetaDir, path.win32)).toBe("C:\\repo\\packages\\coding-agent");
|
|
|
|
const posixMetaDir = "/repo/packages/coding-agent/src/extensibility/plugins";
|
|
expect(__computeBundledSelfPackageRoot(posixMetaDir, path.posix)).toBe("/repo/packages/coding-agent");
|
|
});
|
|
});
|