22[ ![ 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 )
33[ ![ 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 )
44
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 .
66
77## Installation ##
88This plugin requires minimum ** webpack 2** , ** typescript 2.1** and optionally ** tslint 5.0**
99``` sh
10- npm install --save fork-ts-checker-webpack-plugin
10+ npm install --save-dev fork-ts-checker-webpack-plugin
1111```
1212Basic webpack config (with [ ts-loader] ( https://github.com/TypeStrong/ts-loader ) )
1313``` js
@@ -43,18 +43,17 @@ var webpackConfig = {
4343
4444## Motivation ##
4545There 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.
5251
5352## Options ##
5453** tsconfig** ` string ` - Path to tsconfig.json file. If not set, plugin will use ` path.resolve(compiler.options.context, './tsconfig.json') ` .
5554
5655** 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.
5857
5958** watch** ` string | string[] ` - Directories or files to watch by service. Not necessary but improves performance
6059 (reduces number of ` fs.stat ` calls).
@@ -72,18 +71,17 @@ power.
7271
7372** silent** ` boolean ` - If ` true ` , logger will not be used. Default: ` false ` .
7473
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** .
8179 Default: ` ForkTsCheckerWebpackPlugin.ONE_CPU ` .
8280
8381Pre-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)
8785
8886** memoryLimit** ` number ` - Memory limit for service process in MB. If service exits with allocation failed error, increase this number.
8987 Default: ` 2048 ` .
@@ -96,6 +94,7 @@ This plugin provides some custom webpack hooks (all are sync):
9694| ` fork-ts-checker-cancel ` | Cancellation has been requested | ` cancellationToken ` |
9795| ` fork-ts-checker-waiting ` | Waiting for results | ` hasTsLint ` |
9896| ` 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 ` |
9998| ` fork-ts-checker-service-out-of-memory ` | Service is out of memory | - |
10099| ` fork-ts-checker-receive ` | Plugin receives diagnostics and lints from service | ` diagnostics ` , ` lints ` |
101100| ` fork-ts-checker-emit ` | Service will add errors and warnings to webpack compilation (` blockEmit: true ` ) | ` diagnostics ` , ` lints ` , ` elapsed ` |
0 commit comments