We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Publishing Plugins

An OpenCode plugin published on npm uses the same default export as a local plugin. So if you want to publish a plugin, you can treat it as a normal ECMAScript module (ESM), with the plugin runtime listed in dependencies:

{
  "name": "my-slop-opencode-plugin",
  "version": "0.1.0",
  "type": "module",
  "exports": "./dist/index.js",
  "dependencies": {
    "@opencode/plugin": "2.0.3"
  }
}

The exports field identifies the file OpenCode loads. There are two options:

  • Compiled JavaScript: Use "exports": "./dist/index.js" as above, compile the plugin's TypeScript code, and include the generated files in the published package.
  • TypeScript source: Use "exports": "./src/index.ts" and include the source files in the published package. OpenCode can load TypeScript directly.