Files
plainleaf/build_plug_compile.ts
T
Zef HemelandGitHub a524c64884 Go backend (#1555)
* Replaces old Deno server with a Go implementation
* Restructured the code base accordingly
2025-09-19 13:23:20 +02:00

35 lines
973 B
TypeScript

import { denoPlugins } from "@luca/esbuild-deno-loader";
import * as esbuild from "esbuild";
await Deno.mkdir("dist", { recursive: true });
const result = await esbuild.build({
entryPoints: {
"plug-compile": "./bin/plug-compile.ts",
},
outdir: "dist",
format: "esm",
absWorkingDir: Deno.cwd(),
bundle: true,
//metafile: true,
treeShaking: true,
logLevel: "error",
minify: true,
external: [],
plugins: denoPlugins({
configPath: new URL("./deno.json", import.meta.url).pathname,
nodeModulesDir: "auto",
}),
});
if (result.metafile) {
const text = await esbuild.analyzeMetafile(result.metafile!);
console.log("Bundle info", text);
}
const plugBundleJS = await Deno.readTextFile("dist/plug-compile.js");
// Patch output JS with import.meta.main override to avoid ESBuild CLI handling
await Deno.writeTextFile(
"dist/plug-compile.js",
"import.meta.main = false;\n" + plugBundleJS,
);
console.log("Output in dist");
esbuild.stop();