-
-
Notifications
You must be signed in to change notification settings - Fork 226
/
build.ts
58 lines (51 loc) · 946 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { $ } from 'bun'
import { build, type Options } from 'tsup'
const tsupConfig: Options = {
entry: ['src/**/*.ts'],
splitting: false,
sourcemap: false,
clean: true,
bundle: true
// outExtension() {
// return {
// js: '.js'
// }
// }
} satisfies Options
await Promise.all([
// ? tsup esm
build({
outDir: 'dist',
format: 'esm',
target: 'node20',
cjsInterop: false,
...tsupConfig
}),
// ? tsup cjs
build({
outDir: 'dist/cjs',
format: 'cjs',
target: 'node20',
// dts: true,
...tsupConfig
})
])
await $`tsc --project tsconfig.dts.json`
await Bun.build({
entrypoints: ['./src/index.ts'],
outdir: './dist/bun',
minify: {
whitespace: true,
syntax: true,
identifiers: false
},
target: 'bun',
sourcemap: 'external',
external: ['@sinclair/typebox']
})
await Promise.all([
$`cp dist/*.d.ts dist/cjs`,
$`cp dist/ws/*.d.ts dist/cjs/ws/`
])
await $`cp dist/index*.d.ts dist/bun`
process.exit()