Summary
opencode-gemini-auth@1.4.12 (and earlier) ships only TypeScript source (index.ts, src/*.ts) and points main and module at ./index.ts. Under Bun this transpiled on the fly, but since OpenCode 1.14.x switched its plugin host to strict Node ESM (anomalyco/opencode#18308, merged 2026-04-01), the loader cannot resolve index.ts and falls back to a directory import — which Node ESM rejects.
Issue #70 attempted to fix this by adding "main": "./index.ts" in 1.4.10, but pointing main at a .ts file does not solve the underlying problem: OpenCode's loader is now Node-based and does not transpile TypeScript. The plugin needs a compiled dist/index.js (or equivalent exports map pointing at compiled JS) to load.
Error in OpenCode log
ERROR 2026-05-05T08:35:36 service=plugin path=opencode-gemini-auth@1.4.9
target=/Users/.../.cache/opencode/packages/opencode-gemini-auth@1.4.9/node_modules/opencode-gemini-auth
error=Directory import '/Users/.../.cache/opencode/packages/opencode-gemini-auth@1.4.9/node_modules/opencode-gemini-auth'
is not supported resolving ES modules imported from
/Applications/OpenCode.app/Contents/Resources/app.asar/out/main/chunks/node-8ljIuRcm.js
failed to load plugin
(Identical failure on 1.4.10, 1.4.11, 1.4.12 — all ship the same source-only layout.)
Reproduction
npm pack opencode-gemini-auth@1.4.12
tar -xzf opencode-gemini-auth-1.4.12.tgz
ls package/
# LICENSE README.md index.ts package.json src
# (no dist/, no compiled JS)
cat package/package.json | grep -E '"main"|"module"|"type"'
# "main": "./index.ts",
# "module": "index.ts",
# "type": "module",
node -e "import('./package/index.ts').then(()=>console.log('ok')).catch(e=>console.error(e.message))"
# Unknown file extension ".ts" for /.../package/index.ts
When OpenCode's loader (Node 24 / Electron 41) is given a target directory node_modules/opencode-gemini-auth, the only entry it can see is index.ts. Node ESM doesn't load .ts, so it tries to import the directory itself as a module — and fails with "Directory import ... is not supported".
Why this is now broken
Suggested fix
- Add a build step that emits
dist/index.js (e.g. tsup, tsc, or bun build --target=node).
- Update
package.json:
- Add a
prepublishOnly smoke test that does node -e "import(require.resolve('opencode-gemini-auth'))" to catch regressions.
For prior art, see the tsup setup in @tarquinen/opencode-dcp PR #499: Opencode-DCP/opencode-dynamic-context-pruning#499
Environment
- OpenCode: 1.14.37 (Electron 41 / Node 24, macOS arm64)
- Plugin:
opencode-gemini-auth@1.4.9 (also reproduced against 1.4.10, 1.4.11, 1.4.12)
- macOS 26.4.1 arm64
- Plugin declared in a project-level
opencode.json "plugin" array; fails on every workspace bootstrap.
References
Summary
opencode-gemini-auth@1.4.12(and earlier) ships only TypeScript source (index.ts,src/*.ts) and pointsmainandmoduleat./index.ts. Under Bun this transpiled on the fly, but since OpenCode 1.14.x switched its plugin host to strict Node ESM (anomalyco/opencode#18308, merged 2026-04-01), the loader cannot resolveindex.tsand falls back to a directory import — which Node ESM rejects.Issue #70 attempted to fix this by adding
"main": "./index.ts"in1.4.10, but pointingmainat a.tsfile does not solve the underlying problem: OpenCode's loader is now Node-based and does not transpile TypeScript. The plugin needs a compileddist/index.js(or equivalentexportsmap pointing at compiled JS) to load.Error in OpenCode log
(Identical failure on
1.4.10,1.4.11,1.4.12— all ship the same source-only layout.)Reproduction
When OpenCode's loader (Node 24 / Electron 41) is given a target directory
node_modules/opencode-gemini-auth, the only entry it can see isindex.ts. Node ESM doesn't load.ts, so it tries to import the directory itself as a module — and fails with "Directory import ... is not supported".Why this is now broken
@npmcli/arborist+ Nodeimport()(refactor: replace BunProc with Npm module using @npmcli/arborist anomalyco/opencode#18308). The Node loader will not transpile.ts, and treats directory imports as errors per ESM spec.Suggested fix
dist/index.js(e.g.tsup,tsc, orbun build --target=node).package.json:{ "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "import": "./dist/index.js", "types": "./dist/index.d.ts" }, "./server": { "import": "./dist/index.js", "types": "./dist/index.d.ts" } }, "files": ["dist", "README.md", "LICENSE"] }prepublishOnlysmoke test that doesnode -e "import(require.resolve('opencode-gemini-auth'))"to catch regressions.For prior art, see the
tsupsetup in@tarquinen/opencode-dcpPR #499: Opencode-DCP/opencode-dynamic-context-pruning#499Environment
opencode-gemini-auth@1.4.9(also reproduced against1.4.10,1.4.11,1.4.12)opencode.json"plugin"array; fails on every workspace bootstrap.References
main: ./index.tsin1.4.10did not address the Node-ESM-can't-load-TS root cause.