forked from silverbulletmd/silverbullet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_plug_compile.ts
More file actions
34 lines (33 loc) · 973 Bytes
/
build_plug_compile.ts
File metadata and controls
34 lines (33 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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();