@@ -28,7 +28,41 @@ cd apps/studio
2828# 2. Bundle API serverless function
2929node scripts/bundle-api.mjs
3030
31- # 3. Copy Vite build output to public/ for static file serving
31+ # 3. Copy native/external modules into local node_modules for Vercel packaging.
32+ #
33+ # Unlike hotcrm (which uses shamefully-hoist=true), this monorepo uses pnpm's
34+ # default strict node_modules structure. Transitive native dependencies like
35+ # better-sqlite3 only exist in the monorepo root's node_modules/.pnpm/ virtual
36+ # store — they're NOT symlinked into apps/studio/node_modules/.
37+ #
38+ # The vercel.json includeFiles pattern references node_modules/ relative to
39+ # apps/studio/, so we must copy the actual module files here for Vercel to
40+ # include them in the serverless function's deployment package.
41+ echo " [build-vercel] Copying external native modules to local node_modules..."
42+ for mod in better-sqlite3; do
43+ src=" ../../node_modules/$mod "
44+ if [ -e " $src " ]; then
45+ dest=" node_modules/$mod "
46+ mkdir -p " $( dirname " $dest " ) "
47+ cp -rL " $src " " $dest "
48+ echo " [build-vercel] ✓ Copied $mod "
49+ else
50+ echo " [build-vercel] ⚠ $mod not found at $src (skipped)"
51+ fi
52+ done
53+ # Copy the @libsql scope (client + its sub-dependencies like core, hrana-client)
54+ if [ -d " ../../node_modules/@libsql" ]; then
55+ mkdir -p " node_modules/@libsql"
56+ for pkg in ../../node_modules/@libsql/* /; do
57+ pkgname=" $( basename " $pkg " ) "
58+ cp -rL " $pkg " " node_modules/@libsql/$pkgname "
59+ done
60+ echo " [build-vercel] ✓ Copied @libsql/*"
61+ else
62+ echo " [build-vercel] ⚠ @libsql not found (skipped)"
63+ fi
64+
65+ # 4. Copy Vite build output to public/ for static file serving
3266rm -rf public
3367mkdir -p public
3468cp -r dist/* public/
0 commit comments