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.

devops
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.

ESM-only package; CJS require will fail. Use dynamic import or import syntax.

import dtsPlugin from 'esbuild-plugin-dtsx'

Named export also available; preferred for tree-shaking.

import { dtsPlugin } from 'esbuild-plugin-dtsx'

PluginOptions is a TypeScript type; use `import type` to avoid bundling.

import type { PluginOptions } from 'esbuild-plugin-dtsx'

dtsPlugin is a factory function; must call it (with optional options) to get the plugin object.

await esbuild.build({ plugins: [dtsPlugin()] })

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 footguns
gotchaPlugin currently works only with the `esbuild` Node.js API; the CLI `esbuild` command does not support plugins.
breakingVersion 0.5.0 dropped support for Node.js <14, requires ESM.
deprecatedThe option `declarationDir` was deprecated in v0.8.0; use `outdir` from esbuild's own options.
gotchaPlugin emits DTS only for entry points; not for non-entry imports in watch mode.
gotchaType generation may produce incomplete DTS files if input has unresolved external types.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
8 hits · last 30 days
gptbot
3
ahrefsbot
2
Resources