[FEATURE](JS-SDK): Add require exports to support commonjs #2937

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

Originally created by @wan-kong on GitHub (Nov 18, 2025).

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Electron ES Module import transform to require case sdk error.

I’m trying to use the @opencode-ai/sdk inside an Electron application.

But Electron (specifically its build pipeline) transforms this:

import { createOpencode } from '@opencode-ai/sdk'

into:

const sdk = require("@opencode-ai/sdk");

However, the SDK does not provide a CommonJS export, so Electron throws:

Image

✔️ How to fix?

Here is the line in the source:
https://github.com/sst/opencode/blob/ce6436280af6aa1bb5aef6c711a185956cdc56bd/packages/sdk/js/script/publish.ts#L16-L18

add a CommonJS export

Originally created by @wan-kong on GitHub (Nov 18, 2025). ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request Electron ES Module `import` transform to `require` case sdk error. I’m trying to use the `@opencode-ai/sdk` inside an Electron application. But Electron (specifically its build pipeline) transforms this: `import { createOpencode } from '@opencode-ai/sdk'` into: `const sdk = require("@opencode-ai/sdk");` However, the SDK does not provide a CommonJS export, so Electron throws: <img width="622" height="184" alt="Image" src="https://github.com/user-attachments/assets/bf4c65c4-465e-49dc-b900-91db6d35edaa" /> ✔️ How to fix? Here is the line in the source: https://github.com/sst/opencode/blob/ce6436280af6aa1bb5aef6c711a185956cdc56bd/packages/sdk/js/script/publish.ts#L16-L18 add a CommonJS export
yindo added the discussion label 2026-02-16 17:37:53 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2937