Skip to content
Source
Sign inSign up
samwillis/jerry
Open History to see the last commit

build.ts

28 lines879 Bytes

1import { build } from "esbuild";
2import { mkdir } from "node:fs/promises";
3import { loadWebAssets } from "./web-assets.js";
4​
5const assets = Object.fromEntries(
6 Object.entries(await loadWebAssets("dist/web/client")).map(
7 ([path, { body, type }]) => [
8 path,
9 { base64: Buffer.from(body).toString("base64"), type },
10 ],
11 ),
12);
13await mkdir("dist", { recursive: true });
14for (const entry of ["index", "local"])
15 await build({
16 entryPoints: [`src/${entry}.ts`],
17 outfile: `dist/${entry}.mjs`,
18 bundle: true,
19 minify: true,
20 platform: "node",
21 target: "node24",
22 format: "esm",
23 banner: {
24 js: "import {createRequire as __jolCreateRequire} from 'node:module';const require=__jolCreateRequire(import.meta.url);",
25 },
26 define: { __JOL_ASSETS__: JSON.stringify(assets) },
27 });
28console.log("Built JOL API and bundled web journal");