-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ts
More file actions
33 lines (31 loc) · 710 Bytes
/
build.ts
File metadata and controls
33 lines (31 loc) · 710 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
import { watch } from 'node:fs'
import Bun from 'bun'
import dts from 'bun-plugin-dts'
async function build() {
console.time('build')
await Bun.build({
entrypoints: ['./src/AsyncIterableBuilder.ts'],
outdir: './dist',
minify: true,
plugins: [dts()],
sourcemap: 'external',
})
console.timeEnd('build')
}
await build()
if (process.argv[2] === 'watch') {
const watcher = watch(
`${import.meta.dir}/src`,
{ recursive: true },
(event, filename) => {
console.info(`Detected ${event} in ${filename} (src)`)
console.info('compile...')
build()
},
)
process.on('SIGINT', () => {
watcher.close()
console.info('bye')
process.exit(0)
})
}