rollup-plugin-dts-bundle-generator

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

A Rollup plugin that wraps dts-bundle-generator to produce a single, flattened .d.ts bundle from TypeScript declarations. Current version 1.4.0, released with MIT license. It aims to solve the long-standing difficulty of generating bundled TypeScript typings in Rollup builds with a zero-config approach, deriving defaults from Rollup input/output. Supports entry point configuration and compilation options. Compared to alternatives like rollup-plugin-dts, it focuses on simplicity and relies on dts-bundle-generator which is actively maintained. Ships TypeScript types.

error TypeError: generateDtsBundle is not a function
cause Using default import instead of named import
fix
Use import { generateDtsBundle } from 'rollup-plugin-dts-bundle-generator'
error Error: Could not find a 'tsconfig.json'
cause TypeScript config file not found or not specified
fix
Pass compilation.preferredConfigPath in options, or ensure tsconfig.json exists in project root.
error ENOENT: no such file or directory, open '...'
cause Output directory does not exist
fix
Create the output directory before running the build, or use a path that exists.
error Missing required argument: entry
cause No EntryPointConfig provided and Rollup config lacks input or output details
fix
Specify entry in options or ensure Rollup config has valid input and output.
gotcha The plugin may generate incorrect declarations if the TypeScript config has incompatible settings like composite or declarationMap. Ensure output dir is set explicitly.
fix Upgrade to version 1.2.0+ or set outFile explicitly.
deprecated Using options.entry without specifying outFile may cause silent failures. The entry option is pending deprecation in favor of deriving from Rollup config.
fix Rely on auto-derivation from Rollup input/output or specify outFile explicitly.
breaking Version 1.4.0 changed the default behavior for output path derivation when using multiple outputs. Now uses first output's file or dir.
fix If using multiple outputs, set outFile explicitly to avoid unexpected file generation.
gotcha The plugin does not work with Rollup's output.preserveModules or preserveEntrySignatures. These options may interfere with declaration generation.
fix Set preserveModules: false and preserveEntrySignatures: 'strict' in Rollup config.
npm install rollup-plugin-dts-bundle-generator
yarn add rollup-plugin-dts-bundle-generator
pnpm add rollup-plugin-dts-bundle-generator

Configures Rollup plugin to generate a bundled .d.ts file with custom output path and compiler settings.

import { generateDtsBundle } from 'rollup-plugin-dts-bundle-generator';

export default {
  input: 'src/index.ts',
  output: {
    file: 'dist/bundle.js',
    format: 'cjs'
  },
  plugins: [
    generateDtsBundle({
      outFile: 'types/index.d.ts',
      compilation: {
        preferredConfigPath: 'tsconfig.build.json'
      }
    })
  ]
};