Skip to content

Commit ebfcab3

Browse files
committed
fix: defeat Bun static analysis of transformers import in Desktop
OpenCode Desktop sidecar failed to load plugin with: ENOENT: no such file or directory, open '.../@huggingface/transformers/utils/devices.js' The literal 'import("@huggingface/transformers")' was being statically resolved by Bun at plugin load time, which then followed JSDoc-referenced paths in transformers' webpack-bundled dist and tried to open files that only exist as JSDoc @type annotations. Fix: use a runtime-computed template literal specifier so Bun cannot statically analyze the import target. The dynamic import still works normally at runtime, but the load-time static walk no longer fires. Verified e2e: cached tarball install of 0.8.5 with the fix loads in Desktop sidecar and embedding model loads successfully. Closes #4
1 parent 107c32e commit ebfcab3

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/plugin/src/features/magic-context/memory/embedding-local.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,13 @@ export class LocalEmbeddingProvider implements EmbeddingProvider {
125125

126126
this.initPromise = (async () => {
127127
try {
128-
const transformersModule = (await import("@huggingface/transformers")) as Record<
128+
// Non-literal import specifier prevents Bun from eagerly resolving
129+
// @huggingface/transformers at plugin load time. Desktop sidecar spawns
130+
// hit ENOENT on JSDoc-referenced files inside transformers' webpack dist
131+
// when the literal string triggers Bun's static module analysis.
132+
// See: https://github.com/cortexkit/opencode-magic-context/issues/4
133+
const transformersSpec = `@huggingface/${"transformers"}`;
134+
const transformersModule = (await import(transformersSpec)) as Record<
129135
string,
130136
unknown
131137
>;

0 commit comments

Comments
 (0)