{"id":40927,"library":"esbuild-plugin-dtsx","title":"esbuild-plugin-dtsx","description":"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.","status":"active","version":"0.9.26","language":"javascript","source_language":"en","source_url":"https://github.com/stacksjs/dtsx","tags":["javascript","dts","dtsx","emit","generation","typescript","types","auto","stacks"],"install":[{"cmd":"npm install esbuild-plugin-dtsx","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-dtsx","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-dtsx","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime peer dependency; plugin requires esbuild >=0.27.4 to function","package":"esbuild","optional":false}],"imports":[{"note":"ESM-only package; CJS require will fail. Use dynamic import or import syntax.","wrong":"const dtsPlugin = require('esbuild-plugin-dtsx')","symbol":"dtsPlugin (default)","correct":"import dtsPlugin from 'esbuild-plugin-dtsx'"},{"note":"Named export also available; preferred for tree-shaking.","wrong":null,"symbol":"dtsPlugin (named)","correct":"import { dtsPlugin } from 'esbuild-plugin-dtsx'"},{"note":"PluginOptions is a TypeScript type; use `import type` to avoid bundling.","wrong":"import { PluginOptions } from 'esbuild-plugin-dtsx'","symbol":"PluginOptions","correct":"import type { PluginOptions } from 'esbuild-plugin-dtsx'"},{"note":"dtsPlugin is a factory function; must call it (with optional options) to get the plugin object.","wrong":"await esbuild.build({ plugins: [dtsPlugin] })","symbol":"esbuild build with plugin","correct":"await esbuild.build({ plugins: [dtsPlugin()] })"}],"quickstart":{"code":"import dtsPlugin from 'esbuild-plugin-dtsx';\nimport esbuild from 'esbuild';\n\nawait esbuild.build({\n  entryPoints: ['src/index.ts'],\n  bundle: true,\n  outdir: 'dist',\n  format: 'esm',\n  plugins: [dtsPlugin()],\n});","lang":"typescript","description":"Demonstrates basic usage: build TypeScript entry with esbuild and auto-generate DTS files in the output directory."},"warnings":[{"fix":"Use the Node.js API (esbuild.build) for plugin integration.","message":"Plugin currently works only with the `esbuild` Node.js API; the CLI `esbuild` command does not support plugins.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Ensure project is configured for ESM (e.g., `\"type\": \"module\"` in package.json).","message":"Version 0.5.0 dropped support for Node.js <14, requires ESM.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Remove `declarationDir` from plugin options; set `outdir` in esbuild options directly.","message":"The option `declarationDir` was deprecated in v0.8.0; use `outdir` from esbuild's own options.","severity":"deprecated","affected_versions":">=0.8.0"},{"fix":"Ensure all needed types are imported via entry points or use tsconfig `include` pattern.","message":"Plugin emits DTS only for entry points; not for non-entry imports in watch mode.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use `tsconfig.json`'s `paths` and `baseUrl` correctly; consider bundling external types.","message":"Type generation may produce incomplete DTS files if input has unresolved external types.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'/.d.tsx)':16 '0.27.4':33 '0.9.26':25 'activ':89 'altern':50 'auto':101 'automat':9 'base':42 'build':19,75,79 'built':63 'current':21 'd.ts':15 'd.ts/.d.tsx)':14 'declar':12 'depend':32 'dts':57,69,95 'dtsx':4,96 'ecosystem':87 'emiss':48 'emit':97 'esbuild':2,6,30,65 'esbuild-plugin-dtsx':1 'fast':46 'file':13 'focus':35 'generat':10,70,98 'integr':27 'javascript':94 'leverag':38 'like':51 'maintain':90 'oxc':43 'part':72,83 'peer':31 'perform':80 'pipelin':76 'plugin':3,7,56,59 'process':20 'purpos':62 'purpose-built':61 'regular':92 'releas':93 'resolv':44 'rollup':55 'rollup-plugin-dt':54 'rust':41 'rust-bas':40 'sacrif':78 'seamless':28 'speed':37 'stabl':22 'stack':86,102 'tsc':52 'type':47,100 'typescript':11,99 'unlik':49 'user':66 'version':23 'want':68 'without':77","created_at":"2026-06-04T18:49:56.464301+00:00","updated_at":"2026-06-04T18:49:56.464301+00:00","problems":[{"fix":"Call the function: plugins: [dtsPlugin()]","cause":"Default import used as a plugin object without calling the factory function.","error":"TypeError: plugin_esbuild_dtsx is not a function"},{"fix":"Install the package: npm i -D esbuild-plugin-dtsx. If using CommonJS, use dynamic import: const dtsPlugin = (await import('esbuild-plugin-dtsx')).default;","cause":"Missing dependency or incorrect module resolution (CJS context).","error":"Error: Cannot find module 'esbuild-plugin-dtsx'"},{"fix":"Update TypeScript to >=4.5 or configure tsconfig to remove experimental decorators.","cause":"Plugin generated a .d.ts file containing TypeScript decorator syntax not supported by older TypeScript versions.","error":"✘ Error: Build failed with 1 error: error: Unexpected \"@\" in declaration file"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/stacksjs/dtsx/tree/main/packages/esbuild-plugin#readme","github":"https://github.com/stacksjs/dtsx","docs":null,"changelog":null,"pypi":null,"npm":"esbuild-plugin-dtsx","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}