2
2
[ ![ Npm version] ( https://img.shields.io/npm/v/fork-ts-checker-webpack-plugin.svg?style=flat-square )] ( https://www.npmjs.com/package/fork-ts-checker-webpack-plugin )
3
3
[ ![ Build Status] ( https://travis-ci.org/Realytics/fork-ts-checker-webpack-plugin.svg?branch=master )] ( https://travis-ci.org/realytics/fork-ts-checker-webpack-plugin )
4
4
5
- Webpack plugin that runs typescript type checker (with optional linter) on separate processes .
5
+ Webpack plugin that runs typescript type checker on a separate process .
6
6
7
7
## Installation ##
8
8
This plugin requires minimum ** webpack 2** , ** typescript 2.1** and optionally ** tslint 5.0**
9
9
``` sh
10
- npm install --save fork-ts-checker-webpack-plugin
10
+ npm install --save-dev fork-ts-checker-webpack-plugin
11
11
```
12
12
Basic webpack config (with [ ts-loader] ( https://github.com/TypeStrong/ts-loader ) )
13
13
``` js
@@ -43,18 +43,17 @@ var webpackConfig = {
43
43
44
44
## Motivation ##
45
45
There is already similar solution - [ awesome-typescript-loader] ( https://github.com/s-panferov/awesome-typescript-loader ) . You can
46
- add ` CheckerPlugin ` and delegate checker to the separate process. The problem with ` awesome-typescript-loader ` is that it's a lot slower
47
- than [ ts-loader] ( https://github.com/TypeStrong/ts-loader ) on incremental build in our case (~ 20s vs ~ 3s).
48
- Secondly, we use [ tslint] ( https://palantir.github.io/tslint/ ) and we wanted to run this also on separate process.
49
- This is why we've created this plugin. The performance is great because of reusing Abstract Syntax Trees between compilations and sharing
50
- these trees with tslint. We can also scale checker with multi-process mode - it will split work between processes to utilize maximum cpu
51
- power.
46
+ add ` CheckerPlugin ` and delegate checker to the separate process. The problem with ` awesome-typescript-loader ` was that, in our case,
47
+ it was a lot slower than [ ts-loader] ( https://github.com/TypeStrong/ts-loader ) on an incremental build (~ 20s vs ~ 3s).
48
+ Secondly, we use [ tslint] ( https://palantir.github.io/tslint/ ) and we wanted to run this, along with type checker, in a separate process.
49
+ This is why we've created this plugin. To provide better performance, plugin reuses Abstract Syntax Trees between compilations and shares
50
+ these trees with tslint. It can be scaled with a multi-process mode to utilize maximum CPU power.
52
51
53
52
## Options ##
54
53
** tsconfig** ` string ` - Path to tsconfig.json file. If not set, plugin will use ` path.resolve(compiler.options.context, './tsconfig.json') ` .
55
54
56
55
** tslint** ` string | false ` - Path to tslint.json file. If not set, plugin will use ` path.resolve(compiler.options.context, './tslint.json') ` .
57
- If ` false ` , disables tslint.
56
+ If ` false ` , disables tslint.
58
57
59
58
** watch** ` string | string[] ` - Directories or files to watch by service. Not necessary but improves performance
60
59
(reduces number of ` fs.stat ` calls).
@@ -72,18 +71,17 @@ power.
72
71
73
72
** silent** ` boolean ` - If ` true ` , logger will not be used. Default: ` false ` .
74
73
75
- ** workers** ` number ` - You can split type checking to few workers to speed-up on increment build.
76
- ** Be careful** - if you don't want to increase build time, you should keep 1 core for * build* and 1 core for
77
- * system* free * (for example system with 4 cpu threads should use max 2 workers)* .
78
- Second thing - node doesn't share memory between workers so keep in mind that memory usage will increase
79
- linearly. If you want to use workers, please experiment with workers number. In some scenarios increasing this number
80
- ** can increase check time** (and of course memory consumption).
74
+ ** workers** ` number ` - You can split type checking to a few workers to speed-up increment build.
75
+ ** Be careful** - if you don't want to increase build time, you should keep free 1 core for * build* and 1 core for
76
+ a * system* * (for example system with 4 CPUs should use max 2 workers)* .
77
+ Second thing - node doesn't share memory between workers - keep in mind that memory usage will increase.
78
+ Be aware that in some scenarios increasing workers number ** can increase checking time** .
81
79
Default: ` ForkTsCheckerWebpackPlugin.ONE_CPU ` .
82
80
83
81
Pre-computed consts:
84
- * ` ForkTsCheckerWebpackPlugin.ONE_CPU ` - always use one cpu (core)
85
- * ` ForkTsCheckerWebpackPlugin.ONE_CPU_FREE ` - leave only one cpu for build (probably will increase build time)
86
- * ` ForkTsCheckerWebpackPlugin.TWO_CPUS_FREE ` - leave two cpus free (one for build, one for system)
82
+ * ` ForkTsCheckerWebpackPlugin.ONE_CPU ` - always use one CPU
83
+ * ` ForkTsCheckerWebpackPlugin.ONE_CPU_FREE ` - leave only one CPU for build (probably will increase build time)
84
+ * ` ForkTsCheckerWebpackPlugin.TWO_CPUS_FREE ` - leave two CPUs free (one for build, one for system)
87
85
88
86
** memoryLimit** ` number ` - Memory limit for service process in MB. If service exits with allocation failed error, increase this number.
89
87
Default: ` 2048 ` .
@@ -96,6 +94,7 @@ This plugin provides some custom webpack hooks (all are sync):
96
94
| ` fork-ts-checker-cancel ` | Cancellation has been requested | ` cancellationToken ` |
97
95
| ` fork-ts-checker-waiting ` | Waiting for results | ` hasTsLint ` |
98
96
| ` fork-ts-checker-service-start ` | Service will be started | ` tsconfigPath ` , ` tslintPath ` , ` watchPaths ` , ` workersNumber ` , ` memoryLimit ` |
97
+ | ` fork-ts-checker-service-start-error ` | Cannot start service | ` error ` |
99
98
| ` fork-ts-checker-service-out-of-memory ` | Service is out of memory | - |
100
99
| ` fork-ts-checker-receive ` | Plugin receives diagnostics and lints from service | ` diagnostics ` , ` lints ` |
101
100
| ` fork-ts-checker-emit ` | Service will add errors and warnings to webpack compilation (` blockEmit: true ` ) | ` diagnostics ` , ` lints ` , ` elapsed ` |
0 commit comments