{"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,"search_vec":"'2.79.1':31 '2.9.0':28 '4.8.4':35 '5.0':32 '5.8':36 'adher':84 'bundl':18 'bundler':42 'constraint':51 'current':25 'd.ts':12,41 'declar':13 'default':61 'definit':23 'differ':38 'dts':5,102 'export':53,62,72 'file':14,24,81 'flat':4 'flatten':10,44 'generat':19 'ideal':73 'impos':49 'instead':45 'intern':57,60 'javascript':97 'level':66 'librari':75 'limit':87 'mark':59 'merg':21,47 'minor':95 'plugin':3,8,100 'public':55 're':71 're-export':70 'releas':88 'renam':69 'rollup':2,7,30,99 'rollup-plugin':98 'rollup-plugin-flat-dt':1 'rough':89 'singl':17,79 'stabl':26 'strict':50 'support':29 'top':65 'track':93 'twice':90 'type':22,80,103 'typescript':11,34,94,101 'use':56 'version':27,96 'want':77 'year':92","created_at":"2026-04-27T17:03:00.379290+00:00","updated_at":"2026-04-27T17:03:00.379290+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/run-z/rollup-plugin-flat-dts","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/rollup-plugin-flat-dts","openapi_spec":null,"status_page":null,"smithery":null,"categories":["type-stubs","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-18","next_check":"2026-07-26","install_tag":null}}