New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

bun-plugin-dtsx

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bun-plugin-dtsx

A Bun Bundler plugin that auto generates your DTS types extremely fast.

latest
Source
npmnpm
Version
0.9.13
Version published
Weekly downloads
80K
-2.64%
Maintainers
1
Weekly downloads
 
Created
Source

bun-plugin-dtsx

A Bun Bundler plugin for automatic TypeScript declaration file generation using dtsx.

Installation

bun add bun-plugin-dtsx -d
# or
npm install bun-plugin-dtsx --save-dev

Usage

// build.ts
import { dts } from 'bun-plugin-dtsx'

await Bun.build({
  entrypoints: ['src/index.ts'],
  outdir: 'dist',
  plugins: [
    dts({
      // Options
    }),
  ],
})

Options

OptionTypeDefaultDescription
trigger'build' | 'watch' | 'both''build'When to generate declarations
entryPointsOnlybooleantrueOnly generate for entry points
declarationDirstringBun outdirOutput directory for declarations
bundlebooleanfalseBundle all declarations into one file
bundleOutputstring'index.d.ts'Bundled output filename
exclude(string | RegExp)[][]Patterns to exclude
include(string | RegExp)[][]Patterns to include
emitOnErrorbooleantrueEmit even with type errors

Examples

Basic Usage

import { dts } from 'bun-plugin-dtsx'

await Bun.build({
  entrypoints: ['src/index.ts'],
  outdir: 'dist',
  plugins: [dts()],
})

With Bundled Declarations

import { dts } from 'bun-plugin-dtsx'

await Bun.build({
  entrypoints: ['src/index.ts'],
  outdir: 'dist',
  plugins: [
    dts({
      bundle: true,
      bundleOutput: 'types.d.ts',
    }),
  ],
})

Multiple Entry Points

import { dts } from 'bun-plugin-dtsx'

await Bun.build({
  entrypoints: ['src/index.ts', 'src/utils.ts'],
  outdir: 'dist',
  plugins: [
    dts({
      entryPointsOnly: true,
    }),
  ],
})

With Callbacks

import { dts } from 'bun-plugin-dtsx'

await Bun.build({
  entrypoints: ['src/index.ts'],
  outdir: 'dist',
  plugins: [
    dts({
      onStart: () => {
        console.log('Starting declaration generation...')
      },
      onSuccess: (stats) => {
        console.log(`Generated ${stats.totalFiles} files in ${stats.totalTime}ms`)
      },
      onError: (error) => {
        console.error('Failed to generate declarations:', error.message)
      },
    }),
  ],
})

Filter Files

import { dts } from 'bun-plugin-dtsx'

await Bun.build({
  entrypoints: ['src/index.ts'],
  outdir: 'dist',
  plugins: [
    dts({
      include: [/src\/lib/],
      exclude: ['test', /\.spec\.ts$/],
    }),
  ],
})

Custom Output Directory

import { dts } from 'bun-plugin-dtsx'

await Bun.build({
  entrypoints: ['src/index.ts'],
  outdir: 'dist',
  plugins: [
    dts({
      declarationDir: 'types',
    }),
  ],
})

License

MIT

Keywords

dts

FAQs

Package last updated on 03 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts