{"name":"rollup-plugin-dts","version":"6.2.0","keywords":["rollup-plugin","typescript","dts","@types"],"author":{"name":"Arpad Borsos","email":"arpad.borsos@googlemail.com"},"license":"LGPL-3.0-only","_id":"rollup-plugin-dts@6.2.0","maintainers":[{"name":"swatinem","email":"arpad.borsos@googlemail.com"}],"homepage":"https://github.com/Swatinem/rollup-plugin-dts#readme","bugs":{"url":"https://github.com/Swatinem/rollup-plugin-dts/issues"},"dist":{"shasum":"d74239ba155a9354c08a97e9a5cda26404fc74f2","tarball":"http://registry-npm.ywwl.com/rollup-plugin-dts/download/rollup-plugin-dts-6.2.0.tgz","fileCount":8,"integrity":"sha512-iciY+z46mUbN5nCxtJqVynwgrZZljM8of6k8Rg5rVAmu4VHDxexFPgoCa2wrJG5mMsHSGrJmjQPCM4vD0Oe3Lg==","signatures":[{"sig":"MEUCIQCB/sk9GytV8L5XbQZfH0VOf1/fravA+Pz5B9bth3Mc4QIgXlrnGjkoczzLM4o2+Jqw3/Ifn1Fdgn4+0us1pqZbHnA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":237146,"size":56462,"noattachment":false,"key":"/rollup-plugin-dts/-/rollup-plugin-dts-6.2.0.tgz"},"main":"./dist/rollup-plugin-dts.cjs","type":"module","types":"./dist/rollup-plugin-dts.d.cts","engines":{"node":">=16"},"exports":{"import":"./dist/rollup-plugin-dts.mjs","require":"./dist/rollup-plugin-dts.cjs"},"funding":{"url":"https://github.com/sponsors/Swatinem"},"gitHead":"cef4b817f3f34b86a215559b3617a56ac2761aea","scripts":{"test":"c8 node .build/tests/index.js","build":"tsc && rollup --config .build/rollup.config.js","clean":"node -e \"(async () => { try { await require('fs/promises').rm('dist', { recursive: true }); } catch {} })()\"","pretest":"npm run build","prebuild":"npm run clean","prepublishOnly":"npm run test"},"_npmUser":{"name":"swatinem","email":"arpad.borsos@googlemail.com"},"prettier":{"printWidth":120,"trailingComma":"all"},"repository":{"url":"git+https://github.com/Swatinem/rollup-plugin-dts.git","type":"git"},"_npmVersion":"10.1.0","description":"A rollup plugin that will bundle up your .d.ts definition files.","directories":{},"sideEffects":false,"_nodeVersion":"20.7.0","dependencies":{"magic-string":"^0.30.17"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.3","rollup":"4.35.0","typescript":"5.8.2","@types/node":"^22.13.10","@types/react":"^19.0.10","@types/estree":"1.0.6","@types/d3-drag":"^3.0.7","@babel/code-frame":"^7.26.2","@types/babel__code-frame":"^7.0.6"},"peerDependencies":{"rollup":"^3.29.4 || ^4","typescript":"^4.5 || ^5.0"},"optionalDependencies":{"@babel/code-frame":"^7.26.2"},"_npmOperationalInternal":{"tmp":"tmp/rollup-plugin-dts_6.2.0_1742369292078_0.05203598381107821","host":"s3://npm-registry-packages-npm-production"},"readme":"# rollup-plugin-dts\n\n[![Build Status](https://github.com/Swatinem/rollup-plugin-dts/workflows/CI/badge.svg)](https://github.com/Swatinem/rollup-plugin-dts/actions?workflow=CI)\n[![Coverage Status](https://img.shields.io/codecov/c/github/Swatinem/rollup-plugin-dts.svg)](https://codecov.io/gh/Swatinem/rollup-plugin-dts)\n\nThis is a plugin that lets you roll-up your `.d.ts` definition files.\n\n## Usage\n\nInstall the package from `npm`:\n\n    $ npm install --save-dev rollup-plugin-dts\n\nAdd it to your `rollup.config.js`:\n\n```js\nimport { dts } from \"rollup-plugin-dts\";\n\nconst config = [\n  // …\n  {\n    input: \"./my-input/index.d.ts\",\n    output: [{ file: \"dist/my-library.d.ts\", format: \"es\" }],\n    plugins: [dts()],\n  },\n];\n\nexport default config;\n```\n\n**NOTE** A [default import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#default_import) of the plugin using `import dts from \"rollup-plugin-dts\";` is still supported for existing implementations of this package. However, a [named import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#named_import) is suggested to avoid the error `[!] TypeError: dts is not a function`[^1][^2] in certain rollup config file implementations.\n\nAnd then instruct typescript where to find your definitions inside your `package.json`:\n\n```json\n  \"types\": \"dist/my-library.d.ts\",\n```\n\n**NOTE** that the plugin will automatically mark any external library\n(`@types` for example) as `external`, so those will be excluded from bundling.\n\n## Options\n\n```js\nplugins: [dts({\n  // Enable detailed sourcemaps for Go-to-Definition support.\n  // When true: loads .d.ts.map files and captures TypeScript's declarationMap\n  // for .ts inputs, enabling navigation to original source files.\n  // NOTE: Also requires `output.sourcemap: true` in your Rollup config.\n  sourcemap: true,\n\n  // Path to tsconfig.json (default: finds nearest tsconfig.json)\n  tsconfig: \"./tsconfig.json\",\n\n  // TypeScript compiler options (e.g., for path mapping)\n  compilerOptions: { baseUrl: \".\", paths: { \"~/*\": [\"src/*\"] } },\n\n  // Don't auto-externalize node_modules (default: false)\n  respectExternal: true,\n\n  // Bundle types from specific external packages (default: [])\n  includeExternal: [\"some-package\"],\n})]\n```\n\n## TypeScript 7 support\n\nTypeScript 7.0 (the native compiler) does not ship a compiler API, which this\nplugin relies on. When your project uses `typescript@7`, additionally install\nthe official compatibility package that provides the TypeScript 6 API:\n\n    $ npm install --save-dev @typescript/typescript6\n\nThe plugin uses the API from your `typescript` package when it provides one\n(TypeScript 4.5 – 6.x), and automatically falls back to\n`@typescript/typescript6` otherwise. Declaration files are parsed and emitted\nwith the TypeScript 6 language behavior in that case, which is identical for\ndeclaration output. Once TypeScript 7.1+ ships its new compiler API, a future\nrelease will support it directly.\n\nNote that this plugin's public types reference the `typescript` package (e.g.,\n`ts.CompilerOptions`), which `typescript@7` does not currently provide. If you\ntype-check a file that imports `rollup-plugin-dts` (such as `rollup.config.ts`)\nwith TypeScript 7, enable [`skipLibCheck`](https://www.typescriptlang.org/tsconfig/#skipLibCheck)\nto avoid a spurious error inside the plugin's declaration file.\n\n## Maintenance Mode\n\nThis project is in _maintenance mode_. That means there will be no more active feature development.\nThere will still be occasional releases to maintain compatibility with future TypeScript releases.\nPull Requests are always welcome, however reaction time on both Issues and PRs can be slow.\n\n## What to expect\n\nWhile this plugin is fairly complete, it does not support all imaginable use-cases.\nIn particular, the plugin works best with already existing `.d.ts` files generated\nby the typescript compiler from idiomatic code.\n\nWorking with `.ts(x)` or even `.js(x)` (when setting `allowJs: true`) does work,\nbut is not recommended.\n\nThe plugin does its own import resolution through the typescript compiler, and\nusage together with other resolution plugins, such as `node-resolve` can lead\nto errors and is not recommended.\n\nAll external dependencies from `node_modules` are automatically excluded from\nbundling. This can be overridden using the `respectExternal` setting, but it is\ngenerally not recommended. While rollup of external `@types` generally works,\nit is not recommended.\n\n### TS2742 and shared declaration chunks\n\nWhen a bundled entry exposes a type that originally came from a private shared\nchunk, downstream `tsc --declaration` runs can fail with `TS2742`.\n\nThis is part of a broader TypeScript declaration portability problem. For\nupstream context, see\n[`./*.d.ts` required in `exports` to avoid `...not portable...`](https://github.com/microsoft/TypeScript/issues/60913)\nfor one shape of the bug, and\n[`Elaborate on non-portable types`](https://github.com/microsoft/TypeScript/issues/53764)\nfor the related error-message discussion.\n\nThis plugin will try to rewrite that path through an entry that already\nre-exports the type publicly. That keeps the existing public API and can make\nthe bundled declarations portable for downstream consumers.\n\nThe plugin does **not** invent new public exports. If no public entry re-exports\nthe shared type, the bundled package can still trigger `TS2742`. In that case,\nthe plugin emits a warning and the package should re-export the type from a\npublic entry explicitly.\n\n## Why?\n\nWell, ideally TypeScript should just do all this itself, and it even has a\n[proposal](https://github.com/Microsoft/TypeScript/issues/4433) to do that.\nBut there hasn’t been any progress in ~3 years.\n\nSome projects, like [rollup itself](https://github.com/rollup/rollup/blob/24fe07f39da8e4225f4bc4f797331930d8405ec2/src/rollup/types.d.ts)\ngo the route of completely separating their public interfaces in a separate file.\n\n## Alternatives\n\n- [API Extractor](https://api-extractor.com/)\n- [dts-bundle-generator](https://github.com/timocov/dts-bundle-generator)\n- [rollup-plugin-ts](https://github.com/wessberg/rollup-plugin-ts)\n- [tsc-prog](https://github.com/jeremyben/tsc-prog)\n\n[See](https://github.com/Swatinem/rollup-plugin-dts/issues/5)\n[some](https://github.com/Swatinem/rollup-plugin-dts/issues/13)\n[discussions](https://github.com/timocov/dts-bundle-generator/issues/68)\nabout some of these projects and their tradeoffs.\n\n## [How does it work](./docs/how-it-works.md)\n\n## License\n\nThe code is licensed under the copyleft **LGPL-3.0**. I have no intention to\nlicense this under any non-copyleft license.\n\n[^1]: [StackOverflow thread](https://stackoverflow.com/questions/74255565/rollup-typescript-error-dts-is-not-a-function/74304876#74304876) of issue\n[^2]: [Github issue](https://github.com/Swatinem/rollup-plugin-dts/issues/247)\n","publish_time":1742369292278,"_cnpm_publish_time":1742369292278,"dist-tags":{"latest":"6.5.1","next":"1.0.0-alpha.0"}}