Skip to content

Commit

Permalink
chore: use dtsx to generate dts
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Nov 8, 2024
1 parent 6758d2d commit d791c84
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions build.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import process from 'node:process'
import { dts } from 'bun-plugin-dtsx'

console.log('Building...')

const result = await Bun.build({
entrypoints: ['src/index.ts'],
outdir: 'dist',
target: 'bun',
// sourcemap: 'linked',
// minify: true,
// plugins: [dts()],
plugins: [dts()],
})

if (!result.success) {
Expand Down
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"@stacksjs/eslint-config": "^3.8.1-beta.2",
"@types/bun": "^1.1.13",
"bumpp": "^9.8.1",
"bun-plugin-dtsx": "^0.21.4",
"lint-staged": "^15.2.10",
"simple-git-hooks": "^2.11.1",
"typescript": "^5.6.3"
Expand Down
9 changes: 7 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { PluginBuilder } from 'bun'
import type { UnimportOptions } from 'unimport'

function getLoader(path: string) {
function getLoader(path: string): string {
return path.endsWith('ts')
? 'ts'
: path.endsWith('js')
Expand All @@ -11,7 +11,12 @@ function getLoader(path: string) {
: 'jsx'
}

export function autoImports(options: Partial<UnimportOptions & { dts: string }>) {
interface AutoImportsPlugin {
name: string
setup: (builder: PluginBuilder) => Promise<void>
}

export function autoImports(options: Partial<UnimportOptions & { dts: string }>): AutoImportsPlugin {
return {
name: 'bun-plugin-auto-imports',

Expand Down

0 comments on commit d791c84

Please sign in to comment.