Registry / devops / esbuild-plugin-dtsx

esbuild-plugin-dtsx

JSON →
library0.9.26jsnpmunverified

An esbuild plugin that automatically generates TypeScript declaration files (.d.ts/.d.tsx) during the build process. Current stable version is 0.9.26. It integrates seamlessly with esbuild (peer dependency >=0.27.4) and focuses on speed—leveraging the Rust-based `oxc` resolver for fast type emission. Unlike alternatives like `tsc` or `rollup-plugin-dts`, this plugin is purpose-built for esbuild users who want DTS generation as part of their build pipeline without sacrificing build performance. It is part of the Stacks ecosystem and actively maintained with regular releases.

npm install esbuild-plugin-dtsx
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-DTS
E
esbuild-plugin-dtsx
devopsjavascriptv0.9.26
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

dtsPlugin (default)
import dtsPlugin from 'esbuild-plugin-dtsx'
const dtsPlugin = require('esbuild-plugin-dtsx')
ESM-only package; CJS require will fail. Use dynamic import or import syntax.
dtsPlugin (named)
import { dtsPlugin } from 'esbuild-plugin-dtsx'
Named export also available; preferred for tree-shaking.
PluginOptions
import type { PluginOptions } from 'esbuild-plugin-dtsx'
import { PluginOptions } from 'esbuild-plugin-dtsx'
PluginOptions is a TypeScript type; use `import type` to avoid bundling.
esbuild build with plugin
await esbuild.build({ plugins: [dtsPlugin()] })
await esbuild.build({ plugins: [dtsPlugin] })
dtsPlugin is a factory function; must call it (with optional options) to get the plugin object.

Demonstrates basic usage: build TypeScript entry with esbuild and auto-generate DTS files in the output directory.

import dtsPlugin from 'esbuild-plugin-dtsx'; import esbuild from 'esbuild'; await esbuild.build({ entryPoints: ['src/index.ts'], bundle: true, outdir: 'dist', format: 'esm', plugins: [dtsPlugin()], });
Debug
Known issues
gotchaPlugin currently works only with the `esbuild` Node.js API; the CLI `esbuild` command does not support plugins.
fix
Use the Node.js API (esbuild.build) for plugin integration.
affects: >=0.1.0
breakingVersion 0.5.0 dropped support for Node.js <14, requires ESM.
fix
Ensure project is configured for ESM (e.g., `"type": "module"` in package.json).
affects: >=0.5.0
deprecatedThe option `declarationDir` was deprecated in v0.8.0; use `outdir` from esbuild's own options.
fix
Remove `declarationDir` from plugin options; set `outdir` in esbuild options directly.
affects: >=0.8.0
gotchaPlugin emits DTS only for entry points; not for non-entry imports in watch mode.
fix
Ensure all needed types are imported via entry points or use tsconfig `include` pattern.
affects: >=0.1.0
gotchaType generation may produce incomplete DTS files if input has unresolved external types.
fix
Use `tsconfig.json`'s `paths` and `baseUrl` correctly; consider bundling external types.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: plugin_esbuild_dtsx is not a function
Default import used as a plugin object without calling the factory function.
fix
Call the function: plugins: [dtsPlugin()]
Error: Cannot find module 'esbuild-plugin-dtsx'
Missing dependency or incorrect module resolution (CJS context).
fix
Install the package: npm i -D esbuild-plugin-dtsx. If using CommonJS, use dynamic import: const dtsPlugin = (await import('esbuild-plugin-dtsx')).default;
✘ Error: Build failed with 1 error: error: Unexpected "@" in declaration file
Plugin generated a .d.ts file containing TypeScript decorator syntax not supported by older TypeScript versions.
fix
Update TypeScript to >=4.5 or configure tsconfig to remove experimental decorators.
Upgrade
Version history
0.9.26latest on npm
Audit
Dependencies
esbuildrequiredRuntime peer dependency; plugin requires esbuild >=0.27.4 to function
Agent activity
2 hits · last 30 days
node
2
Resources
esbuild-plugin-dtsx — npm install esbuild-plugin-dtsx · libregistry