dts-minify-lite
v0.5.4
Published
A lightweight and zero dependency minifier for TypeScript declaration files (.d.ts).
Readme

🗜️ dts-minify-lite
A lightweight and zero dependency minifier for TypeScript declaration files (.d.ts).
Why?
This library was rewritten to remove the TypeScript dependency found in dts-minify. This was done to reduce the disk install size and improve performance, as the TypeScript dependency is very weighty.
✨ Features
- 🗜️ Minifies TypeScript declaration files (.d.ts) by removing unnecessary whitespace and comments.
- 🔧 Preserves the functionality of the original declaration files while optimizing their size.
- ⚡ Zero dependencies, making it lightweight and easy to integrate into any project.
📦 Installation
You can install dts-minify-lite using npm:
$ npm install dts-minify-liteUsing pnpm:
$ pnpm add dts-minify-liteUsing yarn:
$ yarn add dts-minify-liteUsing bun:
$ bun add dts-minify-lite⚡ Usage
dts-minify-lite uses the same API as dts-minify, so you can simply replace the import and remove TypeScript from your dependencies.
Example:
import { createMinifier } from "dts-minify-lite";
const minifier = createMinifier();
const input = `/** This is a comment that should be removed
*
*/
declare namespace Lib {
// should be removed
interface Thing { value: string }
}`;
const output = minifier.minify(input);
console.log(output);
// declare namespace Lib{interface Thing{value:string;}}⚙️ Options
The .minify() function parameters.
fileText (string) — required
The text of the declaration file (.d.ts) to be minified.
options (object) — optional
An object containing configuration options for the minification process.
options.keepJsDocs (boolean)
Whether to keep JSDoc comments in the output. If set to true, all comments will be kept. Default to false.
const output = minifier.minify(input, { keepJsDocs: true });
// /** This is a comment that should be removed
// *
// */declare namespace Lib{interface Thing{value:string;}}📚 Related Projects
rolldown-plugin-dts-minify-lite: Rolldown plugin fordts-minify-lite, a lightweight and zero dependency minifier for TypeScript declaration files (.d.ts).
🏆 Credits
This project is highly inspired by the original dts-minify. Thanks for the great work on that project.
🤝 Contributing
Contributions to this library are welcome! If you have any ideas for improvements or new features, please feel free to open an issue or submit a pull request. I appreciate your help in making dts-minify-lite better for everyone.
📄 License
This project is licensed under the MIT License. See the LICENSE file for details.
