mirror of
https://github.com/ritz078/transform.git
synced 2026-11-22 00:54:01 +03:00
Keep Vercel server bundle below function size limit
This commit is contained in:
3 files changed
+36
-3
No files matched your search
@@ -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));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user