fork-ts-checker-webpack-plugin 6.2.13 → 6.3.3
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 +27 -14
- package/lib/ForkTsCheckerWebpackPlugin.d.ts +7 -2
- package/lib/ForkTsCheckerWebpackPlugin.js +22 -10
- package/lib/ForkTsCheckerWebpackPluginState.d.ts +2 -1
- package/lib/ForkTsCheckerWebpackPluginState.js +2 -1
- package/lib/hooks/tapDoneToAsyncGetIssues.js +2 -2
- package/lib/hooks/tapStartToConnectAndRunReporter.d.ts +1 -1
- package/lib/hooks/tapStartToConnectAndRunReporter.js +35 -15
- package/lib/hooks/tapStopToDisconnectReporter.d.ts +1 -1
- package/lib/hooks/tapStopToDisconnectReporter.js +6 -4
- package/lib/typescript-reporter/reporter/ControlledTypeScriptSystem.js +16 -4
- package/lib/typescript-reporter/reporter/TypeScriptReporter.js +5 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -362,24 +362,37 @@ When we call this method with a [webpack compiler instance](https://webpack.js.o
|
|
|
362
362
|
[tapable](https://github.com/webpack/tapable) hooks where you can pass in your callbacks.
|
|
363
363
|
|
|
364
364
|
```js
|
|
365
|
-
|
|
365
|
+
// ./src/webpack/MyWebpackPlugin.js
|
|
366
366
|
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
|
367
367
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
368
|
+
class MyWebpackPlugin {
|
|
369
|
+
apply(compiler) {
|
|
370
|
+
const hooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(compiler);
|
|
371
|
+
|
|
372
|
+
// log some message on waiting
|
|
373
|
+
hooks.waiting.tap('MyPlugin', () => {
|
|
374
|
+
console.log('waiting for issues');
|
|
375
|
+
});
|
|
376
|
+
// don't show warnings
|
|
377
|
+
hooks.issues.tap('MyPlugin', (issues) =>
|
|
378
|
+
issues.filter((issue) => issue.severity === 'error')
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
371
382
|
|
|
372
|
-
|
|
373
|
-
// **don't do this if already added through configuration**
|
|
374
|
-
new ForkTsCheckerWebpackPlugin().apply(compiler);
|
|
383
|
+
module.exports = MyWebpackPlugin;
|
|
375
384
|
|
|
376
|
-
//
|
|
377
|
-
const
|
|
385
|
+
// webpack.config.js
|
|
386
|
+
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
|
387
|
+
const MyWebpackPlugin = require('./src/webpack/MyWebpackPlugin');
|
|
378
388
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
389
|
+
module.exports = {
|
|
390
|
+
/* ... */
|
|
391
|
+
plugins: [
|
|
392
|
+
new ForkTsCheckerWebpackPlugin(),
|
|
393
|
+
new MyWebpackPlugin()
|
|
394
|
+
]
|
|
395
|
+
};
|
|
383
396
|
```
|
|
384
397
|
|
|
385
398
|
## Typings
|
|
@@ -397,7 +410,7 @@ yarn add --dev @types/webpack
|
|
|
397
410
|
|
|
398
411
|
## Profiling types resolution
|
|
399
412
|
|
|
400
|
-
Starting from TypeScript 4.1.0
|
|
413
|
+
Starting from TypeScript 4.1.0, you can profile long type checks by
|
|
401
414
|
setting "generateTrace" compiler option. This is an instruction from [microsoft/TypeScript#40063](https://github.com/microsoft/TypeScript/pull/40063):
|
|
402
415
|
|
|
403
416
|
1. Set "generateTrace": "{folderName}" in your `tsconfig.json`
|
|
@@ -7,9 +7,14 @@ declare class ForkTsCheckerWebpackPlugin implements webpack.Plugin {
|
|
|
7
7
|
*/
|
|
8
8
|
static readonly version: string;
|
|
9
9
|
/**
|
|
10
|
-
* Default
|
|
10
|
+
* Default pools for the plugin concurrency limit
|
|
11
11
|
*/
|
|
12
|
-
static readonly
|
|
12
|
+
static readonly issuesPool: Pool;
|
|
13
|
+
static readonly dependenciesPool: Pool;
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Use ForkTsCheckerWebpackPlugin.issuesPool instead
|
|
16
|
+
*/
|
|
17
|
+
static get pool(): Pool;
|
|
13
18
|
private readonly options;
|
|
14
19
|
constructor(options?: ForkTsCheckerWebpackPluginOptions);
|
|
15
20
|
static getCompilerHooks(compiler: webpack.Compiler): {
|
|
@@ -33,27 +33,38 @@ class ForkTsCheckerWebpackPlugin {
|
|
|
33
33
|
// then validate merged options
|
|
34
34
|
schema_utils_1.default(ForkTsCheckerWebpackPluginOptions_json_1.default, this.options, configuration);
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated Use ForkTsCheckerWebpackPlugin.issuesPool instead
|
|
38
|
+
*/
|
|
39
|
+
static get pool() {
|
|
40
|
+
// for backward compatibility
|
|
41
|
+
return ForkTsCheckerWebpackPlugin.issuesPool;
|
|
42
|
+
}
|
|
36
43
|
static getCompilerHooks(compiler) {
|
|
37
44
|
return pluginHooks_1.getForkTsCheckerWebpackPluginHooks(compiler);
|
|
38
45
|
}
|
|
39
46
|
apply(compiler) {
|
|
40
47
|
const configuration = ForkTsCheckerWebpackPluginConfiguration_1.createForkTsCheckerWebpackPluginConfiguration(compiler, this.options);
|
|
41
48
|
const state = ForkTsCheckerWebpackPluginState_1.createForkTsCheckerWebpackPluginState();
|
|
42
|
-
const
|
|
49
|
+
const issuesReporters = [];
|
|
50
|
+
const dependenciesReporters = [];
|
|
43
51
|
if (configuration.typescript.enabled) {
|
|
44
52
|
TypeScriptSupport_1.assertTypeScriptSupport(configuration.typescript);
|
|
45
|
-
|
|
53
|
+
issuesReporters.push(TypeScriptReporterRpcClient_1.createTypeScriptReporterRpcClient(configuration.typescript));
|
|
54
|
+
dependenciesReporters.push(TypeScriptReporterRpcClient_1.createTypeScriptReporterRpcClient(configuration.typescript));
|
|
46
55
|
}
|
|
47
56
|
if (configuration.eslint.enabled) {
|
|
48
57
|
assertEsLintSupport_1.assertEsLintSupport(configuration.eslint);
|
|
49
|
-
|
|
58
|
+
issuesReporters.push(EsLintReporterRpcClient_1.createEsLintReporterRpcClient(configuration.eslint));
|
|
59
|
+
dependenciesReporters.push(EsLintReporterRpcClient_1.createEsLintReporterRpcClient(configuration.eslint));
|
|
50
60
|
}
|
|
51
|
-
if (
|
|
52
|
-
const
|
|
61
|
+
if (issuesReporters.length) {
|
|
62
|
+
const issuesReporter = reporter_1.createAggregatedReporter(reporter_1.composeReporterRpcClients(issuesReporters));
|
|
63
|
+
const dependenciesReporter = reporter_1.createAggregatedReporter(reporter_1.composeReporterRpcClients(dependenciesReporters));
|
|
53
64
|
tapAfterEnvironmentToPatchWatching_1.tapAfterEnvironmentToPatchWatching(compiler, state);
|
|
54
|
-
tapStartToConnectAndRunReporter_1.tapStartToConnectAndRunReporter(compiler,
|
|
65
|
+
tapStartToConnectAndRunReporter_1.tapStartToConnectAndRunReporter(compiler, issuesReporter, dependenciesReporter, configuration, state);
|
|
55
66
|
tapAfterCompileToAddDependencies_1.tapAfterCompileToAddDependencies(compiler, configuration, state);
|
|
56
|
-
tapStopToDisconnectReporter_1.tapStopToDisconnectReporter(compiler,
|
|
67
|
+
tapStopToDisconnectReporter_1.tapStopToDisconnectReporter(compiler, issuesReporter, dependenciesReporter, state);
|
|
57
68
|
tapErrorToLogMessage_1.tapErrorToLogMessage(compiler, configuration);
|
|
58
69
|
}
|
|
59
70
|
else {
|
|
@@ -65,8 +76,9 @@ exports.ForkTsCheckerWebpackPlugin = ForkTsCheckerWebpackPlugin;
|
|
|
65
76
|
/**
|
|
66
77
|
* Current version of the plugin
|
|
67
78
|
*/
|
|
68
|
-
ForkTsCheckerWebpackPlugin.version = '6.
|
|
79
|
+
ForkTsCheckerWebpackPlugin.version = '6.3.3'; // will be replaced by the @semantic-release/exec
|
|
69
80
|
/**
|
|
70
|
-
* Default
|
|
81
|
+
* Default pools for the plugin concurrency limit
|
|
71
82
|
*/
|
|
72
|
-
ForkTsCheckerWebpackPlugin.
|
|
83
|
+
ForkTsCheckerWebpackPlugin.issuesPool = pool_1.createPool(Math.max(1, os_1.default.cpus().length));
|
|
84
|
+
ForkTsCheckerWebpackPlugin.dependenciesPool = pool_1.createPool(Math.max(1, os_1.default.cpus().length));
|
|
@@ -2,7 +2,8 @@ import { Tap } from 'tapable';
|
|
|
2
2
|
import { FilesMatch, Report } from './reporter';
|
|
3
3
|
import { Issue } from './issue';
|
|
4
4
|
interface ForkTsCheckerWebpackPluginState {
|
|
5
|
-
|
|
5
|
+
issuesReportPromise: Promise<Report | undefined>;
|
|
6
|
+
dependenciesReportPromise: Promise<Report | undefined>;
|
|
6
7
|
issuesPromise: Promise<Issue[] | undefined>;
|
|
7
8
|
dependenciesPromise: Promise<FilesMatch | undefined>;
|
|
8
9
|
lastDependencies: FilesMatch | undefined;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
function createForkTsCheckerWebpackPluginState() {
|
|
4
4
|
return {
|
|
5
|
-
|
|
5
|
+
issuesReportPromise: Promise.resolve(undefined),
|
|
6
|
+
dependenciesReportPromise: Promise.resolve(undefined),
|
|
6
7
|
issuesPromise: Promise.resolve(undefined),
|
|
7
8
|
dependenciesPromise: Promise.resolve(undefined),
|
|
8
9
|
lastDependencies: undefined,
|
|
@@ -25,7 +25,7 @@ function tapDoneToAsyncGetIssues(compiler, configuration, state) {
|
|
|
25
25
|
// run only for the compiler that the plugin was registered for
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
const reportPromise = state.
|
|
28
|
+
const reportPromise = state.issuesReportPromise;
|
|
29
29
|
const issuesPromise = state.issuesPromise;
|
|
30
30
|
let issues;
|
|
31
31
|
try {
|
|
@@ -47,7 +47,7 @@ function tapDoneToAsyncGetIssues(compiler, configuration, state) {
|
|
|
47
47
|
// some error has been thrown or it was canceled
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
if (reportPromise !== state.
|
|
50
|
+
if (reportPromise !== state.issuesReportPromise) {
|
|
51
51
|
// there is a newer report - ignore this one
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
@@ -2,5 +2,5 @@ import webpack from 'webpack';
|
|
|
2
2
|
import { ForkTsCheckerWebpackPluginConfiguration } from '../ForkTsCheckerWebpackPluginConfiguration';
|
|
3
3
|
import { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
|
|
4
4
|
import { ReporterRpcClient } from '../reporter';
|
|
5
|
-
declare function tapStartToConnectAndRunReporter(compiler: webpack.Compiler,
|
|
5
|
+
declare function tapStartToConnectAndRunReporter(compiler: webpack.Compiler, issuesReporter: ReporterRpcClient, dependenciesReporter: ReporterRpcClient, configuration: ForkTsCheckerWebpackPluginConfiguration, state: ForkTsCheckerWebpackPluginState): void;
|
|
6
6
|
export { tapStartToConnectAndRunReporter };
|
|
@@ -16,7 +16,7 @@ const tapDoneToAsyncGetIssues_1 = require("./tapDoneToAsyncGetIssues");
|
|
|
16
16
|
const tapAfterCompileToGetIssues_1 = require("./tapAfterCompileToGetIssues");
|
|
17
17
|
const interceptDoneToGetWebpackDevServerTap_1 = require("./interceptDoneToGetWebpackDevServerTap");
|
|
18
18
|
const ForkTsCheckerWebpackPlugin_1 = require("../ForkTsCheckerWebpackPlugin");
|
|
19
|
-
function tapStartToConnectAndRunReporter(compiler,
|
|
19
|
+
function tapStartToConnectAndRunReporter(compiler, issuesReporter, dependenciesReporter, configuration, state) {
|
|
20
20
|
const hooks = pluginHooks_1.getForkTsCheckerWebpackPluginHooks(compiler);
|
|
21
21
|
compiler.hooks.run.tap('ForkTsCheckerWebpackPlugin', () => {
|
|
22
22
|
if (!state.initialized) {
|
|
@@ -56,36 +56,57 @@ function tapStartToConnectAndRunReporter(compiler, reporter, configuration, stat
|
|
|
56
56
|
configuration.logger.infrastructure.info('Calling reporter service for single check.');
|
|
57
57
|
}
|
|
58
58
|
let resolveDependencies;
|
|
59
|
-
let
|
|
59
|
+
let rejectDependencies;
|
|
60
60
|
let resolveIssues;
|
|
61
61
|
let rejectIssues;
|
|
62
62
|
state.dependenciesPromise = new Promise((resolve, reject) => {
|
|
63
63
|
resolveDependencies = resolve;
|
|
64
|
-
|
|
64
|
+
rejectDependencies = reject;
|
|
65
65
|
});
|
|
66
66
|
state.issuesPromise = new Promise((resolve, reject) => {
|
|
67
67
|
resolveIssues = resolve;
|
|
68
68
|
rejectIssues = reject;
|
|
69
69
|
});
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
const previousIssuesReportPromise = state.issuesReportPromise;
|
|
71
|
+
const previousDependenciesReportPromise = state.dependenciesReportPromise;
|
|
72
|
+
change = yield hooks.start.promise(change, compilation);
|
|
73
|
+
state.issuesReportPromise = ForkTsCheckerWebpackPlugin_1.ForkTsCheckerWebpackPlugin.issuesPool.submit((done) => new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
73
74
|
try {
|
|
74
|
-
yield
|
|
75
|
-
const previousReport = yield
|
|
75
|
+
yield issuesReporter.connect();
|
|
76
|
+
const previousReport = yield previousIssuesReportPromise;
|
|
76
77
|
if (previousReport) {
|
|
77
78
|
yield previousReport.close();
|
|
78
79
|
}
|
|
79
|
-
const report = yield
|
|
80
|
+
const report = yield issuesReporter.getReport(change);
|
|
81
|
+
resolve(report);
|
|
82
|
+
report.getIssues().then(resolveIssues).catch(rejectIssues).finally(done);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
if (error instanceof OperationCanceledError_1.OperationCanceledError) {
|
|
86
|
+
hooks.canceled.call(compilation);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
hooks.error.call(error, compilation);
|
|
90
|
+
}
|
|
91
|
+
resolve(undefined);
|
|
92
|
+
resolveIssues(undefined);
|
|
93
|
+
done();
|
|
94
|
+
}
|
|
95
|
+
})));
|
|
96
|
+
state.dependenciesReportPromise = ForkTsCheckerWebpackPlugin_1.ForkTsCheckerWebpackPlugin.dependenciesPool.submit((done) => new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
try {
|
|
98
|
+
yield dependenciesReporter.connect();
|
|
99
|
+
const previousReport = yield previousDependenciesReportPromise;
|
|
100
|
+
if (previousReport) {
|
|
101
|
+
yield previousReport.close();
|
|
102
|
+
}
|
|
103
|
+
const report = yield dependenciesReporter.getReport(change);
|
|
80
104
|
resolve(report);
|
|
81
105
|
report
|
|
82
106
|
.getDependencies()
|
|
83
107
|
.then(resolveDependencies)
|
|
84
|
-
.catch(
|
|
85
|
-
.finally(
|
|
86
|
-
// get issues after dependencies are resolved as it can be blocking
|
|
87
|
-
report.getIssues().then(resolveIssues).catch(rejectIssues).finally(done);
|
|
88
|
-
});
|
|
108
|
+
.catch(rejectDependencies)
|
|
109
|
+
.finally(done);
|
|
89
110
|
}
|
|
90
111
|
catch (error) {
|
|
91
112
|
if (error instanceof OperationCanceledError_1.OperationCanceledError) {
|
|
@@ -96,7 +117,6 @@ function tapStartToConnectAndRunReporter(compiler, reporter, configuration, stat
|
|
|
96
117
|
}
|
|
97
118
|
resolve(undefined);
|
|
98
119
|
resolveDependencies(undefined);
|
|
99
|
-
resolveIssues(undefined);
|
|
100
120
|
done();
|
|
101
121
|
}
|
|
102
122
|
})));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import webpack from 'webpack';
|
|
2
2
|
import { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
|
|
3
3
|
import { ReporterRpcClient } from '../reporter';
|
|
4
|
-
declare function tapStopToDisconnectReporter(compiler: webpack.Compiler,
|
|
4
|
+
declare function tapStopToDisconnectReporter(compiler: webpack.Compiler, issuesReporter: ReporterRpcClient, dependenciesReporter: ReporterRpcClient, state: ForkTsCheckerWebpackPluginState): void;
|
|
5
5
|
export { tapStopToDisconnectReporter };
|
|
@@ -9,18 +9,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
function tapStopToDisconnectReporter(compiler,
|
|
12
|
+
function tapStopToDisconnectReporter(compiler, issuesReporter, dependenciesReporter, state) {
|
|
13
13
|
compiler.hooks.watchClose.tap('ForkTsCheckerWebpackPlugin', () => {
|
|
14
|
-
|
|
14
|
+
issuesReporter.disconnect();
|
|
15
|
+
dependenciesReporter.disconnect();
|
|
15
16
|
});
|
|
16
17
|
compiler.hooks.done.tap('ForkTsCheckerWebpackPlugin', () => __awaiter(this, void 0, void 0, function* () {
|
|
17
18
|
if (!state.watching) {
|
|
18
|
-
yield
|
|
19
|
+
yield Promise.all([issuesReporter.disconnect(), dependenciesReporter.disconnect()]);
|
|
19
20
|
}
|
|
20
21
|
}));
|
|
21
22
|
compiler.hooks.failed.tap('ForkTsCheckerWebpackPlugin', () => {
|
|
22
23
|
if (!state.watching) {
|
|
23
|
-
|
|
24
|
+
issuesReporter.disconnect();
|
|
25
|
+
dependenciesReporter.disconnect();
|
|
24
26
|
}
|
|
25
27
|
});
|
|
26
28
|
}
|
|
@@ -95,9 +95,18 @@ function createControlledTypeScriptSystem(typescript, mode = 'readonly') {
|
|
|
95
95
|
artifacts.extensions.some((extension) => path.endsWith(extension)));
|
|
96
96
|
}
|
|
97
97
|
function getReadFileSystem(path) {
|
|
98
|
-
if (
|
|
99
|
-
(
|
|
100
|
-
|
|
98
|
+
if ((mode === 'readonly' || mode === 'write-tsbuildinfo') && isArtifact(path)) {
|
|
99
|
+
if (isInitialRun && !memFileSystem.exists(path) && passiveFileSystem.exists(path)) {
|
|
100
|
+
// copy file to memory on initial run
|
|
101
|
+
const stats = passiveFileSystem.readStats(path);
|
|
102
|
+
if (stats === null || stats === void 0 ? void 0 : stats.isFile()) {
|
|
103
|
+
const content = passiveFileSystem.readFile(path);
|
|
104
|
+
if (content) {
|
|
105
|
+
memFileSystem.writeFile(path, content);
|
|
106
|
+
memFileSystem.updateTimes(path, stats.atime, stats.mtime);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
101
110
|
return memFileSystem;
|
|
102
111
|
}
|
|
103
112
|
return passiveFileSystem;
|
|
@@ -109,7 +118,10 @@ function createControlledTypeScriptSystem(typescript, mode = 'readonly') {
|
|
|
109
118
|
}
|
|
110
119
|
return passiveFileSystem;
|
|
111
120
|
}
|
|
112
|
-
const controlledSystem = Object.assign(Object.assign({}, typescript.sys), { useCaseSensitiveFileNames: caseSensitive,
|
|
121
|
+
const controlledSystem = Object.assign(Object.assign({}, typescript.sys), { useCaseSensitiveFileNames: caseSensitive, realpath(path) {
|
|
122
|
+
return getReadFileSystem(path).realPath(path);
|
|
123
|
+
},
|
|
124
|
+
fileExists(path) {
|
|
113
125
|
const stats = getReadFileSystem(path).readStats(path);
|
|
114
126
|
return !!stats && stats.isFile();
|
|
115
127
|
},
|
|
@@ -185,13 +185,12 @@ function createTypeScriptReporter(configuration) {
|
|
|
185
185
|
configurationChanged = true;
|
|
186
186
|
}
|
|
187
187
|
else {
|
|
188
|
-
const
|
|
188
|
+
const previousDependencies = dependencies;
|
|
189
189
|
[parsedConfiguration, parseConfigurationDiagnostics] = parseConfiguration();
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
//
|
|
194
|
-
dependencies = getDependencies();
|
|
190
|
+
dependencies = getDependencies();
|
|
191
|
+
if (previousDependencies &&
|
|
192
|
+
JSON.stringify(previousDependencies) !== JSON.stringify(dependencies)) {
|
|
193
|
+
// dependencies changed - we need to recompute artifacts
|
|
195
194
|
artifacts = getArtifacts();
|
|
196
195
|
shouldUpdateRootFiles = true;
|
|
197
196
|
}
|