forked from defenseunicorns/pepr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.mjs
57 lines (46 loc) · 1.28 KB
/
build.mjs
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* eslint-disable no-undef */
import { analyzeMetafile, build } from "esbuild";
import packageJSON from "./package.json" assert { type: "json" };
const { dependencies, peerDependencies } = packageJSON;
const external = Object.keys(dependencies).concat(Object.keys(peerDependencies), "@kubernetes/client-node");
const buildOpts = {
bundle: true,
external,
format: "cjs",
legalComments: "eof",
metafile: true,
platform: "node",
};
async function builder() {
try {
// Build the CLI
const cli = await build({
...buildOpts,
entryPoints: ["src/cli.ts"],
outfile: "dist/cli.js",
define: {
'process.env.PEPR_PRETTY_LOGS': '"true"',
},
});
console.log(await analyzeMetafile(cli.metafile));
// Build the controller runtime
const controller = await build({
...buildOpts,
entryPoints: ["src/runtime/controller.ts"],
outfile: "dist/controller.js",
});
console.log(await analyzeMetafile(controller.metafile));
// Build the library
const lib = await build({
...buildOpts,
entryPoints: ["src/lib.ts"],
outfile: "dist/lib.js",
sourcemap: true,
});
console.log(await analyzeMetafile(lib.metafile));
} catch (e) {
console.error(e);
process.exit(1);
}
}
builder();