Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/studio/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Vercel deployment configuration
# Use hoisted node-linker to avoid symlinks that break Vercel serverless functions
node-linker=hoisted
2 changes: 2 additions & 0 deletions apps/studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@ai-sdk/openai": "^3.0.52",
"@ai-sdk/react": "^3.0.160",
"@hono/node-server": "^1.19.14",
"@libsql/client": "^0.17.2",
"@objectstack/client": "workspace:*",
"@objectstack/client-react": "workspace:*",
"@objectstack/driver-memory": "workspace:*",
Expand Down Expand Up @@ -57,6 +58,7 @@
"@radix-ui/react-toast": "^1.2.15",
"@radix-ui/react-tooltip": "^1.2.8",
"ai": "^6.0.158",
"better-sqlite3": "^12.9.0",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"hono": "^4.12.12",
Expand Down
40 changes: 7 additions & 33 deletions apps/studio/scripts/build-vercel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,15 @@ cd apps/studio
# 2. Bundle API serverless function
node scripts/bundle-api.mjs

# 3. Copy native/external modules into local node_modules for Vercel packaging.
# 3. External dependencies are now handled by adding them as direct dependencies
# in apps/studio/package.json. Vercel installs them automatically during deployment.
#
# Unlike hotcrm (which uses shamefully-hoist=true), this monorepo uses pnpm's
# default strict node_modules structure. Transitive native dependencies like
# better-sqlite3 only exist in the monorepo root's node_modules/.pnpm/ virtual
# store — they're NOT symlinked into apps/studio/node_modules/.
# Packages marked as external in bundle-api.mjs (@libsql/client, better-sqlite3,
# @ai-sdk/*) are listed as direct dependencies in package.json, so Vercel includes
# them in the serverless function's deployment package via normal pnpm install.
#
# The vercel.json includeFiles pattern references node_modules/ relative to
# apps/studio/, so we must copy the actual module files here for Vercel to
# include them in the serverless function's deployment package.
#
# Note: @libsql/client is now bundled by esbuild, so we no longer copy it.
echo "[build-vercel] Copying external native modules to local node_modules..."
for mod in better-sqlite3; do
src="../../node_modules/$mod"
if [ -e "$src" ]; then
dest="node_modules/$mod"
mkdir -p "$(dirname "$dest")"
cp -rL "$src" "$dest"
echo "[build-vercel] ✓ Copied $mod"
else
echo "[build-vercel] ⚠ $mod not found at $src (skipped)"
fi
done
# Copy the @ai-sdk scope (dynamically loaded provider packages)
if [ -d "../../node_modules/@ai-sdk" ]; then
mkdir -p "node_modules/@ai-sdk"
for pkg in ../../node_modules/@ai-sdk/*/; do
pkgname="$(basename "$pkg")"
cp -rL "$pkg" "node_modules/@ai-sdk/$pkgname"
done
echo "[build-vercel] ✓ Copied @ai-sdk/*"
else
echo "[build-vercel] ⚠ @ai-sdk not found (skipped)"
fi
# This avoids the cp -rL infinite recursion issue that occurs when copying packages
# that are already direct dependencies with circular symlinks.

# 4. Copy Vite build output to public/ for static file serving
rm -rf public
Expand Down
6 changes: 3 additions & 3 deletions apps/studio/scripts/bundle-api.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import { build } from 'esbuild';

// Packages that cannot be bundled (native bindings / optional drivers)
const EXTERNAL = [
// @libsql/client is now bundled (pure JS, no native bindings)
// Bundling it solves Vercel deployment issues where external packages
// aren't properly included in the serverless function despite includeFiles config
// @libsql/client has platform-specific native bindings (@libsql/linux-x64-gnu, etc.)
// and must be kept external, then copied to node_modules and included via vercel.json
'@libsql/client',
'better-sqlite3',
// AI SDK provider packages — dynamically imported based on env vars
'@ai-sdk/anthropic',
Expand Down
2 changes: 1 addition & 1 deletion apps/studio/vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"api/**/*.js": {
"memory": 1024,
"maxDuration": 300,
"includeFiles": "node_modules/{better-sqlite3,@ai-sdk}/**"
"includeFiles": "node_modules/{better-sqlite3,@libsql,@ai-sdk}/**"
}
},
"headers": [
Expand Down
18 changes: 12 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading