0.0.3 • Published 4 years ago

dts-umd-webpack-plugin v0.0.3

Weekly downloads
20
License
-
Repository
-
Last release
4 years ago

dts-umd-webpack-plugin

If you are using TypeScript and Webpack, and you want to create umd module with global variable and still have benefits from TypeScript like type definitions, then this plugin is for you!

There is no possibility to create .d.ts files for UMD as global out of the box in Webpack or even in TypeScript.

Installation

You can install it via npm like npm install dts-umd-webpack-plugin@namerci/dts-umd-webpack-plugin

Configuration

First, import your plugin in old way

const DefinitionBundlePlugin = require('dts-umd-webpack-plugin').DefinitionBundlePlugin;

or if you use ES6 modules:

import { DefinitionBundlePlugin } from 'dts-umd-webpack-plugin';

Then use the plugin:

new DefinitionBundlePlugin({
    moduleName: 'MyModuleName',
    output: './',
    entry: 'index.ts',
    dir: 'src',
    cleanDts: true,
}),

Be sure to add declaration: true in tsconfig.json under compilerOptions.

Do not set declarationDir, as this plugin doesn't support it yet.

Options

moduleName

It's your library name.

output

Default './'

It define where to put output definition file relative to webpack output.path directory.

entry

Default index.ts

Your entry point, usually the same as in webpack entry value. It's relative to dir configuration

dir

Default null

Place where to look for definition files.

cleanDts

Default false

It define if plugin should delete old .d.ts files generated by TypeScript

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago