Skip to content

fix(build): break long lines in node bundle for Windows esbuild - #2247

Open
rekty wants to merge 1 commit into
XiaomiMiMo:mainfrom
rekty:fix/win32-desktop-build-esbuild
Open

fix(build): break long lines in node bundle for Windows esbuild#2247
rekty wants to merge 1 commit into
XiaomiMiMo:mainfrom
rekty:fix/win32-desktop-build-esbuild

Conversation

@rekty

@rekty rekty commented Aug 25, 2026

Copy link
Copy Markdown

Summary

Fixes the Windows desktop build failure where esbuild crashes with Unterminated string literal because Bun.build produces a single ~4.3 MB line in the server bundle (dist/node/node.js).

Problem

packages/opencode/script/build-node.ts uses Bun.build to produce the opencode server module. Bun compresses the output into one enormous line (~4.3 MB). When electron-vite bundles this into the desktop main process, its esbuild transpiler hits this line and crashes — but only on Windows (macOS/Linux esbuild handles it fine).

Fix

Post-process every output file after Bun.build: if a file has no newlines (single-line minified bundle), insert a \n every 100 000 characters. esbuild treats newlines as whitespace, so this is semantics-preserving and unblocks the Windows desktop build without changing any runtime behavior.

Changed: 1 file, +21/−1 (packages/opencode/script/build-node.ts)

Testing

  • Verified the output bytes contain proper escaped \n in string literals (not actual newlines)
  • No runtime behavior change — newline insertion is a whitespace-only transformation

Closes #2184

CC @MiMoHardFather @wqymi @yanyihan-xiaomi — please approve CI runs for first-time contributor.

…tibility

Bun.build produces a single-line bundle (~4.3 MB per line) for the
opencode server module.  esbuild on Windows crashes with 'Unterminated
string literal' when it encounters lines this long during the desktop
electron-vite build.

Post-process the bundle output to insert newlines every 100 000
characters.  esbuild treats newlines as whitespace so this is
semantics-preserving and unblocks the Windows desktop build.

Closes XiaomiMiMo#2184
@rekty

rekty commented Aug 25, 2026

Copy link
Copy Markdown
Author

Hi @MiMoHardFather @wqymi @yanyihan-xiaomi! This PR fixes the Windows desktop build crash (esbuild 'Unterminated string literal' on 4.3MB single-line bundle). Could you please approve the CI workflow runs for this first-time contributor? Thank you! 🙏

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.

Windows build fails: esbuild crashes on 4.3MB line ('Unterminated string literal') — blocks desktop build/package for Windows-only users

1 participant