opencode
opencode copied to clipboard
fix(plugin): add .js extensions to ESM imports
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:
-
package.jsonexports pointed to./src/index.tsbut onlydist/is published to npm - Compiled
dist/index.jshadexport * from "./tool"without.jsextension, which does not resolve in Node.js ESM
Solution
- Updated
package.jsonexports to point todist/*.jsfiles with proper ESM conditional exports - Added
.jsextensions 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