Skip to content

fix(build): disable custom codeSplitting that crashed the release bundle (black screen) - #613

Merged
su-fen merged 1 commit into
Stack-Cairn:mainfrom
YUZHEthefool:fix/release-blackscreen-codesplitting
Aug 25, 2026
Merged

fix(build): disable custom codeSplitting that crashed the release bundle (black screen)#613
su-fen merged 1 commit into
Stack-Cairn:mainfrom
YUZHEthefool:fix/release-blackscreen-codesplitting

Conversation

@YUZHEthefool

@YUZHEthefool YUZHEthefool commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

The release (tauri build) bundle crashed on launch with a black screen and AppErrorBoundary showing require_cjs$N is not a function, while tauri dev worked fine. This fixes it by disabling the custom codeSplitting config that split a CommonJS interop chain across chunks.

Closes #612.

Root cause

crates/agent-gui/vite.config.ts recently added build.rolldownOptions.output.codeSplitting with a liveagent-app group. That custom chunking split the style-to-js → style-to-object → inline-style-parser CommonJS chain across chunks. rolldown wraps CJS modules in __commonJSMin thunks, and across a chunk boundary those thunks weren't initialized before the call site ran — so require_cjs$N was undefined at render time → require_cjs$N is not a function.

tauri dev does no chunk splitting, so the chain stays in one module and works — which is why this slipped past tsc, tests, and dev.

In the broken bundle:

// chunk A (style-to-object)
import { r as require_cjs$2 } from "./...-DLqXB6yr.js";  // from chunk B
...
var inline_style_parser_1 = __importDefault(require_cjs$2());  // 💥 not a function

Fix

Set codeSplitting: false to fall back to rolldown's default automatic chunking, which keeps that CJS chain in one chunk. chunkSizeWarningLimit is kept so the known-large Monaco workers don't spam the console.

rolldownOptions: {
  output: {
    codeSplitting: false,
  },
},

Verification

Built the release exe (pnpm tauri build --no-bundle) and confirmed:

  • In the bundle: style-to-js / style-to-object / inline-style-parser now land in the same chunk; the cross-chunk as require_cjs$N named import is gone.
  • The release exe (target/release/liveagent.exe) launches and renders correctly — no black screen, no AppErrorBoundary.

Test plan

  • pnpm tauri build --no-bundle → run target/release/liveagent.exe → app renders (was: black screen).
  • pnpm tauri dev still works (unaffected — dev never split chunks).
  • No new chunk-size regressions beyond the existing Monaco-worker warning (covered by chunkSizeWarningLimit).

Notes

  • This is a build-config regression, not a code-logic change, so no runtime tests cover it; the verification above is the bundle-inspection + run-the-exe check.
  • An alternative finer-grained fix (a high-priority group forcing the CJS chain into one chunk via test: /[\/]\.pnpm[\/](?:style-to-js|style-to-object|inline-style-parser)@/) was attempted first but didn't reliably capture inline-style-parser; default chunking is more robust.

A recent build config added `rolldownOptions.output.codeSplitting` with a
`liveagent-app` group. That custom chunking split the
`style-to-js → style-to-object → inline-style-parser` CommonJS interop
chain across chunks. rolldown's `__commonJSMin` thunks then failed to
initialize across the chunk boundary, so the release bundle crashed at
render time with `require_cjs$N is not a function` — a black screen with
an AppErrorBoundary, while `tauri dev` (no chunk splitting) worked fine.

Set `codeSplitting: false` to fall back to rolldown's default automatic
chunking, which keeps that CJS chain in one chunk. Verified the release
exe launches and renders correctly after the change.
@su-fen

su-fen commented Aug 25, 2026

Copy link
Copy Markdown
Member

谢谢宝宝~

@su-fen
su-fen merged commit 313dd97 into Stack-Cairn:main Aug 25, 2026
10 of 12 checks passed
su-fen added a commit to AlphaCatMeow/LiveAgent that referenced this pull request Aug 25, 2026
su-fen added a commit to AlphaCatMeow/LiveAgent that referenced this pull request Aug 25, 2026
跨大版本 override(1.1.21→2.0.2,消费方 hast-util-to-jsx-runtime 声明 ^1.0.0)
的触发条件是旧 vite 配置的激进代码分割;合并 Stack-Cairn#613 后产物不再分包,
override 失去存在理由,保留只剩兼容性风险。SkillCategoryControls 的
惰性求值修复无害,保留。

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Release build 黑屏 / "require_cjs is not a function" — codeSplitting 拆散 style-to-js CJS 链

2 participants