fork-ts-checker-webpack-plugin 7.2.10 → 7.2.13
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/lib/formatter/webpack-formatter.js +1 -1
- package/lib/hooks/tap-done-to-async-get-issues.js +4 -3
- package/lib/hooks/tap-error-to-log-message.js +4 -0
- package/lib/hooks/tap-start-to-run-workers.js +56 -19
- package/lib/issue/issue-location.d.ts +1 -1
- package/lib/issue/issue-location.js +2 -16
- package/lib/issue/issue-webpack-error.js +1 -1
- package/lib/plugin-state.d.ts +4 -0
- package/lib/plugin-state.js +2 -0
- package/lib/plugin.js +1 -1
- package/lib/utils/async/abort-error.d.ts +6 -0
- package/lib/utils/async/abort-error.js +15 -0
- package/lib/utils/async/pool.d.ts +3 -2
- package/lib/utils/async/pool.js +5 -2
- package/lib/watch/inclusive-node-watch-file-system.js +1 -1
- package/package.json +4 -3
|
@@ -16,7 +16,7 @@ function createWebpackFormatter(formatter) {
|
|
|
16
16
|
if (issue.file) {
|
|
17
17
|
let location = chalk_1.default.bold((0, relative_to_context_1.relativeToContext)(issue.file, process.cwd()));
|
|
18
18
|
if (issue.location) {
|
|
19
|
-
location +=
|
|
19
|
+
location += `:${chalk_1.default.green.bold((0, issue_1.formatIssueLocation)(issue.location))}`;
|
|
20
20
|
}
|
|
21
21
|
return [`${color(severity)} in ${location}`, formatter(issue), ''].join(os_1.default.EOL);
|
|
22
22
|
}
|
|
@@ -41,16 +41,17 @@ function tapDoneToAsyncGetIssues(compiler, config, state) {
|
|
|
41
41
|
yield (0, wait_1.wait)(10);
|
|
42
42
|
}
|
|
43
43
|
issues = yield issuesPromise;
|
|
44
|
-
debug('Got issues from getIssuesWorker.', issues === null || issues === void 0 ? void 0 : issues.length);
|
|
45
44
|
}
|
|
46
45
|
catch (error) {
|
|
47
46
|
hooks.error.call(error, stats.compilation);
|
|
48
47
|
return;
|
|
49
48
|
}
|
|
50
|
-
if (!issues
|
|
51
|
-
//
|
|
49
|
+
if (!issues || // some error has been thrown
|
|
50
|
+
state.issuesPromise !== issuesPromise // we have a new request - don't show results for the old one
|
|
51
|
+
) {
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
+
debug(`Got ${(issues === null || issues === void 0 ? void 0 : issues.length) || 0} issues from getIssuesWorker.`);
|
|
54
55
|
// filter list of issues by provided issue predicate
|
|
55
56
|
issues = issues.filter(config.issue.predicate);
|
|
56
57
|
// modify list of issues in the plugin hooks
|
|
@@ -7,9 +7,13 @@ exports.tapErrorToLogMessage = void 0;
|
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const plugin_hooks_1 = require("../plugin-hooks");
|
|
9
9
|
const rpc_1 = require("../rpc");
|
|
10
|
+
const abort_error_1 = require("../utils/async/abort-error");
|
|
10
11
|
function tapErrorToLogMessage(compiler, config) {
|
|
11
12
|
const hooks = (0, plugin_hooks_1.getPluginHooks)(compiler);
|
|
12
13
|
hooks.error.tap('ForkTsCheckerWebpackPlugin', (error) => {
|
|
14
|
+
if (error instanceof abort_error_1.AbortError) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
13
17
|
config.logger.error(String(error));
|
|
14
18
|
if (error instanceof rpc_1.RpcExitError) {
|
|
15
19
|
if (error.signal === 'SIGINT') {
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.tapStartToRunWorkers = void 0;
|
|
13
|
+
const node_abort_controller_1 = require("node-abort-controller");
|
|
13
14
|
const files_change_1 = require("../files-change");
|
|
14
15
|
const infrastructure_logger_1 = require("../infrastructure-logger");
|
|
15
16
|
const plugin_hooks_1 = require("../plugin-hooks");
|
|
@@ -48,39 +49,75 @@ function tapStartToRunWorkers(compiler, getIssuesWorker, getDependenciesWorker,
|
|
|
48
49
|
// run only for the compiler that the plugin was registered for
|
|
49
50
|
return;
|
|
50
51
|
}
|
|
52
|
+
// get current iteration number
|
|
51
53
|
const iteration = ++state.iteration;
|
|
52
|
-
|
|
54
|
+
// abort previous iteration
|
|
55
|
+
if (state.abortController) {
|
|
56
|
+
debug(`Aborting iteration ${iteration - 1}.`);
|
|
57
|
+
state.abortController.abort();
|
|
58
|
+
}
|
|
59
|
+
// create new abort controller for the new iteration
|
|
60
|
+
const abortController = new node_abort_controller_1.AbortController();
|
|
61
|
+
state.abortController = abortController;
|
|
62
|
+
let filesChange = {};
|
|
53
63
|
if (state.watching) {
|
|
54
|
-
|
|
64
|
+
filesChange = (0, files_change_1.consumeFilesChange)(compiler);
|
|
55
65
|
log([
|
|
56
66
|
'Calling reporter service for incremental check.',
|
|
57
|
-
` Changed files: ${JSON.stringify(
|
|
58
|
-
` Deleted files: ${JSON.stringify(
|
|
67
|
+
` Changed files: ${JSON.stringify(filesChange.changedFiles)}`,
|
|
68
|
+
` Deleted files: ${JSON.stringify(filesChange.deletedFiles)}`,
|
|
59
69
|
].join('\n'));
|
|
60
70
|
}
|
|
61
71
|
else {
|
|
62
72
|
log('Calling reporter service for single check.');
|
|
63
73
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
state.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
filesChange = yield hooks.start.promise(filesChange, compilation);
|
|
75
|
+
let aggregatedFilesChange = filesChange;
|
|
76
|
+
if (state.aggregatedFilesChange) {
|
|
77
|
+
aggregatedFilesChange = (0, files_change_1.aggregateFilesChanges)([aggregatedFilesChange, filesChange]);
|
|
78
|
+
debug([
|
|
79
|
+
`Aggregating with previous files change, iteration ${iteration}.`,
|
|
80
|
+
` Changed files: ${JSON.stringify(aggregatedFilesChange.changedFiles)}`,
|
|
81
|
+
` Deleted files: ${JSON.stringify(aggregatedFilesChange.deletedFiles)}`,
|
|
82
|
+
].join('\n'));
|
|
83
|
+
}
|
|
84
|
+
state.aggregatedFilesChange = aggregatedFilesChange;
|
|
85
|
+
// submit one at a time for a single compiler
|
|
86
|
+
state.issuesPromise = (state.issuesPromise || Promise.resolve())
|
|
87
|
+
// resolve to undefined on error
|
|
88
|
+
.catch(() => undefined)
|
|
89
|
+
.then(() => {
|
|
90
|
+
// early return
|
|
91
|
+
if (abortController.signal.aborted) {
|
|
73
92
|
return undefined;
|
|
74
93
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
94
|
+
debug(`Submitting the getIssuesWorker to the pool, iteration ${iteration}.`);
|
|
95
|
+
return plugin_pools_1.issuesPool.submit(() => __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
try {
|
|
97
|
+
debug(`Running the getIssuesWorker, iteration ${iteration}.`);
|
|
98
|
+
const issues = yield getIssuesWorker(aggregatedFilesChange, state.watching);
|
|
99
|
+
if (state.aggregatedFilesChange === aggregatedFilesChange) {
|
|
100
|
+
state.aggregatedFilesChange = undefined;
|
|
101
|
+
}
|
|
102
|
+
if (state.abortController === abortController) {
|
|
103
|
+
state.abortController = undefined;
|
|
104
|
+
}
|
|
105
|
+
return issues;
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
hooks.error.call(error, compilation);
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
finally {
|
|
112
|
+
debug(`The getIssuesWorker finished its job, iteration ${iteration}.`);
|
|
113
|
+
}
|
|
114
|
+
}), abortController.signal);
|
|
115
|
+
});
|
|
79
116
|
debug(`Submitting the getDependenciesWorker to the pool, iteration ${iteration}.`);
|
|
80
117
|
state.dependenciesPromise = plugin_pools_1.dependenciesPool.submit(() => __awaiter(this, void 0, void 0, function* () {
|
|
81
118
|
try {
|
|
82
119
|
debug(`Running the getDependenciesWorker, iteration ${iteration}.`);
|
|
83
|
-
return yield getDependenciesWorker(
|
|
120
|
+
return yield getDependenciesWorker(filesChange);
|
|
84
121
|
}
|
|
85
122
|
catch (error) {
|
|
86
123
|
hooks.error.call(error, compilation);
|
|
@@ -89,7 +126,7 @@ function tapStartToRunWorkers(compiler, getIssuesWorker, getDependenciesWorker,
|
|
|
89
126
|
finally {
|
|
90
127
|
debug(`The getDependenciesWorker finished its job, iteration ${iteration}.`);
|
|
91
128
|
}
|
|
92
|
-
}));
|
|
129
|
+
})); // don't pass abortController.signal because getDependencies() is blocking
|
|
93
130
|
}));
|
|
94
131
|
}
|
|
95
132
|
exports.tapStartToRunWorkers = tapStartToRunWorkers;
|
|
@@ -4,5 +4,5 @@ interface IssueLocation {
|
|
|
4
4
|
end: IssuePosition;
|
|
5
5
|
}
|
|
6
6
|
declare function compareIssueLocations(locationA?: IssueLocation, locationB?: IssueLocation): number;
|
|
7
|
-
declare function formatIssueLocation(
|
|
7
|
+
declare function formatIssueLocation(location: IssueLocation): string;
|
|
8
8
|
export { IssueLocation, compareIssueLocations, formatIssueLocation };
|
|
@@ -16,21 +16,7 @@ function compareIssueLocations(locationA, locationB) {
|
|
|
16
16
|
(0, issue_position_1.compareIssuePositions)(locationA.end, locationB.end));
|
|
17
17
|
}
|
|
18
18
|
exports.compareIssueLocations = compareIssueLocations;
|
|
19
|
-
function formatIssueLocation(
|
|
20
|
-
|
|
21
|
-
// the same line
|
|
22
|
-
if (!end.column || start.column === end.column) {
|
|
23
|
-
// the same column
|
|
24
|
-
return `${start.line}:${start.column}`;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
// different column
|
|
28
|
-
return `${start.line}:${start.column}-${end.column}`;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
// different lines
|
|
33
|
-
return `${start.line}:${start.column}-${end.line}:${end.column}`;
|
|
34
|
-
}
|
|
19
|
+
function formatIssueLocation(location) {
|
|
20
|
+
return `${location.start.line}:${location.start.column}`;
|
|
35
21
|
}
|
|
36
22
|
exports.formatIssueLocation = formatIssueLocation;
|
|
@@ -19,7 +19,7 @@ class IssueWebpackError extends webpack_1.default.WebpackError {
|
|
|
19
19
|
if (issue.file) {
|
|
20
20
|
this.file = (0, relative_to_context_1.relativeToContext)(issue.file, process.cwd());
|
|
21
21
|
if (issue.location) {
|
|
22
|
-
this.file +=
|
|
22
|
+
this.file += `:${chalk_1.default.green.bold((0, issue_location_1.formatIssueLocation)(issue.location))}`;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
Error.captureStackTrace(this, this.constructor);
|
package/lib/plugin-state.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import type { AbortController } from 'node-abort-controller';
|
|
1
2
|
import type { FullTap } from 'tapable';
|
|
3
|
+
import type { FilesChange } from './files-change';
|
|
2
4
|
import type { FilesMatch } from './files-match';
|
|
3
5
|
import type { Issue } from './issue';
|
|
4
6
|
interface ForkTsCheckerWebpackPluginState {
|
|
5
7
|
issuesPromise: Promise<Issue[] | undefined>;
|
|
6
8
|
dependenciesPromise: Promise<FilesMatch | undefined>;
|
|
9
|
+
abortController: AbortController | undefined;
|
|
10
|
+
aggregatedFilesChange: FilesChange | undefined;
|
|
7
11
|
lastDependencies: FilesMatch | undefined;
|
|
8
12
|
watching: boolean;
|
|
9
13
|
initialized: boolean;
|
package/lib/plugin-state.js
CHANGED
|
@@ -5,6 +5,8 @@ function createPluginState() {
|
|
|
5
5
|
return {
|
|
6
6
|
issuesPromise: Promise.resolve(undefined),
|
|
7
7
|
dependenciesPromise: Promise.resolve(undefined),
|
|
8
|
+
abortController: undefined,
|
|
9
|
+
aggregatedFilesChange: undefined,
|
|
8
10
|
lastDependencies: undefined,
|
|
9
11
|
watching: false,
|
|
10
12
|
initialized: false,
|
package/lib/plugin.js
CHANGED
|
@@ -70,7 +70,7 @@ exports.ForkTsCheckerWebpackPlugin = ForkTsCheckerWebpackPlugin;
|
|
|
70
70
|
/**
|
|
71
71
|
* Current version of the plugin
|
|
72
72
|
*/
|
|
73
|
-
ForkTsCheckerWebpackPlugin.version = '7.2.
|
|
73
|
+
ForkTsCheckerWebpackPlugin.version = '7.2.13'; // will be replaced by the @semantic-release/exec
|
|
74
74
|
/**
|
|
75
75
|
* Default pools for the plugin concurrency limit
|
|
76
76
|
*/
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbortError = void 0;
|
|
4
|
+
class AbortError extends Error {
|
|
5
|
+
constructor(message = 'Task aborted.') {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'AbortError';
|
|
8
|
+
}
|
|
9
|
+
static throwIfAborted(signal) {
|
|
10
|
+
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
11
|
+
throw new AbortError();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.AbortError = AbortError;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { AbortSignal } from 'node-abort-controller';
|
|
2
|
+
declare type Task<T> = (signal?: AbortSignal) => Promise<T>;
|
|
2
3
|
interface Pool {
|
|
3
|
-
submit<T>(task: Task<T
|
|
4
|
+
submit<T>(task: Task<T>, signal?: AbortSignal): Promise<T>;
|
|
4
5
|
size: number;
|
|
5
6
|
readonly pending: number;
|
|
6
7
|
readonly drained: Promise<void>;
|
package/lib/utils/async/pool.js
CHANGED
|
@@ -10,15 +10,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.createPool = void 0;
|
|
13
|
+
const abort_error_1 = require("./abort-error");
|
|
13
14
|
function createPool(size) {
|
|
14
15
|
let pendingPromises = [];
|
|
15
16
|
const pool = {
|
|
16
|
-
submit(task) {
|
|
17
|
+
submit(task, signal) {
|
|
17
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
19
|
while (pendingPromises.length >= pool.size) {
|
|
20
|
+
abort_error_1.AbortError.throwIfAborted(signal);
|
|
19
21
|
yield Promise.race(pendingPromises).catch(() => undefined);
|
|
20
22
|
}
|
|
21
|
-
|
|
23
|
+
abort_error_1.AbortError.throwIfAborted(signal);
|
|
24
|
+
const taskPromise = task(signal).finally(() => {
|
|
22
25
|
pendingPromises = pendingPromises.filter((pendingPromise) => pendingPromise !== taskPromise);
|
|
23
26
|
});
|
|
24
27
|
pendingPromises.push(taskPromise);
|
|
@@ -9,7 +9,7 @@ const chokidar_1 = __importDefault(require("chokidar"));
|
|
|
9
9
|
const minimatch_1 = __importDefault(require("minimatch"));
|
|
10
10
|
const files_change_1 = require("../files-change");
|
|
11
11
|
const infrastructure_logger_1 = require("../infrastructure-logger");
|
|
12
|
-
const BUILTIN_IGNORED_DIRS = ['
|
|
12
|
+
const BUILTIN_IGNORED_DIRS = ['.git'];
|
|
13
13
|
function createIsIgnored(ignored, excluded) {
|
|
14
14
|
const ignoredPatterns = ignored ? (Array.isArray(ignored) ? ignored : [ignored]) : [];
|
|
15
15
|
const ignoredFunctions = ignoredPatterns.map((pattern) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fork-ts-checker-webpack-plugin",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.13",
|
|
4
4
|
"description": "Runs typescript type checker and linter on separate process.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -63,14 +63,15 @@
|
|
|
63
63
|
"fs-extra": "^10.0.0",
|
|
64
64
|
"memfs": "^3.4.1",
|
|
65
65
|
"minimatch": "^3.0.4",
|
|
66
|
+
"node-abort-controller": "^3.0.1",
|
|
66
67
|
"schema-utils": "^3.1.1",
|
|
67
68
|
"semver": "^7.3.5",
|
|
68
69
|
"tapable": "^2.2.1"
|
|
69
70
|
},
|
|
70
71
|
"peerDependencies": {
|
|
71
72
|
"typescript": ">3.6.0",
|
|
72
|
-
"
|
|
73
|
-
"
|
|
73
|
+
"vue-template-compiler": "*",
|
|
74
|
+
"webpack": "^5.11.0"
|
|
74
75
|
},
|
|
75
76
|
"peerDependenciesMeta": {
|
|
76
77
|
"vue-template-compiler": {
|