Skip to content

Plugin fails to load in opencode 1.3.17 on Windows (ESM/CJS interop issues) #10

@Strelitzia-reginae

Description

@Strelitzia-reginae

Summary

@morphllm/opencode-morph-plugin@2.0.9 fails to load in opencode 1.3.17.

This does not look like a single missing export. It appears to be a runtime compatibility problem between the plugin / @morphllm/morphsdk and opencode's plugin loader, likely around ESM/CJS interop.

Environment

  • OS: Windows 11
  • opencode: 1.3.17
  • plugin: @morphllm/opencode-morph-plugin@2.0.9
  • install path: loaded as an opencode plugin from .config/opencode/opencode.json

Reproduction

  1. Add the plugin to opencode.json:
{
  "plugin": [
    "@morphllm/opencode-morph-plugin"
  ],
  "instructions": [
    "node_modules/@morphllm/opencode-morph-plugin/instructions/morph-tools.md"
  ]
}
  1. Run:
opencode debug config --print-logs --log-level DEBUG
  1. opencode fails while loading the plugin.

Errors observed

I consistently reproduced these loader errors while debugging:

Export named 'rgPath' not found in module '...@vscode\\ripgrep\\lib\\index.js'
Export named 'getVercelOidcToken' not found in module '...@vercel\\oidc\\dist\\index.js'

I also tried locally patching the plugin to route around the ESM entrypoint and use the CJS build of morphsdk, but opencode's loader then surfaced this:

require() async module '...@morphllm\\morphsdk\\dist\\index.cjs' is unsupported. use "await import()" instead.

When forcing await import() against index.cjs, opencode's runtime appeared to return an empty namespace object for that module, which then led to:

undefined is not a constructor (evaluating 'new MorphClient(...)')

Notes

  • The same plugin/module shape was testable separately under plain bun, so this seems specific to opencode's plugin runtime/loader behavior.
  • Because of the chained failures, this may need a compatibility pass in the plugin build output rather than a one-line fix.

If useful, I can provide the full opencode debug config --print-logs --log-level DEBUG output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions