fix(build): bun-on-Windows compatibility for the package.json build script#1480
Open
mikepsinn wants to merge 1 commit into
Open
fix(build): bun-on-Windows compatibility for the package.json build script#1480mikepsinn wants to merge 1 commit into
mikepsinn wants to merge 1 commit into
Conversation
Three changes to package.json 'build' script so bun run build completes on
Windows + Bun 1.3 (where bun's shell parser does not accept the POSIX
brace-group + redirect form, the (subshell) + redirect form, or a glob
that matches nothing even with || true):
1. Replace three '{ git rev-parse HEAD 2>/dev/null || true; } > FILE'
constructs with one 'node scripts/write-versions.mjs' invocation that
writes browse/dist/.version, design/dist/.version, and
make-pdf/dist/.version from a single try/catch around 'git rev-parse
HEAD'. Same semantics, parses on bun-on-Windows.
2. Remove the final '(rm -f .*.bun-build || true)' cleanup. Bun's shell
errors on the glob no-match BEFORE the '|| true' has a chance to
catch it, so the cleanup itself blocks the entire build. The build
tool already cleans temp files on success.
scripts/write-versions.mjs is intentionally Node-version-portable:
uses fileURLToPath(new URL('..', import.meta.url)) rather than
import.meta.dirname, so it works on Node versions before the dirname
property landed.
Verified: 'bun run build' now completes cleanly on Windows 11 + Bun
1.3.6 + Node 22, producing browse/dist/browse.exe, browse/dist/find-
browse.exe, design/dist/design.exe, make-pdf/dist/pdf.exe,
bin/gstack-global-discover.exe, browse/dist/server-node.mjs, and the
three .version files (all containing the current HEAD SHA).
No behavior change on macOS/Linux — the brace-grouped redirects were
just version-stamp writes, which the node helper now does
cross-platform.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Problem
bun run buildfails on Windows + Bun 1.3 because three things in the current build script don't parse in bun's POSIX shell on Windows:{ git rev-parse HEAD 2>/dev/null || true; } > browse/dist/.version(and two more fordesign/dist,make-pdf/dist). Bun on Windows treats{as a literal command and errors withbun: command not found: {.( ... ) > FILEas a fix — bun errors withSubshells with redirections are currently not supported.(rm -f .*.bun-build || true)fails BEFORE the|| truehas a chance to catch the no-match, because bun's glob rejection happens at parse time.Net effect:
./setupon Windows logs a real-looking build then dies witherror: script "build" exited with code 1, leaving.versionfiles unwritten.Fix
git rev-parse HEAD ... > .versionconstructs with a singlenode scripts/write-versions.mjsinvocation. Same semantics — write the current HEAD SHA intobrowse/dist/.version,design/dist/.version,make-pdf/dist/.version, with atry/catchfallback when not in a git repo. Cross-platform.(rm -f .*.bun-build || true)cleanup; bun on Windows can't parse it and the build tool already cleans its temp files on success.scripts/write-versions.mjsusesfileURLToPath(new URL('..', import.meta.url))(portable to older Node) rather thanimport.meta.dirname(newer-Node-only).Verified
bun run buildnow completes and producesbrowse.exe,find-browse.exe,design.exe,pdf.exe,gstack-global-discover.exe,server-node.mjs, and the three.versionfiles (containing the current HEAD SHA).Notes
scripts/build.shthat runs the brace-grouped writes viabashinstead of bun's shell). Tell me what you'd prefer and I'll re-shape.Need help on this PR? Tag
@codesmithwith what you need.