mirror of
https://github.com/versia-pub/server.git
synced 2026-04-27 20:59:15 +02:00
refactor: ♻️ Rewrite build system to fit the monorepo architecture
This commit is contained in:
parent
7de4b573e3
commit
90b6399407
217 changed files with 2143 additions and 1858 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { readdir } from "node:fs/promises";
|
||||
import { $, build } from "bun";
|
||||
import manifest from "./package.json" with { type: "json" };
|
||||
import { routes } from "./routes.ts";
|
||||
|
||||
console.log("Building...");
|
||||
|
|
@ -11,10 +12,7 @@ const pluginDirs = await readdir("plugins", { withFileTypes: true });
|
|||
|
||||
await build({
|
||||
entrypoints: [
|
||||
"packages/api/index.ts",
|
||||
// HACK: Include to avoid cyclical import errors
|
||||
"packages/config/index.ts",
|
||||
"cli/index.ts",
|
||||
...Object.values(manifest.exports).map((entry) => entry.import),
|
||||
// Force Bun to include endpoints
|
||||
...Object.values(routes),
|
||||
// Include all plugins
|
||||
|
|
@ -25,43 +23,24 @@ await build({
|
|||
outdir: "dist",
|
||||
target: "bun",
|
||||
splitting: true,
|
||||
minify: false,
|
||||
external: ["acorn", "@bull-board/ui"],
|
||||
minify: true,
|
||||
external: [
|
||||
...Object.keys(manifest.dependencies).filter((dep) =>
|
||||
dep.startsWith("@versia"),
|
||||
),
|
||||
"@bull-board/ui",
|
||||
],
|
||||
});
|
||||
|
||||
console.log("Copying files...");
|
||||
|
||||
// Fix Bun build mistake
|
||||
await $`sed -i 's/ProxiableUrl, url, sensitiveString, keyPair, exportedConfig/url, sensitiveString, keyPair, exportedConfig/g' dist/packages/config/*.js`;
|
||||
|
||||
// Copy Drizzle stuff
|
||||
await $`mkdir -p dist/packages/plugin-kit/tables`;
|
||||
await $`cp -rL packages/plugin-kit/tables/migrations dist/packages/plugin-kit/tables`;
|
||||
|
||||
// Copy plugin manifests
|
||||
await $`cp plugins/openid/manifest.json dist/plugins/openid/manifest.json`;
|
||||
|
||||
await $`mkdir -p dist/node_modules`;
|
||||
|
||||
// Copy Sharp to dist
|
||||
await $`mkdir -p dist/node_modules/@img`;
|
||||
await $`cp -rL node_modules/@img/sharp-libvips-linux* dist/node_modules/@img`;
|
||||
await $`cp -rL node_modules/@img/sharp-linux* dist/node_modules/@img`;
|
||||
|
||||
// Copy acorn to dist
|
||||
await $`cp -rL node_modules/acorn dist/node_modules/acorn`;
|
||||
|
||||
// Copy bull-board to dist
|
||||
await $`mkdir -p dist/node_modules/@bull-board`;
|
||||
await $`cp -rL node_modules/@bull-board/ui dist/node_modules/@bull-board/ui`;
|
||||
|
||||
// Copy the Bee Movie script from pages
|
||||
await $`cp beemovie.txt dist/beemovie.txt`;
|
||||
|
||||
// Copy package.json
|
||||
await $`cp package.json dist/package.json`;
|
||||
|
||||
// Fixes issues with sharp
|
||||
await $`cp -rL node_modules/detect-libc dist/node_modules/`;
|
||||
await $`cp -rL ../../node_modules/@bull-board/ui dist/node_modules/@bull-board/ui`;
|
||||
|
||||
console.log("Build complete!");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue