From 24168219fb8053adf19813501989ba3f21461971 Mon Sep 17 00:00:00 2001 From: iceteaSA <171169159+iceteaSA@users.noreply.github.com> Date: Sun, 17 May 2026 11:21:55 +0200 Subject: [PATCH] feat(opencode): bundle deps with bun build for zero-dependency runtime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Default build now uses bun to inline core + xxhash-wasm into dist/. No node_modules needed at runtime — the plugin works via file:// path. Keeps build:dev for tsc output during development. Output: 3 files totaling ~85KB (minified, code-split). --- packages/opencode/README.md | 19 +++++++++++++++++++ packages/opencode/package.json | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/opencode/README.md b/packages/opencode/README.md index 6630e7d..0d4646c 100644 --- a/packages/opencode/README.md +++ b/packages/opencode/README.md @@ -459,6 +459,25 @@ bun run lint bun run format:check ``` +### Build modes + +Two build modes are available: + +```bash +bun run build # Deploy: bun build → bundled dist/ with all deps inlined (core + xxhash-wasm) +bun run build:dev # Dev: tsc → individual dist/*.js files (requires workspace node_modules) +``` + +The default `build` uses `bun build` to bundle `@cortexkit/anthropic-auth-core` and all transitive dependencies into self-contained output files. No `node_modules/` needed at runtime — the plugin works via `file://` path in OpenCode config: + +```json +{ + "plugin": ["file:///path/to/anthropic-auth/packages/opencode"] +} +``` + +`@opencode-ai/plugin` remains external (peer dep provided by OpenCode). + Inspect package contents: ```bash diff --git a/packages/opencode/package.json b/packages/opencode/package.json index 7c40708..f81a940 100644 --- a/packages/opencode/package.json +++ b/packages/opencode/package.json @@ -27,7 +27,8 @@ "LICENSE" ], "scripts": { - "build": "rm -rf dist && tsc -p tsconfig.build.json", + "build": "rm -rf dist && bun build src/index.ts src/cli.ts --outdir dist --target node --format esm --splitting --external @opencode-ai/plugin --minify && tsc -p tsconfig.build.json --emitDeclarationOnly", + "build:dev": "rm -rf dist && tsc -p tsconfig.build.json", "dev": "bun ../../scripts/dev.ts", "dev:clean": "bun ../../scripts/dev-clean.ts", "extract": "bun ../../scripts/extract-system-prompt.ts",