fork-ts-checker-webpack-plugin 9.1.1 → 10.0.0-alpha.1
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 +23 -13
- package/lib/files-change.js +5 -6
- package/lib/formatter/basic-formatter.js +3 -4
- package/lib/formatter/code-frame-formatter.d.ts +3 -2
- package/lib/formatter/code-frame-formatter.js +14 -5
- package/lib/formatter/formatter-config.js +3 -3
- package/lib/formatter/formatter-options.d.ts +1 -1
- package/lib/formatter/stats-formatter.js +4 -5
- package/lib/formatter/webpack-formatter.js +6 -11
- package/lib/hooks/intercept-done-to-get-dev-server-tap.js +1 -2
- package/lib/hooks/report-issues.d.ts +8 -0
- package/lib/hooks/report-issues.js +22 -0
- package/lib/hooks/tap-after-compile-to-add-dependencies.js +4 -14
- package/lib/hooks/tap-after-compile-to-get-issues.js +7 -29
- package/lib/hooks/tap-after-environment-to-patch-watching.js +1 -2
- package/lib/hooks/tap-done-to-async-get-issues.js +13 -34
- package/lib/hooks/tap-error-to-log-message.js +6 -9
- package/lib/hooks/tap-start-to-run-workers.js +13 -24
- package/lib/hooks/tap-stop-to-terminate-workers.js +1 -2
- package/lib/infrastructure-logger.js +1 -2
- package/lib/issue/issue-config.js +1 -2
- package/lib/issue/issue-location.js +2 -3
- package/lib/issue/issue-match.js +3 -4
- package/lib/issue/issue-position.js +1 -2
- package/lib/issue/issue-predicate.js +2 -3
- package/lib/issue/issue-severity.js +2 -3
- package/lib/issue/issue-webpack-error.js +21 -18
- package/lib/issue/issue.js +2 -3
- package/lib/plugin-config.js +1 -2
- package/lib/plugin-hooks.d.ts +4 -4
- package/lib/plugin-hooks.js +1 -2
- package/lib/plugin-options.json +4 -8
- package/lib/plugin-pools.js +17 -7
- package/lib/plugin-state.d.ts +0 -1
- package/lib/plugin-state.js +1 -2
- package/lib/plugin.d.ts +2 -2
- package/lib/plugin.js +39 -24
- package/lib/rpc/expose-rpc.js +6 -16
- package/lib/rpc/rpc-error.js +2 -0
- package/lib/rpc/rpc-worker.d.ts +1 -2
- package/lib/rpc/rpc-worker.js +26 -17
- package/lib/rpc/wrap-rpc.d.ts +0 -1
- package/lib/rpc/wrap-rpc.js +4 -14
- package/lib/typescript/type-script-package.d.ts +4 -0
- package/lib/typescript/type-script-package.js +88 -0
- package/lib/typescript/type-script-support.js +26 -27
- package/lib/typescript/type-script-worker-config.d.ts +2 -3
- package/lib/typescript/type-script-worker-config.js +24 -4
- package/lib/typescript/type-script-worker-options.d.ts +4 -3
- package/lib/typescript/type-script-worker-options.js +4 -0
- package/lib/typescript/worker/get-dependencies-worker.js +15 -4
- package/lib/typescript/worker/get-issues-worker.d.ts +1 -1
- package/lib/typescript/worker/get-issues-worker.js +52 -64
- package/lib/typescript/worker/lib/api.d.ts +13 -0
- package/lib/typescript/worker/lib/api.js +62 -0
- package/lib/typescript/worker/lib/config.d.ts +13 -9
- package/lib/typescript/worker/lib/config.js +93 -65
- package/lib/typescript/worker/lib/dependencies.d.ts +6 -1
- package/lib/typescript/worker/lib/dependencies.js +187 -53
- package/lib/typescript/worker/lib/diagnostics.d.ts +5 -4
- package/lib/typescript/worker/lib/diagnostics.js +67 -51
- package/lib/typescript/worker/lib/in-memory-file-system.d.ts +14 -0
- package/lib/typescript/worker/lib/in-memory-file-system.js +140 -0
- package/lib/typescript/worker/lib/performance.d.ts +1 -2
- package/lib/typescript/worker/lib/performance.js +13 -21
- package/lib/typescript/worker/lib/program/program.d.ts +6 -2
- package/lib/typescript/worker/lib/program/program.js +136 -26
- package/lib/typescript/worker/lib/program/solution-builder.d.ts +3 -1
- package/lib/typescript/worker/lib/program/solution-builder.js +43 -27
- package/lib/typescript/worker/lib/typescript.d.ts +4 -2
- package/lib/typescript/worker/lib/typescript.js +69 -3
- package/lib/utils/async/abort-error.d.ts +0 -1
- package/lib/utils/async/abort-error.js +1 -1
- package/lib/utils/async/controlled-promise.js +1 -2
- package/lib/utils/async/is-pending.js +1 -2
- package/lib/utils/async/pool.d.ts +0 -1
- package/lib/utils/async/pool.js +13 -25
- package/lib/utils/async/wait.js +1 -2
- package/lib/utils/deep-merge.d.ts +5 -0
- package/lib/utils/deep-merge.js +56 -0
- package/lib/utils/path/format-file-path.d.ts +3 -0
- package/lib/utils/path/format-file-path.js +15 -0
- package/lib/utils/path/forward-slash.js +1 -2
- package/lib/utils/path/is-inside-another-path.js +1 -2
- package/lib/utils/path/relative-to-context.js +1 -2
- package/lib/watch/inclusive-node-watch-file-system.d.ts +3 -0
- package/lib/watch/inclusive-node-watch-file-system.js +121 -113
- package/lib/watch/watch-file-system.d.ts +0 -1
- package/package.json +43 -53
- package/lib/formatter/types/babel__code-frame.d.ts +0 -21
- package/lib/formatter/types/babel__code-frame.js +0 -7
- package/lib/typescript/worker/lib/artifacts.d.ts +0 -4
- package/lib/typescript/worker/lib/artifacts.js +0 -94
- package/lib/typescript/worker/lib/emit.d.ts +0 -2
- package/lib/typescript/worker/lib/emit.js +0 -13
- package/lib/typescript/worker/lib/file-system/file-system.d.ts +0 -18
- package/lib/typescript/worker/lib/file-system/file-system.js +0 -2
- package/lib/typescript/worker/lib/file-system/mem-file-system.d.ts +0 -5
- package/lib/typescript/worker/lib/file-system/mem-file-system.js +0 -78
- package/lib/typescript/worker/lib/file-system/passive-file-system.d.ts +0 -5
- package/lib/typescript/worker/lib/file-system/passive-file-system.js +0 -65
- package/lib/typescript/worker/lib/file-system/real-file-system.d.ts +0 -5
- package/lib/typescript/worker/lib/file-system/real-file-system.js +0 -191
- package/lib/typescript/worker/lib/host/compiler-host.d.ts +0 -2
- package/lib/typescript/worker/lib/host/compiler-host.js +0 -10
- package/lib/typescript/worker/lib/host/watch-compiler-host.d.ts +0 -2
- package/lib/typescript/worker/lib/host/watch-compiler-host.js +0 -20
- package/lib/typescript/worker/lib/host/watch-solution-builder-host.d.ts +0 -2
- package/lib/typescript/worker/lib/host/watch-solution-builder-host.js +0 -47
- package/lib/typescript/worker/lib/program/watch-program.d.ts +0 -3
- package/lib/typescript/worker/lib/program/watch-program.js +0 -51
- package/lib/typescript/worker/lib/system.d.ts +0 -19
- package/lib/typescript/worker/lib/system.js +0 -232
- package/lib/typescript/worker/lib/tracing.d.ts +0 -4
- package/lib/typescript/worker/lib/tracing.js +0 -29
- package/lib/typescript/worker/lib/tsbuildinfo.d.ts +0 -4
- package/lib/typescript/worker/lib/tsbuildinfo.js +0 -96
package/lib/rpc/rpc-worker.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import type { ChildProcess } from 'child_process';
|
|
3
2
|
import type { RpcMethod, RpcRemoteMethod } from './types';
|
|
4
3
|
interface RpcWorkerBase {
|
|
@@ -8,6 +7,6 @@ interface RpcWorkerBase {
|
|
|
8
7
|
readonly process: ChildProcess | undefined;
|
|
9
8
|
}
|
|
10
9
|
type RpcWorker<T extends RpcMethod = RpcMethod> = RpcWorkerBase & RpcRemoteMethod<T>;
|
|
11
|
-
declare function createRpcWorker<T extends RpcMethod>(modulePath: string, data: unknown
|
|
10
|
+
declare function createRpcWorker<T extends RpcMethod>(modulePath: string, data: unknown): RpcWorker<T>;
|
|
12
11
|
declare function getRpcWorkerData(): unknown;
|
|
13
12
|
export { createRpcWorker, getRpcWorkerData, RpcWorker };
|
package/lib/rpc/rpc-worker.js
CHANGED
|
@@ -15,28 +15,39 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
36
|
+
exports.createRpcWorker = createRpcWorker;
|
|
37
|
+
exports.getRpcWorkerData = getRpcWorkerData;
|
|
27
38
|
const child_process = __importStar(require("child_process"));
|
|
28
39
|
const process = __importStar(require("process"));
|
|
29
40
|
const wrap_rpc_1 = require("./wrap-rpc");
|
|
30
41
|
const WORKER_DATA_ENV_KEY = 'WORKER_DATA';
|
|
31
|
-
function createRpcWorker(modulePath, data
|
|
42
|
+
function createRpcWorker(modulePath, data) {
|
|
32
43
|
const options = {
|
|
33
|
-
env:
|
|
44
|
+
env: {
|
|
45
|
+
...process.env,
|
|
46
|
+
[WORKER_DATA_ENV_KEY]: JSON.stringify(data || {}),
|
|
47
|
+
},
|
|
34
48
|
stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
|
|
35
49
|
serialization: 'advanced',
|
|
36
50
|
};
|
|
37
|
-
if (memoryLimit) {
|
|
38
|
-
options.execArgv = [`--max-old-space-size=${memoryLimit}`];
|
|
39
|
-
}
|
|
40
51
|
let childProcess;
|
|
41
52
|
let remoteMethod;
|
|
42
53
|
const worker = {
|
|
@@ -46,7 +57,7 @@ function createRpcWorker(modulePath, data, memoryLimit) {
|
|
|
46
57
|
childProcess = undefined;
|
|
47
58
|
remoteMethod = undefined;
|
|
48
59
|
}
|
|
49
|
-
if (!
|
|
60
|
+
if (!childProcess?.connected) {
|
|
50
61
|
childProcess = child_process.fork(modulePath, options);
|
|
51
62
|
remoteMethod = (0, wrap_rpc_1.wrapRpc)(childProcess);
|
|
52
63
|
}
|
|
@@ -59,7 +70,7 @@ function createRpcWorker(modulePath, data, memoryLimit) {
|
|
|
59
70
|
}
|
|
60
71
|
},
|
|
61
72
|
get connected() {
|
|
62
|
-
return Boolean(childProcess
|
|
73
|
+
return Boolean(childProcess?.connected);
|
|
63
74
|
},
|
|
64
75
|
get process() {
|
|
65
76
|
return childProcess;
|
|
@@ -76,8 +87,6 @@ function createRpcWorker(modulePath, data, memoryLimit) {
|
|
|
76
87
|
return remoteMethod(...args);
|
|
77
88
|
}, worker);
|
|
78
89
|
}
|
|
79
|
-
exports.createRpcWorker = createRpcWorker;
|
|
80
90
|
function getRpcWorkerData() {
|
|
81
91
|
return JSON.parse(process.env[WORKER_DATA_ENV_KEY] || '{}');
|
|
82
92
|
}
|
|
83
|
-
exports.getRpcWorkerData = getRpcWorkerData;
|
package/lib/rpc/wrap-rpc.d.ts
CHANGED
package/lib/rpc/wrap-rpc.js
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.wrapRpc =
|
|
3
|
+
exports.wrapRpc = wrapRpc;
|
|
13
4
|
const controlled_promise_1 = require("../utils/async/controlled-promise");
|
|
14
5
|
const rpc_error_1 = require("./rpc-error");
|
|
15
6
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
7
|
function wrapRpc(childProcess) {
|
|
17
|
-
return ((...args) =>
|
|
8
|
+
return (async (...args) => {
|
|
18
9
|
if (!childProcess.send) {
|
|
19
10
|
throw new Error(`Process ${childProcess.pid} doesn't have IPC channels`);
|
|
20
11
|
}
|
|
@@ -26,7 +17,7 @@ function wrapRpc(childProcess) {
|
|
|
26
17
|
const { promise: resultPromise, resolve: resolveResult, reject: rejectResult, } = (0, controlled_promise_1.createControlledPromise)();
|
|
27
18
|
const { promise: sendPromise, resolve: resolveSend, reject: rejectSend, } = (0, controlled_promise_1.createControlledPromise)();
|
|
28
19
|
const handleMessage = (message) => {
|
|
29
|
-
if (
|
|
20
|
+
if (message?.id === id) {
|
|
30
21
|
if (message.type === 'resolve') {
|
|
31
22
|
// assume the contract is respected
|
|
32
23
|
resolveResult(message.value);
|
|
@@ -68,9 +59,8 @@ function wrapRpc(childProcess) {
|
|
|
68
59
|
}
|
|
69
60
|
});
|
|
70
61
|
return sendPromise.then(() => resultPromise);
|
|
71
|
-
})
|
|
62
|
+
});
|
|
72
63
|
}
|
|
73
|
-
exports.wrapRpc = wrapRpc;
|
|
74
64
|
function uuid() {
|
|
75
65
|
return new Array(4)
|
|
76
66
|
.fill(0)
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function findTypeScriptPackageDirectory(typescriptPath: string): string;
|
|
2
|
+
export declare function readTypeScriptPackageJson(packageDirectory: string): any;
|
|
3
|
+
/** The version of the TypeScript package that `typescriptPath` points into, if any. */
|
|
4
|
+
export declare function getTypeScriptVersion(typescriptPath: string): string | undefined;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.findTypeScriptPackageDirectory = findTypeScriptPackageDirectory;
|
|
37
|
+
exports.readTypeScriptPackageJson = readTypeScriptPackageJson;
|
|
38
|
+
exports.getTypeScriptVersion = getTypeScriptVersion;
|
|
39
|
+
const fs = __importStar(require("fs"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
/**
|
|
42
|
+
* `typescriptPath` points somewhere inside the TypeScript package (by default
|
|
43
|
+
* `require.resolve('typescript')`, i.e. `lib/version.cjs`), or at the package
|
|
44
|
+
* directory itself. TypeScript 7 has no `main`, and its entry points are only
|
|
45
|
+
* reachable through the `exports` map, so locate the package.json ourselves.
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* Skips unrelated package.json files on the way up, such as the user's project
|
|
49
|
+
* when `typescriptPath` is wrong. A package exposing `./sync` also counts, so a
|
|
50
|
+
* TypeScript build published under another name still works.
|
|
51
|
+
*/
|
|
52
|
+
function isTypeScriptPackage(directory) {
|
|
53
|
+
try {
|
|
54
|
+
const packageJson = readTypeScriptPackageJson(directory);
|
|
55
|
+
return packageJson.name === 'typescript' || packageJson.exports?.['./sync'] !== undefined;
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function findTypeScriptPackageDirectory(typescriptPath) {
|
|
62
|
+
let directory = fs.existsSync(typescriptPath) && fs.statSync(typescriptPath).isDirectory()
|
|
63
|
+
? typescriptPath
|
|
64
|
+
: path.dirname(typescriptPath);
|
|
65
|
+
while (true) {
|
|
66
|
+
if (isTypeScriptPackage(directory)) {
|
|
67
|
+
return directory;
|
|
68
|
+
}
|
|
69
|
+
const parent = path.dirname(directory);
|
|
70
|
+
if (parent === directory) {
|
|
71
|
+
throw new Error(`Cannot find the TypeScript package.json for "${typescriptPath}".`);
|
|
72
|
+
}
|
|
73
|
+
directory = parent;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function readTypeScriptPackageJson(packageDirectory) {
|
|
77
|
+
return JSON.parse(fs.readFileSync(path.join(packageDirectory, 'package.json'), 'utf8'));
|
|
78
|
+
}
|
|
79
|
+
/** The version of the TypeScript package that `typescriptPath` points into, if any. */
|
|
80
|
+
function getTypeScriptVersion(typescriptPath) {
|
|
81
|
+
try {
|
|
82
|
+
const packageJson = readTypeScriptPackageJson(findTypeScriptPackageDirectory(typescriptPath));
|
|
83
|
+
return typeof packageJson.version === 'string' ? packageJson.version : undefined;
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -15,46 +15,46 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.assertTypeScriptSupport =
|
|
39
|
+
exports.assertTypeScriptSupport = assertTypeScriptSupport;
|
|
40
|
+
const fs_1 = __importDefault(require("fs"));
|
|
30
41
|
const os_1 = __importDefault(require("os"));
|
|
31
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
32
42
|
const semver = __importStar(require("semver"));
|
|
43
|
+
const type_script_package_1 = require("./type-script-package");
|
|
44
|
+
const MINIMUM_TYPESCRIPT_VERSION = '7.1.0-beta';
|
|
33
45
|
function assertTypeScriptSupport(config) {
|
|
34
|
-
|
|
35
|
-
try {
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
37
|
-
typescriptVersion = require(config.typescriptPath).version;
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
// silent catch
|
|
41
|
-
}
|
|
46
|
+
const typescriptVersion = (0, type_script_package_1.getTypeScriptVersion)(config.typescriptPath);
|
|
42
47
|
if (!typescriptVersion) {
|
|
43
48
|
throw new Error('When you use ForkTsCheckerWebpackPlugin with typescript reporter enabled, you must install `typescript` package.');
|
|
44
49
|
}
|
|
45
|
-
if (semver.lt(typescriptVersion,
|
|
50
|
+
if (semver.lt(typescriptVersion, MINIMUM_TYPESCRIPT_VERSION)) {
|
|
46
51
|
throw new Error([
|
|
47
52
|
`ForkTsCheckerWebpackPlugin cannot use the current typescript version of ${typescriptVersion}.`,
|
|
48
|
-
|
|
53
|
+
`The minimum required version is ${MINIMUM_TYPESCRIPT_VERSION}.`,
|
|
54
|
+
'Use fork-ts-checker-webpack-plugin@9 for older TypeScript versions.',
|
|
49
55
|
].join(os_1.default.EOL));
|
|
50
56
|
}
|
|
51
|
-
if (
|
|
52
|
-
throw new Error([
|
|
53
|
-
`ForkTsCheckerWebpackPlugin doesn't support build option for the current typescript version of ${typescriptVersion}.`,
|
|
54
|
-
'The minimum required version is 3.8.0.',
|
|
55
|
-
].join(os_1.default.EOL));
|
|
56
|
-
}
|
|
57
|
-
if (!fs_extra_1.default.existsSync(config.configFile)) {
|
|
57
|
+
if (!fs_1.default.existsSync(config.configFile)) {
|
|
58
58
|
throw new Error([
|
|
59
59
|
`Cannot find the "${config.configFile}" file.`,
|
|
60
60
|
`Please check webpack and ForkTsCheckerWebpackPlugin configuration.`,
|
|
@@ -64,4 +64,3 @@ function assertTypeScriptSupport(config) {
|
|
|
64
64
|
].join(os_1.default.EOL));
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
exports.assertTypeScriptSupport = assertTypeScriptSupport;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import type * as webpack from 'webpack';
|
|
2
2
|
import type { TypeScriptConfigOverwrite } from './type-script-config-overwrite';
|
|
3
3
|
import type { TypeScriptDiagnosticsOptions } from './type-script-diagnostics-options';
|
|
4
|
-
import type { TypeScriptWorkerOptions } from './type-script-worker-options';
|
|
4
|
+
import type { TypeScriptWorkerMode, TypeScriptWorkerOptions } from './type-script-worker-options';
|
|
5
5
|
interface TypeScriptWorkerConfig {
|
|
6
|
-
memoryLimit: number;
|
|
7
6
|
configFile: string;
|
|
8
7
|
configOverwrite: TypeScriptConfigOverwrite;
|
|
9
8
|
build: boolean;
|
|
10
9
|
context: string;
|
|
11
|
-
mode:
|
|
10
|
+
mode: TypeScriptWorkerMode;
|
|
12
11
|
diagnosticOptions: TypeScriptDiagnosticsOptions;
|
|
13
12
|
profile: boolean;
|
|
14
13
|
typescriptPath: string;
|
|
@@ -3,16 +3,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createTypeScriptWorkerConfig =
|
|
6
|
+
exports.createTypeScriptWorkerConfig = createTypeScriptWorkerConfig;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
function createTypeScriptWorkerConfig(compiler, options) {
|
|
9
|
-
let configFile =
|
|
9
|
+
let configFile = options?.configFile || 'tsconfig.json';
|
|
10
10
|
// ensure that `configFile` is an absolute normalized path
|
|
11
11
|
configFile = path_1.default.normalize(path_1.default.isAbsolute(configFile)
|
|
12
12
|
? configFile
|
|
13
13
|
: path_1.default.resolve(compiler.options.context || process.cwd(), configFile));
|
|
14
14
|
const optionsAsObject = typeof options === 'object' ? options : {};
|
|
15
15
|
const typescriptPath = optionsAsObject.typescriptPath || require.resolve('typescript');
|
|
16
|
-
|
|
16
|
+
const build = Boolean(optionsAsObject.build);
|
|
17
|
+
const mode = optionsAsObject.mode || 'in-memory';
|
|
18
|
+
return {
|
|
19
|
+
profile: false,
|
|
20
|
+
...optionsAsObject,
|
|
21
|
+
build,
|
|
22
|
+
mode,
|
|
23
|
+
configFile: configFile,
|
|
24
|
+
configOverwrite: optionsAsObject.configOverwrite || {},
|
|
25
|
+
// ensure that `context` is an absolute normalized path, like `configFile`
|
|
26
|
+
context: optionsAsObject.context
|
|
27
|
+
? path_1.default.resolve(optionsAsObject.context)
|
|
28
|
+
: path_1.default.dirname(configFile),
|
|
29
|
+
diagnosticOptions: {
|
|
30
|
+
syntactic: false, // by default they are reported by the loader
|
|
31
|
+
semantic: true,
|
|
32
|
+
declaration: false,
|
|
33
|
+
global: false,
|
|
34
|
+
...(optionsAsObject.diagnosticOptions || {}),
|
|
35
|
+
},
|
|
36
|
+
typescriptPath: typescriptPath,
|
|
37
|
+
};
|
|
17
38
|
}
|
|
18
|
-
exports.createTypeScriptWorkerConfig = createTypeScriptWorkerConfig;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { TypeScriptConfigOverwrite } from './type-script-config-overwrite';
|
|
2
2
|
import type { TypeScriptDiagnosticsOptions } from './type-script-diagnostics-options';
|
|
3
|
+
declare const TYPESCRIPT_WORKER_MODES: readonly ['in-memory', 'write'];
|
|
4
|
+
type TypeScriptWorkerMode = (typeof TYPESCRIPT_WORKER_MODES)[number];
|
|
3
5
|
type TypeScriptWorkerOptions = {
|
|
4
|
-
memoryLimit?: number;
|
|
5
6
|
configFile?: string;
|
|
6
7
|
configOverwrite?: TypeScriptConfigOverwrite;
|
|
7
8
|
context?: string;
|
|
8
9
|
build?: boolean;
|
|
9
|
-
mode?:
|
|
10
|
+
mode?: TypeScriptWorkerMode;
|
|
10
11
|
diagnosticOptions?: Partial<TypeScriptDiagnosticsOptions>;
|
|
11
12
|
profile?: boolean;
|
|
12
13
|
typescriptPath?: string;
|
|
13
14
|
};
|
|
14
|
-
export { TypeScriptWorkerOptions };
|
|
15
|
+
export { TYPESCRIPT_WORKER_MODES, TypeScriptWorkerMode, TypeScriptWorkerOptions };
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TYPESCRIPT_WORKER_MODES = void 0;
|
|
4
|
+
// keep in sync with the `mode` enum in plugin-options.json - a unit test checks it
|
|
5
|
+
const TYPESCRIPT_WORKER_MODES = ['in-memory', 'write'];
|
|
6
|
+
exports.TYPESCRIPT_WORKER_MODES = TYPESCRIPT_WORKER_MODES;
|
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const rpc_1 = require("../../rpc");
|
|
4
|
+
const api_1 = require("./lib/api");
|
|
4
5
|
const config_1 = require("./lib/config");
|
|
5
6
|
const dependencies_1 = require("./lib/dependencies");
|
|
6
|
-
|
|
7
|
+
// the native compiler process must not outlive the worker (see get-issues-worker.ts)
|
|
8
|
+
process.on('exit', api_1.closeApi);
|
|
7
9
|
const getDependenciesWorker = (change) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
try {
|
|
11
|
+
if ((0, config_1.didConfigFileChanged)((0, dependencies_1.getConfigFiles)(), change) ||
|
|
12
|
+
(0, config_1.didDependenciesProbablyChanged)((0, dependencies_1.getDependencies)(), change)) {
|
|
13
|
+
(0, config_1.invalidateConfig)();
|
|
14
|
+
(0, dependencies_1.invalidateDependencies)();
|
|
15
|
+
}
|
|
16
|
+
return (0, dependencies_1.getDependencies)();
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
// the compiler process may have died - start from scratch on the next call
|
|
20
|
+
(0, api_1.closeApi)();
|
|
10
21
|
(0, config_1.invalidateConfig)();
|
|
11
22
|
(0, dependencies_1.invalidateDependencies)();
|
|
23
|
+
throw error;
|
|
12
24
|
}
|
|
13
|
-
return (0, dependencies_1.getDependencies)();
|
|
14
25
|
};
|
|
15
26
|
(0, rpc_1.exposeRpc)(getDependenciesWorker);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FilesChange } from '../../files-change';
|
|
2
2
|
import type { Issue } from '../../issue';
|
|
3
|
-
declare const getIssuesWorker: (change: FilesChange
|
|
3
|
+
declare const getIssuesWorker: (change: FilesChange) => Promise<Issue[]>;
|
|
4
4
|
export type GetIssuesWorker = typeof getIssuesWorker;
|
|
5
5
|
export {};
|
|
@@ -1,80 +1,68 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
const rpc_1 = require("../../rpc");
|
|
13
|
-
const
|
|
4
|
+
const api_1 = require("./lib/api");
|
|
14
5
|
const config_1 = require("./lib/config");
|
|
15
6
|
const dependencies_1 = require("./lib/dependencies");
|
|
16
7
|
const diagnostics_1 = require("./lib/diagnostics");
|
|
17
8
|
const performance_1 = require("./lib/performance");
|
|
18
9
|
const program_1 = require("./lib/program/program");
|
|
19
10
|
const solution_builder_1 = require("./lib/program/solution-builder");
|
|
20
|
-
const watch_program_1 = require("./lib/program/watch-program");
|
|
21
|
-
const system_1 = require("./lib/system");
|
|
22
|
-
const tracing_1 = require("./lib/tracing");
|
|
23
|
-
const tsbuildinfo_1 = require("./lib/tsbuildinfo");
|
|
24
11
|
const worker_config_1 = require("./lib/worker-config");
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
(0,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
(0, config_1.invalidateConfig)();
|
|
40
|
-
(0, dependencies_1.invalidateDependencies)();
|
|
41
|
-
(0, artifacts_1.invalidateArtifacts)();
|
|
42
|
-
if ((0, config_1.didRootFilesChanged)()) {
|
|
43
|
-
(0, watch_program_1.invalidateWatchProgramRootFileNames)();
|
|
12
|
+
// The native compiler runs in its own process, which must not outlive the worker.
|
|
13
|
+
// Signals are deliberately left alone: the compiler exits by itself once the
|
|
14
|
+
// worker's end of the pipe closes, and a signal handler couldn't run while the
|
|
15
|
+
// worker is blocked in a synchronous compiler call, so the plugin's SIGTERM
|
|
16
|
+
// wouldn't stop a busy worker.
|
|
17
|
+
process.on('exit', api_1.closeApi);
|
|
18
|
+
(0, api_1.interceptBuildOutputs)();
|
|
19
|
+
const getIssuesWorker = async (change) => {
|
|
20
|
+
try {
|
|
21
|
+
if ((0, config_1.didConfigFileChanged)((0, dependencies_1.getConfigFiles)(), change)) {
|
|
22
|
+
(0, config_1.invalidateConfig)();
|
|
23
|
+
(0, dependencies_1.invalidateDependencies)();
|
|
24
|
+
(0, diagnostics_1.invalidateDiagnostics)();
|
|
25
|
+
(0, program_1.invalidateProgramConfig)();
|
|
44
26
|
(0, solution_builder_1.invalidateSolutionBuilder)();
|
|
45
27
|
}
|
|
28
|
+
else if ((0, config_1.didDependenciesProbablyChanged)((0, dependencies_1.getDependencies)(), change)) {
|
|
29
|
+
const previousRootFiles = (0, config_1.getParsedConfig)().fileNames;
|
|
30
|
+
(0, config_1.invalidateConfig)();
|
|
31
|
+
(0, dependencies_1.invalidateDependencies)();
|
|
32
|
+
if ((0, config_1.didRootFilesChanged)(previousRootFiles)) {
|
|
33
|
+
(0, program_1.invalidateProgramRootFileNames)();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
(0, performance_1.resetPerformanceIfNeeded)();
|
|
37
|
+
const parseConfigIssues = (0, config_1.getParseConfigIssues)();
|
|
38
|
+
if (parseConfigIssues.length) {
|
|
39
|
+
// the program never sees this run's file changes, so it has to start afresh
|
|
40
|
+
// once the config can be parsed again
|
|
41
|
+
(0, program_1.invalidateProgramConfig)();
|
|
42
|
+
// report config parse issues and exit
|
|
43
|
+
return parseConfigIssues;
|
|
44
|
+
}
|
|
45
|
+
// use proper implementation based on the config
|
|
46
|
+
if (worker_config_1.config.build) {
|
|
47
|
+
(0, solution_builder_1.useSolutionBuilder)();
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
(0, program_1.useProgram)(change);
|
|
51
|
+
}
|
|
52
|
+
// the timings come from the compiler process too
|
|
53
|
+
(0, performance_1.printPerformanceMeasuresIfNeeded)();
|
|
46
54
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
(0, solution_builder_1.useSolutionBuilder)();
|
|
57
|
-
}
|
|
58
|
-
else if (watching) {
|
|
59
|
-
(0, watch_program_1.useWatchProgram)();
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
(0, program_1.useProgram)();
|
|
55
|
+
catch (error) {
|
|
56
|
+
// the compiler process may have died - start from scratch on the next run
|
|
57
|
+
(0, program_1.resetProgram)();
|
|
58
|
+
(0, solution_builder_1.resetSolutionBuilder)();
|
|
59
|
+
(0, api_1.closeApi)();
|
|
60
|
+
(0, config_1.invalidateConfig)();
|
|
61
|
+
(0, dependencies_1.invalidateDependencies)();
|
|
62
|
+
(0, diagnostics_1.invalidateDiagnostics)();
|
|
63
|
+
return (0, diagnostics_1.createIssuesFromDiagnostics)([(0, diagnostics_1.createCrashDiagnostic)(error)]);
|
|
63
64
|
}
|
|
64
|
-
// simulate file system events
|
|
65
|
-
(_a = change.changedFiles) === null || _a === void 0 ? void 0 : _a.forEach((changedFile) => {
|
|
66
|
-
system_1.system === null || system_1.system === void 0 ? void 0 : system_1.system.invokeFileChanged(changedFile);
|
|
67
|
-
});
|
|
68
|
-
(_b = change.deletedFiles) === null || _b === void 0 ? void 0 : _b.forEach((deletedFile) => {
|
|
69
|
-
system_1.system === null || system_1.system === void 0 ? void 0 : system_1.system.invokeFileDeleted(deletedFile);
|
|
70
|
-
});
|
|
71
|
-
// wait for all queued events to be processed
|
|
72
|
-
yield system_1.system.waitForQueued();
|
|
73
65
|
// retrieve all collected diagnostics as normalized issues
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
(0, performance_1.printPerformanceMeasuresIfNeeded)();
|
|
77
|
-
(0, performance_1.disablePerformanceIfNeeded)();
|
|
78
|
-
return issues;
|
|
79
|
-
});
|
|
66
|
+
return (0, diagnostics_1.getIssues)();
|
|
67
|
+
};
|
|
80
68
|
(0, rpc_1.exposeRpc)(getIssuesWorker);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { API, BuildOrchestrator, BuildOrchestratorOptions } from 'typescript/sync';
|
|
2
|
+
/**
|
|
3
|
+
* Makes the API keep build-mode outputs in memory in the `in-memory` mode. Only
|
|
4
|
+
* the worker that builds needs it: the callbacks are round trips from the native
|
|
5
|
+
* compiler, which a worker that only parses tsconfig files would pay for nothing.
|
|
6
|
+
* Call it before the first `getApi()`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function interceptBuildOutputs(): void;
|
|
9
|
+
/** Forgets the resolved symlinks, in case packages were relinked between builds. */
|
|
10
|
+
export declare function invalidateRealDirectories(): void;
|
|
11
|
+
export declare function getApi(): API;
|
|
12
|
+
export declare function createBuildOrchestrator(rootNames: readonly string[], options: BuildOrchestratorOptions): BuildOrchestrator;
|
|
13
|
+
export declare function closeApi(): void;
|