-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
61 lines (57 loc) · 1.35 KB
/
build.js
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
58
59
60
61
const { build } = require("esbuild");
void main();
async function main() {
await bundle({
platform: "node",
target: "node14",
format: "cjs",
outdir: "node",
});
await bundle({
platform: "browser",
format: "esm",
outdir: "browser/esm",
});
await bundle({
platform: "browser",
format: "cjs",
outdir: "browser/cjs",
});
}
async function bundle({ platform, target, format, outdir }) {
await runEsbuild({
platform,
target,
format,
entryPoint: "./src/index.ts",
outfile: `./dist/${outdir}/index.js`,
});
await runEsbuild({
platform,
target,
format,
entryPoint: "./src/core/index.ts",
outfile: `./dist/${outdir}/core.js`,
});
await runEsbuild({
platform,
target,
format,
entryPoint: "./src/serialization/index.ts",
outfile: `./dist/${outdir}/serialization.js`,
});
}
async function runEsbuild({ platform, target, format, entryPoint, outfile }) {
await build({
platform,
target,
format,
entryPoints: [entryPoint],
outfile,
bundle: true,
alias: {
// matches up with tsconfig paths
"@ravenapp/raven": "./src",
}
}).catch(() => process.exit(1));
}