Skip to content

Commit 37a86e8

Browse files
committed
fix: bundle plugin to JS for server mode compatibility
Bun's on-the-fly TypeScript transpilation fails to extract named exports from CJS modules (like @opentelemetry/*) when loaded via `await import()` in opencode's compiled binary. This causes plugins to fail in server/CLI mode while working fine in TUI mode. Fix by pre-bundling all dependencies into a single JavaScript file using `bun build`, which resolves imports at build time and avoids CJS/ESM interop issues at runtime. - Add `build` script: `bun build src/index.ts --outdir=./dist --target=node` - Update exports/main/module to point to `dist/index.js` - Add `prepublishOnly` to ensure build runs before npm publish - Add `./server` export for explicit server mode entry point Fixes #35
1 parent f79aa8e commit 37a86e8

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@
2929
"eslint-plugin-jsdoc": "^50.6.11"
3030
},
3131
"exports": {
32-
".": "./src/index.ts"
32+
".": "./dist/index.js",
33+
"./server": "./dist/index.js"
3334
},
3435
"files": [
35-
"src/"
36+
"dist/"
3637
],
3738
"homepage": "https://github.com/DEVtheOPS/opencode-plugin-otel#readme",
3839
"keywords": [
@@ -44,8 +45,8 @@
4445
"observability"
4546
],
4647
"license": "MPL-2.0",
47-
"main": "src/index.ts",
48-
"module": "src/index.ts",
48+
"main": "dist/index.js",
49+
"module": "dist/index.js",
4950
"name": "@devtheops/opencode-plugin-otel",
5051
"oc-plugin": [
5152
"server"
@@ -58,9 +59,11 @@
5859
"url": "https://github.com/DEVtheOPS/opencode-plugin-otel.git"
5960
},
6061
"scripts": {
62+
"build": "bun build src/index.ts --outdir=./dist --target=node",
6163
"check:jsdoc-coverage": "bun scripts/check-jsdoc-coverage.mjs",
6264
"lint": "bun --bun eslint .",
63-
"typecheck": "tsc --noEmit"
65+
"typecheck": "tsc --noEmit",
66+
"prepublishOnly": "bun run build"
6467
},
6568
"type": "module",
6669
"version": "0.8.0"

0 commit comments

Comments
 (0)