fork-ts-checker-webpack-plugin 6.0.4 → 6.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -6
- package/lib/ForkTsCheckerWebpackPlugin.js +1 -1
- package/lib/hooks/tapAfterEnvironmentToPatchWatching.js +1 -1
- package/lib/hooks/tapDoneToAsyncGetIssues.js +3 -1
- package/lib/hooks/tapStartToConnectAndRunReporter.js +2 -6
- package/lib/reporter/FilesChange.d.ts +5 -1
- package/lib/reporter/FilesChange.js +13 -0
- package/lib/watch/InclusiveNodeWatchFileSystem.d.ts +3 -3
- package/lib/watch/InclusiveNodeWatchFileSystem.js +9 -15
- package/package.json +1 -1
- package/lib/hooks/getChangedFiles.d.ts +0 -3
- package/lib/hooks/getChangedFiles.js +0 -14
- package/lib/hooks/getDeletedFiles.d.ts +0 -3
- package/lib/hooks/getDeletedFiles.js +0 -14
- package/lib/hooks/getWatcher.d.ts +0 -8
- package/lib/hooks/getWatcher.js +0 -11
package/README.md
CHANGED
|
@@ -187,13 +187,51 @@ Options for the ESLint linter (`eslint` option object).
|
|
|
187
187
|
|
|
188
188
|
### Issues options
|
|
189
189
|
|
|
190
|
-
Options for the issues filtering (`
|
|
190
|
+
Options for the issues filtering (`issue` option object).
|
|
191
|
+
I could write some plain text explanation of these options but I think code will explain it better:
|
|
191
192
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
193
|
+
```typescript
|
|
194
|
+
interface Issue {
|
|
195
|
+
origin: 'typescript' | 'eslint';
|
|
196
|
+
severity: 'error' | 'warning';
|
|
197
|
+
code: string;
|
|
198
|
+
file?: string;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
type IssueMatch = Partial<Issue>; // file field supports glob matching
|
|
202
|
+
type IssuePredicate = (issue: Issue) => boolean;
|
|
203
|
+
type IssueFilter = IssueMatch | IssuePredicate | (IssueMatch | IssuePredicate)[];
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
| Name | Type | Default value | Description |
|
|
207
|
+
| --------- | ------------- | ------------- | ----------- |
|
|
208
|
+
| `include` | `IssueFilter` | `undefined` | If `object`, defines issue properties that should be [matched](./src/issue/IssueMatch.ts). If `function`, acts as a predicate where `issue` is an argument. |
|
|
209
|
+
| `exclude` | `IssueFilter` | `undefined` | Same as `include` but issues that match this predicate will be excluded. |
|
|
210
|
+
|
|
211
|
+
<details>
|
|
212
|
+
<summary>Expand example</summary>
|
|
213
|
+
|
|
214
|
+
Include issues from the `src` directory, exclude eslint issues from `.spec.ts` files:
|
|
215
|
+
|
|
216
|
+
```js
|
|
217
|
+
module.exports = {
|
|
218
|
+
// ...the webpack configuration
|
|
219
|
+
plugins: [
|
|
220
|
+
new ForkTsCheckerWebpackPlugin({
|
|
221
|
+
issue: {
|
|
222
|
+
include: [
|
|
223
|
+
{ file: '**/src/**/*' }
|
|
224
|
+
],
|
|
225
|
+
exclude: [
|
|
226
|
+
{ origin: 'eslint', file: '**/*.spec.ts' }
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
})
|
|
230
|
+
]
|
|
231
|
+
};
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
</details>
|
|
197
235
|
|
|
198
236
|
## Vue.js
|
|
199
237
|
|
|
@@ -60,4 +60,4 @@ class ForkTsCheckerWebpackPlugin {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
exports.ForkTsCheckerWebpackPlugin = ForkTsCheckerWebpackPlugin;
|
|
63
|
-
ForkTsCheckerWebpackPlugin.version = '6.0.
|
|
63
|
+
ForkTsCheckerWebpackPlugin.version = '6.0.8'; // will be replaced by the @semantic-release/exec
|
|
@@ -6,7 +6,7 @@ function tapAfterEnvironmentToPatchWatching(compiler, state) {
|
|
|
6
6
|
const watchFileSystem = compiler.watchFileSystem;
|
|
7
7
|
if (watchFileSystem) {
|
|
8
8
|
// wrap original watch file system
|
|
9
|
-
compiler.watchFileSystem = new InclusiveNodeWatchFileSystem_1.InclusiveNodeWatchFileSystem(watchFileSystem, state);
|
|
9
|
+
compiler.watchFileSystem = new InclusiveNodeWatchFileSystem_1.InclusiveNodeWatchFileSystem(watchFileSystem, compiler, state);
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
}
|
|
@@ -63,7 +63,9 @@ function tapDoneToAsyncGetIssues(compiler, configuration, state) {
|
|
|
63
63
|
else {
|
|
64
64
|
configuration.logger.issues.log(chalk_1.default.green('No issues found.'));
|
|
65
65
|
}
|
|
66
|
-
if
|
|
66
|
+
// report issues to webpack-dev-server, if it's listening
|
|
67
|
+
// skip reporting if there are no issues, to avoid an extra hot reload
|
|
68
|
+
if (issues.length && state.webpackDevServerDoneTap) {
|
|
67
69
|
issues.forEach((issue) => {
|
|
68
70
|
const error = new IssueWebpackError_1.IssueWebpackError(configuration.formatter(issue), issue);
|
|
69
71
|
if (issue.severity === 'warning') {
|
|
@@ -10,8 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const pluginHooks_1 = require("./pluginHooks");
|
|
13
|
-
const
|
|
14
|
-
const getChangedFiles_1 = require("./getChangedFiles");
|
|
13
|
+
const reporter_1 = require("../reporter");
|
|
15
14
|
const OperationCanceledError_1 = require("../error/OperationCanceledError");
|
|
16
15
|
const tapDoneToAsyncGetIssues_1 = require("./tapDoneToAsyncGetIssues");
|
|
17
16
|
const tapAfterCompileToGetIssues_1 = require("./tapAfterCompileToGetIssues");
|
|
@@ -45,10 +44,7 @@ function tapStartToConnectAndRunReporter(compiler, reporter, configuration, stat
|
|
|
45
44
|
}
|
|
46
45
|
let change = {};
|
|
47
46
|
if (state.watching) {
|
|
48
|
-
change =
|
|
49
|
-
changedFiles: getChangedFiles_1.getChangedFiles(compilation.compiler),
|
|
50
|
-
deletedFiles: getDeletedFiles_1.getDeletedFiles(compilation.compiler),
|
|
51
|
-
};
|
|
47
|
+
change = reporter_1.getFilesChange(compiler);
|
|
52
48
|
configuration.logger.infrastructure.info([
|
|
53
49
|
'Calling reporter service for incremental check.',
|
|
54
50
|
` Changed files: ${JSON.stringify(change.changedFiles)}`,
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { Compiler } from 'webpack';
|
|
1
2
|
interface FilesChange {
|
|
2
3
|
changedFiles?: string[];
|
|
3
4
|
deletedFiles?: string[];
|
|
4
5
|
}
|
|
6
|
+
declare function getFilesChange(compiler: Compiler): FilesChange;
|
|
7
|
+
declare function updateFilesChange(compiler: Compiler, change: FilesChange): void;
|
|
8
|
+
declare function clearFilesChange(compiler: Compiler): void;
|
|
5
9
|
/**
|
|
6
10
|
* Computes aggregated files change based on the subsequent files changes.
|
|
7
11
|
*
|
|
@@ -9,4 +13,4 @@ interface FilesChange {
|
|
|
9
13
|
* @returns Files change that represents all subsequent changes as a one event
|
|
10
14
|
*/
|
|
11
15
|
declare function aggregateFilesChanges(changes: FilesChange[]): FilesChange;
|
|
12
|
-
export { FilesChange, aggregateFilesChanges };
|
|
16
|
+
export { FilesChange, getFilesChange, updateFilesChange, clearFilesChange, aggregateFilesChanges };
|
|
@@ -5,6 +5,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const substract_1 = __importDefault(require("../utils/array/substract"));
|
|
7
7
|
const unique_1 = __importDefault(require("../utils/array/unique"));
|
|
8
|
+
const compilerFilesChangeMap = new WeakMap();
|
|
9
|
+
function getFilesChange(compiler) {
|
|
10
|
+
return compilerFilesChangeMap.get(compiler) || {};
|
|
11
|
+
}
|
|
12
|
+
exports.getFilesChange = getFilesChange;
|
|
13
|
+
function updateFilesChange(compiler, change) {
|
|
14
|
+
compilerFilesChangeMap.set(compiler, aggregateFilesChanges([getFilesChange(compiler), change]));
|
|
15
|
+
}
|
|
16
|
+
exports.updateFilesChange = updateFilesChange;
|
|
17
|
+
function clearFilesChange(compiler) {
|
|
18
|
+
compilerFilesChangeMap.delete(compiler);
|
|
19
|
+
}
|
|
20
|
+
exports.clearFilesChange = clearFilesChange;
|
|
8
21
|
/**
|
|
9
22
|
* Computes aggregated files change based on the subsequent files changes.
|
|
10
23
|
*
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
|
|
2
2
|
import { FSWatcher } from 'chokidar';
|
|
3
3
|
import { Watcher, WatchFileSystem, WatchFileSystemOptions } from './WatchFileSystem';
|
|
4
|
+
import { Compiler } from 'webpack';
|
|
4
5
|
declare class InclusiveNodeWatchFileSystem implements WatchFileSystem {
|
|
5
6
|
private watchFileSystem;
|
|
7
|
+
private compiler;
|
|
6
8
|
private pluginState;
|
|
7
9
|
get watcher(): import("./WatchFileSystem").Watchpack;
|
|
8
|
-
readonly changedFiles: Set<string>;
|
|
9
|
-
readonly removedFiles: Set<string>;
|
|
10
10
|
readonly dirsWatchers: Map<string, FSWatcher | undefined>;
|
|
11
|
-
constructor(watchFileSystem: WatchFileSystem, pluginState: ForkTsCheckerWebpackPluginState);
|
|
11
|
+
constructor(watchFileSystem: WatchFileSystem, compiler: Compiler, pluginState: ForkTsCheckerWebpackPluginState);
|
|
12
12
|
private paused;
|
|
13
13
|
watch(files: Iterable<string>, dirs: Iterable<string>, missing: Iterable<string>, startTime?: number, options?: Partial<WatchFileSystemOptions>, callback?: Function, callbackUndelayed?: Function): Watcher;
|
|
14
14
|
}
|
|
@@ -5,17 +5,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const chokidar_1 = __importDefault(require("chokidar"));
|
|
7
7
|
const path_1 = require("path");
|
|
8
|
+
const reporter_1 = require("../reporter");
|
|
8
9
|
const IGNORED_DIRS = ['node_modules', '.git', '.yarn', '.pnp'];
|
|
9
10
|
function isIgnored(path) {
|
|
10
11
|
return IGNORED_DIRS.some((ignoredDir) => path.includes(`/${ignoredDir}/`));
|
|
11
12
|
}
|
|
12
13
|
class InclusiveNodeWatchFileSystem {
|
|
13
|
-
constructor(watchFileSystem, pluginState) {
|
|
14
|
+
constructor(watchFileSystem, compiler, pluginState) {
|
|
14
15
|
this.watchFileSystem = watchFileSystem;
|
|
16
|
+
this.compiler = compiler;
|
|
15
17
|
this.pluginState = pluginState;
|
|
16
18
|
this.paused = true;
|
|
17
|
-
this.changedFiles = new Set();
|
|
18
|
-
this.removedFiles = new Set();
|
|
19
19
|
this.dirsWatchers = new Map();
|
|
20
20
|
}
|
|
21
21
|
get watcher() {
|
|
@@ -24,20 +24,17 @@ class InclusiveNodeWatchFileSystem {
|
|
|
24
24
|
}
|
|
25
25
|
watch(files, dirs, missing, startTime, options, callback, callbackUndelayed) {
|
|
26
26
|
var _a, _b, _c;
|
|
27
|
-
this.
|
|
28
|
-
this.removedFiles.clear();
|
|
27
|
+
reporter_1.clearFilesChange(this.compiler);
|
|
29
28
|
// use standard watch file system for files and missing
|
|
30
29
|
const standardWatcher = this.watchFileSystem.watch(files, dirs, missing, startTime, options, callback, callbackUndelayed);
|
|
31
30
|
(_a = this.watcher) === null || _a === void 0 ? void 0 : _a.on('change', (file) => {
|
|
32
31
|
if (typeof file === 'string' && !isIgnored(file)) {
|
|
33
|
-
this.changedFiles
|
|
34
|
-
this.removedFiles.delete(file);
|
|
32
|
+
reporter_1.updateFilesChange(this.compiler, { changedFiles: [file] });
|
|
35
33
|
}
|
|
36
34
|
});
|
|
37
35
|
(_b = this.watcher) === null || _b === void 0 ? void 0 : _b.on('remove', (file) => {
|
|
38
36
|
if (typeof file === 'string' && !isIgnored(file)) {
|
|
39
|
-
this.
|
|
40
|
-
this.changedFiles.delete(file);
|
|
37
|
+
reporter_1.updateFilesChange(this.compiler, { deletedFiles: [file] });
|
|
41
38
|
}
|
|
42
39
|
});
|
|
43
40
|
// calculate what to change
|
|
@@ -74,8 +71,7 @@ class InclusiveNodeWatchFileSystem {
|
|
|
74
71
|
if (!supportedExtensions.includes(extension)) {
|
|
75
72
|
return;
|
|
76
73
|
}
|
|
77
|
-
this.changedFiles
|
|
78
|
-
this.removedFiles.delete(file);
|
|
74
|
+
reporter_1.updateFilesChange(this.compiler, { changedFiles: [file] });
|
|
79
75
|
const mtime = (stats === null || stats === void 0 ? void 0 : stats.mtimeMs) || (stats === null || stats === void 0 ? void 0 : stats.ctimeMs) || 1;
|
|
80
76
|
(_b = this.watcher) === null || _b === void 0 ? void 0 : _b._onChange(dirToWatch, mtime, file, 'rename');
|
|
81
77
|
});
|
|
@@ -89,16 +85,14 @@ class InclusiveNodeWatchFileSystem {
|
|
|
89
85
|
if (!supportedExtensions.includes(extension)) {
|
|
90
86
|
return;
|
|
91
87
|
}
|
|
92
|
-
this.
|
|
93
|
-
this.changedFiles.delete(file);
|
|
88
|
+
reporter_1.updateFilesChange(this.compiler, { deletedFiles: [file] });
|
|
94
89
|
(_b = this.watcher) === null || _b === void 0 ? void 0 : _b._onRemove(dirToWatch, file, 'rename');
|
|
95
90
|
});
|
|
96
91
|
this.dirsWatchers.set(dirToWatch, dirWatcher);
|
|
97
92
|
});
|
|
98
93
|
this.paused = false;
|
|
99
94
|
return Object.assign(Object.assign({}, standardWatcher), { close: () => {
|
|
100
|
-
this.
|
|
101
|
-
this.removedFiles.clear();
|
|
95
|
+
reporter_1.clearFilesChange(this.compiler);
|
|
102
96
|
if (standardWatcher) {
|
|
103
97
|
standardWatcher.close();
|
|
104
98
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const path_1 = __importDefault(require("path"));
|
|
7
|
-
function getChangedFiles(compiler) {
|
|
8
|
-
const watchFileSystem = compiler
|
|
9
|
-
.watchFileSystem;
|
|
10
|
-
return watchFileSystem
|
|
11
|
-
? Array.from(watchFileSystem.changedFiles).map((changedFile) => path_1.default.normalize(changedFile))
|
|
12
|
-
: [];
|
|
13
|
-
}
|
|
14
|
-
exports.getChangedFiles = getChangedFiles;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const path_1 = __importDefault(require("path"));
|
|
7
|
-
function getDeletedFiles(compiler) {
|
|
8
|
-
const watchFileSystem = compiler
|
|
9
|
-
.watchFileSystem;
|
|
10
|
-
return watchFileSystem
|
|
11
|
-
? Array.from(watchFileSystem.removedFiles).map((removeFile) => path_1.default.normalize(removeFile))
|
|
12
|
-
: [];
|
|
13
|
-
}
|
|
14
|
-
exports.getDeletedFiles = getDeletedFiles;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import webpack from 'webpack';
|
|
3
|
-
import { EventEmitter } from 'events';
|
|
4
|
-
interface Watcher extends EventEmitter {
|
|
5
|
-
mtimes: Record<string, number>;
|
|
6
|
-
}
|
|
7
|
-
declare function getWatcher(compiler: webpack.Compiler): Watcher | undefined;
|
|
8
|
-
export { getWatcher, Watcher };
|
package/lib/hooks/getWatcher.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function getWatcher(compiler) {
|
|
4
|
-
// webpack 4
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
-
const { watchFileSystem } = compiler;
|
|
7
|
-
if (watchFileSystem) {
|
|
8
|
-
return watchFileSystem.watcher || (watchFileSystem.wfs && watchFileSystem.wfs.watcher);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.getWatcher = getWatcher;
|