fix(browse): externalize @ngrok/ngrok in Node server bundle#978
Open
muddy-clay wants to merge 1 commit intogarrytan:mainfrom
Open
fix(browse): externalize @ngrok/ngrok in Node server bundle#978muddy-clay wants to merge 1 commit intogarrytan:mainfrom
muddy-clay wants to merge 1 commit intogarrytan:mainfrom
Conversation
bun 1.3.12+ inlines @ngrok/ngrok's native .node binary as a second
bundle asset, which causes `bun build --outfile` to fail with:
error: cannot write multiple output files without an output directory
This breaks `./setup` on Windows for every user on bun >= 1.3.12,
leaving browse/dist/server-node.mjs unbuilt.
@ngrok/ngrok ships a native binary per platform and is loaded from
node_modules at runtime by its package index, so there is no benefit
to bundling it — it must be externalized for the same reason as
playwright and playwright-core.
Tested locally: re-running ./setup on Windows with bun 1.3.12 now
produces server-node.mjs (317KB) cleanly.
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
./setupfails on Windows with bun ≥ 1.3.12 at the Node server bundle stepcannot write multiple output files without an output directory--external "@ngrok/ngrok"alongside the existing externalsRoot cause
bun 1.3.12 inlines
@ngrok/ngrok's native.nodebinary as a second bundle asset when buildingbrowse/src/server.ts.bun build --outfileonly allows a single output file, so the build aborts:Switching to
--outdirreveals what the second output is:@ngrok/ngrokships a platform-specific native binary and loads it fromnode_modulesat runtime via its package index — bundling buys nothing and forces the multi-output failure. It needs the same--externaltreatment asplaywrightandplaywright-core.The existing build previously worked on earlier bun versions because they didn't treat
.nodeassets as bundle outputs the same way. bun 1.3.12 (the current version bun.sh's installer hands out as of this PR) triggers it consistently.Blast radius
This is the one-line diff:
--external "bun:sqlite" \ + --external "@ngrok/ngrok"No behavior change —
@ngrok/ngrokis stillrequire'd from node_modules at runtime exactly as before. The compiledbrowse.exe/find-browse.exearen't affected (those usebun build --compile, not this script).Test plan
./setupon Windows 10 with bun 1.3.12:Node server bundle ready: .../server-node.mjs(317KB)browse/dist/server-node.mjs,bun-polyfill.cjs, andngrok.*.nodeall present inbrowse/dist/after buildRepro before this PR: install bun 1.3.10 via
bun.sh/install(installer actually hands out 1.3.12 despiteBUN_VERSION=1.3.10env var), then run./setupon Windows. Setup reportsgstack readybut the Node bundle step silently errors mid-run.