@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,86 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.tapDoneToAsyncGetIssues = void 0;
16
+ const chalk_1 = __importDefault(require("chalk"));
17
+ const stats_formatter_1 = require("../formatter/stats-formatter");
18
+ const webpack_formatter_1 = require("../formatter/webpack-formatter");
19
+ const infrastructure_logger_1 = require("../infrastructure-logger");
20
+ const issue_webpack_error_1 = require("../issue/issue-webpack-error");
21
+ const plugin_hooks_1 = require("../plugin-hooks");
22
+ const is_pending_1 = require("../utils/async/is-pending");
23
+ const wait_1 = require("../utils/async/wait");
24
+ function tapDoneToAsyncGetIssues(compiler, config, state) {
25
+ const hooks = (0, plugin_hooks_1.getPluginHooks)(compiler);
26
+ const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
27
+ compiler.hooks.done.tap('ForkTsCheckerWebpackPlugin', (stats) => __awaiter(this, void 0, void 0, function* () {
28
+ if (stats.compilation.compiler !== compiler) {
29
+ // run only for the compiler that the plugin was registered for
30
+ return;
31
+ }
32
+ const issuesPromise = state.issuesPromise;
33
+ let issues;
34
+ try {
35
+ if (yield (0, is_pending_1.isPending)(issuesPromise)) {
36
+ hooks.waiting.call(stats.compilation);
37
+ config.logger.log(chalk_1.default.cyan('Type-checking in progress...'));
38
+ }
39
+ else {
40
+ // wait 10ms to log issues after webpack stats
41
+ yield (0, wait_1.wait)(10);
42
+ }
43
+ issues = yield issuesPromise;
44
+ }
45
+ catch (error) {
46
+ hooks.error.call(error, stats.compilation);
47
+ return;
48
+ }
49
+ if (!issues || // some error has been thrown
50
+ state.issuesPromise !== issuesPromise // we have a new request - don't show results for the old one
51
+ ) {
52
+ return;
53
+ }
54
+ debug(`Got ${(issues === null || issues === void 0 ? void 0 : issues.length) || 0} issues from getIssuesWorker.`);
55
+ // filter list of issues by provided issue predicate
56
+ issues = issues.filter(config.issue.predicate);
57
+ // modify list of issues in the plugin hooks
58
+ issues = hooks.issues.call(issues, stats.compilation);
59
+ const formatter = (0, webpack_formatter_1.createWebpackFormatter)(config.formatter.format, config.formatter.pathType);
60
+ if (issues.length) {
61
+ // follow webpack's approach - one process.write to stderr with all errors and warnings
62
+ config.logger.error(issues.map((issue) => formatter(issue)).join('\n'));
63
+ // print stats of the compilation
64
+ config.logger.log((0, stats_formatter_1.statsFormatter)(issues, stats));
65
+ }
66
+ else {
67
+ config.logger.log(chalk_1.default.green('No typescript errors found.'));
68
+ }
69
+ // report issues to webpack-dev-server, if it's listening
70
+ // skip reporting if there are no issues, to avoid an extra hot reload
71
+ if (issues.length && state.webpackDevServerDoneTap) {
72
+ issues.forEach((issue) => {
73
+ const error = new issue_webpack_error_1.IssueWebpackError(config.formatter.format(issue), config.formatter.pathType, issue);
74
+ if (issue.severity === 'warning') {
75
+ stats.compilation.warnings.push(error);
76
+ }
77
+ else {
78
+ stats.compilation.errors.push(error);
79
+ }
80
+ });
81
+ debug('Sending issues to the webpack-dev-server.');
82
+ state.webpackDevServerDoneTap.fn(stats);
83
+ }
84
+ }));
85
+ }
86
+ exports.tapDoneToAsyncGetIssues = tapDoneToAsyncGetIssues;
@@ -0,0 +1,4 @@
1
+ import type * as webpack from 'webpack';
2
+ import type { ForkTsCheckerWebpackPluginConfig } from '../plugin-config';
3
+ declare function tapErrorToLogMessage(compiler: webpack.Compiler, config: ForkTsCheckerWebpackPluginConfig): void;
4
+ export { tapErrorToLogMessage };
@@ -0,0 +1,32 @@
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.tapErrorToLogMessage = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const plugin_hooks_1 = require("../plugin-hooks");
9
+ const rpc_1 = require("../rpc");
10
+ const abort_error_1 = require("../utils/async/abort-error");
11
+ function tapErrorToLogMessage(compiler, config) {
12
+ const hooks = (0, plugin_hooks_1.getPluginHooks)(compiler);
13
+ hooks.error.tap('ForkTsCheckerWebpackPlugin', (error) => {
14
+ if (error instanceof abort_error_1.AbortError) {
15
+ return;
16
+ }
17
+ config.logger.error(String(error));
18
+ if (error instanceof rpc_1.RpcExitError) {
19
+ if (error.signal === 'SIGINT') {
20
+ config.logger.error(chalk_1.default.red('Issues checking service interrupted - If running in a docker container, this may be caused ' +
21
+ "by the container running out of memory. If so, try increasing the container's memory limit " +
22
+ 'or lowering the `memoryLimit` value in the ForkTsCheckerWebpackPlugin configuration.'));
23
+ }
24
+ else {
25
+ config.logger.error(chalk_1.default.red('Issues checking service aborted - probably out of memory. ' +
26
+ 'Check the `memoryLimit` option in the ForkTsCheckerWebpackPlugin configuration.\n' +
27
+ "If increasing the memory doesn't solve the issue, it's most probably a bug in the TypeScript."));
28
+ }
29
+ }
30
+ });
31
+ }
32
+ exports.tapErrorToLogMessage = tapErrorToLogMessage;
@@ -0,0 +1,8 @@
1
+ import type * as webpack from 'webpack';
2
+ import type { ForkTsCheckerWebpackPluginConfig } from '../plugin-config';
3
+ import type { ForkTsCheckerWebpackPluginState } from '../plugin-state';
4
+ import type { RpcWorker } from '../rpc';
5
+ import type { GetDependenciesWorker } from '../typescript/worker/get-dependencies-worker';
6
+ import type { GetIssuesWorker } from '../typescript/worker/get-issues-worker';
7
+ declare function tapStartToRunWorkers(compiler: webpack.Compiler, getIssuesWorker: RpcWorker<GetIssuesWorker>, getDependenciesWorker: RpcWorker<GetDependenciesWorker>, config: ForkTsCheckerWebpackPluginConfig, state: ForkTsCheckerWebpackPluginState): void;
8
+ export { tapStartToRunWorkers };
@@ -0,0 +1,132 @@
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.tapStartToRunWorkers = void 0;
13
+ const node_abort_controller_1 = require("node-abort-controller");
14
+ const files_change_1 = require("../files-change");
15
+ const infrastructure_logger_1 = require("../infrastructure-logger");
16
+ const plugin_hooks_1 = require("../plugin-hooks");
17
+ const plugin_pools_1 = require("../plugin-pools");
18
+ const intercept_done_to_get_dev_server_tap_1 = require("./intercept-done-to-get-dev-server-tap");
19
+ const tap_after_compile_to_get_issues_1 = require("./tap-after-compile-to-get-issues");
20
+ const tap_done_to_async_get_issues_1 = require("./tap-done-to-async-get-issues");
21
+ function tapStartToRunWorkers(compiler, getIssuesWorker, getDependenciesWorker, config, state) {
22
+ const hooks = (0, plugin_hooks_1.getPluginHooks)(compiler);
23
+ const { log, debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
24
+ compiler.hooks.run.tap('ForkTsCheckerWebpackPlugin', () => {
25
+ if (!state.initialized) {
26
+ debug('Initializing plugin for single run (not async).');
27
+ state.initialized = true;
28
+ state.watching = false;
29
+ (0, tap_after_compile_to_get_issues_1.tapAfterCompileToGetIssues)(compiler, config, state);
30
+ }
31
+ });
32
+ compiler.hooks.watchRun.tap('ForkTsCheckerWebpackPlugin', () => __awaiter(this, void 0, void 0, function* () {
33
+ if (!state.initialized) {
34
+ state.initialized = true;
35
+ state.watching = true;
36
+ if (config.async) {
37
+ debug('Initializing plugin for watch run (async).');
38
+ (0, tap_done_to_async_get_issues_1.tapDoneToAsyncGetIssues)(compiler, config, state);
39
+ (0, intercept_done_to_get_dev_server_tap_1.interceptDoneToGetDevServerTap)(compiler, config, state);
40
+ }
41
+ else {
42
+ debug('Initializing plugin for watch run (not async).');
43
+ (0, tap_after_compile_to_get_issues_1.tapAfterCompileToGetIssues)(compiler, config, state);
44
+ }
45
+ }
46
+ }));
47
+ compiler.hooks.compilation.tap('ForkTsCheckerWebpackPlugin', (compilation) => __awaiter(this, void 0, void 0, function* () {
48
+ if (compilation.compiler !== compiler) {
49
+ // run only for the compiler that the plugin was registered for
50
+ return;
51
+ }
52
+ // get current iteration number
53
+ const iteration = ++state.iteration;
54
+ // abort previous iteration
55
+ if (state.abortController) {
56
+ debug(`Aborting iteration ${iteration - 1}.`);
57
+ state.abortController.abort();
58
+ }
59
+ // create new abort controller for the new iteration
60
+ const abortController = new node_abort_controller_1.AbortController();
61
+ state.abortController = abortController;
62
+ let filesChange = {};
63
+ if (state.watching) {
64
+ filesChange = (0, files_change_1.consumeFilesChange)(compiler);
65
+ log([
66
+ 'Calling reporter service for incremental check.',
67
+ ` Changed files: ${JSON.stringify(filesChange.changedFiles)}`,
68
+ ` Deleted files: ${JSON.stringify(filesChange.deletedFiles)}`,
69
+ ].join('\n'));
70
+ }
71
+ else {
72
+ log('Calling reporter service for single check.');
73
+ }
74
+ filesChange = yield hooks.start.promise(filesChange, compilation);
75
+ let aggregatedFilesChange = filesChange;
76
+ if (state.aggregatedFilesChange) {
77
+ aggregatedFilesChange = (0, files_change_1.aggregateFilesChanges)([aggregatedFilesChange, filesChange]);
78
+ debug([
79
+ `Aggregating with previous files change, iteration ${iteration}.`,
80
+ ` Changed files: ${JSON.stringify(aggregatedFilesChange.changedFiles)}`,
81
+ ` Deleted files: ${JSON.stringify(aggregatedFilesChange.deletedFiles)}`,
82
+ ].join('\n'));
83
+ }
84
+ state.aggregatedFilesChange = aggregatedFilesChange;
85
+ // submit one at a time for a single compiler
86
+ state.issuesPromise = (state.issuesPromise || Promise.resolve())
87
+ // resolve to undefined on error
88
+ .catch(() => undefined)
89
+ .then(() => {
90
+ // early return
91
+ if (abortController.signal.aborted) {
92
+ return undefined;
93
+ }
94
+ debug(`Submitting the getIssuesWorker to the pool, iteration ${iteration}.`);
95
+ return plugin_pools_1.issuesPool.submit(() => __awaiter(this, void 0, void 0, function* () {
96
+ try {
97
+ debug(`Running the getIssuesWorker, iteration ${iteration}.`);
98
+ const issues = yield getIssuesWorker(aggregatedFilesChange, state.watching);
99
+ if (state.aggregatedFilesChange === aggregatedFilesChange) {
100
+ state.aggregatedFilesChange = undefined;
101
+ }
102
+ if (state.abortController === abortController) {
103
+ state.abortController = undefined;
104
+ }
105
+ return issues;
106
+ }
107
+ catch (error) {
108
+ hooks.error.call(error, compilation);
109
+ return undefined;
110
+ }
111
+ finally {
112
+ debug(`The getIssuesWorker finished its job, iteration ${iteration}.`);
113
+ }
114
+ }), abortController.signal);
115
+ });
116
+ debug(`Submitting the getDependenciesWorker to the pool, iteration ${iteration}.`);
117
+ state.dependenciesPromise = plugin_pools_1.dependenciesPool.submit(() => __awaiter(this, void 0, void 0, function* () {
118
+ try {
119
+ debug(`Running the getDependenciesWorker, iteration ${iteration}.`);
120
+ return yield getDependenciesWorker(filesChange);
121
+ }
122
+ catch (error) {
123
+ hooks.error.call(error, compilation);
124
+ return undefined;
125
+ }
126
+ finally {
127
+ debug(`The getDependenciesWorker finished its job, iteration ${iteration}.`);
128
+ }
129
+ })); // don't pass abortController.signal because getDependencies() is blocking
130
+ }));
131
+ }
132
+ exports.tapStartToRunWorkers = tapStartToRunWorkers;
@@ -0,0 +1,5 @@
1
+ import type * as webpack from 'webpack';
2
+ import type { ForkTsCheckerWebpackPluginState } from '../plugin-state';
3
+ import type { RpcWorker } from '../rpc';
4
+ declare function tapStopToTerminateWorkers(compiler: webpack.Compiler, getIssuesWorker: RpcWorker, getDependenciesWorker: RpcWorker, state: ForkTsCheckerWebpackPluginState): void;
5
+ export { tapStopToTerminateWorkers };
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tapStopToTerminateWorkers = void 0;
4
+ const infrastructure_logger_1 = require("../infrastructure-logger");
5
+ function tapStopToTerminateWorkers(compiler, getIssuesWorker, getDependenciesWorker, state) {
6
+ const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
7
+ const terminateWorkers = () => {
8
+ debug('Compiler is going to close - terminating workers...');
9
+ getIssuesWorker.terminate();
10
+ getDependenciesWorker.terminate();
11
+ };
12
+ compiler.hooks.watchClose.tap('ForkTsCheckerWebpackPlugin', () => {
13
+ terminateWorkers();
14
+ });
15
+ compiler.hooks.done.tap('ForkTsCheckerWebpackPlugin', () => {
16
+ if (!state.watching) {
17
+ terminateWorkers();
18
+ }
19
+ });
20
+ compiler.hooks.failed.tap('ForkTsCheckerWebpackPlugin', () => {
21
+ if (!state.watching) {
22
+ terminateWorkers();
23
+ }
24
+ });
25
+ }
26
+ exports.tapStopToTerminateWorkers = tapStopToTerminateWorkers;
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { ForkTsCheckerWebpackPlugin } from './plugin';
2
+ export = ForkTsCheckerWebpackPlugin;
package/lib/index.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ const plugin_1 = require("./plugin");
3
+ module.exports = plugin_1.ForkTsCheckerWebpackPlugin;
@@ -0,0 +1,9 @@
1
+ import type * as webpack from 'webpack';
2
+ export interface InfrastructureLogger {
3
+ log(...args: unknown[]): void;
4
+ debug(...args: unknown[]): void;
5
+ error(...args: unknown[]): void;
6
+ warn(...args: unknown[]): void;
7
+ info(...args: unknown[]): void;
8
+ }
9
+ export declare function getInfrastructureLogger(compiler: webpack.Compiler): InfrastructureLogger;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getInfrastructureLogger = void 0;
4
+ function getInfrastructureLogger(compiler) {
5
+ const logger = compiler.getInfrastructureLogger('ForkTsCheckerWebpackPlugin');
6
+ return {
7
+ log: logger.log.bind(logger),
8
+ debug: logger.debug.bind(logger),
9
+ error: logger.error.bind(logger),
10
+ warn: logger.warn.bind(logger),
11
+ info: logger.info.bind(logger),
12
+ };
13
+ }
14
+ exports.getInfrastructureLogger = getInfrastructureLogger;
@@ -0,0 +1,3 @@
1
+ export * from './issue';
2
+ export * from './issue-severity';
3
+ export * from './issue-location';
@@ -0,0 +1,19 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./issue"), exports);
18
+ __exportStar(require("./issue-severity"), exports);
19
+ __exportStar(require("./issue-location"), exports);
@@ -0,0 +1,8 @@
1
+ import type * as webpack from 'webpack';
2
+ import type { IssueOptions } from './issue-options';
3
+ import type { IssuePredicate } from './issue-predicate';
4
+ interface IssueConfig {
5
+ predicate: IssuePredicate;
6
+ }
7
+ declare function createIssueConfig(compiler: webpack.Compiler, options: IssueOptions | undefined): IssueConfig;
8
+ export { IssueConfig, createIssueConfig };
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createIssueConfig = void 0;
4
+ const issue_match_1 = require("./issue-match");
5
+ const issue_predicate_1 = require("./issue-predicate");
6
+ function createIssuePredicateFromOption(context, option) {
7
+ if (Array.isArray(option)) {
8
+ return (0, issue_predicate_1.composeIssuePredicates)(option.map((option) => typeof option === 'function' ? option : (0, issue_match_1.createIssuePredicateFromIssueMatch)(context, option)));
9
+ }
10
+ return typeof option === 'function'
11
+ ? option
12
+ : (0, issue_match_1.createIssuePredicateFromIssueMatch)(context, option);
13
+ }
14
+ function createIssueConfig(compiler, options) {
15
+ const context = compiler.options.context || process.cwd();
16
+ if (!options) {
17
+ options = {};
18
+ }
19
+ const include = options.include
20
+ ? createIssuePredicateFromOption(context, options.include)
21
+ : (0, issue_predicate_1.createTrivialIssuePredicate)(true);
22
+ const exclude = options.exclude
23
+ ? createIssuePredicateFromOption(context, options.exclude)
24
+ : (0, issue_predicate_1.createTrivialIssuePredicate)(false);
25
+ return {
26
+ predicate: (issue) => include(issue) && !exclude(issue),
27
+ };
28
+ }
29
+ exports.createIssueConfig = createIssueConfig;
@@ -0,0 +1,8 @@
1
+ import type { IssuePosition } from './issue-position';
2
+ interface IssueLocation {
3
+ start: IssuePosition;
4
+ end: IssuePosition;
5
+ }
6
+ declare function compareIssueLocations(locationA?: IssueLocation, locationB?: IssueLocation): number;
7
+ declare function formatIssueLocation(location: IssueLocation): string;
8
+ export { IssueLocation, compareIssueLocations, formatIssueLocation };
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatIssueLocation = exports.compareIssueLocations = void 0;
4
+ const issue_position_1 = require("./issue-position");
5
+ function compareIssueLocations(locationA, locationB) {
6
+ if (locationA === locationB) {
7
+ return 0;
8
+ }
9
+ if (!locationA) {
10
+ return -1;
11
+ }
12
+ if (!locationB) {
13
+ return 1;
14
+ }
15
+ return ((0, issue_position_1.compareIssuePositions)(locationA.start, locationB.start) ||
16
+ (0, issue_position_1.compareIssuePositions)(locationA.end, locationB.end));
17
+ }
18
+ exports.compareIssueLocations = compareIssueLocations;
19
+ function formatIssueLocation(location) {
20
+ return `${location.start.line}:${location.start.column}`;
21
+ }
22
+ exports.formatIssueLocation = formatIssueLocation;
@@ -0,0 +1,5 @@
1
+ import type { IssuePredicate } from './issue-predicate';
2
+ import type { Issue } from './index';
3
+ type IssueMatch = Partial<Pick<Issue, 'severity' | 'code' | 'file'>>;
4
+ declare function createIssuePredicateFromIssueMatch(context: string, match: IssueMatch): IssuePredicate;
5
+ export { IssueMatch, createIssuePredicateFromIssueMatch };
@@ -0,0 +1,20 @@
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.createIssuePredicateFromIssueMatch = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const minimatch_1 = __importDefault(require("minimatch"));
9
+ const forward_slash_1 = require("../utils/path/forward-slash");
10
+ function createIssuePredicateFromIssueMatch(context, match) {
11
+ return (issue) => {
12
+ const matchesSeverity = !match.severity || match.severity === issue.severity;
13
+ const matchesCode = !match.code || match.code === issue.code;
14
+ const matchesFile = !issue.file ||
15
+ (!!issue.file &&
16
+ (!match.file || (0, minimatch_1.default)((0, forward_slash_1.forwardSlash)(path_1.default.relative(context, issue.file)), match.file)));
17
+ return matchesSeverity && matchesCode && matchesFile;
18
+ };
19
+ }
20
+ exports.createIssuePredicateFromIssueMatch = createIssuePredicateFromIssueMatch;
@@ -0,0 +1,8 @@
1
+ import type { IssueMatch } from './issue-match';
2
+ import type { IssuePredicate } from './issue-predicate';
3
+ type IssuePredicateOption = IssuePredicate | IssueMatch | (IssuePredicate | IssueMatch)[];
4
+ interface IssueOptions {
5
+ include?: IssuePredicateOption;
6
+ exclude?: IssuePredicateOption;
7
+ }
8
+ export { IssueOptions, IssuePredicateOption };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ interface IssuePosition {
2
+ line: number;
3
+ column: number;
4
+ }
5
+ declare function compareIssuePositions(positionA?: IssuePosition, positionB?: IssuePosition): number;
6
+ export { IssuePosition, compareIssuePositions };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.compareIssuePositions = void 0;
4
+ function compareIssuePositions(positionA, positionB) {
5
+ if (positionA === positionB) {
6
+ return 0;
7
+ }
8
+ if (!positionA) {
9
+ return -1;
10
+ }
11
+ if (!positionB) {
12
+ return 1;
13
+ }
14
+ return (Math.sign(positionA.line - positionB.line) || Math.sign(positionA.column - positionB.column));
15
+ }
16
+ exports.compareIssuePositions = compareIssuePositions;
@@ -0,0 +1,5 @@
1
+ import type { Issue } from './index';
2
+ type IssuePredicate = (issue: Issue) => boolean;
3
+ declare function createTrivialIssuePredicate(result: boolean): IssuePredicate;
4
+ declare function composeIssuePredicates(predicates: IssuePredicate[]): IssuePredicate;
5
+ export { IssuePredicate, createTrivialIssuePredicate, composeIssuePredicates };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.composeIssuePredicates = exports.createTrivialIssuePredicate = void 0;
4
+ function createTrivialIssuePredicate(result) {
5
+ return () => result;
6
+ }
7
+ exports.createTrivialIssuePredicate = createTrivialIssuePredicate;
8
+ function composeIssuePredicates(predicates) {
9
+ return (issue) => predicates.some((predicate) => predicate(issue));
10
+ }
11
+ exports.composeIssuePredicates = composeIssuePredicates;
@@ -0,0 +1,4 @@
1
+ type IssueSeverity = 'error' | 'warning';
2
+ declare function isIssueSeverity(value: unknown): value is IssueSeverity;
3
+ declare function compareIssueSeverities(severityA: IssueSeverity, severityB: IssueSeverity): number;
4
+ export { IssueSeverity, isIssueSeverity, compareIssueSeverities };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.compareIssueSeverities = exports.isIssueSeverity = void 0;
4
+ function isIssueSeverity(value) {
5
+ return ['error', 'warning'].includes(value);
6
+ }
7
+ exports.isIssueSeverity = isIssueSeverity;
8
+ function compareIssueSeverities(severityA, severityB) {
9
+ const [priorityA, priorityB] = [severityA, severityB].map((severity) => ['warning' /* 0 */, 'error' /* 1 */].indexOf(severity));
10
+ return Math.sign(priorityB - priorityA);
11
+ }
12
+ exports.compareIssueSeverities = compareIssueSeverities;
@@ -0,0 +1,9 @@
1
+ import * as webpack from 'webpack';
2
+ import type { FormatterPathType } from '../formatter';
3
+ import type { Issue } from './issue';
4
+ declare class IssueWebpackError extends webpack.WebpackError {
5
+ readonly issue: Issue;
6
+ readonly hideStack = true;
7
+ constructor(message: string, pathType: FormatterPathType, issue: Issue);
8
+ }
9
+ export { IssueWebpackError };
@@ -0,0 +1,55 @@
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.IssueWebpackError = void 0;
30
+ const path_1 = __importDefault(require("path"));
31
+ const webpack = __importStar(require("webpack"));
32
+ const forward_slash_1 = require("../utils/path/forward-slash");
33
+ const relative_to_context_1 = require("../utils/path/relative-to-context");
34
+ const issue_location_1 = require("./issue-location");
35
+ class IssueWebpackError extends webpack.WebpackError {
36
+ constructor(message, pathType, issue) {
37
+ super(message);
38
+ this.issue = issue;
39
+ this.hideStack = true;
40
+ // to display issue location using `loc` property, webpack requires `error.module` which
41
+ // should be a NormalModule instance.
42
+ // to avoid such a dependency, we do a workaround - error.file will contain formatted location instead
43
+ if (issue.file) {
44
+ this.file =
45
+ pathType === 'absolute'
46
+ ? (0, forward_slash_1.forwardSlash)(path_1.default.resolve(issue.file))
47
+ : (0, relative_to_context_1.relativeToContext)(issue.file, process.cwd());
48
+ if (issue.location) {
49
+ this.file += `:${(0, issue_location_1.formatIssueLocation)(issue.location)}`;
50
+ }
51
+ }
52
+ Error.captureStackTrace(this, this.constructor);
53
+ }
54
+ }
55
+ exports.IssueWebpackError = IssueWebpackError;
@@ -0,0 +1,12 @@
1
+ import type { IssueLocation } from './issue-location';
2
+ import type { IssueSeverity } from './issue-severity';
3
+ interface Issue {
4
+ severity: IssueSeverity;
5
+ code: string;
6
+ message: string;
7
+ file?: string;
8
+ location?: IssueLocation;
9
+ }
10
+ declare function isIssue(value: unknown): value is Issue;
11
+ declare function deduplicateAndSortIssues(issues: Issue[]): Issue[];
12
+ export { Issue, isIssue, deduplicateAndSortIssues };