-
Notifications
You must be signed in to change notification settings - Fork 452
Expand file tree
/
Copy pathbuild.mjs
More file actions
38 lines (31 loc) · 1018 Bytes
/
build.mjs
File metadata and controls
38 lines (31 loc) · 1018 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
35
36
37
38
import { rm } from "node:fs/promises";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import * as esbuild from "esbuild";
import { globSync } from "glob";
import { typecheckPlugin } from "@jgoz/esbuild-plugin-typecheck";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const OUT_DIR = "lib";
await rm(join(__dirname, OUT_DIR), { recursive: true, force: true });
// This will just log when a build ends
/** @type {esbuild.Plugin} */
const onEndPlugin = {
name: "on-end",
setup(build) {
build.onEnd((result) => {
// eslint-disable-next-line no-console
console.log(`Build ended with ${result.errors.length} errors`);
});
},
};
const context = await esbuild.context({
entryPoints: globSync(["src/*-action.ts", "src/*-action-post.ts"]),
bundle: true,
format: "cjs",
outdir: OUT_DIR,
platform: "node",
plugins: [typecheckPlugin(), onEndPlugin],
});
await context.rebuild();
await context.dispose();