fix(build): break long lines in node bundle for Windows esbuild - #2247
Open
rekty wants to merge 1 commit into
Open
fix(build): break long lines in node bundle for Windows esbuild#2247rekty wants to merge 1 commit into
rekty wants to merge 1 commit into
Conversation
…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
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! 🙏 |
2 tasks
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.
Summary
Fixes the Windows desktop build failure where esbuild crashes with
Unterminated string literalbecauseBun.buildproduces a single ~4.3 MB line in the server bundle (dist/node/node.js).Problem
packages/opencode/script/build-node.tsusesBun.buildto produce the opencode server module. Bun compresses the output into one enormous line (~4.3 MB). Whenelectron-vitebundles 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\nevery 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
\nin string literals (not actual newlines)Closes #2184
CC @MiMoHardFather @wqymi @yanyihan-xiaomi — please approve CI runs for first-time contributor.