Skip to content

Commit 7b80726

Browse files
committed
fix: externalize ws and Node.js builtins from plugin bundle
The bundled ws library uses Node.js http/https/net modules which are incompatible with Bun's runtime. When ws is bundled, it uses __require polyfill instead of Bun's native ws polyfill, causing WebSocket upgrade errors (Unexpected server response: 101). By marking ws and Node.js builtins as external in tsup, they will be resolved at runtime by Bun's compatibility layer. @slack/* packages remain bundled to avoid the CJS/ESM interop issue. Signed-off-by: xuezhaojun <xuezhaokeepgoing@gmail.com>
1 parent ce4cc26 commit 7b80726

3 files changed

Lines changed: 37 additions & 8 deletions

File tree

opencode-slack-plugin/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

opencode-slack-plugin/package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kubeopencode/opencode-slack-plugin",
3-
"version": "0.1.6",
3+
"version": "0.1.7",
44
"type": "module",
55
"license": "MIT",
66
"description": "OpenCode plugin that connects to Slack via Socket Mode — zero port exposure, runs inside your OpenCode process",
@@ -30,15 +30,16 @@
3030
"dist"
3131
],
3232
"scripts": {
33-
"build": "tsup src/index.ts --format esm --dts --clean",
33+
"build": "tsup",
3434
"typecheck": "tsc --noEmit",
35-
"dev": "tsup src/index.ts --format esm --dts --watch"
35+
"dev": "tsup --watch"
36+
},
37+
"dependencies": {
38+
"@slack/socket-mode": "^2.0.5",
39+
"@slack/web-api": "^7.13.0"
3640
},
37-
"dependencies": {},
3841
"devDependencies": {
3942
"@opencode-ai/plugin": "^1.2.15",
40-
"@slack/socket-mode": "^2.0.5",
41-
"@slack/web-api": "^7.13.0",
4243
"@types/node": "^22.0.0",
4344
"tsup": "^8.5.0",
4445
"typescript": "^5.9.0"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { defineConfig } from "tsup"
2+
3+
export default defineConfig({
4+
entry: ["src/index.ts"],
5+
format: ["esm"],
6+
dts: true,
7+
clean: true,
8+
noExternal: [
9+
"@slack/web-api",
10+
"@slack/socket-mode",
11+
"@slack/types",
12+
"@slack/logger",
13+
],
14+
external: [
15+
"ws",
16+
"http",
17+
"https",
18+
"net",
19+
"tls",
20+
"crypto",
21+
"stream",
22+
"events",
23+
"url",
24+
"zlib",
25+
"bufferutil",
26+
"utf-8-validate",
27+
],
28+
})

0 commit comments

Comments
 (0)