Keep Vercel server bundle below function size limit

This commit is contained in:
Ritesh Kumar committed 2026-09-29 01:39:27 +05:30
1 parent 929eea2660
commit 5637ec2cd6
3 files changed
+36 -3

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
import {
copyFileSync,
existsSync,
mkdirSync,
readFileSync,
readdirSync
} from "node:fs";
import { join } from "node:path";
const sourcePackage = "node_modules/typescript-converter";
const version = JSON.parse(
readFileSync(join(sourcePackage, "package.json"), "utf8")
).version;
const output = process.env.VERCEL
? ".vercel/output/functions/__server.func"
: ".output/server";
const target = join(
output,
"node_modules/.nf3",
`typescript@${version}`,
"lib"
);
if (!existsSync(target)) {
throw new Error(`Traced TypeScript compiler not found at ${target}`);
}
mkdirSync(target, { recursive: true });
for (const name of readdirSync(join(sourcePackage, "lib"))) {
if (name.startsWith("lib.") && name.endsWith(".d.ts")) {
copyFileSync(join(sourcePackage, "lib", name), join(target, name));
}
}