mirror of
https://github.com/garrytan/gstack.git
synced 2026-07-06 16:17:56 +02:00
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) <noreply@anthropic.com>
This commit is contained in:
@@ -14,13 +14,19 @@ DIST_DIR="$GSTACK_DIR/browse/dist"
|
|||||||
echo "Building Node-compatible server bundle..."
|
echo "Building Node-compatible server bundle..."
|
||||||
|
|
||||||
# Step 1: Transpile server.ts to a single .mjs bundle (externalize runtime deps)
|
# 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" \
|
bun build "$SRC_DIR/server.ts" \
|
||||||
--target=node \
|
--target=node \
|
||||||
--outfile "$DIST_DIR/server-node.mjs" \
|
--outfile "$DIST_DIR/server-node.mjs" \
|
||||||
--external playwright \
|
--external playwright \
|
||||||
--external playwright-core \
|
--external playwright-core \
|
||||||
--external diff \
|
--external diff \
|
||||||
--external "bun:sqlite"
|
--external "bun:sqlite" \
|
||||||
|
--external "@ngrok/ngrok"
|
||||||
|
|
||||||
# Step 2: Post-process
|
# Step 2: Post-process
|
||||||
# Replace import.meta.dir with a resolvable reference
|
# Replace import.meta.dir with a resolvable reference
|
||||||
|
|||||||
Reference in New Issue
Block a user