Skip to content

Commit de3e1ad

Browse files
Fix Vercel deploy error - mark @libsql/client as external
- @libsql/client has platform-specific native binaries (@libsql/linux-x64-gnu) - Cannot be bundled - must be kept external and copied from pnpm virtual store - Update build-vercel.sh to copy @libsql scope from node_modules/.pnpm/node_modules - Update vercel.json includeFiles to include @libsql scope - Also fix @ai-sdk copy to use pnpm virtual store path Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/05489ac4-2d01-43c2-b9b3-e50ff9b92b03 Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
1 parent 78b7039 commit de3e1ad

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

apps/studio/scripts/build-vercel.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ node scripts/bundle-api.mjs
3939
# apps/studio/, so we must copy the actual module files here for Vercel to
4040
# include them in the serverless function's deployment package.
4141
#
42-
# Note: @libsql/client is now bundled by esbuild, so we no longer copy it.
4342
echo "[build-vercel] Copying external native modules to local node_modules..."
4443
for mod in better-sqlite3; do
4544
src="../../node_modules/$mod"
@@ -52,11 +51,26 @@ for mod in better-sqlite3; do
5251
echo "[build-vercel] ⚠ $mod not found at $src (skipped)"
5352
fi
5453
done
54+
# Copy the @libsql scope (includes @libsql/client and platform-specific binaries)
55+
# In pnpm monorepos, @libsql packages exist in the virtual store at node_modules/.pnpm/node_modules/@libsql
56+
if [ -d "../../node_modules/.pnpm/node_modules/@libsql" ]; then
57+
mkdir -p "node_modules/@libsql"
58+
for pkg in ../../node_modules/.pnpm/node_modules/@libsql/*/; do
59+
pkgname="$(basename "$pkg")"
60+
# Use cp -rL to dereference symlinks and copy actual files
61+
cp -rL "$pkg" "node_modules/@libsql/$pkgname"
62+
done
63+
echo "[build-vercel] ✓ Copied @libsql/*"
64+
else
65+
echo "[build-vercel] ⚠ @libsql not found (skipped)"
66+
fi
5567
# Copy the @ai-sdk scope (dynamically loaded provider packages)
56-
if [ -d "../../node_modules/@ai-sdk" ]; then
68+
# In pnpm monorepos, @ai-sdk packages exist in the virtual store at node_modules/.pnpm/node_modules/@ai-sdk
69+
if [ -d "../../node_modules/.pnpm/node_modules/@ai-sdk" ]; then
5770
mkdir -p "node_modules/@ai-sdk"
58-
for pkg in ../../node_modules/@ai-sdk/*/; do
71+
for pkg in ../../node_modules/.pnpm/node_modules/@ai-sdk/*/; do
5972
pkgname="$(basename "$pkg")"
73+
# Use cp -rL to dereference symlinks and copy actual files
6074
cp -rL "$pkg" "node_modules/@ai-sdk/$pkgname"
6175
done
6276
echo "[build-vercel] ✓ Copied @ai-sdk/*"

apps/studio/scripts/bundle-api.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import { build } from 'esbuild';
1616

1717
// Packages that cannot be bundled (native bindings / optional drivers)
1818
const EXTERNAL = [
19-
// @libsql/client is now bundled (pure JS, no native bindings)
20-
// Bundling it solves Vercel deployment issues where external packages
21-
// aren't properly included in the serverless function despite includeFiles config
19+
// @libsql/client has platform-specific native bindings (@libsql/linux-x64-gnu, etc.)
20+
// and must be kept external, then copied to node_modules and included via vercel.json
21+
'@libsql/client',
2222
'better-sqlite3',
2323
// AI SDK provider packages — dynamically imported based on env vars
2424
'@ai-sdk/anthropic',

apps/studio/vercel.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"api/**/*.js": {
1414
"memory": 1024,
1515
"maxDuration": 300,
16-
"includeFiles": "node_modules/{better-sqlite3,@ai-sdk}/**"
16+
"includeFiles": "node_modules/{better-sqlite3,@libsql,@ai-sdk}/**"
1717
}
1818
},
1919
"headers": [

0 commit comments

Comments
 (0)