Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dts-bundle-generator

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dts-bundle-generator - npm Package Compare versions

Comparing version 0.6.1 to 1.0.0

bin/dts-bundle-generator.js

33

package.json
{
"name": "dts-bundle-generator",
"version": "0.6.1",
"version": "1.0.0",
"description": "DTS Bundle Generator",
"main": "dist/bundle-generator.js",
"bin": {
"dts-bundle-generator": "bin/cli.js"
},
"main": "bundle-generator.js",
"bin": "bin/dts-bundle-generator.js",
"author": "Eugene Timokhov",

@@ -14,16 +12,5 @@ "bugs": {

"dependencies": {
"argparse": "1.0.9",
"tslib": "1.7.1",
"typescript": "^2.2.1"
"typescript": "^2.5.1",
"yargs": "~11.0.0"
},
"devDependencies": {
"@types/argparse": "1.0.32",
"@types/node": "7.0.8",
"tslint": "~5.7.0"
},
"files": [
"bin/cli.js",
"dist/**/*.js",
"README.md"
],
"license": "MIT",

@@ -35,6 +22,8 @@ "readme": "README.md",

},
"scripts": {
"lint": "tslint --config tslint.json --project tsconfig.json",
"compile": "tsc"
"yargs": {
"boolean-negation": false,
"camel-case-expansion": false,
"dot-notation": false,
"short-option-groups": false
}
}
}

@@ -5,3 +5,3 @@ [![npm version](https://badge.fury.io/js/dts-bundle-generator.svg)](https://badge.fury.io/js/dts-bundle-generator) [![Build Status](https://travis-ci.org/timocov/dts-bundle-generator.svg?branch=master)](https://travis-ci.org/timocov/dts-bundle-generator)

This small tool can generate a bundle of dts from your ts code.
Small tool to generate a dts bundle from your ts code.

@@ -32,3 +32,3 @@ For example:

When you run it as `dts-bundle-generator -o my.d.ts entry.ts` in `my.d.ts` you will get the following:
When you run `dts-bundle-generator -o my.d.ts entry.ts` in `my.d.ts` you will get the following:

@@ -43,55 +43,49 @@ ```ts

1. Installing the package from `npm`:
1. Install the package from `npm`:
```bash
npm install --save-dev dts-bundle-generator
```
```bash
npm install --save-dev dts-bundle-generator
```
or
or
```bash
npm install -g dts-bundle-generator
```
```bash
npm install -g dts-bundle-generator
```
1. Enable `declaration` compiler option in `tsconfig.json`
2. Enable `declaration` compiler options in `tsconfig.json`
## Usage
```
usage: dts-bundle-generator [-h] [-o OUTFILE] [-v] [--no-check] [--output-source-file]
[--fail-on-class] [--external-inlines EXTERNALINLINES]
[--external-imports EXTERNALIMPORTS]
[--external-types EXTERNALTYPES] [--config CONFIG]
file
Usage: dts-bundle-generator [options] <file>
Positional arguments:
file
Optional arguments:
-h, --help Show this help message and exit.
-o OUTFILE, --out-file OUTFILE
File name of generated d.ts
-v, --verbose Enable verbose logging
Options:
--help Show help [boolean]
--out-file, -o File name of generated d.ts [string]
--verbose Enable verbose logging [boolean] [default: false]
--no-check Skip validation of generated d.ts file
[boolean] [default: false]
--output-source-file Add comment with file path the definitions came from
[boolean] [default: false]
--fail-on-class Fail if generated dts contains class declaration
--external-inlines EXTERNALINLINES
Comma-separated packages from node_modules to inline
[boolean] [default: false]
--external-inlines Comma-separated packages from node_modules to inline
typings from it. Used types will be just inlined into
output file
--external-imports EXTERNALIMPORTS
Comma-separated packages from node_modules to import
typings from it. Used types will be imported by
"import { First, Second } from 'library-name';". By
default all libraries will be imported (except
inlined)
--external-types EXTERNALTYPES
Comma-separated packages from @types to import
typings from it via triple-slash reference directive.
output file [string]
--external-imports Comma-separated packages from node_modules to import
typings from it.
Used types will be imported by "import { First, Second }
from 'library-name';".
By default all libraries will be imported (except
inlined) [string]
--external-types Comma-separated packages from @types to import typings
from it via triple-slash reference directive.
By default all packages are allowed and will be used
according their usages
--umd-module-name UMDMODULENAME
The name of UMD module. If specified `export as
namespace ModuleName;` will be emitted
--config CONFIG File path to generator config file
according their usages [string]
--umd-module-name The name of UMD module. If specified `export as
namespace ModuleName;` will be emitted [string]
--project The path to a tsconfig.json file that will be used to
compile files [string]
--config File path to generator config file
--version Show version number [boolean]
```

@@ -113,11 +107,5 @@

## TODO
1. Add parameter to use custom `tsconfig` (currently it uses the closest `tsconfig.json`)
1. Add tests ([#2](https://github.com/timocov/dts-bundle-generator/issues/2))
## Why
If you have modules you can create definitions by default via `tsc`, but it generates them for each module separately. Yeah, you can use `outFile` (for `amd` and `system`) but it generates code like this:
If you have modules you can create definitions by default via `tsc`, but `tsc` generates them for each module separately. Yeah, you can use `outFile` (for `amd` and `system`) but generated code looks like this:

@@ -141,5 +129,5 @@ ```ts

1. There is no one usages of `A` (maybe you do not want to export it?)
1. There is not a single usage of `A` (maybe you do not want to export it?)
1. If you bundle your code in such a way all the modules are merged (like when using Webpack or Rollup) and there are no such modules as `a` or `b` (actually `entry` too).
1. If you bundle your code this way all the modules are merged (like when using Webpack or Rollup) and there are no such modules as `a` or `b` (actually `entry` too).

@@ -150,37 +138,37 @@ ## Known limitations

```ts
import { A as B } from './b';
export C extends B {}
```
```ts
import { A as B } from './b';
export C extends B {}
```
you will get an error because this tool does not follow your renaming (and actually cannot).
you will get an error because this tool does not follow your renaming (and actually cannot).
2. Do not use types from `* as name`-imports:
1. Do not use types from `* as name`-imports:
```ts
import * as someName from './some';
export class A extends someName.SomeClass {}
```
```ts
import * as someName from './some';
export class A extends someName.SomeClass {}
```
This case is very similar to the previous one.
This case is very similar to the previous one.
**NOTE:** some libraries with typings in `@types` (for example `react` or `react-dom`) has named exported namespace. As soon typings for this libraries will be imported via triple-slash directive you should import this libraries with renaming. For example for source
**NOTE:** some libraries with typings in `@types` (for example `react` or `react-dom`) has named exported namespace. As soon typings for this libraries will be imported via triple-slash directive you should import this libraries with renaming. For example for source
```ts
import * as ReactDOM from 'react-dom';
export interface MyRenderer extends ReactDOM.Renderer {}
```
```ts
import * as ReactDOM from 'react-dom';
export interface MyRenderer extends ReactDOM.Renderer {}
```
generated dts will be
generated dts will be
```ts
/// <reference types="react" />
/// <reference types="react-dom" />
```ts
/// <reference types="react" />
/// <reference types="react-dom" />
export interface MyRenderer extends ReactDOM.Renderer {
}
```
export interface MyRenderer extends ReactDOM.Renderer {
}
```
So please **make sure** that your `* as name`-import has right `name`.
So please **make sure** that your `* as name`-import has right `name`.
3. All your types should have different names inside a bundle. If you have 2 `interface Options {}` they will be merged by `TypeScript` and you will get wrong definitions.
1. All your types should have different names inside a bundle. If you have 2 `interface Options {}` they will be merged by `TypeScript` and you will get wrong definitions.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc