{"id":22027,"library":"rollup-plugin-flat-dts","title":"rollup-plugin-flat-dts","description":"A Rollup plugin that flattens TypeScript .d.ts declaration files into a single bundle, generating a merged type definition file. Current stable version 2.9.0 supports Rollup 2.79.1–5.0 and TypeScript 4.8.4–5.8. It differs from other .d.ts bundlers by flattening instead of merging, which imposes strict constraints: all exports are public (use @internal to mark internals), default exports only at top level, and no renamed re-exports. Ideal for libraries that want a single type file and can adhere to its limitations. Released roughly twice a year, tracking TypeScript minor versions.","status":"active","version":"2.9.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/run-z/rollup-plugin-flat-dts","tags":["javascript","rollup-plugin","typescript","dts","@types"],"install":[{"cmd":"npm install rollup-plugin-flat-dts","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-flat-dts","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-flat-dts","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: the plugin operates as a Rollup output plugin.","package":"rollup","optional":false},{"reason":"Peer dependency: uses TypeScript compiler API to process declaration files.","package":"typescript","optional":false}],"imports":[{"note":"Default export; named export not available. CommonJS users must use default interop.","wrong":"const { flatDts } = require('rollup-plugin-flat-dts')","symbol":"flatDts","correct":"import flatDts from 'rollup-plugin-flat-dts'"},{"note":"Options type exported for TypeScript users; import via type-only import to avoid runtime overhead.","wrong":null,"symbol":"flatDts (type)","correct":"import type { FlatDtsOptions } from 'rollup-plugin-flat-dts'"}],"quickstart":{"code":"import commonjs from '@rollup/plugin-commonjs';\nimport nodeResolve from '@rollup/plugin-node-resolve';\nimport flatDts from 'rollup-plugin-flat-dts';\nimport ts from 'rollup-plugin-typescript2';\n\nexport default {\n  input: './src/index.ts',\n  plugins: [commonjs(), ts(), nodeResolve()],\n  output: {\n    format: 'esm',\n    file: 'dist/index.js',\n    plugins: [flatDts({ tsconfig: 'tsconfig.json' })],\n  },\n};","lang":"typescript","description":"Rollup config producing a single .js and flattened .d.ts. Demonstrates typical setup with TypeScript plugin and the flatDts output plugin."},"warnings":[{"fix":"Avoid default exports in nested modules; use named exports and re-export in index.","message":"Default exports only supported at top level in entry points","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Rename duplicate exports to be globally unique.","message":"Exported symbols must be unique across the codebase","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use direct exports or alias via separate declaration: `const Bar = Foo; export { Bar };`","message":"Re-exports with aliases (e.g., `export { Foo as Bar }`) are not supported","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Add `@internal` JSDoc tag to internal exports, or use `internal` option with glob patterns.","message":"Every export in every file becomes part of public API unless marked @internal","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Avoid importing JSON modules in your source; or use a different output format.","message":"Forces `resolveJsonModule: false` as JSON module imports unsupported by SystemJS","severity":"breaking","affected_versions":">=2.3.1"},{"fix":"Do not set `verbatimModuleSyntax` in tsconfig; plugin overrides it.","message":"Disables `verbatimModuleSyntax` option as incompatible with SystemJS target","severity":"breaking","affected_versions":">=2.3.0 <2.4.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Move flatDts() to `output.plugins` array in rollup.config.js.","cause":"Adding flatDts() to `plugins` array instead of inside `output.plugins`","error":"The plugin is intended to be used as an output plugin, not a regular plugin"},{"fix":"Ensure tsconfig compilerOptions does not force a different module system that conflicts; plugin overrides as needed.","cause":"The plugin expects module system set to 'System' internally (ignored in output) but user config may conflict","error":"Error: TypeScript compiler options 'module' must be set to 'System' for DTS flattening"},{"fix":"Install: `npm install --save-dev rollup-plugin-flat-dts`. Ensure rollup.config is ESM or use dynamic import.","cause":"Package not installed; or ESM import in CommonJS context","error":"Error: Cannot find module 'rollup-plugin-flat-dts'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}