Skip to content

Commit 04c80bc

Browse files
fix: build
1 parent 218d149 commit 04c80bc

File tree

3 files changed

+582
-402
lines changed

3 files changed

+582
-402
lines changed

build.ts

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,40 @@
1-
import { dts } from 'bun-plugin-dtsx'
1+
import { execSync } from 'node:child_process'
2+
import { existsSync, rmSync } from 'node:fs'
3+
import process from 'node:process'
24

3-
await Bun.build({
5+
// Clean dist directory
6+
if (existsSync('./dist')) {
7+
rmSync('./dist', { recursive: true })
8+
}
9+
10+
console.log('Building JavaScript files...')
11+
12+
// Build JavaScript files using Bun's bundler
13+
const jsResult = await Bun.build({
414
entrypoints: ['src/index.ts'],
515
outdir: './dist',
616
target: 'bun',
7-
plugins: [dts()],
17+
format: 'esm',
18+
minify: false,
19+
sourcemap: 'external',
820
})
21+
22+
if (!jsResult.success) {
23+
console.error('JavaScript build failed:', jsResult.logs)
24+
process.exit(1)
25+
}
26+
27+
console.log('Generating TypeScript declaration files...')
28+
29+
// Generate declaration files using TypeScript compiler
30+
try {
31+
execSync('bunx tsc --declaration --emitDeclarationOnly --outDir dist --project tsconfig.json', {
32+
stdio: 'inherit',
33+
cwd: process.cwd(),
34+
})
35+
console.log('✅ Build completed successfully!')
36+
}
37+
catch (error) {
38+
console.error('❌ Failed to generate declaration files:', error)
39+
process.exit(1)
40+
}

0 commit comments

Comments
 (0)