mirror of
https://github.com/ritz078/transform.git
synced 2026-11-21 00:32:56 +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
+1
-1
@@ -7,7 +7,7 @@
|
||||
"scripts": {
|
||||
"dev": "node --max-old-space-size=8192 node_modules/vite/bin/vite.js --host 127.0.0.1",
|
||||
"dev:inspect": "NODE_OPTIONS=--inspect vite",
|
||||
"build": "vite build",
|
||||
"build": "vite build && node scripts/copy-typescript-libs.mjs",
|
||||
"start": "node .output/server/index.mjs",
|
||||
"typecheck": "node node_modules/typescript/bin/tsc --noEmit",
|
||||
"test:api": "node --test tests/api.test.mjs",
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -65,8 +65,8 @@ export default defineConfig({
|
||||
"@babel/plugin-transform-flow-strip-types",
|
||||
"@babel/plugin-transform-typescript",
|
||||
"@khanacademy/flow-to-ts",
|
||||
"typescript-converter*",
|
||||
"typescript*",
|
||||
"typescript-converter",
|
||||
"typescript",
|
||||
"recast",
|
||||
"html2pug",
|
||||
"@openapi-contrib/json-schema-to-openapi-schema",
|
||||
|
||||
Reference in new issue
Block a user