opencode icon indicating copy to clipboard operation
opencode copied to clipboard

fix(plugin): add .js extensions to ESM imports

Open derekross opened this issue 3 days ago • 1 comments

Summary

Fixes the @opencode-ai/plugin package so it works when installed from npm.

Problem

The plugin package fails to load with error:

Cannot find module './tool' imported from .../node_modules/@opencode-ai/plugin/dist/index.js

Root causes:

  1. package.json exports pointed to ./src/index.ts but only dist/ is published to npm
  2. Compiled dist/index.js had export * from "./tool" without .js extension, which does not resolve in Node.js ESM

Solution

  1. Updated package.json exports to point to dist/*.js files with proper ESM conditional exports
  2. Added .js extensions to all relative imports in source files

Testing

Tested with opencode-shakespeare-plugin which was unable to load until this fix was applied.

Fixes #8006

derekross avatar Jan 12 '26 13:01 derekross