@@ -4,8 +4,9 @@ set -euo pipefail
44# Build script for Vercel deployment of @objectstack/studio.
55#
66# Follows the same Vercel deployment pattern as hotcrm:
7- # - api/[[...route]].ts is committed to the repo (Vercel detects it pre-build)
8- # - esbuild bundles server/index.ts → api/[[...route]].js (replaces TS at deploy)
7+ # - api/[[...route]].js is committed to the repo (Vercel detects it pre-build)
8+ # - esbuild bundles server/index.ts → api/_handler.js (self-contained bundle)
9+ # - The committed .js wrapper re-exports from _handler.js at runtime
910# - Vite SPA output is copied to public/ for CDN serving
1011#
1112# Vercel routing (framework: null, no outputDirectory):
@@ -14,7 +15,7 @@ set -euo pipefail
1415#
1516# Steps:
1617# 1. Turbo build (Vite SPA → dist/)
17- # 2. Bundle the API serverless function (→ api/[[...route]] .js)
18+ # 2. Bundle the API serverless function (→ api/_handler .js)
1819# 3. Copy Vite output to public/ for Vercel CDN serving
1920
2021echo " [build-vercel] Starting studio build..."
@@ -26,15 +27,10 @@ cd apps/studio
2627
2728# 2. Bundle API serverless function
2829node scripts/bundle-api.mjs
29- # Remove the TS source file so Vercel's @vercel/node builder uses the
30- # pre-bundled JS directly. Without this, Vercel compiles the TS stub
31- # itself, producing a thin re-export that references ../server/index —
32- # a file that doesn't exist at runtime (ERR_MODULE_NOT_FOUND).
33- rm -f " api/[[...route]].ts"
3430
3531# 3. Copy Vite build output to public/ for static file serving
3632rm -rf public
3733mkdir -p public
3834cp -r dist/* public/
3935
40- echo " [build-vercel] Done. Static files in public/, serverless function in api/[[...route]].js"
36+ echo " [build-vercel] Done. Static files in public/, serverless function in api/[[...route]].js → api/_handler.js "
0 commit comments