npm package ships TypeScript source instead of compiled JavaScript — plugin fails to load
Bug Report
Package: [email protected] (npm)
Affected: All OpenCode installations loading this plugin via npm
Severity: High — plugin completely non-functional
Problem
The published npm package contains only TypeScript source files (.ts), but OpenCode's ESM plugin loader resolves imports with .js extensions. This causes the plugin to fail on load with ENOENT.
Reproduction
# Install plugin
cd ~/.opencode && npm install [email protected]
# Enable in config
echo '{"plugin": ["opencode-qwencode-auth"]}' > ~/.config/opencode/opencode.json
# Try to use
opencode auth login
Expected: Qwen Code appears in provider list Actual: Plugin fails silently; qwen-code does not appear
Error
ERROR service=plugin path=opencode-qwencode-auth
error=ENOENT: no such file or directory, open '.../src/constants.js'
failed to load plugin
Root Cause
package.jsonhas"module": "index.ts"- Published package has
src/constants.ts(not.js) - ESM loader expects
.js, throwsENOENT
Verified Fix
I compiled the plugin locally and confirmed it works end-to-end:
git clone https://github.com/gustavodiasdev/opencode-qwencode-auth.git
cd opencode-qwencode-auth
bun install && bun run build
# Built dist/index.js and dist/cli.js
After manually copying compiled files and updating package.json:
- ✓
opencode auth loginshows "Qwen Code" - ✓ OAuth flow completes successfully
- ✓
qwen3-coder-plus,qwen3-coder-flash, etc. models available
Proposed Fix
Update package.json:
{
"module": "dist/index.js",
"scripts": {
"build": "bun build ./src/index.ts --outdir ./dist --target node --format esm && bun build ./src/cli.ts --outdir ./dist --target node --format esm",
"prepublishOnly": "bun run build"
},
"files": [
"dist",
"README.md"
]
}
Changes:
modulepoints to compiled JS indist/prepublishOnlyensuresdist/is built before everynpm publishfilesships compiled output instead of raw TypeScript
Checklist for Author
- [ ] Apply the
package.jsonchanges above - [ ] Run
bun run build - [ ] Run
npm packand verify tarball containsdist/index.jsanddist/cli.js - [ ] Publish new version
Related
- #14 — "Stopped working with latest version" (possibly same root cause — plugin load failure may hang desktop app)
Environment
- OpenCode CLI: v1.14.29
- Node.js: v20+
- OS: Linux (tested)
Willing to Contribute
I submitted PR #XX with this exact fix. The change is minimal (~5 lines) and I've already verified it works end-to-end.