fix(build): escape literal braces in bun:sqlite stub regex

The Node server bundle post-processing in build-node-server.sh uses a
Perl substitution with an unescaped literal `{` in the pattern
`import { Database } from "bun:sqlite";`. Perl treats an unescaped `{`
that is not part of a valid quantifier as an error ("Unescaped left
brace in regex is illegal here in regex"), hard-failing the build with
exit code 255 and breaking `./setup`.

Reproduced on Windows Git Bash (msys Perl 5.26.2); also affects modern
Perl 5.32+ on Linux. Escaping the braces (`\{ \}`) matches them
literally and is backward compatible; verified the substitution still
produces the expected `const Database = null` stub and `node --check`
passes on the resulting server-node.mjs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
shlim 2026-06-26 01:27:54 +09:00
parent 9fd03fae9e
commit ee24bfc32d
1 changed files with 1 additions and 1 deletions

View File

@ -32,7 +32,7 @@ bun build "$SRC_DIR/server.ts" \
# Replace import.meta.dir with a resolvable reference
perl -pi -e 's/import\.meta\.dir/__browseNodeSrcDir/g' "$DIST_DIR/server-node.mjs"
# Stub out bun:sqlite (macOS-only cookie import, not needed on Windows)
perl -pi -e 's|import { Database } from "bun:sqlite";|const Database = null; // bun:sqlite stubbed on Node|g' "$DIST_DIR/server-node.mjs"
perl -pi -e 's|import \{ Database \} from "bun:sqlite";|const Database = null; // bun:sqlite stubbed on Node|g' "$DIST_DIR/server-node.mjs"
# Step 3: Create the final file with polyfill header injected after the first line
{