-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.mjs
36 lines (28 loc) · 804 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 { $ } from 'bun'
import { logger } from './src/logger'
const entrypoint = './index.ts'
const outdir = './dist'
logger.info('Cleaning output directory...')
await $`rm -rf ${outdir}`
logger.success('Output directory cleaned!')
logger.info(`Building package ${entrypoint}...`)
const result = await Bun.build({
entrypoints: [entrypoint],
outdir: outdir,
target: 'browser',
format: 'esm',
splitting: true,
sourcemap: 'external',
minify: false,
external: ['react', 'react-dom', 'react-native'],
})
if (!result.success) {
logger.error('ESM build failed:')
logger.error(result.logs.join('\n'))
process.exit(1)
}
logger.success('Package built!')
logger.info('Generating types...')
await $`tsc --project tsconfig.json`
logger.success('Types generated!')
logger.success('Build finished!')