diff --git a/packages/opencode/script/build.ts b/packages/opencode/script/build.ts index c22ed93451..86172e640b 100755 --- a/packages/opencode/script/build.ts +++ b/packages/opencode/script/build.ts @@ -287,26 +287,10 @@ for (const item of targets) { const bunfsRoot = item.os === "win32" ? "B:/~BUN/root/" : "/$bunfs/root/" const workerRelativePath = path.relative(dir, parserWorker).replaceAll("\\", "/") - // kilocode_change start - redirect @morphllm/morphsdk to its self-contained CJS bundle. - // Prefer the CJS build (client.cjs) over the pre-split ESM barrel (client.js + 52 chunk-*.js) - // so the bundler pulls in one self-contained module instead of dozens of side-import chunks. - // require.resolve uses the package's "require" condition, which maps the warp-grep/client - // subpath straight to client.cjs. The deep dist path is not an exported subpath, so resolving - // it directly throws "Cannot find module" — go through the public specifier instead. - const morphsdkCjs = require.resolve("@morphllm/morphsdk/tools/warp-grep/client") - const morphsdkCjsPlugin: import("bun").BunPlugin = { - name: "morphsdk-cjs", - setup(build) { - build.onResolve({ filter: /^@morphllm\/morphsdk\/tools\/warp-grep\/client$/ }, () => ({ - path: morphsdkCjs, - })) - }, - } - // kilocode_change end await Bun.build({ conditions: ["browser"], tsconfig: "./tsconfig.json", - plugins: [plugin, morphsdkCjsPlugin], // kilocode_change + plugins: [plugin], // kilocode_change start - skip sourcemaps for release builds (each .js.map adds ~50 MB per target → ~600 MB total) sourcemap: Script.release ? "none" : "external", // kilocode_change end diff --git a/packages/opencode/src/kilocode/compat/morphsdk.ts b/packages/opencode/src/kilocode/compat/morphsdk.ts deleted file mode 100644 index e8fd2501c5..0000000000 --- a/packages/opencode/src/kilocode/compat/morphsdk.ts +++ /dev/null @@ -1,14 +0,0 @@ -// kilocode_change - new file -// Re-exports from @morphllm/morphsdk/tools/warp-grep/client. -// -// @morphllm/morphsdk ships a pre-split ESM distribution for this path (client.js, an 805-byte -// barrel that re-imports from ~52 chunk-*.js files). To keep the bundle simple, script/build.ts -// adds a morphsdkCjsPlugin (onResolve) that redirects this specifier to client.cjs — a fully -// self-contained CJS bundle with no chunk-*.js side-imports. -// -// NOTE: this redirect is not what fixes the release build. The startup crash -// SyntaxError: Exported binding 'G9' needs to refer to a top-level declared variable -// is a Bun 1.3.14 code-splitting bug (oven-sh/bun#25621); the fix is splitting:false in -// script/build.ts, not this re-export. - -export { WarpGrepClient } from "@morphllm/morphsdk/tools/warp-grep/client" diff --git a/packages/opencode/src/tool/warpgrep.ts b/packages/opencode/src/tool/warpgrep.ts index 5ee3a3ff32..16ffb47415 100644 --- a/packages/opencode/src/tool/warpgrep.ts +++ b/packages/opencode/src/tool/warpgrep.ts @@ -1,6 +1,6 @@ import { Effect, Schema } from "effect" import * as Tool from "./tool" -import { WarpGrepClient } from "@/kilocode/compat/morphsdk" // kilocode_change +import { WarpGrepClient } from "@morphllm/morphsdk/tools/warp-grep/client" // kilocode_change import { Telemetry } from "@kilocode/kilo-telemetry" // kilocode_change import { Instance } from "../project/instance" import { Bus } from "../bus"