rollup-plugin-dts-bundle

raw JSON →
1.0.0 verified Mon Apr 27 auth: no javascript

A Rollup plugin that bundles all generated .d.ts files into a single declaration file using dts-bundle under the hood. Version 1.0.0 is the latest stable release; the project appears to be maintained sporadically. It integrates seamlessly with Rollup's build hooks (default writeBundle) and provides options like file cleanup and verbosity. Compared to alternatives like rollup-plugin-dts or @rollup/plugin-dts, this plugin offers less configuration overhead but relies on the older dts-bundle library.

error Error: Cannot find module 'dts-bundle'
cause Missing peer dependency dts-bundle which is not automatically installed
fix
Run 'npm install dts-bundle --save-dev' or 'yarn add dts-bundle -D'
error TypeError: dtsBundle is not a function
cause Using require instead of import in an ES module context, or incorrect import syntax
fix
Use 'import dtsBundle from 'rollup-plugin-dts-bundle'' in your config
error Error: The 'bundle' option is required
cause Missing or incorrectly named 'bundle' configuration object
fix
Provide a bundle object with at least 'name' and 'main' properties
gotcha The plugin requires dts-bundle, which is an older library with its own quirks (e.g., does not handle re-exports well).
fix Ensure your .d.ts files are generated correctly; use the removeSource option to avoid duplicate declarations.
gotcha Default hook is writeBundle, which runs after the bundle is written. If you use generateBundle, types may not be available yet.
fix Set hook to 'buildEnd' or 'generateBundle' based on your Rollup version and workflow.
deprecated dts-bundle is in maintenance mode and may not support modern TypeScript features like project references or strict mode.
fix Consider using rollup-plugin-dts or @microsoft/api-extractor for more robust declaration bundling.
npm install rollup-plugin-dts-bundle
yarn add rollup-plugin-dts-bundle
pnpm add rollup-plugin-dts-bundle

Rollup config with typescript2 plugin and dts-bundle plugin to bundle .d.ts files into one.

// rollup.config.js
import typescript from 'rollup-plugin-typescript2';
import dtsBundle from 'rollup-plugin-dts-bundle';

export default {
  input: 'src/index.ts',
  output: {
    file: 'dist/bundle.js',
    format: 'esm'
  },
  plugins: [
    typescript({ tsconfig: './tsconfig.json' }),
    dtsBundle({
      bundle: {
        name: 'my-library',
        main: 'dist/index.d.ts',
        out: 'bundle.d.ts',
        removeSource: true
      },
      deleteOnComplete: ['dist/**/*.d.ts', '!dist/bundle.d.ts'],
      verbose: true
    })
  ]
};