-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bundle.ts
37 lines (31 loc) · 874 Bytes
/
bundle.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
import { existsSync, rmSync } from 'node:fs'
import { build } from 'bun'
export const entryPoints = ['./src/index.js']
export const baseBuildDir = './dist'
export const browserBuildDir = `${baseBuildDir}/browser`
export const commonJsBuildDir = `${baseBuildDir}/cjs`
console.time('Browser build time')
if (existsSync(browserBuildDir)) {
rmSync(browserBuildDir, { recursive: true })
}
await build({
entrypoints: entryPoints,
outdir: browserBuildDir,
target: 'browser',
minify: true,
sourcemap: 'external',
})
console.timeEnd('Browser build time')
console.time('CommonJS build time')
if (existsSync(commonJsBuildDir)) {
rmSync(commonJsBuildDir, { recursive: true })
}
await build({
entrypoints: entryPoints,
outdir: commonJsBuildDir,
target: 'node',
format: 'cjs',
minify: true,
sourcemap: 'external',
})
console.timeEnd('CommonJS build time')