fork-ts-checker-webpack-plugin 6.0.5 → 6.1.0
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.d.ts +8 -0
- package/lib/ForkTsCheckerWebpackPlugin.js +10 -1
- package/lib/hooks/tapDoneToAsyncGetIssues.js +3 -1
- package/lib/hooks/tapStartToConnectAndRunReporter.js +5 -3
- package/lib/utils/async/pool.d.ts +8 -0
- package/lib/utils/async/pool.js +45 -0
- package/package.json +1 -1
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
|
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import webpack from 'webpack';
|
|
2
2
|
import { ForkTsCheckerWebpackPluginOptions } from './ForkTsCheckerWebpackPluginOptions';
|
|
3
|
+
import { Pool } from './utils/async/pool';
|
|
3
4
|
declare class ForkTsCheckerWebpackPlugin implements webpack.Plugin {
|
|
5
|
+
/**
|
|
6
|
+
* Current version of the plugin
|
|
7
|
+
*/
|
|
4
8
|
static readonly version: string;
|
|
9
|
+
/**
|
|
10
|
+
* Default pool for the plugin concurrency limit
|
|
11
|
+
*/
|
|
12
|
+
static readonly pool: Pool;
|
|
5
13
|
private readonly options;
|
|
6
14
|
constructor(options?: ForkTsCheckerWebpackPluginOptions);
|
|
7
15
|
static getCompilerHooks(compiler: webpack.Compiler): {
|
|
@@ -20,6 +20,8 @@ const tapAfterCompileToAddDependencies_1 = require("./hooks/tapAfterCompileToAdd
|
|
|
20
20
|
const tapErrorToLogMessage_1 = require("./hooks/tapErrorToLogMessage");
|
|
21
21
|
const pluginHooks_1 = require("./hooks/pluginHooks");
|
|
22
22
|
const tapAfterEnvironmentToPatchWatching_1 = require("./hooks/tapAfterEnvironmentToPatchWatching");
|
|
23
|
+
const pool_1 = require("./utils/async/pool");
|
|
24
|
+
const os_1 = __importDefault(require("os"));
|
|
23
25
|
class ForkTsCheckerWebpackPlugin {
|
|
24
26
|
constructor(options = {}) {
|
|
25
27
|
const explorerSync = cosmiconfig_1.cosmiconfigSync('fork-ts-checker');
|
|
@@ -60,4 +62,11 @@ class ForkTsCheckerWebpackPlugin {
|
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
64
|
exports.ForkTsCheckerWebpackPlugin = ForkTsCheckerWebpackPlugin;
|
|
63
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Current version of the plugin
|
|
67
|
+
*/
|
|
68
|
+
ForkTsCheckerWebpackPlugin.version = '6.1.0'; // will be replaced by the @semantic-release/exec
|
|
69
|
+
/**
|
|
70
|
+
* Default pool for the plugin concurrency limit
|
|
71
|
+
*/
|
|
72
|
+
ForkTsCheckerWebpackPlugin.pool = pool_1.createPool(Math.max(1, os_1.default.cpus().length));
|
|
@@ -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') {
|
|
@@ -15,6 +15,7 @@ const OperationCanceledError_1 = require("../error/OperationCanceledError");
|
|
|
15
15
|
const tapDoneToAsyncGetIssues_1 = require("./tapDoneToAsyncGetIssues");
|
|
16
16
|
const tapAfterCompileToGetIssues_1 = require("./tapAfterCompileToGetIssues");
|
|
17
17
|
const interceptDoneToGetWebpackDevServerTap_1 = require("./interceptDoneToGetWebpackDevServerTap");
|
|
18
|
+
const ForkTsCheckerWebpackPlugin_1 = require("../ForkTsCheckerWebpackPlugin");
|
|
18
19
|
function tapStartToConnectAndRunReporter(compiler, reporter, configuration, state) {
|
|
19
20
|
const hooks = pluginHooks_1.getForkTsCheckerWebpackPluginHooks(compiler);
|
|
20
21
|
compiler.hooks.run.tap('ForkTsCheckerWebpackPlugin', () => {
|
|
@@ -67,7 +68,7 @@ function tapStartToConnectAndRunReporter(compiler, reporter, configuration, stat
|
|
|
67
68
|
rejectIssues = reject;
|
|
68
69
|
});
|
|
69
70
|
const previousReportPromise = state.reportPromise;
|
|
70
|
-
state.reportPromise = new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
state.reportPromise = ForkTsCheckerWebpackPlugin_1.ForkTsCheckerWebpackPlugin.pool.submit((done) => new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
71
72
|
change = yield hooks.start.promise(change, compilation);
|
|
72
73
|
try {
|
|
73
74
|
yield reporter.connect();
|
|
@@ -83,7 +84,7 @@ function tapStartToConnectAndRunReporter(compiler, reporter, configuration, stat
|
|
|
83
84
|
.catch(rejectedDependencies)
|
|
84
85
|
.finally(() => {
|
|
85
86
|
// get issues after dependencies are resolved as it can be blocking
|
|
86
|
-
report.getIssues().then(resolveIssues).catch(rejectIssues);
|
|
87
|
+
report.getIssues().then(resolveIssues).catch(rejectIssues).finally(done);
|
|
87
88
|
});
|
|
88
89
|
}
|
|
89
90
|
catch (error) {
|
|
@@ -96,8 +97,9 @@ function tapStartToConnectAndRunReporter(compiler, reporter, configuration, stat
|
|
|
96
97
|
resolve(undefined);
|
|
97
98
|
resolveDependencies(undefined);
|
|
98
99
|
resolveIssues(undefined);
|
|
100
|
+
done();
|
|
99
101
|
}
|
|
100
|
-
}));
|
|
102
|
+
})));
|
|
101
103
|
}));
|
|
102
104
|
}
|
|
103
105
|
exports.tapStartToConnectAndRunReporter = tapStartToConnectAndRunReporter;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
function createPool(size) {
|
|
13
|
+
let pendingPromises = [];
|
|
14
|
+
const pool = {
|
|
15
|
+
submit(task) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
while (pendingPromises.length >= pool.size) {
|
|
18
|
+
yield Promise.race(pendingPromises).catch(() => undefined);
|
|
19
|
+
}
|
|
20
|
+
let resolve;
|
|
21
|
+
let reject;
|
|
22
|
+
const taskPromise = new Promise((taskResolve, taskReject) => {
|
|
23
|
+
resolve = taskResolve;
|
|
24
|
+
reject = taskReject;
|
|
25
|
+
});
|
|
26
|
+
const donePromise = new Promise((doneResolve) => {
|
|
27
|
+
task(() => {
|
|
28
|
+
doneResolve(undefined);
|
|
29
|
+
pendingPromises = pendingPromises.filter((pendingPromise) => pendingPromise !== donePromise);
|
|
30
|
+
})
|
|
31
|
+
.then(resolve)
|
|
32
|
+
.catch(reject);
|
|
33
|
+
});
|
|
34
|
+
pendingPromises.push(donePromise);
|
|
35
|
+
return taskPromise;
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
size,
|
|
39
|
+
get pending() {
|
|
40
|
+
return pendingPromises.length;
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
return pool;
|
|
44
|
+
}
|
|
45
|
+
exports.createPool = createPool;
|