mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-28 19:11:03 +08:00
refactor(cli): drop morphsdk compat layer and CJS build plugin
The compat re-export and the build's CJS-redirect plugin only existed to work around the 'G9' crash that's actually a Bun --splitting bug (now fixed by splitting:false). With splitting off the morphsdk ESM barrel bundles cleanly, so import it directly in warpgrep.ts and remove the indirection.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user