fork-ts-checker-webpack-plugin 7.2.3 → 7.2.6
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 +6 -2
- package/lib/plugin.js +1 -1
- package/lib/rpc/wrap-rpc.js +44 -61
- package/lib/typescript/worker/lib/program/program.js +3 -0
- package/lib/typescript/worker/lib/tracing.d.ts +1 -1
- package/lib/typescript/worker/lib/tracing.js +10 -9
- package/lib/utils/async/controlled-promise.d.ts +6 -0
- package/lib/utils/async/controlled-promise.js +17 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -347,10 +347,10 @@ yarn add --dev @types/webpack
|
|
|
347
347
|
|
|
348
348
|
## Profiling types resolution
|
|
349
349
|
|
|
350
|
-
|
|
350
|
+
When using TypeScript 4.3.0 or newer you can profile long type checks by
|
|
351
351
|
setting "generateTrace" compiler option. This is an instruction from [microsoft/TypeScript#40063](https://github.com/microsoft/TypeScript/pull/40063):
|
|
352
352
|
|
|
353
|
-
1. Set "generateTrace": "{folderName}" in your `tsconfig.json`
|
|
353
|
+
1. Set "generateTrace": "{folderName}" in your `tsconfig.json` (under `compilerOptions`)
|
|
354
354
|
2. Look in the resulting folder. If you used build mode, there will be a `legend.json` telling you what went where.
|
|
355
355
|
Otherwise, there will be `trace.json` file and `types.json` files.
|
|
356
356
|
3. Navigate to [edge://tracing](edge://tracing) or [chrome://tracing](chrome://tracing) and load `trace.json`
|
|
@@ -359,6 +359,10 @@ setting "generateTrace" compiler option. This is an instruction from [microsoft/
|
|
|
359
359
|
6. Open `types.json` in an editor
|
|
360
360
|
7. When you see a type ID in the tracing output, go-to-line {id} to find data about that type
|
|
361
361
|
|
|
362
|
+
## Enabling incremental mode
|
|
363
|
+
|
|
364
|
+
You must both set "incremental": true in your `tsconfig.json` (under `compilerOptions`) and also specify mode: 'write-references' in `ForkTsCheckerWebpackPlugin` settings.
|
|
365
|
+
|
|
362
366
|
|
|
363
367
|
## Related projects
|
|
364
368
|
|
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.6'; // will be replaced by the @semantic-release/exec
|
|
74
74
|
/**
|
|
75
75
|
* Default pools for the plugin concurrency limit
|
|
76
76
|
*/
|
package/lib/rpc/wrap-rpc.js
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -29,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
29
10
|
};
|
|
30
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
12
|
exports.wrapRpc = void 0;
|
|
32
|
-
const
|
|
13
|
+
const controlled_promise_1 = require("../utils/async/controlled-promise");
|
|
33
14
|
const rpc_error_1 = require("./rpc-error");
|
|
34
15
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
16
|
function wrapRpc(childProcess) {
|
|
@@ -41,50 +22,52 @@ function wrapRpc(childProcess) {
|
|
|
41
22
|
throw new Error(`Process ${childProcess.pid} doesn't have open IPC channels`);
|
|
42
23
|
}
|
|
43
24
|
const id = uuid();
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
unsubscribe();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
const handleClose = (code, signal) => {
|
|
58
|
-
reject(new rpc_error_1.RpcExitError(code
|
|
59
|
-
? `Process ${process.pid} exited with code "${code}" [${signal}]`
|
|
60
|
-
: `Process ${process.pid} exited [${signal}].`, code, signal));
|
|
61
|
-
unsubscribe();
|
|
62
|
-
};
|
|
63
|
-
const subscribe = () => {
|
|
64
|
-
childProcess.on('message', handleMessage);
|
|
65
|
-
childProcess.on('close', handleClose);
|
|
66
|
-
};
|
|
67
|
-
const unsubscribe = () => {
|
|
68
|
-
childProcess.off('message', handleMessage);
|
|
69
|
-
childProcess.off('exit', handleClose);
|
|
70
|
-
};
|
|
71
|
-
subscribe();
|
|
72
|
-
});
|
|
73
|
-
yield new Promise((resolve, reject) => {
|
|
74
|
-
childProcess.send({
|
|
75
|
-
type: 'call',
|
|
76
|
-
id,
|
|
77
|
-
args,
|
|
78
|
-
}, (error) => {
|
|
79
|
-
if (error) {
|
|
80
|
-
reject(error);
|
|
25
|
+
// create promises
|
|
26
|
+
const { promise: resultPromise, resolve: resolveResult, reject: rejectResult, } = (0, controlled_promise_1.createControlledPromise)();
|
|
27
|
+
const { promise: sendPromise, resolve: resolveSend, reject: rejectSend, } = (0, controlled_promise_1.createControlledPromise)();
|
|
28
|
+
const handleMessage = (message) => {
|
|
29
|
+
if ((message === null || message === void 0 ? void 0 : message.id) === id) {
|
|
30
|
+
if (message.type === 'resolve') {
|
|
31
|
+
// assume the contract is respected
|
|
32
|
+
resolveResult(message.value);
|
|
33
|
+
removeHandlers();
|
|
81
34
|
}
|
|
82
|
-
else {
|
|
83
|
-
|
|
35
|
+
else if (message.type === 'reject') {
|
|
36
|
+
rejectResult(message.error);
|
|
37
|
+
removeHandlers();
|
|
84
38
|
}
|
|
85
|
-
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const handleClose = (code, signal) => {
|
|
42
|
+
rejectResult(new rpc_error_1.RpcExitError(code
|
|
43
|
+
? `Process ${childProcess.pid} exited with code ${code}` +
|
|
44
|
+
(signal ? ` [${signal}]` : '')
|
|
45
|
+
: `Process ${childProcess.pid} exited` + (signal ? ` [${signal}]` : ''), code, signal));
|
|
46
|
+
removeHandlers();
|
|
47
|
+
};
|
|
48
|
+
// to prevent event handler leaks
|
|
49
|
+
const removeHandlers = () => {
|
|
50
|
+
childProcess.off('message', handleMessage);
|
|
51
|
+
childProcess.off('close', handleClose);
|
|
52
|
+
};
|
|
53
|
+
// add event listeners
|
|
54
|
+
childProcess.on('message', handleMessage);
|
|
55
|
+
childProcess.on('close', handleClose);
|
|
56
|
+
// send call message
|
|
57
|
+
childProcess.send({
|
|
58
|
+
type: 'call',
|
|
59
|
+
id,
|
|
60
|
+
args,
|
|
61
|
+
}, (error) => {
|
|
62
|
+
if (error) {
|
|
63
|
+
rejectSend(error);
|
|
64
|
+
removeHandlers();
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
resolveSend(undefined);
|
|
68
|
+
}
|
|
86
69
|
});
|
|
87
|
-
return resultPromise;
|
|
70
|
+
return sendPromise.then(() => resultPromise);
|
|
88
71
|
}));
|
|
89
72
|
}
|
|
90
73
|
exports.wrapRpc = wrapRpc;
|
|
@@ -5,6 +5,7 @@ const config_1 = require("../config");
|
|
|
5
5
|
const diagnostics_1 = require("../diagnostics");
|
|
6
6
|
const emit_1 = require("../emit");
|
|
7
7
|
const compiler_host_1 = require("../host/compiler-host");
|
|
8
|
+
const tracing_1 = require("../tracing");
|
|
8
9
|
const typescript_1 = require("../typescript");
|
|
9
10
|
let compilerHost;
|
|
10
11
|
let program;
|
|
@@ -14,6 +15,7 @@ function useProgram() {
|
|
|
14
15
|
compilerHost = (0, compiler_host_1.createCompilerHost)(parsedConfig);
|
|
15
16
|
}
|
|
16
17
|
if (!program) {
|
|
18
|
+
(0, tracing_1.startTracingIfNeeded)(parsedConfig.options);
|
|
17
19
|
program = typescript_1.typescript.createProgram({
|
|
18
20
|
rootNames: parsedConfig.fileNames,
|
|
19
21
|
options: parsedConfig.options,
|
|
@@ -23,6 +25,7 @@ function useProgram() {
|
|
|
23
25
|
}
|
|
24
26
|
(0, diagnostics_1.updateDiagnostics)((0, config_1.getConfigFilePathFromProgram)(program), (0, diagnostics_1.getDiagnosticsOfProgram)(program));
|
|
25
27
|
(0, emit_1.emitDtsIfNeeded)(program);
|
|
28
|
+
(0, tracing_1.stopTracingIfNeeded)(program);
|
|
26
29
|
}
|
|
27
30
|
exports.useProgram = useProgram;
|
|
28
31
|
function invalidateProgram(withHost = false) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type * as ts from 'typescript';
|
|
2
2
|
export declare function startTracingIfNeeded(compilerOptions: ts.CompilerOptions): void;
|
|
3
|
-
export declare function stopTracingIfNeeded(program: ts.BuilderProgram): void;
|
|
3
|
+
export declare function stopTracingIfNeeded(program: ts.Program | ts.BuilderProgram): void;
|
|
4
4
|
export declare function dumpTracingLegendIfNeeded(): void;
|
|
@@ -5,24 +5,25 @@ const config_1 = require("./config");
|
|
|
5
5
|
const typescript_1 = require("./typescript");
|
|
6
6
|
const worker_config_1 = require("./worker-config");
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
-
const
|
|
8
|
+
const traceableTypescript = typescript_1.typescript;
|
|
9
9
|
function startTracingIfNeeded(compilerOptions) {
|
|
10
|
-
if (compilerOptions.generateTrace
|
|
11
|
-
|
|
10
|
+
if (typeof compilerOptions.generateTrace === 'string' &&
|
|
11
|
+
typeof traceableTypescript.startTracing === 'function') {
|
|
12
|
+
traceableTypescript.startTracing(worker_config_1.config.build ? 'build' : 'project', compilerOptions.generateTrace, (0, config_1.getConfigFilePathFromCompilerOptions)(compilerOptions));
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
exports.startTracingIfNeeded = startTracingIfNeeded;
|
|
15
16
|
function stopTracingIfNeeded(program) {
|
|
17
|
+
var _a;
|
|
16
18
|
const compilerOptions = program.getCompilerOptions();
|
|
17
|
-
if (compilerOptions.generateTrace
|
|
18
|
-
|
|
19
|
-
tracing.stopTracing(
|
|
19
|
+
if (typeof compilerOptions.generateTrace === 'string' &&
|
|
20
|
+
typeof ((_a = traceableTypescript.tracing) === null || _a === void 0 ? void 0 : _a.stopTracing) === 'function') {
|
|
21
|
+
traceableTypescript.tracing.stopTracing();
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
exports.stopTracingIfNeeded = stopTracingIfNeeded;
|
|
23
25
|
function dumpTracingLegendIfNeeded() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
26
|
+
var _a;
|
|
27
|
+
(_a = traceableTypescript.tracing) === null || _a === void 0 ? void 0 : _a.dumpLegend();
|
|
27
28
|
}
|
|
28
29
|
exports.dumpTracingLegendIfNeeded = dumpTracingLegendIfNeeded;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createControlledPromise = void 0;
|
|
4
|
+
function createControlledPromise() {
|
|
5
|
+
let resolve = () => undefined;
|
|
6
|
+
let reject = () => undefined;
|
|
7
|
+
const promise = new Promise((aResolve, aReject) => {
|
|
8
|
+
resolve = aResolve;
|
|
9
|
+
reject = aReject;
|
|
10
|
+
});
|
|
11
|
+
return {
|
|
12
|
+
promise,
|
|
13
|
+
resolve,
|
|
14
|
+
reject,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
exports.createControlledPromise = createControlledPromise;
|