-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.ts
34 lines (31 loc) · 837 Bytes
/
build.ts
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 { build } from "esbuild";
import { replace } from "esbuild-plugin-replace";
import fs from "node:fs";
const pkg = JSON.parse(fs.readFileSync("./package.json", "utf-8"));
let makeAllPackagesExternalPlugin = {
name: "make-all-packages-external",
setup(build) {
let filter = /^[^.\/]|^\.[^.\/]|^\.\.[^\/]/; // Must not start with "/" or "./" or "../"
build.onResolve({ filter }, (args) => ({
path: args.path,
external: true,
}));
},
};
build({
bundle: true,
preserveSymlinks: true,
entryPoints: ["./bin.ts", "./index.ts"],
external: ["./node_modules/*"],
platform: "node",
format: "esm",
target: "es2020",
outdir: "./build/",
banner: { js: "#!/usr/bin/env node" },
plugins: [
makeAllPackagesExternalPlugin,
replace({
__build_version__: pkg.version,
}),
],
});