Skip to content

Commit e5d5c8d

Browse files
Dereference pnpm symlinks for Vercel deployment
- Replace symlinked packages with real files in node_modules - Vercel doesn't support symlinked directories in serverless functions - Use readlink to get real path, then copy with cp -rL - Prevents "invalid deployment package" error from Vercel - Applies to better-sqlite3, @libsql/client, and @ai-sdk packages Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/131c9b60-a3c7-43b6-a080-0de180a91db0 Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
1 parent 466e085 commit e5d5c8d

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

apps/studio/scripts/build-vercel.sh

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,27 @@ cd apps/studio
2828
# 2. Bundle API serverless function
2929
node scripts/bundle-api.mjs
3030

31-
# 3. Copy @ai-sdk packages into local node_modules for Vercel packaging.
31+
# 3. Dereference symlinks in node_modules for Vercel packaging.
3232
#
33-
# The @ai-sdk packages are workspace dependencies that need to be copied from
34-
# the monorepo root. @libsql/client and better-sqlite3 are now direct dependencies
35-
# in apps/studio/package.json, so pnpm installs them automatically.
33+
# pnpm creates symlinks in node_modules/ by default. Vercel's serverless function
34+
# packaging doesn't support symlinked directories, so we need to replace symlinks
35+
# with actual file copies.
3636
#
3737
# The vercel.json includeFiles pattern references node_modules/ relative to
38-
# apps/studio/, so we must copy @ai-sdk packages here for Vercel to include
39-
# them in the serverless function's deployment package.
40-
echo "[build-vercel] Copying external modules to local node_modules..."
38+
# apps/studio/, so we must ensure these directories contain real files, not symlinks.
39+
echo "[build-vercel] Dereferencing symlinks in node_modules..."
40+
for mod in better-sqlite3 @libsql/client; do
41+
if [ -L "node_modules/$mod" ] || [ -d "node_modules/$mod" ]; then
42+
# Get the real path that the symlink points to
43+
real_path=$(readlink -f "node_modules/$mod" 2>/dev/null || echo "")
44+
if [ -n "$real_path" ] && [ -d "$real_path" ]; then
45+
echo "[build-vercel] Dereferencing $mod..."
46+
rm -rf "node_modules/$mod"
47+
cp -rL "$real_path" "node_modules/$mod"
48+
echo "[build-vercel] ✓ Dereferenced $mod"
49+
fi
50+
fi
51+
done
4152
# Copy the @ai-sdk scope (dynamically loaded provider packages)
4253
if [ -d "../../node_modules/@ai-sdk" ]; then
4354
mkdir -p "node_modules/@ai-sdk"

0 commit comments

Comments
 (0)