dts-bundle-generator
Advanced tools
Comparing version 0.6.1 to 1.0.0
{ | ||
"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 | ||
} | ||
} | ||
} |
140
README.md
@@ -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. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
2
0
1
35380
12
640
169
1
+ Addedyargs@~11.0.0
+ Addedansi-regex@2.1.13.0.1(transitive)
+ Addedcamelcase@4.1.0(transitive)
+ Addedcliui@4.1.0(transitive)
+ Addedcode-point-at@1.1.0(transitive)
+ Addedcross-spawn@5.1.0(transitive)
+ Addeddecamelize@1.2.0(transitive)
+ Addedexeca@0.7.0(transitive)
+ Addedfind-up@2.1.0(transitive)
+ Addedget-caller-file@1.0.3(transitive)
+ Addedget-stream@3.0.0(transitive)
+ Addedinvert-kv@1.0.0(transitive)
+ Addedis-fullwidth-code-point@1.0.02.0.0(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedlcid@1.0.0(transitive)
+ Addedlocate-path@2.0.0(transitive)
+ Addedlru-cache@4.1.5(transitive)
+ Addedmem@1.1.0(transitive)
+ Addedmimic-fn@1.2.0(transitive)
+ Addednpm-run-path@2.0.2(transitive)
+ Addednumber-is-nan@1.0.1(transitive)
+ Addedos-locale@2.1.0(transitive)
+ Addedp-finally@1.0.0(transitive)
+ Addedp-limit@1.3.0(transitive)
+ Addedp-locate@2.0.0(transitive)
+ Addedp-try@1.0.0(transitive)
+ Addedpath-exists@3.0.0(transitive)
+ Addedpath-key@2.0.1(transitive)
+ Addedpseudomap@1.0.2(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedrequire-main-filename@1.0.1(transitive)
+ Addedset-blocking@2.0.0(transitive)
+ Addedshebang-command@1.2.0(transitive)
+ Addedshebang-regex@1.0.0(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedstring-width@1.0.22.1.1(transitive)
+ Addedstrip-ansi@3.0.14.0.0(transitive)
+ Addedstrip-eof@1.0.0(transitive)
+ Addedwhich@1.3.1(transitive)
+ Addedwhich-module@2.0.1(transitive)
+ Addedwrap-ansi@2.1.0(transitive)
+ Addedy18n@3.2.2(transitive)
+ Addedyallist@2.1.2(transitive)
+ Addedyargs@11.0.0(transitive)
+ Addedyargs-parser@9.0.2(transitive)
- Removedargparse@1.0.9
- Removedtslib@1.7.1
- Removedargparse@1.0.9(transitive)
- Removedsprintf-js@1.0.3(transitive)
- Removedtslib@1.7.1(transitive)
Updatedtypescript@^2.5.1