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
* Adds support for custom compilers to CompilerHost
* Attaches the options to the plugin
* Adds support for IncrementalChecker
* Adds a test
* Updates the README
* Fixes undefined env values on Node 8
* Bumps version
* Avoids any
Copy file name to clipboardExpand all lines: CHANGELOG.md
+7-3
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,7 @@
1
+
## v1.1.0
2
+
3
+
*[Add new custom resolution options](https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/250)
4
+
1
5
## v1.0.4
2
6
3
7
*[gracefully handle error thrown from the service](https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/249)
@@ -8,7 +12,7 @@
8
12
9
13
## v1.0.2
10
14
11
-
*[Fix ignoreLintWarning mark warnings as errors](https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/243)
15
+
*[Fix ignoreLintWarning mark warnings as errors](https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/243)
12
16
13
17
## v1.0.1
14
18
@@ -20,7 +24,7 @@
20
24
21
25
This is the first major version of `fork-ts-checker-webpack-plugin`. A long time coming :-)
22
26
23
-
There are actually no breaking changes that we're aware of; users of 0.x `fork-ts-checker-webpack-plugin` should be be able to upgrade without any drama. Users of TypeScript 3+ may notice a performance improvement as by default the plugin now uses the [incremental watch API](https://github.com/Microsoft/TypeScript/pull/20234) in TypeScript. Should this prove problematic you can opt out of using it by supplying `useTypescriptIncrementalApi: false`.
27
+
There are actually no breaking changes that we're aware of; users of 0.x `fork-ts-checker-webpack-plugin` should be be able to upgrade without any drama. Users of TypeScript 3+ may notice a performance improvement as by default the plugin now uses the [incremental watch API](https://github.com/Microsoft/TypeScript/pull/20234) in TypeScript. Should this prove problematic you can opt out of using it by supplying `useTypescriptIncrementalApi: false`.
24
28
25
29
We are aware of an [issue with Vue and the incremental API](https://github.com/Realytics/fork-ts-checker-webpack-plugin/issues/219). We hope it will be fixed soon - a generous member of the community is taking a look. In the meantime, we will *not* default to using the incremental watch API when in Vue mode.
26
30
@@ -79,7 +83,7 @@ Version `1.x` additionally supports webpack 5 alongside webpack 4, whose hooks a
Webpack plugin that runs typescript type checker on a separate process.
6
-
6
+
7
7
## Installation
8
8
This plugin requires minimum **webpack 2.3**, **typescript 2.1** and optionally **tslint 4.0**
9
9
```sh
@@ -23,7 +23,7 @@ var webpackConfig = {
23
23
loader:'ts-loader',
24
24
options: {
25
25
// disable type checker - we will use it in fork plugin
26
-
transpileOnly:true
26
+
transpileOnly:true
27
27
}
28
28
}
29
29
]
@@ -39,21 +39,21 @@ There is already similar solution - [awesome-typescript-loader](https://github.c
39
39
add `CheckerPlugin` and delegate checker to the separate process. The problem with `awesome-typescript-loader` was that, in our case,
40
40
it was a lot slower than [ts-loader](https://github.com/TypeStrong/ts-loader) on an incremental build (~20s vs ~3s).
41
41
Secondly, we use [tslint](https://palantir.github.io/tslint) and we wanted to run this, along with type checker, in a separate process.
42
-
This is why we've created this plugin. To provide better performance, plugin reuses Abstract Syntax Trees between compilations and shares
42
+
This is why we've created this plugin. To provide better performance, plugin reuses Abstract Syntax Trees between compilations and shares
43
43
these trees with tslint. It can be scaled with a multi-process mode to utilize maximum CPU power.
44
44
45
45
## Modules resolution
46
-
It's very important to be aware that **this plugin uses [typescript](https://github.com/Microsoft/TypeScript)'s, not
47
-
[webpack](https://github.com/webpack/webpack)'s modules resolution**. It means that you have to setup `tsconfig.json` correctly. For example
48
-
if you set `files: ['./src/someFile.ts']` in `tsconfig.json`, this plugin will check only `someFile.ts` for semantic errors. It's because
49
-
of performance. The goal of this plugin is to be *as fast as possible*. With typescript's module resolution we don't have to wait for webpack
46
+
It's very important to be aware that **this plugin uses [typescript](https://github.com/Microsoft/TypeScript)'s, not
47
+
[webpack](https://github.com/webpack/webpack)'s modules resolution**. It means that you have to setup `tsconfig.json` correctly. For example
48
+
if you set `files: ['./src/someFile.ts']` in `tsconfig.json`, this plugin will check only `someFile.ts` for semantic errors. It's because
49
+
of performance. The goal of this plugin is to be *as fast as possible*. With typescript's module resolution we don't have to wait for webpack
50
50
to compile files (which traverses dependency graph during compilation) - we have a full list of files from the begin.
51
51
52
52
To debug typescript's modules resolution, you can use `tsc --traceResolution` command.
53
53
54
54
## TSLint
55
-
If you have installed [tslint](https://palantir.github.io/tslint), you can enable it by setting `tslint: true` or
56
-
`tslint: './path/to/tslint.json'`. We recommend changing `defaultSeverity` to a `"warning"` in `tslint.json` file.
55
+
If you have installed [tslint](https://palantir.github.io/tslint), you can enable it by setting `tslint: true` or
56
+
`tslint: './path/to/tslint.json'`. We recommend changing `defaultSeverity` to a `"warning"` in `tslint.json` file.
57
57
It helps to distinguish lints from typescript's diagnostics.
Allows overriding TypeScript options. Should be specified in the same format as you would do for the `compilerOptions` property in tsconfig.json. Default: `{}`.
65
65
66
-
***tslint**`string | true | undefined`:
66
+
***tslint**`string | true | undefined`:
67
67
- If `string`, path to *tslint.json* file to check source files against.
68
68
- If `true`, path to `tslint.json` file will be computed with respect to currently checked file, just like TSLint
69
69
CLI would do. Suppose you have a project:
@@ -81,13 +81,13 @@ Allows overriding TypeScript options. Should be specified in the same format as
81
81
```
82
82
In such a case `src/file.ts` and `src/anotherFile.ts` would be checked against root `tslint.json`, and
83
83
`src/lib/someHelperFile.ts` would be checked against `src/lib/tslint.json`.
84
-
84
+
85
85
Default: `undefined`.
86
86
87
87
* **tslintAutoFix** `boolean `:
88
88
Passes on `--fix` flag while running `tslint` to auto fix linting errors. Default: false.
89
89
90
-
* **watch** `string | string[]`:
90
+
* **watch** `string | string[]`:
91
91
Directories or files to watch by service. Not necessary but improves performance (reduces number of `fs.stat` calls).
92
92
93
93
* **async** `boolean`:
@@ -97,13 +97,13 @@ We recommend to set this to `false` in projects where type checking is faster th
97
97
* **ignoreDiagnostics** `number[]`:
98
98
List of typescript diagnostic codes to ignore.
99
99
100
-
* **ignoreLints** `string[]`:
100
+
* **ignoreLints** `string[]`:
101
101
List of tslint rule names to ignore.
102
102
103
103
* **ignoreLintWarnings** `boolean`:
104
104
If true, will ignore all lint warnings.
105
105
106
-
* **reportFiles** `string[]`:
106
+
* **reportFiles** `string[]`:
107
107
Only report errors on files matching these glob patterns. This can be useful when certain types definitions have errors that are not fatal to your application. Default: `[]`. Please note that this may behave unexpectedly if using the incremental API as the incremental API doesn't look for global and semantic errors [if it has already found syntactic errors](https://github.com/Microsoft/TypeScript/blob/89386ddda7dafc63cb35560e05412487f47cc267/src/compiler/watch.ts#L141).
108
108
109
109
```js
@@ -127,25 +127,25 @@ Options passed to formatters (currently only `codeframe` - see [available option
127
127
***silent**`boolean`:
128
128
If `true`, logger will not be used. Default: `false`.
129
129
130
-
***checkSyntacticErrors**`boolean`:
130
+
***checkSyntacticErrors**`boolean`:
131
131
This option is useful if you're using ts-loader in `happyPackMode` with [HappyPack](https://github.com/amireh/happypack) or [thread-loader](https://github.com/webpack-contrib/thread-loader) to parallelise your builds. If `true` it will ensure that the plugin checks for *both* syntactic errors (eg `const array = [{} {}];`) and semantic errors (eg `const x: number = '1';`). By default the plugin only checks for semantic errors. This is because when ts-loader is used in `transpileOnly` mode, ts-loader will still report syntactic errors. When used in `happyPackMode` it does not. Default: `false`.
132
132
133
-
***memoryLimit**`number`:
133
+
***memoryLimit**`number`:
134
134
Memory limit for service process in MB. If service exits with allocation failed error, increase this number. Default: `2048`.
135
135
136
136
***workers**`number`:
137
-
You can split type checking to a few workers to speed-up increment build. **Be careful** - if you don't want to increase build time, you
137
+
You can split type checking to a few workers to speed-up increment build. **Be careful** - if you don't want to increase build time, you
138
138
should keep free 1 core for *build* and 1 core for a *system**(for example system with 4 CPUs should use max 2 workers)*. Second thing -
139
139
node doesn't share memory between workers - keep in mind that memory usage will increase. Be aware that in some scenarios increasing workers
140
140
number **can increase checking time**. Default: `ForkTsCheckerWebpackPlugin.ONE_CPU`.
141
141
142
142
***vue**`boolean`:
143
-
If `true`, the linter and compiler will process VueJs single-file-component (.vue) files. See the
143
+
If `true`, the linter and compiler will process VueJs single-file-component (.vue) files. See the
144
144
[Vue section](https://github.com/Realytics/fork-ts-checker-webpack-plugin#vue) further down for information on how to correctly setup your project.
145
145
146
146
***useTypescriptIncrementalApi**`boolean`:
147
-
If true, the plugin will use incremental compilation API introduced in typescript 2.7. In this mode you can only have 1
148
-
worker, but if the changes in your code are small (like you normally have when you work in 'watch' mode), the compilation
147
+
If true, the plugin will use incremental compilation API introduced in typescript 2.7. In this mode you can only have 1
148
+
worker, but if the changes in your code are small (like you normally have when you work in 'watch' mode), the compilation
149
149
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.
150
150
151
151
***measureCompilationTime**`boolean`:
@@ -155,7 +155,26 @@ especially if there are other loaders/plugins involved in the compilation. **req
155
155
***typescript**`string`:
156
156
If supplied this is a custom path where `typescript` can be found. Defaults to `require.resolve('typescript')`.
157
157
158
-
### Pre-computed consts:
158
+
***resolveModuleNameModule** and **resolveTypeReferenceDirectiveModule**`string`:
159
+
Both of those options refer to files on the disk that respectively export a `resolveModuleName` or a `resolveTypeReferenceDirectiveModule` function. These functions will be used to resolve the import statements and the `<reference types="...">` directives instead of the default TypeScript implementation. Check the following code for an example of what those functions should look like:
*`ForkTsCheckerWebpackPlugin.ONE_CPU` - always use one CPU
160
179
*`ForkTsCheckerWebpackPlugin.ALL_CPUS` - always use all CPUs (will increase build time)
161
180
*`ForkTsCheckerWebpackPlugin.ONE_CPU_FREE` - leave only one CPU for build (probably will increase build time)
@@ -188,7 +207,7 @@ This plugin provides some custom webpack hooks (all are sync):
188
207
|`fork-ts-checker-service-start`| Service will be started |`tsconfigPath`, `tslintPath`, `watchPaths`, `workersNumber`, `memoryLimit`|
189
208
|`fork-ts-checker-service-start-error`| Cannot start service |`error`|
190
209
|`fork-ts-checker-service-out-of-memory`| Service is out of memory | - |
191
-
|`fork-ts-checker-receive`| Plugin receives diagnostics and lints from service |`diagnostics`, `lints`|
210
+
|`fork-ts-checker-receive`| Plugin receives diagnostics and lints from service |`diagnostics`, `lints`|
192
211
|`fork-ts-checker-emit`| Service will add errors and warnings to webpack compilation ('build' mode) |`diagnostics`, `lints`, `elapsed`|
193
212
|`fork-ts-checker-done`| Service finished type checking and webpack finished compilation ('watch' mode) |`diagnostics`, `lints`, `elapsed`|
194
213
@@ -203,7 +222,7 @@ new ForkTsCheckerWebpackPlugin({
203
222
```
204
223
205
224
2. To activate TypeScript in your `.vue` files, you need to ensure your script tag's language attribute is set
206
-
to `ts` or `tsx` (also make sure you include the `.vue` extension in all your import statements as shown below):
225
+
to `ts` or `tsx` (also make sure you include the `.vue` extension in all your import statements as shown below):
207
226
208
227
```html
209
228
<scriptlang="ts">
@@ -213,7 +232,7 @@ import Hello from '@/components/hello.vue'
213
232
</script>
214
233
```
215
234
216
-
3. Ideally you are also using `ts-loader` (in transpileOnly mode). Your Webpack config rules may look something like this:
235
+
3. Ideally you are also using `ts-loader` (in transpileOnly mode). Your Webpack config rules may look something like this:
217
236
218
237
```js
219
238
{
@@ -231,7 +250,7 @@ import Hello from '@/components/hello.vue'
231
250
options: vueLoaderConfig
232
251
},
233
252
```
234
-
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:
253
+
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:
235
254
236
255
```json
237
256
{
@@ -241,7 +260,7 @@ import Hello from '@/components/hello.vue'
241
260
]
242
261
}
243
262
```
244
-
5. Ensure your `tsconfig.json` includes .vue files:
263
+
5. Ensure your `tsconfig.json` includes .vue files:
245
264
246
265
```js
247
266
// tsconfig.json
@@ -256,12 +275,12 @@ import Hello from '@/components/hello.vue'
256
275
}
257
276
```
258
277
259
-
6. It accepts any wildcard in your TypeScript configuration:
278
+
6. It accepts any wildcard in your TypeScript configuration:
0 commit comments