integrations/vercel #632
Replies: 2 comments
-
How do you deploy without having the entire code in one file?
I can't find any example for this that uses more than one file. |
Beta Was this translation helpful? Give feedback.
0 replies
-
For anyone have the turborepo vercel deploy issues Idea: Emit the Build Output API layout so Vercel unambiguously treats the output as a Serverless Function (not a static file). New folder structure
Build script (Bun → Node runtime, bundled ESM)Create import { $ } from "bun";
import { promises as fs } from "node:fs";
import path from "node:path";
const outDir = ".vercel/output";
const funcDir = path.join(outDir, "functions", "index.func");
const staticDir = path.join(outDir, "static");
const entryJs = path.join(funcDir, "index.js");
async function main() {
await fs.rm(outDir, { recursive: true, force: true });
await fs.mkdir(funcDir, { recursive: true });
await fs.mkdir(staticDir, { recursive: true });
// Bundle a single ESM file for Node runtime (not --target bun)
await $`bun build src/index.ts \
--target=node \
--format=esm \
--minify-syntax --minify-whitespace \
--outfile ${entryJs}`;
// Make Node treat index.js as ESM inside the function mount
await fs.writeFile(path.join(funcDir, "package.json"), JSON.stringify({ type: "module" }, null, 2));
// Function runtime config
await fs.writeFile(
path.join(funcDir, ".vc-config.json"),
JSON.stringify({ runtime: "nodejs22.x", handler: "index.js", launcherType: "Nodejs", shouldAddHelpers: true }, null, 2)
);
// Routes: static first, then all to the function
await fs.writeFile(
path.join(outDir, "config.json"),
JSON.stringify({
version: 3,
routes: [ { handle: "filesystem" }, { src: "/(.*)", dest: "/index" } ]
}, null, 2)
);
console.log("✅ Build Output API ready at .vercel/output");
}
main().catch((err) => {
console.error("❌ Build failed:", err);
process.exit(1);
}); Build commandIn {
"type": "module",
"scripts": {
"build": "bun run scripts/vercel-build-node-bun.ts"
}
} Run: bun run build |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
integrations/vercel
Vercel Function support Web Standard Framework by default, so you can run Elysia on Vercel Function without any additional configuration.
https://elysiajs.com/integrations/vercel
Beta Was this translation helpful? Give feedback.
All reactions