Skip to content

npm package ships TypeScript source instead of compiled JavaScript — plugin fails to load #15

@kostyun

Description

@kostyun

Bug Report

Package: opencode-qwencode-auth@1.3.0 (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 opencode-qwencode-auth@1.3.0

# 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.json has "module": "index.ts"
  • Published package has src/constants.ts (not .js)
  • ESM loader expects .js, throws ENOENT

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 login shows "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:

  1. module points to compiled JS in dist/
  2. prepublishOnly ensures dist/ is built before every npm publish
  3. files ships compiled output instead of raw TypeScript

Checklist for Author

  • Apply the package.json changes above
  • Run bun run build
  • Run npm pack and verify tarball contains dist/index.js and dist/cli.js
  • Publish new version

Related

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions