Skip to content

Commit 87eb235

Browse files
chore: wip
1 parent b266271 commit 87eb235

File tree

3 files changed

+9
-53
lines changed

3 files changed

+9
-53
lines changed

build.ts

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,10 @@
1-
import { execSync } from 'node:child_process'
2-
import fs, { existsSync, rmSync } from 'node:fs'
3-
import path from 'node:path'
4-
import process from 'node:process'
1+
import { dts } from 'bun-plugin-dtsx'
52

6-
// Clean dist directory
7-
if (existsSync('./dist')) {
8-
rmSync('./dist', { recursive: true })
9-
}
10-
11-
console.log('Building JavaScript files...')
12-
13-
// Build JavaScript files using Bun's bundler
14-
const jsResult = await Bun.build({
3+
await Bun.build({
154
entrypoints: ['src/index.ts'],
165
outdir: './dist',
6+
splitting: true,
177
target: 'bun',
188
format: 'esm',
19-
minify: false,
20-
sourcemap: 'external',
9+
plugins: [dts()],
2110
})
22-
23-
if (!jsResult.success) {
24-
console.error('JavaScript build failed:', jsResult.logs)
25-
process.exit(1)
26-
}
27-
28-
console.log('Generating TypeScript declaration files...')
29-
30-
// Generate declaration files using TypeScript compiler
31-
try {
32-
execSync('bunx tsc --declaration --emitDeclarationOnly --outDir dist --project tsconfig.json', {
33-
stdio: 'inherit',
34-
cwd: process.cwd(),
35-
})
36-
37-
const srcIndexDts = path.join(process.cwd(), 'dist', 'src', 'index.d.ts')
38-
const distIndexDts = path.join(process.cwd(), 'dist', 'index.d.ts')
39-
40-
if (fs.existsSync(srcIndexDts)) {
41-
let content = fs.readFileSync(srcIndexDts, 'utf8')
42-
43-
// Fix relative paths to point to src/ subdirectory
44-
content = content.replace(/from '\.\//g, 'from \'./src/')
45-
46-
fs.writeFileSync(distIndexDts, content)
47-
console.log('✅ Copied and fixed main declaration file to dist root')
48-
}
49-
50-
console.log('✅ Build completed successfully!')
51-
}
52-
catch (error) {
53-
console.error('❌ Failed to generate declaration files:', error)
54-
process.exit(1)
55-
}

bun.lock

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"@types/bun": "^1.3.1",
6565
"buddy-bot": "^0.9.11",
6666
"bun-git-hooks": "^0.3.1",
67-
"bun-plugin-dtsx": "^0.21.17",
67+
"bun-plugin-dtsx": "^0.9.9",
6868
"bunfig": "^0.15.6",
6969
"typescript": "^5.9.3"
7070
},

0 commit comments

Comments
 (0)