typescript-declaration-webpack-plugin
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

typescript-declaration-webpack-plugin

Bundles typescript declarations generated by typescript loaded into one .d.ts file.

What it does

The Plugin looks at all declaration files which the typescript loader generated and merges them into one. Import will be sorted so that each module or package is only imported once.

Setup

Install via npm

Install this plugin via npm.

npm install --dev typescript-declaration-webpack-plugin

tsconfig.json

Enable declaration generation by adding the following to the compiler options in your tsconfig.json file.

{
    "compilerOptions": {
        "declaration": true
    }
}

Webpack plugin

Add the following to your webpack.config.js file.

const TypescriptDeclarationPlugin = require('typescript-declaration-webpack-plugin');
//...
module.exports = {
    //...
    plugins: [
        new TypescriptDeclarationPlugin({
            // Options for TypescriptDeclarationPlugin (see below)
        }),
    ],
    //..
};
//...

Options

There are several options how you can customize the behavior of this plugin. Just pass these options to the constructor of the TypescriptDeclarationPlugin class.

Option Descrption Type
out Name of the bundled file. Per default index.d.ts string
removeMergedDeclarations If true the plugin will remove all merged declaration files. Per default true bool
removeComments Remove all comments from declaration files. Per default true bool

Feature plan

  • Merging declaration map's generated by declarationMap compiler option
  • Support multiple entry points, only include declarations of imported sources
  • Multiline comments should remove only the comment part

Package Sidebar

Install

npm i typescript-declaration-webpack-plugin

Weekly Downloads

1,151

Version

0.3.0

License

MIT

Unpacked Size

10.1 kB

Total Files

7

Last publish

Collaborators

  • chitter99