You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+27-99Lines changed: 27 additions & 99 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,9 @@
15
15
16
16
## Installation
17
17
18
-
This plugin requires minimum **webpack 2.3**, **TypeScript 2.1** and optionally **ESLint 6.0.0** or **TSLint 4.0**
18
+
This plugin requires minimum **Node.js 6.11.5**, **webpack 4**, **TypeScript 2.1** and optionally **ESLint 6** (which itself requires minimum **Node.js 8.10.0**)
19
+
20
+
If you depend on **webpack 2**, **webpack 3**, or **tslint 4**, please use [older version](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/tree/v3.1.1) of the plugin.
19
21
20
22
```sh
21
23
# with npm
@@ -56,7 +58,7 @@ add `CheckerPlugin` and delegate checker to the separate process. The problem wi
56
58
it was a lot slower than [ts-loader](https://github.com/TypeStrong/ts-loader) on an incremental build (~20s vs ~3s).
57
59
Secondly, we used [tslint](https://palantir.github.io/tslint) and we wanted to run this, along with type checker, in a separate process.
58
60
This is why this plugin was created. To provide better performance, the plugin reuses Abstract Syntax Trees between compilations and shares
59
-
these trees with TSLint. It can be scaled with a multi-process mode to utilize maximum CPU power.
61
+
these trees with TSLint.
60
62
61
63
## Modules resolution
62
64
@@ -98,17 +100,6 @@ module.exports = {
98
100
99
101
There's a good explanation on setting up TypeScript ESLint support by Robert Cooper [here](https://dev.to/robertcoopercode/using-eslint-and-prettier-in-a-typescript-project-53jb).
100
102
101
-
## TSLint
102
-
103
-
*[TSLint is being replaced by ESLint](https://medium.com/palantir/tslint-in-2019-1a144c2317a9).
104
-
https://eslint.org/blog/2019/01/future-typescript-eslint. As a consequence, support for TSLint in fork-ts-checker-webpack-plugin will be deprecated and removed in future versions of the plugin.*
105
-
106
-
If you have installed [tslint](https://palantir.github.io/tslint), you can enable it by setting `tslint: true` or
107
-
`tslint: './path/to/tslint.json'`. We recommend changing `defaultSeverity` to a `"warning"` in `tslint.json` file.
108
-
It helps to distinguish lints from TypeScript's diagnostics.
109
-
110
-
111
-
112
103
## Options
113
104
114
105
-**tsconfig**`string`:
@@ -124,37 +115,7 @@ It helps to distinguish lints from TypeScript's diagnostics.
124
115
-**eslintOptions**`object`:
125
116
126
117
- Options that can be used to initialise ESLint. See https://eslint.org/docs/1.0.0/developer-guide/nodejs-api#cliengine
127
-
128
-
-**tslint**`string | true | undefined`:
129
-
130
-
- If `string`, path to _tslint.json_ file to check source files against.
131
-
- If `true`, path to `tslint.json` file will be computed with respect to currently checked file, just like TSLint
132
-
CLI would do. Suppose you have a project:
133
-
134
-
```
135
-
./
136
-
tslint.json
137
-
138
-
src/
139
-
file.ts
140
-
anotherFile.ts
141
-
142
-
lib/
143
-
tslint.json
144
-
someHelperFile.ts
145
-
```
146
-
147
-
In such a case `src/file.ts` and `src/anotherFile.ts` would be checked against root `tslint.json`, and
148
-
`src/lib/someHelperFile.ts` would be checked against `src/lib/tslint.json`.
149
-
150
-
Default: `undefined`.
151
-
152
-
- **tslintAutoFix** `boolean`:
153
-
Passes on `--fix` flag while running `tslint` to auto fix linting errors. Default: false.
154
-
155
-
- **watch** `string | string[]`:
156
-
Directories or files to watch by service. Not necessary but improves performance (reduces number of `fs.stat` calls). Not applicable when `useTypescriptIncrementalApi` is `true`, in which case watching is handled automatically.
157
-
118
+
158
119
-**async**`boolean`:
159
120
True by default - `async: false` can block webpack's emit to wait for type checker/linter and to add errors to the webpack's compilation.
160
121
We recommend to set this to `false` in projects where type checking is faster than webpack's build - it's better for integration with other plugins. Another scenario where you might want to set this to `false` is if you use the `overlay` functionality of `webpack-dev-server`.
@@ -163,7 +124,7 @@ It helps to distinguish lints from TypeScript's diagnostics.
163
124
List of TypeScript diagnostic codes to ignore.
164
125
165
126
-**ignoreLints**`string[]`:
166
-
List of tslint rule names to ignore.
127
+
List of eslint rule names to ignore.
167
128
168
129
-**ignoreLintWarnings**`boolean`:
169
130
If true, will ignore all lint warnings.
@@ -178,15 +139,12 @@ new ForkTsCheckerWebpackPlugin({
178
139
});
179
140
```
180
141
181
-
-**colors**`boolean`:
182
-
If `false`, disables built-in colors in logger messages. Default: `true`.
183
-
184
142
-**logger**`object`:
185
143
Logger instance. It should be object that implements method: `error`, `warn`, `info`. Default: `console`.
If `true` or `enabled: true`, the linter and compiler will process VueJs single-file-component (.vue) files. See the
211
163
[Vue section](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin#vue) further down for information on how to correctly setup your project.
212
164
213
165
-**useTypescriptIncrementalApi**`boolean`:
214
-
If true, the plugin will use incremental compilation API introduced in TypeScript 2.7. In this mode you can only have 1
215
-
worker, but if the changes in your code are small (like you normally have when you work in 'watch' mode), the compilation
216
-
may be much faster, even compared to multi-threaded compilation. Defaults to `true` when working with TypeScript 3+ and `false` when below 3. The default can be overridden by directly specifying a value.
166
+
If true, the plugin will use incremental compilation API introduced in TypeScript 2.7. Defaults to `true` when working with TypeScript 3+ and `false` when below 3. The default can be overridden by directly specifying a value.
167
+
Don't use it together with VueJs enabled - it's not supported yet.
217
168
218
169
-**measureCompilationTime**`boolean`:
219
170
If true, the plugin will measure the time spent inside the compilation code. This may be useful to compare modes,
220
-
especially if there are other loaders/plugins involved in the compilation. **requires node 8+**
171
+
especially if there are other loaders/plugins involved in the compilation. **requires Node.js >= 8.5.0**
221
172
222
173
-**typescript**`string`:
223
174
If supplied this is a custom path where `typescript` can be found. Defaults to `require.resolve('typescript')`.
@@ -266,13 +217,6 @@ new ForkTsCheckerWebpackPlugin({
266
217
267
218
</details>
268
219
269
-
### Pre-computed consts:
270
-
271
-
-`ForkTsCheckerWebpackPlugin.ONE_CPU` - always use one CPU
272
-
-`ForkTsCheckerWebpackPlugin.ALL_CPUS` - always use all CPUs (will increase build time)
273
-
-`ForkTsCheckerWebpackPlugin.ONE_CPU_FREE` - leave only one CPU for build (probably will increase build time)
274
-
-`ForkTsCheckerWebpackPlugin.TWO_CPUS_FREE` - **recommended** - leave two CPUs free (one for build, one for system)
275
-
276
220
## Different behaviour in watch mode
277
221
278
222
If you turn on [webpacks watch mode](https://webpack.js.org/configuration/watch/#watch) the `fork-ts-checker-notifier-webpack-plugin` will take care of logging type errors, _not_ webpack itself. That means if you set `silent: true` you won't see type errors in your console in watch mode.
@@ -293,26 +237,21 @@ We hope this will be resolved in future; the issue can be tracked [here](https:/
293
237
294
238
This plugin provides some custom webpack hooks (all are sync):
|`cancel`| Cancellation has been requested |`cancellationToken`|
243
+
|`waiting`| Waiting for results | - |
244
+
|`serviceBeforeStart`| Async plugin that can be used for delaying `fork-ts-checker-service-start`| - |
245
+
|`serviceStart`| Service will be started |`tsconfigPath`, `memoryLimit`|
246
+
|`serviceStartError`| Cannot start service |`error`|
247
+
|`serviceOutOfMemory`| Service is out of memory | - |
248
+
|`receive`| Plugin receives diagnostics and lints from service |`diagnostics`, `lints`|
249
+
|`emit`| Service will add errors and warnings to webpack compilation ('build' mode) |`diagnostics`, `lints`, `elapsed`|
250
+
|`done`| Service finished type checking and webpack finished compilation ('watch' mode) |`diagnostics`, `lints`, `elapsed`|
311
251
312
252
### Accessing plugin hooks
313
253
314
-
All plugin hooks are compatible with both [webpack](https://webpack.js.org) version
315
-
4 and version 2. To access plugin hooks and tap into the event, we need to use
254
+
To access plugin hooks and tap into the event, we need to use
316
255
the `getCompilerHooks` static method. When we call this method with a [webpack compiler instance](https://webpack.js.org/api/node/),
317
256
it returns the series of [tapable](https://github.com/webpack/tapable)
318
257
hooks where you can pass in your callbacks.
@@ -404,14 +343,12 @@ if ('compilers' in compiler) {
404
343
405
344
```js
406
345
newForkTsCheckerWebpackPlugin({
407
-
tslint:true,
408
346
vue:true
409
347
});
410
348
```
411
349
Optionally change default [vue-template-compiler](https://github.com/vuejs/vue/tree/dev/packages/vue-template-compiler) to [nativescript-vue-template-compiler](https://github.com/nativescript-vue/nativescript-vue/tree/master/packages/nativescript-vue-template-compiler) if you use [nativescript-vue](https://github.com/nativescript-vue/nativescript-vue)
@@ -446,16 +383,7 @@ new ForkTsCheckerWebpackPlugin({
446
383
},
447
384
```
448
385
449
-
4. Add rules to your `tslint.json` and they will be applied to Vue files. For example, you could apply the Standard JS rules [tslint-config-standard](https://github.com/blakeembrey/tslint-config-standard) like this:
450
-
451
-
```json
452
-
{
453
-
"defaultSeverity": "error",
454
-
"extends": ["tslint-config-standard"]
455
-
}
456
-
```
457
-
458
-
5. Ensure your `tsconfig.json` includes .vue files:
386
+
4. Ensure your `tsconfig.json` includes .vue files:
459
387
460
388
```js
461
389
// tsconfig.json
@@ -470,7 +398,7 @@ new ForkTsCheckerWebpackPlugin({
470
398
}
471
399
```
472
400
473
-
6. It accepts any wildcard in your TypeScript configuration:
401
+
5. It accepts any wildcard in your TypeScript configuration:
474
402
475
403
```js
476
404
// tsconfig.json
@@ -495,7 +423,7 @@ new ForkTsCheckerWebpackPlugin({
495
423
importHellofrom'@/components/hello.vue'
496
424
```
497
425
498
-
7. If you are working in **VSCode**, you can get extensions[Vetur](https://marketplace.visualstudio.com/items?itemName=octref.vetur)and [TSLint Vue](https://marketplace.visualstudio.com/items?itemName=prograhammer.tslint-vue) to complete the developer workflow.
426
+
6. If you are working in **VSCode**, you can get the[Vetur](https://marketplace.visualstudio.com/items?itemName=octref.vetur)extension to complete the developer workflow.
0 commit comments