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
38 lines (37 loc) · 1.08 KB
/
build_plug_compile.ts
File metadata and controls
38 lines (37 loc) · 1.08 KB
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
35
36
37
38
import { denoPlugin, esbuild } from "./build_deps.ts";
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: false,
treeShaking: true,
logLevel: "error",
minify: true,
external: [
// Exclude weird yarn detection modules
"pnpapi",
// Exclude some larger dependencies that can be downloaded on the fly
"npm:esbuild*",
"jsr:@deno/esbuild-plugin*",
],
plugins: [denoPlugin({
configPath: new URL("./deno.json", import.meta.url).pathname,
})],
});
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();