-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
45 lines (40 loc) · 899 Bytes
/
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
import {build} from "esbuild";
import fs from "fs/promises"
const rewriteNodeImport = async (filename) => {
const esm = await fs.readFile(filename)
await fs.writeFile(filename, esm.toString()
.replaceAll("async_hooks", "node:async_hooks")
)
}
const shared = {
bundle: true,
entryPoints: [
"src/index.ts",
"src/wache/index.ts",
"src/wetch/index.ts",
],
logLevel: 'info',
minify: true,
sourcemap: false,
platform: "node",
target: "es2022",
tsconfig: "tsconfig.json",
jsx: "automatic",
outdir: "./dist"
}
await build({
...shared,
format: 'esm',
outExtension: {
".js": ".mjs"
}
})
await build({
...shared,
format: 'cjs',
outExtension: {
".js": ".cjs.js"
}
})
await rewriteNodeImport('./dist/wache/index.cjs.js')
await rewriteNodeImport('./dist/wache/index.mjs')