Summary
Since v2.14.0, dist/plugin.js line 1 imports package.json without an ESM import attribute:
import pkg from "../package.json";
Bun's strict-ESM mode (used by opencode's embedded Bun runtime in recent versions, e.g. opencode 1.15.x) — and Node.js ≥22 — both require an import attribute for JSON modules. Without it the module fails to load and opencode logs:
ERROR service=plugin path=opencode-mem
target=file:///…/opencode-mem@latest/node_modules/opencode-mem/dist/plugin.js
error=Module "file:///…/opencode-mem/package.json" needs an import attribute of "type: json"
failed to load plugin
The plugin never initializes. No memory tool, no web server, no auto-capture.
Affected versions
Verified by extracting each dist/plugin.js from npm:
| Version |
First line of dist/plugin.js |
Loads? |
| 2.13.0 |
const { OpenCodeMemPlugin } = await import("./index.js"); |
✅ |
| 2.14.0 |
import pkg from "../package.json"; |
❌ |
| 2.14.1 |
import pkg from "../package.json"; |
❌ |
| 2.14.2 (latest) |
import pkg from "../package.json"; |
❌ |
The regression was introduced when export const id was added (probably as part of opencode plugin metadata work in 2.14.0).
Environment
- macOS 26.3 (Apple Silicon, arm64)
- opencode
1.15.3 (Homebrew, anomalyco/opencode)
- opencode-mem
2.14.2 installed via opencode's plugin cache at ~/.cache/opencode/packages/opencode-mem@latest/
- Reproduction is platform-independent — same error on Linux and Windows with a strict-ESM runtime
Reproduction
- Configure opencode with
"plugin": ["opencode-mem"] (no version pin, picks up @latest).
- Wipe the cache:
rm -rf ~/.cache/opencode/packages/opencode-mem@latest.
- Start opencode (TUI or GUI). Cache repopulates with v2.14.2.
- Observe the error in
~/.local/share/opencode/log/<latest>.log.
Fix
One-line change in the TypeScript source (presumably src/plugin.ts):
- import pkg from "../package.json";
+ import pkg from "../package.json" with { type: "json" };
This is the standard ESM JSON import attribute syntax (TC39 proposal, shipped in Node 22 and Bun ≥1.2). Older runtimes that don't yet support with are not relevant here because opencode itself targets recent Bun.
Alternative if broader compatibility matters: read the file at runtime instead:
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
const pkg = JSON.parse(
readFileSync(new URL("../package.json", import.meta.url), "utf8")
);
This avoids the import-attribute question entirely and works in all ESM runtimes.
Why this isn't already in the tracker
I suspect most users hit it after the recent opencode update to 1.15 (which bundles a newer Bun with stricter ESM enforcement), and either rolled back to 2.13.0 or disabled the plugin without filing. Stuck on this with a fresh cache today.
Workaround for users until fixed
Pin to 2.13.0 in opencode.jsonc:
(Note: 2.13.0 has the unrelated sharp native-binary issue — see #88 / #94 / #97 — but the plugin at least loads, and the sharp path is only hit at embedding time. For users who don't trigger the embedding code path, 2.13.0 + the manual npm install onnxruntime-node@1.14.0 sharp@^0.32.0 --no-save in the cache directory is a working stopgap.)
Notes / related
Summary
Since v2.14.0,
dist/plugin.jsline 1 importspackage.jsonwithout an ESM import attribute:Bun's strict-ESM mode (used by opencode's embedded Bun runtime in recent versions, e.g. opencode 1.15.x) — and Node.js ≥22 — both require an
import attributefor JSON modules. Without it the module fails to load and opencode logs:The plugin never initializes. No
memorytool, no web server, no auto-capture.Affected versions
Verified by extracting each
dist/plugin.jsfrom npm:dist/plugin.jsconst { OpenCodeMemPlugin } = await import("./index.js");import pkg from "../package.json";import pkg from "../package.json";import pkg from "../package.json";The regression was introduced when
export const idwas added (probably as part of opencode plugin metadata work in 2.14.0).Environment
1.15.3(Homebrew,anomalyco/opencode)2.14.2installed via opencode's plugin cache at~/.cache/opencode/packages/opencode-mem@latest/Reproduction
"plugin": ["opencode-mem"](no version pin, picks up@latest).rm -rf ~/.cache/opencode/packages/opencode-mem@latest.~/.local/share/opencode/log/<latest>.log.Fix
One-line change in the TypeScript source (presumably
src/plugin.ts):This is the standard ESM JSON import attribute syntax (TC39 proposal, shipped in Node 22 and Bun ≥1.2). Older runtimes that don't yet support
withare not relevant here because opencode itself targets recent Bun.Alternative if broader compatibility matters: read the file at runtime instead:
This avoids the import-attribute question entirely and works in all ESM runtimes.
Why this isn't already in the tracker
I suspect most users hit it after the recent opencode update to 1.15 (which bundles a newer Bun with stricter ESM enforcement), and either rolled back to 2.13.0 or disabled the plugin without filing. Stuck on this with a fresh cache today.
Workaround for users until fixed
Pin to 2.13.0 in
opencode.jsonc:(Note: 2.13.0 has the unrelated
sharpnative-binary issue — see #88 / #94 / #97 — but the plugin at least loads, and thesharppath is only hit at embedding time. For users who don't trigger the embedding code path, 2.13.0 + the manualnpm install onnxruntime-node@1.14.0 sharp@^0.32.0 --no-savein the cache directory is a working stopgap.)Notes / related
--ignore-scriptsplugin-install behavior was filed separately at joshuadavidthomas/opencode-agent-memory#15 (same class of issue, different plugin).embedding.jsis the relevant mitigation for the sharp issue — but the plugin still can't load due to this JSON-import regression.