fix(cli): disable Bun code-splitting to fix baseline release crash - #10958
Merged
Conversation
The real cause of the 'Exported binding G9 needs to refer to a top-level declared variable' SyntaxError is a Bun 1.3.14 --splitting codegen bug (oven-sh/bun#25621), not @morphllm/morphsdk. With splitting:true Bun emits invalid cross-chunk re-exports (import{vn as G9}) that crash the compiled baseline binary at startup. Disabling splitting produces a valid binary; verified the 'as G9' artifact is gone from the compiled output.
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.
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (3 files)
lgtm — the root cause analysis is sound, the fix is minimal and correct. Reviewed by claude-4.6-sonnet-20260217 · 294,858 tokens Review guidance: REVIEW.md from base branch |
lambertjosh
approved these changes
Jun 5, 2026
t7tran
pushed a commit
to t7tran/kilocode
that referenced
this pull request
Aug 14, 2026
…plitting fix(cli): disable Bun code-splitting to fix baseline release crash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Follow-up to #10955, #10956, #10957. Despite the morphsdk CJS redirect, the
build-clijob still fails — now at thecli-linux-x64-baselinesmoke test:See https://github.com/Kilo-Org/kilocode/actions/runs/27035450876/job/79798417163.
Root cause — it was never morphsdk
The previous fixes targeted
@morphllm/morphsdkon the theory that its pre-split ESM barrel was feeding bad chunks to Bun's splitter. Inspecting the compiled binary disproves that:client.cjscontent is embedded, no morphsdkchunk-*.jsimports remain.SyntaxErroris a runtime crash at binary startup, not a build-time error.import{vn as G9}from"/$bunfs/root/chunk-*.js"— a cross-chunk re-export Bun itself generates undersplitting: true, where the exported binding isn't top-level.This is a known Bun 1.3.14 code-splitting bug (oven-sh/bun#25621, #5344, #7265; also hit by opencode#23349), fixed upstream in Bun#26089 (post-1.3.14). It only crashes on the baseline target, whose stricter runtime rejects the invalid binding.
Fix
Set
splitting: falseinscript/build.ts. Splitting only deduplicated shared code between the 5 entrypoints (index + 4 workers); disabling it inlines per entrypoint and produces a valid binary. The morphsdk redirect is kept (harmless, simplifies the bundle) but its comments are corrected to note it is not the actual fix.Verification
Built locally from
packages/opencode/with the realscript/build.tsand inspected the compiled binary:splittingas G9in binarytrue(before)false(after)bun run typecheckpasses.bun run script/check-opencode-annotations.tspasses.The local smoke test exits 139 on my Nix host — a pre-existing environment segfault in Bun's compiled-binary bootstrap (crashes right after
execve, before any JS), unrelated to this change and not present on CI's Ubuntu runners.No changeset — CI-only build fix.