rollup-dts-bundler: Rollup plugin for accurate .d.ts bundling via @microsoft/api-extractor.
Provides a specialized Rollup plugin to accurately bundle TypeScript declaration files (.d.ts) using Microsoft's official API Extractor. Addresses the limitation of monolithic CLI tools by wrapping API Extractor into a simple, consumable Rollup interface.
liverollup-dts-bundler
TaglineRollup plugin for accurate .d.ts bundling via @microsoft/api-extractor.
Platformweb
CategoryDeveloper Tools · TypeScript
Visitgithub.com
Source
The developer experience surrounding TypeScript declaration file (.d.ts) generation can be notoriously complex. While tools like Rollup are exceptional for bundling JavaScript, handling the type side-effects requires dedicated, robust tooling. The `rollup-dts-bundler` aims to solve this by integrating the power of @microsoft/api-extractor directly into the standard Rollup workflow. This is not just another wrapper; it specifically targets the strengths of Microsoft's official API Extractor, which is built to handle the intricacies of type metadata without mangling names or discarding necessary re-exports—problems that plague many competing bundlers.
Historically, using API Extractor required dealing with a complex, CLI-driven setup, making it difficult to integrate seamlessly into modern build systems like Rollup. This plugin mitigates that architectural hurdle. By exposing API Extractor's functionality as a clean, minimal Rollup plugin interface, it vastly simplifies the integration process for library authors. The core mechanism is clever: it intercepts the build process, allowing Rollup to provide the necessary input and output contexts, while the plugin executes the type extraction logic via the `generateBundle` hook, ensuring the resulting declarations are correctly output as an asset.
Functionally, the plugin allows for fine-grained control over the build process. Developers can specify paths to dedicated `tsconfig` files, define internal workspace packages (`bundledPackages`) whose types must be inlined (preventing external references), and manage the overall build structure directly within `rollup.config.js`. This level of control makes it ideal for monorepo environments or complex libraries where type consistency across multiple internal packages is paramount. For consumption, the developer simply needs to point `package.json` to the generated type file, assuring consumers that the API is correctly typed upon installation.
In summary, if your project is a library that relies heavily on accurate, comprehensive type definitions—especially in a multi-package or enterprise setting—this tool is highly valuable. It professionalizes the typically messy process of typing library outputs, allowing developers to focus on feature logic while trusting that the type definitions will be generated with Microsoft-grade fidelity. It represents a critical piece of infrastructure for high-quality TypeScript library development.
Article Tags
indiedeveloper toolstypescript