From 84f1ef1359b79b100cbc03de81bb3b690d6624df Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Thu, 16 Apr 2026 13:32:34 -0700 Subject: [PATCH] fix(browse): externalize @ngrok/ngrok so Node server bundle builds on Windows @ngrok/ngrok has a native .node addon that causes `bun build --outfile` to fail with "cannot write multiple output files without an output directory". Externalize it alongside the existing runtime deps (playwright, diff, bun:sqlite), matching the exact pattern used for every other dynamic import in server.ts. Adds a policy comment explaining when to extend the externals list so the next native dep doesn't repeat this failure. Two community contributors independently converged on this fix: - @tomasmontbrun-hash (#1019) - @scarson (#1013) Also fixes issues #1010 and #960. Co-Authored-By: Claude Opus 4.7 (1M context) --- browse/scripts/build-node-server.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/browse/scripts/build-node-server.sh b/browse/scripts/build-node-server.sh index 539e391c..3ab652ac 100755 --- a/browse/scripts/build-node-server.sh +++ b/browse/scripts/build-node-server.sh @@ -14,13 +14,19 @@ DIST_DIR="$GSTACK_DIR/browse/dist" echo "Building Node-compatible server bundle..." # Step 1: Transpile server.ts to a single .mjs bundle (externalize runtime deps) +# +# Externalize packages with native addons, dynamic imports, or runtime resolution. +# If you add a new dependency that uses `await import()` or has a .node addon, +# add it here. Otherwise `bun build --outfile` will fail with +# "cannot write multiple output files without an output directory". bun build "$SRC_DIR/server.ts" \ --target=node \ --outfile "$DIST_DIR/server-node.mjs" \ --external playwright \ --external playwright-core \ --external diff \ - --external "bun:sqlite" + --external "bun:sqlite" \ + --external "@ngrok/ngrok" # Step 2: Post-process # Replace import.meta.dir with a resolvable reference