fork-ts-checker-webpack-plugin 6.0.8 → 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.
|
@@ -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));
|
|
@@ -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;
|