dts-generator-optimizer
Integrates with gulp to optimizes typescript declaration files generated with dts-generator.
What it does
- Remove
private
class members declarations; - Parses all dynamic
import()
statements, removes inline imports, and injects external import paths to the top of the file; - Parses all external
import
statements, removes duplicates among them, and injects the result in alphabetical order at the top of the file; - Removes
/// <references />
directives; - Compresses all
declare module 'internal/path/in/project' {...}
statements inside a singledeclare module ${moduleName} {...}
statement; - Exports the declarations as a commonjs, AMD, and UMD modules so it can be imported everywhere;
- Remove unecessary blanklines;
Installation
npm i -D dts-generator-optimizer
Usage
Simple gulp configuration example.
const dtsGenerator = ;const optimizeDeclarations = ; gulp; gulp; gulp;
Options
libraryName: string
: The name of the exported UMD variable.internalImportPaths: RegExp[]
: The import paths internal to your projects that will be parsed out and combined in a single module.externalTypesToExport: string[]
: The external library names whose types need to be exported.