Registry / type-stubs / bun-plugin-dtsx

bun-plugin-dtsx

JSON →
library0.9.13jsnpmunverified

Bun-plugin-dtsx is a specialized Bun Bundler plugin designed for rapidly generating TypeScript declaration files (DTS) directly during the build process. As of its current stable version, 0.9.13, the package maintains a consistent, albeit minor, release cadence with frequent patch and minor updates, often noting 'no significant changes' in recent versions. This indicates a focus on stability and incremental improvements within its pre-1.0 development phase. Its primary differentiator lies in its tight integration with the Bun runtime and bundler, offering an extremely fast solution for type emission compared to more generalized TypeScript compilation pipelines. It is essential for projects leveraging Bun that require `.d.ts` files for their distributed packages or internal module resolution, ensuring type safety and IDE support for consumers of the compiled output. It aims to streamline the development workflow for TypeScript projects built with Bun.

npm install bun-plugin-dtsx
INSTALL
IMPORT
SIG · BUN-PLUGIN-DTSX
B
bun-plugin-dtsx
type-stubsjavascriptv0.9.13
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

dtsx
import dtsx from 'bun-plugin-dtsx';
const dtsx = require('bun-plugin-dtsx');
The primary plugin function is typically a default export. Bun heavily favors ESM imports.

Demonstrates how to integrate `bun-plugin-dtsx` into a `Bun.build` process to generate TypeScript declaration files alongside your bundled output.

import { build } from 'bun'; import dtsx from 'bun-plugin-dtsx'; const entrypoint = './src/index.ts'; const outputPath = './dist'; console.log(`Starting Bun build with DTSX for ${entrypoint}...`); await build({ entrypoints: [entrypoint], outdir: outputPath, target: 'bun', // Or 'node', 'browser' depending on your target environment plugins: [ dtsx({ // Optional: configuration options for dtsx // For example, to specify a custom tsconfig path: // project: './tsconfig.build.json', // To output types to a separate directory (relative to outdir): // outDir: './types', }), ], minify: true, sourcemap: 'external', }); console.log('Bun build with DTSX type generation complete!'); console.log(`Check ${outputPath} for bundled code and generated .d.ts files.`);
Debug
Known issues
gotchaAs a pre-1.0 release (version 0.9.x), `bun-plugin-dtsx` may introduce breaking changes in minor or even patch releases. While recent changes logs show 'no significant changes', API stability is not guaranteed until a 1.0 stable release.
fix
Regularly review the GitHub releases page and test your builds after updating the package.
affects: >=0.0.0
gotchaThis plugin is designed exclusively for the Bun runtime and bundler. It is not compatible with other JavaScript runtimes (like Node.js) or bundlers (like Webpack, Rollup, or esbuild) outside of a Bun build context.
fix
Ensure you are running your build process with Bun (e.g., `bun build ...` or `bun run your-build-script.ts`).
affects: >=0.0.0
gotchaIf your `tsconfig.json` already has `declaration: true` or `emitDeclarationOnly: true`, `bun-plugin-dtsx` might conflict or duplicate efforts. It's generally recommended to let `dtsx` manage type emission and potentially disable these options in your `tsconfig.json` for Bun builds.
fix
Consider setting `declaration: false` and `emitDeclarationOnly: false` in your `tsconfig.json` when using `bun-plugin-dtsx`, as the plugin handles the type generation.
affects: >=0.0.0
Errors
Common errors & fixes
error: Cannot find module 'bun-plugin-dtsx'
The package `bun-plugin-dtsx` is not installed or the import path is incorrect.
fix
Install the package using `bun add bun-plugin-dtsx` and verify the import statement `import dtsx from 'bun-plugin-dtsx';`.
error: plugins must be functions that return a BunPlugin object or a BunPlugin object directly
The `dtsx` function was not called when passed to the `plugins` array, or its return value is not a valid BunPlugin object.
fix
Ensure you are calling the plugin function, e.g., `plugins: [dtsx({ /* options */ })]`.
error: TypeScript diagnostics: [TSxxxx] ... (during build with bun-plugin-dtsx)
The type generation process failed due to underlying TypeScript compilation errors in your source code. `bun-plugin-dtsx` relies on a valid TypeScript compilation to emit declarations.
fix
Review and resolve the specific TypeScript errors indicated in the diagnostic messages within your source files.
Upgrade
Version history
0.9.13latest on npm
Audit
Dependencies
bunrequiredRuntime environment for the plugin to operate.
typescriptrequiredCore dependency for parsing and emitting TypeScript declaration files.
Agent activity
38 hits · last 30 days
node
34
OpenAI (training)
1
Resources
bun-plugin-dtsx — npm install bun-plugin-dtsx · libregistry