2025-10-12 17:17:05 +00:00
|
|
|
import { build } from "esbuild";
|
|
|
|
|
import { cp, readdir, rm } from "fs/promises";
|
2025-12-01 17:13:26 -06:00
|
|
|
|
2025-10-12 17:17:05 +00:00
|
|
|
const projectDir = "../..";
|
2024-11-28 13:08:06 -06:00
|
|
|
const srcRoot = `${projectDir}/packages/bot`;
|
|
|
|
|
const distRoot = `${projectDir}/dist/bot`;
|
2026-02-18 16:45:06 -06:00
|
|
|
const modulesRoot = "../../node_modules";
|
2024-11-27 19:59:53 -06:00
|
|
|
const workers = await readdir(`${srcRoot}/src/workers`);
|
|
|
|
|
|
|
|
|
|
await rm(distRoot, { recursive: true, force: true });
|
2024-11-26 21:03:01 -06:00
|
|
|
|
|
|
|
|
build({
|
|
|
|
|
entryPoints: [
|
2024-11-27 19:59:53 -06:00
|
|
|
`${srcRoot}/src/main.ts`,
|
|
|
|
|
...workers.map((worker) => `${srcRoot}/src/workers/${worker}`),
|
2024-11-26 21:03:01 -06:00
|
|
|
],
|
|
|
|
|
bundle: true,
|
2025-10-12 17:17:05 +00:00
|
|
|
outdir: "../../dist/bot",
|
|
|
|
|
platform: "node",
|
|
|
|
|
format: "esm",
|
2024-11-26 21:03:01 -06:00
|
|
|
loader: {
|
2025-10-12 17:17:05 +00:00
|
|
|
".ttf": "file",
|
|
|
|
|
".node": "empty",
|
|
|
|
|
".json": "json",
|
2024-11-26 21:03:01 -06:00
|
|
|
},
|
2025-10-12 17:17:05 +00:00
|
|
|
external: ["sharp"],
|
2024-11-27 20:09:31 -06:00
|
|
|
minifyIdentifiers: false, // causes goofy ahh issues
|
2026-02-18 16:45:06 -06:00
|
|
|
minifySyntax: true,
|
|
|
|
|
minifyWhitespace: true,
|
|
|
|
|
sourcemap: true,
|
2025-10-12 17:17:05 +00:00
|
|
|
jsxImportSource: "react",
|
|
|
|
|
jsx: "automatic",
|
2024-11-26 21:03:01 -06:00
|
|
|
});
|
2024-11-27 19:59:53 -06:00
|
|
|
|
2024-11-28 13:08:06 -06:00
|
|
|
for (const module of await readdir(`${modulesRoot}/@resvg`)) {
|
|
|
|
|
readdir(`${modulesRoot}/@resvg/${module}`).then((files) =>
|
|
|
|
|
files
|
2025-10-12 17:17:05 +00:00
|
|
|
.filter((file) => file.endsWith(".node"))
|
2024-11-28 13:08:06 -06:00
|
|
|
.map((file) =>
|
|
|
|
|
cp(
|
2024-11-27 19:59:53 -06:00
|
|
|
`${modulesRoot}/@resvg/${module}/${file}`,
|
2026-02-18 16:36:12 -06:00
|
|
|
`${distRoot}/workers/${file}`,
|
|
|
|
|
),
|
|
|
|
|
),
|
2024-11-28 13:08:06 -06:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-18 16:45:06 -06:00
|
|
|
await cp(`${projectDir}/prisma`, `${distRoot}/prisma`, { recursive: true });
|
2024-11-28 13:08:06 -06:00
|
|
|
|
2026-02-18 16:45:06 -06:00
|
|
|
for (const file of await readdir(`${modulesRoot}/prisma`).then((files) =>
|
|
|
|
|
files.filter((file) => file.endsWith(".node")),
|
|
|
|
|
)) {
|
|
|
|
|
cp(`${modulesRoot}/prisma/${file}`, `${distRoot}/prisma/${file}`);
|
2024-11-28 13:08:06 -06:00
|
|
|
}
|