@depup/fork-ts-checker-webpack-plugin 9.1.0-depup.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.
Files changed (169) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +42 -0
  3. package/changes.json +54 -0
  4. package/lib/files-change.d.ts +17 -0
  5. package/lib/files-change.js +57 -0
  6. package/lib/files-match.d.ts +7 -0
  7. package/lib/files-match.js +2 -0
  8. package/lib/formatter/basic-formatter.d.ts +3 -0
  9. package/lib/formatter/basic-formatter.js +13 -0
  10. package/lib/formatter/code-frame-formatter.d.ts +4 -0
  11. package/lib/formatter/code-frame-formatter.js +29 -0
  12. package/lib/formatter/formatter-config.d.ts +8 -0
  13. package/lib/formatter/formatter-config.js +36 -0
  14. package/lib/formatter/formatter-options.d.ts +14 -0
  15. package/lib/formatter/formatter-options.js +2 -0
  16. package/lib/formatter/formatter.d.ts +4 -0
  17. package/lib/formatter/formatter.js +2 -0
  18. package/lib/formatter/index.d.ts +6 -0
  19. package/lib/formatter/index.js +22 -0
  20. package/lib/formatter/stats-formatter.d.ts +3 -0
  21. package/lib/formatter/stats-formatter.js +28 -0
  22. package/lib/formatter/types/babel__code-frame.d.ts +21 -0
  23. package/lib/formatter/types/babel__code-frame.js +7 -0
  24. package/lib/formatter/webpack-formatter.d.ts +3 -0
  25. package/lib/formatter/webpack-formatter.js +32 -0
  26. package/lib/hooks/intercept-done-to-get-dev-server-tap.d.ts +5 -0
  27. package/lib/hooks/intercept-done-to-get-dev-server-tap.js +18 -0
  28. package/lib/hooks/tap-after-compile-to-add-dependencies.d.ts +5 -0
  29. package/lib/hooks/tap-after-compile-to-add-dependencies.js +31 -0
  30. package/lib/hooks/tap-after-compile-to-get-issues.d.ts +5 -0
  31. package/lib/hooks/tap-after-compile-to-get-issues.js +52 -0
  32. package/lib/hooks/tap-after-environment-to-patch-watching.d.ts +4 -0
  33. package/lib/hooks/tap-after-environment-to-patch-watching.js +22 -0
  34. package/lib/hooks/tap-done-to-async-get-issues.d.ts +5 -0
  35. package/lib/hooks/tap-done-to-async-get-issues.js +86 -0
  36. package/lib/hooks/tap-error-to-log-message.d.ts +4 -0
  37. package/lib/hooks/tap-error-to-log-message.js +32 -0
  38. package/lib/hooks/tap-start-to-run-workers.d.ts +8 -0
  39. package/lib/hooks/tap-start-to-run-workers.js +132 -0
  40. package/lib/hooks/tap-stop-to-terminate-workers.d.ts +5 -0
  41. package/lib/hooks/tap-stop-to-terminate-workers.js +26 -0
  42. package/lib/index.d.ts +2 -0
  43. package/lib/index.js +3 -0
  44. package/lib/infrastructure-logger.d.ts +9 -0
  45. package/lib/infrastructure-logger.js +14 -0
  46. package/lib/issue/index.d.ts +3 -0
  47. package/lib/issue/index.js +19 -0
  48. package/lib/issue/issue-config.d.ts +8 -0
  49. package/lib/issue/issue-config.js +29 -0
  50. package/lib/issue/issue-location.d.ts +8 -0
  51. package/lib/issue/issue-location.js +22 -0
  52. package/lib/issue/issue-match.d.ts +5 -0
  53. package/lib/issue/issue-match.js +20 -0
  54. package/lib/issue/issue-options.d.ts +8 -0
  55. package/lib/issue/issue-options.js +2 -0
  56. package/lib/issue/issue-position.d.ts +6 -0
  57. package/lib/issue/issue-position.js +16 -0
  58. package/lib/issue/issue-predicate.d.ts +5 -0
  59. package/lib/issue/issue-predicate.js +11 -0
  60. package/lib/issue/issue-severity.d.ts +4 -0
  61. package/lib/issue/issue-severity.js +12 -0
  62. package/lib/issue/issue-webpack-error.d.ts +9 -0
  63. package/lib/issue/issue-webpack-error.js +55 -0
  64. package/lib/issue/issue.d.ts +12 -0
  65. package/lib/issue/issue.js +41 -0
  66. package/lib/logger.d.ts +5 -0
  67. package/lib/logger.js +2 -0
  68. package/lib/plugin-config.d.ts +16 -0
  69. package/lib/plugin-config.js +26 -0
  70. package/lib/plugin-hooks.d.ts +20 -0
  71. package/lib/plugin-hooks.js +45 -0
  72. package/lib/plugin-options.d.ts +13 -0
  73. package/lib/plugin-options.js +2 -0
  74. package/lib/plugin-options.json +197 -0
  75. package/lib/plugin-pools.d.ts +4 -0
  76. package/lib/plugin-pools.js +32 -0
  77. package/lib/plugin-state.d.ts +18 -0
  78. package/lib/plugin-state.js +17 -0
  79. package/lib/plugin.d.ts +28 -0
  80. package/lib/plugin.js +86 -0
  81. package/lib/rpc/expose-rpc.d.ts +1 -0
  82. package/lib/rpc/expose-rpc.js +78 -0
  83. package/lib/rpc/index.d.ts +5 -0
  84. package/lib/rpc/index.js +12 -0
  85. package/lib/rpc/rpc-error.d.ts +6 -0
  86. package/lib/rpc/rpc-error.js +12 -0
  87. package/lib/rpc/rpc-worker.d.ts +13 -0
  88. package/lib/rpc/rpc-worker.js +83 -0
  89. package/lib/rpc/types.d.ts +19 -0
  90. package/lib/rpc/types.js +2 -0
  91. package/lib/rpc/wrap-rpc.d.ts +4 -0
  92. package/lib/rpc/wrap-rpc.js +79 -0
  93. package/lib/typescript/type-script-config-overwrite.d.ts +12 -0
  94. package/lib/typescript/type-script-config-overwrite.js +2 -0
  95. package/lib/typescript/type-script-diagnostics-options.d.ts +7 -0
  96. package/lib/typescript/type-script-diagnostics-options.js +2 -0
  97. package/lib/typescript/type-script-support.d.ts +3 -0
  98. package/lib/typescript/type-script-support.js +67 -0
  99. package/lib/typescript/type-script-worker-config.d.ts +17 -0
  100. package/lib/typescript/type-script-worker-config.js +18 -0
  101. package/lib/typescript/type-script-worker-options.d.ts +14 -0
  102. package/lib/typescript/type-script-worker-options.js +2 -0
  103. package/lib/typescript/worker/get-dependencies-worker.d.ts +5 -0
  104. package/lib/typescript/worker/get-dependencies-worker.js +15 -0
  105. package/lib/typescript/worker/get-issues-worker.d.ts +5 -0
  106. package/lib/typescript/worker/get-issues-worker.js +80 -0
  107. package/lib/typescript/worker/lib/artifacts.d.ts +4 -0
  108. package/lib/typescript/worker/lib/artifacts.js +94 -0
  109. package/lib/typescript/worker/lib/config.d.ts +15 -0
  110. package/lib/typescript/worker/lib/config.js +135 -0
  111. package/lib/typescript/worker/lib/dependencies.d.ts +3 -0
  112. package/lib/typescript/worker/lib/dependencies.js +85 -0
  113. package/lib/typescript/worker/lib/diagnostics.d.ts +7 -0
  114. package/lib/typescript/worker/lib/diagnostics.js +112 -0
  115. package/lib/typescript/worker/lib/emit.d.ts +2 -0
  116. package/lib/typescript/worker/lib/emit.js +13 -0
  117. package/lib/typescript/worker/lib/file-system/file-system.d.ts +18 -0
  118. package/lib/typescript/worker/lib/file-system/file-system.js +2 -0
  119. package/lib/typescript/worker/lib/file-system/mem-file-system.d.ts +5 -0
  120. package/lib/typescript/worker/lib/file-system/mem-file-system.js +78 -0
  121. package/lib/typescript/worker/lib/file-system/passive-file-system.d.ts +5 -0
  122. package/lib/typescript/worker/lib/file-system/passive-file-system.js +65 -0
  123. package/lib/typescript/worker/lib/file-system/real-file-system.d.ts +5 -0
  124. package/lib/typescript/worker/lib/file-system/real-file-system.js +191 -0
  125. package/lib/typescript/worker/lib/host/compiler-host.d.ts +2 -0
  126. package/lib/typescript/worker/lib/host/compiler-host.js +10 -0
  127. package/lib/typescript/worker/lib/host/watch-compiler-host.d.ts +2 -0
  128. package/lib/typescript/worker/lib/host/watch-compiler-host.js +20 -0
  129. package/lib/typescript/worker/lib/host/watch-solution-builder-host.d.ts +2 -0
  130. package/lib/typescript/worker/lib/host/watch-solution-builder-host.js +47 -0
  131. package/lib/typescript/worker/lib/performance.d.ts +3 -0
  132. package/lib/typescript/worker/lib/performance.js +32 -0
  133. package/lib/typescript/worker/lib/program/program.d.ts +2 -0
  134. package/lib/typescript/worker/lib/program/program.js +37 -0
  135. package/lib/typescript/worker/lib/program/solution-builder.d.ts +2 -0
  136. package/lib/typescript/worker/lib/program/solution-builder.js +39 -0
  137. package/lib/typescript/worker/lib/program/watch-program.d.ts +3 -0
  138. package/lib/typescript/worker/lib/program/watch-program.js +51 -0
  139. package/lib/typescript/worker/lib/system.d.ts +19 -0
  140. package/lib/typescript/worker/lib/system.js +232 -0
  141. package/lib/typescript/worker/lib/tracing.d.ts +4 -0
  142. package/lib/typescript/worker/lib/tracing.js +29 -0
  143. package/lib/typescript/worker/lib/tsbuildinfo.d.ts +4 -0
  144. package/lib/typescript/worker/lib/tsbuildinfo.js +96 -0
  145. package/lib/typescript/worker/lib/typescript.d.ts +2 -0
  146. package/lib/typescript/worker/lib/typescript.js +6 -0
  147. package/lib/typescript/worker/lib/worker-config.d.ts +2 -0
  148. package/lib/typescript/worker/lib/worker-config.js +5 -0
  149. package/lib/utils/async/abort-error.d.ts +6 -0
  150. package/lib/utils/async/abort-error.js +15 -0
  151. package/lib/utils/async/controlled-promise.d.ts +6 -0
  152. package/lib/utils/async/controlled-promise.js +17 -0
  153. package/lib/utils/async/is-pending.d.ts +2 -0
  154. package/lib/utils/async/is-pending.js +10 -0
  155. package/lib/utils/async/pool.d.ts +10 -0
  156. package/lib/utils/async/pool.js +47 -0
  157. package/lib/utils/async/wait.d.ts +2 -0
  158. package/lib/utils/async/wait.js +7 -0
  159. package/lib/utils/path/forward-slash.d.ts +6 -0
  160. package/lib/utils/path/forward-slash.js +15 -0
  161. package/lib/utils/path/is-inside-another-path.d.ts +2 -0
  162. package/lib/utils/path/is-inside-another-path.js +22 -0
  163. package/lib/utils/path/relative-to-context.d.ts +2 -0
  164. package/lib/utils/path/relative-to-context.js +16 -0
  165. package/lib/watch/inclusive-node-watch-file-system.d.ts +15 -0
  166. package/lib/watch/inclusive-node-watch-file-system.js +166 -0
  167. package/lib/watch/watch-file-system.d.ts +16 -0
  168. package/lib/watch/watch-file-system.js +2 -0
  169. package/package.json +182 -0
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RpcExitError = exports.getRpcWorkerData = exports.createRpcWorker = exports.wrapRpc = exports.exposeRpc = void 0;
4
+ var expose_rpc_1 = require("./expose-rpc");
5
+ Object.defineProperty(exports, "exposeRpc", { enumerable: true, get: function () { return expose_rpc_1.exposeRpc; } });
6
+ var wrap_rpc_1 = require("./wrap-rpc");
7
+ Object.defineProperty(exports, "wrapRpc", { enumerable: true, get: function () { return wrap_rpc_1.wrapRpc; } });
8
+ var rpc_worker_1 = require("./rpc-worker");
9
+ Object.defineProperty(exports, "createRpcWorker", { enumerable: true, get: function () { return rpc_worker_1.createRpcWorker; } });
10
+ Object.defineProperty(exports, "getRpcWorkerData", { enumerable: true, get: function () { return rpc_worker_1.getRpcWorkerData; } });
11
+ var rpc_error_1 = require("./rpc-error");
12
+ Object.defineProperty(exports, "RpcExitError", { enumerable: true, get: function () { return rpc_error_1.RpcExitError; } });
@@ -0,0 +1,6 @@
1
+ declare class RpcExitError extends Error {
2
+ readonly code?: string | number | null | undefined;
3
+ readonly signal?: string | null | undefined;
4
+ constructor(message: string, code?: string | number | null | undefined, signal?: string | null | undefined);
5
+ }
6
+ export { RpcExitError };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RpcExitError = void 0;
4
+ class RpcExitError extends Error {
5
+ constructor(message, code, signal) {
6
+ super(message);
7
+ this.code = code;
8
+ this.signal = signal;
9
+ this.name = 'RpcExitError';
10
+ }
11
+ }
12
+ exports.RpcExitError = RpcExitError;
@@ -0,0 +1,13 @@
1
+ /// <reference types="node" />
2
+ import type { ChildProcess } from 'child_process';
3
+ import type { RpcMethod, RpcRemoteMethod } from './types';
4
+ interface RpcWorkerBase {
5
+ connect(): void;
6
+ terminate(): void;
7
+ readonly connected: boolean;
8
+ readonly process: ChildProcess | undefined;
9
+ }
10
+ type RpcWorker<T extends RpcMethod = RpcMethod> = RpcWorkerBase & RpcRemoteMethod<T>;
11
+ declare function createRpcWorker<T extends RpcMethod>(modulePath: string, data: unknown, memoryLimit?: number): RpcWorker<T>;
12
+ declare function getRpcWorkerData(): unknown;
13
+ export { createRpcWorker, getRpcWorkerData, RpcWorker };
@@ -0,0 +1,83 @@
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 (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.getRpcWorkerData = exports.createRpcWorker = void 0;
27
+ const child_process = __importStar(require("child_process"));
28
+ const process = __importStar(require("process"));
29
+ const wrap_rpc_1 = require("./wrap-rpc");
30
+ const WORKER_DATA_ENV_KEY = 'WORKER_DATA';
31
+ function createRpcWorker(modulePath, data, memoryLimit) {
32
+ const options = {
33
+ env: Object.assign(Object.assign({}, process.env), { [WORKER_DATA_ENV_KEY]: JSON.stringify(data || {}) }),
34
+ stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
35
+ serialization: 'advanced',
36
+ };
37
+ if (memoryLimit) {
38
+ options.execArgv = [`--max-old-space-size=${memoryLimit}`];
39
+ }
40
+ let childProcess;
41
+ let remoteMethod;
42
+ const worker = {
43
+ connect() {
44
+ if (childProcess && !childProcess.connected) {
45
+ childProcess.kill('SIGTERM');
46
+ childProcess = undefined;
47
+ remoteMethod = undefined;
48
+ }
49
+ if (!(childProcess === null || childProcess === void 0 ? void 0 : childProcess.connected)) {
50
+ childProcess = child_process.fork(modulePath, options);
51
+ remoteMethod = (0, wrap_rpc_1.wrapRpc)(childProcess);
52
+ }
53
+ },
54
+ terminate() {
55
+ if (childProcess) {
56
+ childProcess.kill('SIGTERM');
57
+ childProcess = undefined;
58
+ remoteMethod = undefined;
59
+ }
60
+ },
61
+ get connected() {
62
+ return Boolean(childProcess === null || childProcess === void 0 ? void 0 : childProcess.connected);
63
+ },
64
+ get process() {
65
+ return childProcess;
66
+ },
67
+ };
68
+ return Object.assign((...args) => {
69
+ if (!worker.connected) {
70
+ // try to auto-connect
71
+ worker.connect();
72
+ }
73
+ if (!remoteMethod) {
74
+ return Promise.reject('Worker is not connected - cannot perform RPC.');
75
+ }
76
+ return remoteMethod(...args);
77
+ }, worker);
78
+ }
79
+ exports.createRpcWorker = createRpcWorker;
80
+ function getRpcWorkerData() {
81
+ return JSON.parse(process.env[WORKER_DATA_ENV_KEY] || '{}');
82
+ }
83
+ exports.getRpcWorkerData = getRpcWorkerData;
@@ -0,0 +1,19 @@
1
+ interface RpcCallMessage {
2
+ type: 'call';
3
+ id: string;
4
+ args: unknown[];
5
+ }
6
+ interface RpcResolveMessage {
7
+ type: 'resolve';
8
+ id: string;
9
+ value: unknown;
10
+ }
11
+ interface RpcRejectMessage {
12
+ type: 'reject';
13
+ id: string;
14
+ error: unknown;
15
+ }
16
+ type RpcMessage = RpcCallMessage | RpcResolveMessage | RpcRejectMessage;
17
+ type RpcMethod = (...args: any[]) => any;
18
+ type RpcRemoteMethod<T extends RpcMethod> = T extends (...args: infer A) => infer R ? R extends Promise<any> ? (...args: A) => R : (...args: A) => Promise<R> : (...args: unknown[]) => Promise<unknown>;
19
+ export { RpcCallMessage, RpcResolveMessage, RpcRejectMessage, RpcMessage, RpcMethod, RpcRemoteMethod, };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ /// <reference types="node" />
2
+ import type { ChildProcess } from 'child_process';
3
+ import type { RpcRemoteMethod } from './types';
4
+ export declare function wrapRpc<T extends (...args: any[]) => any>(childProcess: ChildProcess): RpcRemoteMethod<T>;
@@ -0,0 +1,79 @@
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
+ exports.wrapRpc = void 0;
13
+ const controlled_promise_1 = require("../utils/async/controlled-promise");
14
+ const rpc_error_1 = require("./rpc-error");
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ function wrapRpc(childProcess) {
17
+ return ((...args) => __awaiter(this, void 0, void 0, function* () {
18
+ if (!childProcess.send) {
19
+ throw new Error(`Process ${childProcess.pid} doesn't have IPC channels`);
20
+ }
21
+ else if (!childProcess.connected) {
22
+ throw new Error(`Process ${childProcess.pid} doesn't have open IPC channels`);
23
+ }
24
+ const id = uuid();
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();
34
+ }
35
+ else if (message.type === 'reject') {
36
+ rejectResult(message.error);
37
+ removeHandlers();
38
+ }
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
+ }
69
+ });
70
+ return sendPromise.then(() => resultPromise);
71
+ }));
72
+ }
73
+ exports.wrapRpc = wrapRpc;
74
+ function uuid() {
75
+ return new Array(4)
76
+ .fill(0)
77
+ .map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16))
78
+ .join('-');
79
+ }
@@ -0,0 +1,12 @@
1
+ interface TypeScriptConfigOverwrite {
2
+ extends?: string;
3
+ compilerOptions?: any;
4
+ include?: string[];
5
+ exclude?: string[];
6
+ files?: string[];
7
+ references?: {
8
+ path: string;
9
+ prepend?: boolean;
10
+ }[];
11
+ }
12
+ export { TypeScriptConfigOverwrite };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ interface TypeScriptDiagnosticsOptions {
2
+ syntactic: boolean;
3
+ semantic: boolean;
4
+ declaration: boolean;
5
+ global: boolean;
6
+ }
7
+ export { TypeScriptDiagnosticsOptions };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ import type { TypeScriptWorkerConfig } from './type-script-worker-config';
2
+ declare function assertTypeScriptSupport(config: TypeScriptWorkerConfig): void;
3
+ export { assertTypeScriptSupport };
@@ -0,0 +1,67 @@
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 (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.assertTypeScriptSupport = void 0;
30
+ const os_1 = __importDefault(require("os"));
31
+ const fs_extra_1 = __importDefault(require("fs-extra"));
32
+ const semver = __importStar(require("semver"));
33
+ function assertTypeScriptSupport(config) {
34
+ let typescriptVersion;
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
+ }
42
+ if (!typescriptVersion) {
43
+ throw new Error('When you use ForkTsCheckerWebpackPlugin with typescript reporter enabled, you must install `typescript` package.');
44
+ }
45
+ if (semver.lt(typescriptVersion, '3.6.0')) {
46
+ throw new Error([
47
+ `ForkTsCheckerWebpackPlugin cannot use the current typescript version of ${typescriptVersion}.`,
48
+ 'The minimum required version is 3.6.0.',
49
+ ].join(os_1.default.EOL));
50
+ }
51
+ if (config.build && semver.lt(typescriptVersion, '3.8.0')) {
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)) {
58
+ throw new Error([
59
+ `Cannot find the "${config.configFile}" file.`,
60
+ `Please check webpack and ForkTsCheckerWebpackPlugin configuration.`,
61
+ `Possible errors:`,
62
+ ' - wrong `context` directory in webpack configuration (if `configFile` is not set or is a relative path in the fork plugin configuration)',
63
+ ' - wrong `typescript.configFile` path in the plugin configuration (should be a relative or absolute path)',
64
+ ].join(os_1.default.EOL));
65
+ }
66
+ }
67
+ exports.assertTypeScriptSupport = assertTypeScriptSupport;
@@ -0,0 +1,17 @@
1
+ import type * as webpack from 'webpack';
2
+ import type { TypeScriptConfigOverwrite } from './type-script-config-overwrite';
3
+ import type { TypeScriptDiagnosticsOptions } from './type-script-diagnostics-options';
4
+ import type { TypeScriptWorkerOptions } from './type-script-worker-options';
5
+ interface TypeScriptWorkerConfig {
6
+ memoryLimit: number;
7
+ configFile: string;
8
+ configOverwrite: TypeScriptConfigOverwrite;
9
+ build: boolean;
10
+ context: string;
11
+ mode: 'readonly' | 'write-dts' | 'write-tsbuildinfo' | 'write-references';
12
+ diagnosticOptions: TypeScriptDiagnosticsOptions;
13
+ profile: boolean;
14
+ typescriptPath: string;
15
+ }
16
+ declare function createTypeScriptWorkerConfig(compiler: webpack.Compiler, options: TypeScriptWorkerOptions | undefined): TypeScriptWorkerConfig;
17
+ export { createTypeScriptWorkerConfig, TypeScriptWorkerConfig };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createTypeScriptWorkerConfig = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ function createTypeScriptWorkerConfig(compiler, options) {
9
+ let configFile = (options === null || options === void 0 ? void 0 : options.configFile) || 'tsconfig.json';
10
+ // ensure that `configFile` is an absolute normalized path
11
+ configFile = path_1.default.normalize(path_1.default.isAbsolute(configFile)
12
+ ? configFile
13
+ : path_1.default.resolve(compiler.options.context || process.cwd(), configFile));
14
+ const optionsAsObject = typeof options === 'object' ? options : {};
15
+ const typescriptPath = optionsAsObject.typescriptPath || require.resolve('typescript');
16
+ return Object.assign(Object.assign({ memoryLimit: 2048, build: false, mode: optionsAsObject.build ? 'write-tsbuildinfo' : 'readonly', profile: false }, optionsAsObject), { configFile: configFile, configOverwrite: optionsAsObject.configOverwrite || {}, context: optionsAsObject.context || path_1.default.dirname(configFile), diagnosticOptions: Object.assign({ syntactic: false, semantic: true, declaration: false, global: false }, (optionsAsObject.diagnosticOptions || {})), typescriptPath: typescriptPath });
17
+ }
18
+ exports.createTypeScriptWorkerConfig = createTypeScriptWorkerConfig;
@@ -0,0 +1,14 @@
1
+ import type { TypeScriptConfigOverwrite } from './type-script-config-overwrite';
2
+ import type { TypeScriptDiagnosticsOptions } from './type-script-diagnostics-options';
3
+ type TypeScriptWorkerOptions = {
4
+ memoryLimit?: number;
5
+ configFile?: string;
6
+ configOverwrite?: TypeScriptConfigOverwrite;
7
+ context?: string;
8
+ build?: boolean;
9
+ mode?: 'readonly' | 'write-tsbuildinfo' | 'write-dts' | 'write-references';
10
+ diagnosticOptions?: Partial<TypeScriptDiagnosticsOptions>;
11
+ profile?: boolean;
12
+ typescriptPath?: string;
13
+ };
14
+ export { TypeScriptWorkerOptions };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ import type { FilesChange } from '../../files-change';
2
+ import type { FilesMatch } from '../../files-match';
3
+ declare const getDependenciesWorker: (change: FilesChange) => FilesMatch;
4
+ export type GetDependenciesWorker = typeof getDependenciesWorker;
5
+ export {};
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const rpc_1 = require("../../rpc");
4
+ const config_1 = require("./lib/config");
5
+ const dependencies_1 = require("./lib/dependencies");
6
+ const system_1 = require("./lib/system");
7
+ const getDependenciesWorker = (change) => {
8
+ system_1.system.invalidateCache();
9
+ if ((0, config_1.didConfigFileChanged)(change) || (0, config_1.didDependenciesProbablyChanged)((0, dependencies_1.getDependencies)(), change)) {
10
+ (0, config_1.invalidateConfig)();
11
+ (0, dependencies_1.invalidateDependencies)();
12
+ }
13
+ return (0, dependencies_1.getDependencies)();
14
+ };
15
+ (0, rpc_1.exposeRpc)(getDependenciesWorker);
@@ -0,0 +1,5 @@
1
+ import type { FilesChange } from '../../files-change';
2
+ import type { Issue } from '../../issue';
3
+ declare const getIssuesWorker: (change: FilesChange, watching: boolean) => Promise<Issue[]>;
4
+ export type GetIssuesWorker = typeof getIssuesWorker;
5
+ export {};
@@ -0,0 +1,80 @@
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
+ const rpc_1 = require("../../rpc");
13
+ const artifacts_1 = require("./lib/artifacts");
14
+ const config_1 = require("./lib/config");
15
+ const dependencies_1 = require("./lib/dependencies");
16
+ const diagnostics_1 = require("./lib/diagnostics");
17
+ const performance_1 = require("./lib/performance");
18
+ const program_1 = require("./lib/program/program");
19
+ 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
+ const worker_config_1 = require("./lib/worker-config");
25
+ const getIssuesWorker = (change, watching) => __awaiter(void 0, void 0, void 0, function* () {
26
+ var _a, _b;
27
+ system_1.system.invalidateCache();
28
+ if ((0, config_1.didConfigFileChanged)(change)) {
29
+ (0, config_1.invalidateConfig)();
30
+ (0, dependencies_1.invalidateDependencies)();
31
+ (0, artifacts_1.invalidateArtifacts)();
32
+ (0, diagnostics_1.invalidateDiagnostics)();
33
+ (0, program_1.invalidateProgram)(true);
34
+ (0, watch_program_1.invalidateWatchProgram)(true);
35
+ (0, solution_builder_1.invalidateSolutionBuilder)(true);
36
+ (0, tsbuildinfo_1.invalidateTsBuildInfo)();
37
+ }
38
+ else if ((0, config_1.didDependenciesProbablyChanged)((0, dependencies_1.getDependencies)(), change)) {
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)();
44
+ (0, solution_builder_1.invalidateSolutionBuilder)();
45
+ }
46
+ }
47
+ (0, artifacts_1.registerArtifacts)();
48
+ (0, performance_1.enablePerformanceIfNeeded)();
49
+ const parseConfigIssues = (0, config_1.getParseConfigIssues)();
50
+ if (parseConfigIssues.length) {
51
+ // report config parse issues and exit
52
+ return parseConfigIssues;
53
+ }
54
+ // use proper implementation based on the config
55
+ if (worker_config_1.config.build) {
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)();
63
+ }
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
+ // retrieve all collected diagnostics as normalized issues
74
+ const issues = (0, diagnostics_1.getIssues)();
75
+ (0, tracing_1.dumpTracingLegendIfNeeded)();
76
+ (0, performance_1.printPerformanceMeasuresIfNeeded)();
77
+ (0, performance_1.disablePerformanceIfNeeded)();
78
+ return issues;
79
+ });
80
+ (0, rpc_1.exposeRpc)(getIssuesWorker);
@@ -0,0 +1,4 @@
1
+ import type { FilesMatch } from '../../../files-match';
2
+ export declare function getArtifacts(force?: boolean): FilesMatch;
3
+ export declare function invalidateArtifacts(): void;
4
+ export declare function registerArtifacts(): void;
@@ -0,0 +1,94 @@
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 (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.registerArtifacts = exports.invalidateArtifacts = exports.getArtifacts = void 0;
27
+ const path = __importStar(require("path"));
28
+ const config_1 = require("./config");
29
+ const system_1 = require("./system");
30
+ const tsbuildinfo_1 = require("./tsbuildinfo");
31
+ const typescript_1 = require("./typescript");
32
+ const worker_config_1 = require("./worker-config");
33
+ let artifacts;
34
+ function getArtifacts(force = false) {
35
+ if (!artifacts || force) {
36
+ const parsedConfig = (0, config_1.getParsedConfig)();
37
+ artifacts = getArtifactsWorker(parsedConfig, worker_config_1.config.context);
38
+ }
39
+ return artifacts;
40
+ }
41
+ exports.getArtifacts = getArtifacts;
42
+ function invalidateArtifacts() {
43
+ artifacts = undefined;
44
+ }
45
+ exports.invalidateArtifacts = invalidateArtifacts;
46
+ function registerArtifacts() {
47
+ system_1.system.setArtifacts(getArtifacts());
48
+ }
49
+ exports.registerArtifacts = registerArtifacts;
50
+ function getArtifactsWorker(parsedConfig, configFileContext, processedConfigFiles = []) {
51
+ const files = new Set();
52
+ const dirs = new Set();
53
+ if (parsedConfig.fileNames.length > 0) {
54
+ if (parsedConfig.options.outFile) {
55
+ files.add(path.resolve(configFileContext, parsedConfig.options.outFile));
56
+ }
57
+ const tsBuildInfoPath = (0, tsbuildinfo_1.getTsBuildInfoEmitPath)(parsedConfig.options);
58
+ if (tsBuildInfoPath) {
59
+ files.add(path.resolve(configFileContext, tsBuildInfoPath));
60
+ }
61
+ if (parsedConfig.options.outDir) {
62
+ dirs.add(path.resolve(configFileContext, parsedConfig.options.outDir));
63
+ }
64
+ }
65
+ for (const projectReference of parsedConfig.projectReferences || []) {
66
+ const configFile = typescript_1.typescript.resolveProjectReferencePath(projectReference);
67
+ if (processedConfigFiles.includes(configFile)) {
68
+ // handle circular dependencies
69
+ continue;
70
+ }
71
+ const parsedConfig = (0, config_1.parseConfig)(configFile, path.dirname(configFile));
72
+ const childArtifacts = getArtifactsWorker(parsedConfig, configFileContext, [
73
+ ...processedConfigFiles,
74
+ configFile,
75
+ ]);
76
+ childArtifacts.files.forEach((file) => {
77
+ files.add(file);
78
+ });
79
+ childArtifacts.dirs.forEach((dir) => {
80
+ dirs.add(dir);
81
+ });
82
+ }
83
+ const extensions = [
84
+ typescript_1.typescript.Extension.Dts,
85
+ typescript_1.typescript.Extension.Js,
86
+ typescript_1.typescript.Extension.TsBuildInfo,
87
+ ];
88
+ return {
89
+ files: Array.from(files).map((file) => path.normalize(file)),
90
+ dirs: Array.from(dirs).map((dir) => path.normalize(dir)),
91
+ excluded: [],
92
+ extensions,
93
+ };
94
+ }
@@ -0,0 +1,15 @@
1
+ import type * as ts from 'typescript';
2
+ import type { FilesChange } from '../../../files-change';
3
+ import type { FilesMatch } from '../../../files-match';
4
+ import type { Issue } from '../../../issue';
5
+ export declare function parseConfig(configFileName: string, configFileContext: string): ts.ParsedCommandLine;
6
+ export declare function getParseConfigIssues(): Issue[];
7
+ export declare function getParsedConfig(force?: boolean): ts.ParsedCommandLine;
8
+ export declare function parseNextConfig(): readonly [ts.ParsedCommandLine | undefined, ts.ParsedCommandLine];
9
+ export declare function invalidateConfig(): void;
10
+ export declare function getConfigFilePathFromCompilerOptions(compilerOptions: ts.CompilerOptions): string;
11
+ export declare function getConfigFilePathFromProgram(program: ts.Program): string;
12
+ export declare function getConfigFilePathFromBuilderProgram(builderProgram: ts.BuilderProgram): string;
13
+ export declare function didConfigFileChanged({ changedFiles, deletedFiles }: FilesChange): boolean;
14
+ export declare function didDependenciesProbablyChanged(dependencies: FilesMatch, { changedFiles, deletedFiles }: FilesChange): boolean;
15
+ export declare function didRootFilesChanged(): boolean | undefined;