[PR #8007] fix(plugin): add .js extensions to ESM imports #12589

Open
opened 2026-02-16 18:17:29 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/8007

State: open
Merged: No


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

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8007 **State:** open **Merged:** No --- ## 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](https://github.com/derekross/opencode-shakespeare-plugin) which was unable to load until this fix was applied. Fixes #8006
yindo added the pull-request label 2026-02-16 18:17:29 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12589