-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.mjs
36 lines (33 loc) · 805 Bytes
/
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
import esbuild from "esbuild";
import { nodeExternalsPlugin } from "esbuild-node-externals";
const entryFile = "src/index.ts";
const sharedBuildProps = {
bundle: true,
entryPoints: [entryFile],
logLevel: "info",
minify: true,
sourcemap: true,
plugins: [nodeExternalsPlugin()],
};
// ESM
esbuild
.build({
...sharedBuildProps,
format: "esm",
outfile: "./dist/index.esm.js",
target: ["esnext"],
loader: { ".ts": "ts", ".tsx": "tsx" },
})
.then(() => console.log("⚡ ESM Done"))
.catch(() => process.exit(1));
// CJS
esbuild
.build({
...sharedBuildProps,
format: "cjs",
outfile: "./dist/index.cjs.js",
target: ["esnext"],
loader: { ".ts": "ts", ".tsx": "tsx" },
})
.then(() => console.log("⚡ CJS Done"))
.catch(() => process.exit(1));