fork-ts-checker-webpack-plugin 7.0.0-alpha.1 → 7.0.0-alpha.10

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 (174) hide show
  1. package/README.md +17 -83
  2. package/lib/ForkTsCheckerWebpackPlugin.d.ts +15 -11
  3. package/lib/ForkTsCheckerWebpackPlugin.js +30 -38
  4. package/lib/ForkTsCheckerWebpackPluginConfiguration.d.ts +6 -8
  5. package/lib/ForkTsCheckerWebpackPluginConfiguration.js +3 -4
  6. package/lib/ForkTsCheckerWebpackPluginOptions.d.ts +4 -6
  7. package/lib/ForkTsCheckerWebpackPluginOptions.json +73 -111
  8. package/lib/ForkTsCheckerWebpackPluginState.d.ts +8 -7
  9. package/lib/ForkTsCheckerWebpackPluginState.js +3 -1
  10. package/lib/error/OperationCanceledError.js +1 -0
  11. package/lib/formatter/BasicFormatter.d.ts +1 -1
  12. package/lib/formatter/BasicFormatter.js +1 -0
  13. package/lib/formatter/CodeFrameFormatter.d.ts +1 -1
  14. package/lib/formatter/CodeFrameFormatter.js +2 -1
  15. package/lib/formatter/Formatter.d.ts +1 -1
  16. package/lib/formatter/FormatterConfiguration.d.ts +3 -3
  17. package/lib/formatter/FormatterConfiguration.js +21 -2
  18. package/lib/formatter/FormatterOptions.d.ts +11 -6
  19. package/lib/formatter/WebpackFormatter.d.ts +1 -1
  20. package/lib/formatter/WebpackFormatter.js +6 -6
  21. package/lib/formatter/index.d.ts +0 -1
  22. package/lib/formatter/index.js +16 -8
  23. package/lib/formatter/types/babel__code-frame.js +1 -1
  24. package/lib/hooks/interceptDoneToGetWebpackDevServerTap.d.ts +3 -3
  25. package/lib/hooks/interceptDoneToGetWebpackDevServerTap.js +1 -0
  26. package/lib/hooks/pluginHooks.d.ts +13 -13
  27. package/lib/hooks/pluginHooks.js +1 -0
  28. package/lib/hooks/pluginPools.d.ts +4 -0
  29. package/lib/hooks/pluginPools.js +28 -0
  30. package/lib/hooks/tapAfterCompileToAddDependencies.d.ts +3 -3
  31. package/lib/hooks/tapAfterCompileToAddDependencies.js +1 -0
  32. package/lib/hooks/tapAfterCompileToGetIssues.d.ts +3 -3
  33. package/lib/hooks/tapAfterCompileToGetIssues.js +2 -1
  34. package/lib/hooks/tapAfterEnvironmentToPatchWatching.d.ts +2 -2
  35. package/lib/hooks/tapAfterEnvironmentToPatchWatching.js +4 -1
  36. package/lib/hooks/tapDoneToAsyncGetIssues.d.ts +3 -3
  37. package/lib/hooks/tapDoneToAsyncGetIssues.js +6 -5
  38. package/lib/hooks/tapErrorToLogMessage.d.ts +2 -2
  39. package/lib/hooks/tapErrorToLogMessage.js +4 -3
  40. package/lib/hooks/tapStartToConnectAndRunReporter.d.ts +5 -5
  41. package/lib/hooks/tapStartToConnectAndRunReporter.js +47 -22
  42. package/lib/hooks/tapStopToDisconnectReporter.d.ts +4 -4
  43. package/lib/hooks/tapStopToDisconnectReporter.js +7 -4
  44. package/lib/issue/Issue.d.ts +2 -3
  45. package/lib/issue/Issue.js +2 -3
  46. package/lib/issue/IssueConfiguration.d.ts +3 -3
  47. package/lib/issue/IssueConfiguration.js +1 -0
  48. package/lib/issue/IssueLocation.d.ts +2 -2
  49. package/lib/issue/IssueLocation.js +17 -2
  50. package/lib/issue/IssueMatch.d.ts +3 -3
  51. package/lib/issue/IssueMatch.js +3 -3
  52. package/lib/issue/IssueOptions.d.ts +2 -2
  53. package/lib/issue/IssuePosition.js +1 -0
  54. package/lib/issue/IssuePredicate.d.ts +1 -1
  55. package/lib/issue/IssuePredicate.js +1 -0
  56. package/lib/issue/IssueSeverity.js +1 -0
  57. package/lib/issue/IssueWebpackError.d.ts +3 -3
  58. package/lib/issue/IssueWebpackError.js +7 -5
  59. package/lib/issue/index.js +13 -6
  60. package/lib/logger/LoggerConfiguration.d.ts +3 -3
  61. package/lib/logger/LoggerConfiguration.js +2 -1
  62. package/lib/logger/LoggerFactory.d.ts +2 -2
  63. package/lib/logger/LoggerFactory.js +2 -1
  64. package/lib/logger/LoggerOptions.d.ts +2 -2
  65. package/lib/logger/PartialLogger.d.ts +1 -1
  66. package/lib/logger/PartialLogger.js +1 -0
  67. package/lib/logger/WebpackInfrastructureLogger.d.ts +2 -2
  68. package/lib/logger/WebpackInfrastructureLogger.js +1 -0
  69. package/lib/profile/Performance.js +1 -0
  70. package/lib/reporter/AggregatedReporter.d.ts +1 -1
  71. package/lib/reporter/AggregatedReporter.js +2 -1
  72. package/lib/reporter/FilesChange.d.ts +1 -1
  73. package/lib/reporter/FilesChange.js +2 -1
  74. package/lib/reporter/FilesMatch.d.ts +7 -0
  75. package/lib/{eslint-reporter/EsLintReporterOptions.js → reporter/FilesMatch.js} +0 -0
  76. package/lib/reporter/Report.d.ts +3 -3
  77. package/lib/reporter/Reporter.d.ts +2 -2
  78. package/lib/reporter/index.d.ts +1 -1
  79. package/lib/reporter/index.js +17 -7
  80. package/lib/reporter/reporter-rpc/ReporterRpcClient.d.ts +2 -2
  81. package/lib/reporter/reporter-rpc/ReporterRpcClient.js +17 -4
  82. package/lib/reporter/reporter-rpc/ReporterRpcProcedure.d.ts +5 -5
  83. package/lib/reporter/reporter-rpc/ReporterRpcProcedure.js +3 -0
  84. package/lib/reporter/reporter-rpc/ReporterRpcService.d.ts +2 -2
  85. package/lib/reporter/reporter-rpc/ReporterRpcService.js +3 -0
  86. package/lib/rpc/RpcClient.d.ts +2 -2
  87. package/lib/rpc/RpcClient.js +2 -1
  88. package/lib/rpc/RpcMessage.d.ts +1 -1
  89. package/lib/rpc/RpcMessage.js +3 -0
  90. package/lib/rpc/RpcMessageChannel.d.ts +1 -1
  91. package/lib/rpc/RpcMessageChannel.js +1 -0
  92. package/lib/rpc/RpcService.d.ts +2 -2
  93. package/lib/rpc/RpcService.js +1 -0
  94. package/lib/rpc/error/RpcMessagePortClosedError.js +1 -0
  95. package/lib/rpc/error/RpcRemoteError.js +1 -0
  96. package/lib/rpc/index.js +17 -7
  97. package/lib/rpc/rpc-ipc/RpcIpcMessageChannel.d.ts +1 -1
  98. package/lib/rpc/rpc-ipc/RpcIpcMessageChannel.js +1 -0
  99. package/lib/rpc/rpc-ipc/RpcIpcMessagePort.d.ts +2 -2
  100. package/lib/rpc/rpc-ipc/RpcIpcMessagePort.js +1 -0
  101. package/lib/rpc/rpc-ipc/error/RpcIpcMessagePortClosedError.js +1 -0
  102. package/lib/rpc/rpc-ipc/index.js +12 -5
  103. package/lib/typescript-reporter/TypeScriptConfigurationOverwrite.d.ts +1 -1
  104. package/lib/typescript-reporter/TypeScriptReporterConfiguration.d.ts +5 -5
  105. package/lib/typescript-reporter/TypeScriptReporterConfiguration.js +2 -0
  106. package/lib/typescript-reporter/TypeScriptReporterOptions.d.ts +4 -5
  107. package/lib/typescript-reporter/TypeScriptSupport.d.ts +1 -1
  108. package/lib/typescript-reporter/TypeScriptSupport.js +26 -11
  109. package/lib/typescript-reporter/extension/TypeScriptEmbeddedExtension.d.ts +1 -1
  110. package/lib/typescript-reporter/extension/TypeScriptEmbeddedExtension.js +2 -1
  111. package/lib/typescript-reporter/extension/TypeScriptExtension.d.ts +4 -4
  112. package/lib/typescript-reporter/extension/vue/TypeScriptVueExtension.d.ts +2 -2
  113. package/lib/typescript-reporter/extension/vue/TypeScriptVueExtension.js +2 -1
  114. package/lib/typescript-reporter/extension/vue/TypeScriptVueExtensionConfiguration.d.ts +1 -1
  115. package/lib/typescript-reporter/extension/vue/TypeScriptVueExtensionConfiguration.js +1 -0
  116. package/lib/typescript-reporter/extension/vue/TypeScriptVueExtensionSupport.d.ts +1 -1
  117. package/lib/typescript-reporter/extension/vue/TypeScriptVueExtensionSupport.js +1 -0
  118. package/lib/typescript-reporter/file-system/FileSystem.d.ts +1 -1
  119. package/lib/typescript-reporter/file-system/MemFileSystem.d.ts +8 -0
  120. package/lib/typescript-reporter/file-system/MemFileSystem.js +83 -0
  121. package/lib/typescript-reporter/file-system/PassiveFileSystem.d.ts +3 -3
  122. package/lib/typescript-reporter/file-system/PassiveFileSystem.js +11 -72
  123. package/lib/typescript-reporter/file-system/RealFileSystem.d.ts +1 -1
  124. package/lib/typescript-reporter/file-system/RealFileSystem.js +2 -0
  125. package/lib/typescript-reporter/issue/TypeScriptIssueFactory.d.ts +2 -2
  126. package/lib/typescript-reporter/issue/TypeScriptIssueFactory.js +17 -5
  127. package/lib/typescript-reporter/profile/TypeScriptPerformance.d.ts +2 -2
  128. package/lib/typescript-reporter/profile/TypeScriptPerformance.js +1 -0
  129. package/lib/typescript-reporter/reporter/ControlledCompilerHost.d.ts +3 -3
  130. package/lib/typescript-reporter/reporter/ControlledCompilerHost.js +1 -0
  131. package/lib/typescript-reporter/reporter/ControlledTypeScriptSystem.d.ts +3 -1
  132. package/lib/typescript-reporter/reporter/ControlledTypeScriptSystem.js +50 -15
  133. package/lib/typescript-reporter/reporter/ControlledWatchCompilerHost.d.ts +3 -3
  134. package/lib/typescript-reporter/reporter/ControlledWatchCompilerHost.js +1 -0
  135. package/lib/typescript-reporter/reporter/ControlledWatchSolutionBuilderHost.d.ts +3 -3
  136. package/lib/typescript-reporter/reporter/ControlledWatchSolutionBuilderHost.js +2 -9
  137. package/lib/typescript-reporter/reporter/TypeScriptConfigurationParser.d.ts +7 -5
  138. package/lib/typescript-reporter/reporter/TypeScriptConfigurationParser.js +114 -19
  139. package/lib/typescript-reporter/reporter/TypeScriptReporter.d.ts +2 -2
  140. package/lib/typescript-reporter/reporter/TypeScriptReporter.js +24 -16
  141. package/lib/typescript-reporter/reporter/TypeScriptReporterRpcClient.d.ts +2 -2
  142. package/lib/typescript-reporter/reporter/TypeScriptReporterRpcClient.js +1 -0
  143. package/lib/typescript-reporter/reporter/TypeScriptReporterRpcService.js +2 -2
  144. package/lib/utils/async/pool.d.ts +1 -0
  145. package/lib/utils/async/pool.js +10 -0
  146. package/lib/utils/path/relativeToContext.d.ts +2 -0
  147. package/lib/utils/path/relativeToContext.js +16 -0
  148. package/lib/watch/InclusiveNodeWatchFileSystem.d.ts +5 -5
  149. package/lib/watch/InclusiveNodeWatchFileSystem.js +111 -90
  150. package/lib/watch/WatchFileSystem.d.ts +5 -22
  151. package/package.json +52 -54
  152. package/CHANGELOG.md +0 -318
  153. package/changelog.config.js +0 -36
  154. package/lib/eslint-reporter/EsLintReporterConfiguration.d.ts +0 -11
  155. package/lib/eslint-reporter/EsLintReporterConfiguration.js +0 -26
  156. package/lib/eslint-reporter/EsLintReporterOptions.d.ts +0 -8
  157. package/lib/eslint-reporter/assertEsLintSupport.d.ts +0 -3
  158. package/lib/eslint-reporter/assertEsLintSupport.js +0 -30
  159. package/lib/eslint-reporter/issue/EsLintIssueFactory.d.ts +0 -4
  160. package/lib/eslint-reporter/issue/EsLintIssueFactory.js +0 -32
  161. package/lib/eslint-reporter/reporter/EsLintReporter.d.ts +0 -4
  162. package/lib/eslint-reporter/reporter/EsLintReporter.js +0 -85
  163. package/lib/eslint-reporter/reporter/EsLintReporterRpcClient.d.ts +0 -4
  164. package/lib/eslint-reporter/reporter/EsLintReporterRpcClient.js +0 -13
  165. package/lib/eslint-reporter/reporter/EsLintReporterRpcService.d.ts +0 -1
  166. package/lib/eslint-reporter/reporter/EsLintReporterRpcService.js +0 -11
  167. package/lib/eslint-reporter/types/eslint.d.ts +0 -31
  168. package/lib/eslint-reporter/types/eslint.js +0 -2
  169. package/lib/formatter/FormatterFactory.d.ts +0 -13
  170. package/lib/formatter/FormatterFactory.js +0 -17
  171. package/lib/reporter/Dependencies.d.ts +0 -6
  172. package/lib/reporter/Dependencies.js +0 -2
  173. package/lib/watch/CompilerWithWatchFileSystem.d.ts +0 -6
  174. package/lib/watch/CompilerWithWatchFileSystem.js +0 -2
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.createPool = void 0;
12
13
  function createPool(size) {
13
14
  let pendingPromises = [];
14
15
  const pool = {
@@ -39,6 +40,15 @@ function createPool(size) {
39
40
  get pending() {
40
41
  return pendingPromises.length;
41
42
  },
43
+ get drained() {
44
+ // eslint-disable-next-line no-async-promise-executor
45
+ return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
46
+ while (pendingPromises.length > 0) {
47
+ yield Promise.race(pendingPromises).catch(() => undefined);
48
+ }
49
+ resolve(undefined);
50
+ }));
51
+ },
42
52
  };
43
53
  return pool;
44
54
  }
@@ -0,0 +1,2 @@
1
+ declare function relativeToContext(file: string, context: string): string;
2
+ export { relativeToContext };
@@ -0,0 +1,16 @@
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.relativeToContext = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const forwardSlash_1 = __importDefault(require("./forwardSlash"));
9
+ function relativeToContext(file, context) {
10
+ let fileInContext = forwardSlash_1.default(path_1.default.relative(context, file));
11
+ if (!fileInContext.startsWith('../')) {
12
+ fileInContext = './' + fileInContext;
13
+ }
14
+ return fileInContext;
15
+ }
16
+ exports.relativeToContext = relativeToContext;
@@ -1,7 +1,7 @@
1
- import { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
2
- import { FSWatcher } from 'chokidar';
3
- import { Watcher, WatchFileSystem, WatchFileSystemOptions } from './WatchFileSystem';
4
- import { Compiler } from 'webpack';
1
+ import type { FSWatcher } from 'chokidar';
2
+ import type { Compiler } from 'webpack';
3
+ import type { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
4
+ import type { WatchFileSystem } from './WatchFileSystem';
5
5
  declare class InclusiveNodeWatchFileSystem implements WatchFileSystem {
6
6
  private watchFileSystem;
7
7
  private compiler;
@@ -10,6 +10,6 @@ declare class InclusiveNodeWatchFileSystem implements WatchFileSystem {
10
10
  readonly dirsWatchers: Map<string, FSWatcher | undefined>;
11
11
  constructor(watchFileSystem: WatchFileSystem, compiler: Compiler, pluginState: ForkTsCheckerWebpackPluginState);
12
12
  private paused;
13
- watch(files: Iterable<string>, dirs: Iterable<string>, missing: Iterable<string>, startTime?: number, options?: Partial<WatchFileSystemOptions>, callback?: Function, callbackUndelayed?: Function): Watcher;
13
+ watch: WatchFileSystem['watch'];
14
14
  }
15
15
  export { InclusiveNodeWatchFileSystem };
@@ -3,12 +3,32 @@ 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
- const chokidar_1 = __importDefault(require("chokidar"));
6
+ exports.InclusiveNodeWatchFileSystem = void 0;
7
7
  const path_1 = require("path");
8
+ const chokidar_1 = __importDefault(require("chokidar"));
9
+ const minimatch_1 = __importDefault(require("minimatch"));
8
10
  const reporter_1 = require("../reporter");
9
- const IGNORED_DIRS = ['node_modules', '.git', '.yarn', '.pnp'];
10
- function isIgnored(path) {
11
- return IGNORED_DIRS.some((ignoredDir) => path.includes(`/${ignoredDir}/`));
11
+ const BUILTIN_IGNORED_DIRS = ['node_modules', '.git', '.yarn', '.pnp'];
12
+ function createIsIgnored(ignored, excluded) {
13
+ const ignoredPatterns = ignored ? (Array.isArray(ignored) ? ignored : [ignored]) : [];
14
+ const ignoredFunctions = ignoredPatterns.map((pattern) => {
15
+ // ensure patterns are valid - see https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/594
16
+ if (typeof pattern === 'string') {
17
+ return (path) => minimatch_1.default(path, pattern);
18
+ }
19
+ else if (pattern instanceof RegExp) {
20
+ return (path) => pattern.test(path);
21
+ }
22
+ else {
23
+ // fallback to no-ignore function
24
+ return () => false;
25
+ }
26
+ });
27
+ ignoredFunctions.push((path) => excluded.some((excludedPath) => path.startsWith(excludedPath)));
28
+ ignoredFunctions.push((path) => BUILTIN_IGNORED_DIRS.some((ignoredDir) => path.includes(`/${ignoredDir}/`)));
29
+ return function isIgnored(path) {
30
+ return ignoredFunctions.some((ignoredFunction) => ignoredFunction(path));
31
+ };
12
32
  }
13
33
  class InclusiveNodeWatchFileSystem {
14
34
  constructor(watchFileSystem, compiler, pluginState) {
@@ -16,97 +36,98 @@ class InclusiveNodeWatchFileSystem {
16
36
  this.compiler = compiler;
17
37
  this.pluginState = pluginState;
18
38
  this.paused = true;
19
- this.dirsWatchers = new Map();
20
- }
21
- get watcher() {
22
- var _a;
23
- return this.watchFileSystem.watcher || ((_a = this.watchFileSystem.wfs) === null || _a === void 0 ? void 0 : _a.watcher);
24
- }
25
- watch(files, dirs, missing, startTime, options, callback, callbackUndelayed) {
26
- var _a, _b, _c;
27
- reporter_1.clearFilesChange(this.compiler);
28
- // use standard watch file system for files and missing
29
- const standardWatcher = this.watchFileSystem.watch(files, dirs, missing, startTime, options, callback, callbackUndelayed);
30
- (_a = this.watcher) === null || _a === void 0 ? void 0 : _a.on('change', (file) => {
31
- if (typeof file === 'string' && !isIgnored(file)) {
32
- reporter_1.updateFilesChange(this.compiler, { changedFiles: [file] });
33
- }
34
- });
35
- (_b = this.watcher) === null || _b === void 0 ? void 0 : _b.on('remove', (file) => {
36
- if (typeof file === 'string' && !isIgnored(file)) {
37
- reporter_1.updateFilesChange(this.compiler, { deletedFiles: [file] });
38
- }
39
- });
40
- // calculate what to change
41
- const prevDirs = Array.from(this.dirsWatchers.keys());
42
- const nextDirs = Array.from(((_c = this.pluginState.lastDependencies) === null || _c === void 0 ? void 0 : _c.dirs) || []);
43
- const dirsToUnwatch = prevDirs.filter((prevDir) => !nextDirs.includes(prevDir));
44
- const dirsToWatch = nextDirs.filter((nextDir) => !prevDirs.includes(nextDir) && !isIgnored(nextDir));
45
- // update dirs watcher
46
- dirsToUnwatch.forEach((dirToUnwatch) => {
47
- var _a;
48
- (_a = this.dirsWatchers.get(dirToUnwatch)) === null || _a === void 0 ? void 0 : _a.close();
49
- this.dirsWatchers.delete(dirToUnwatch);
50
- });
51
- dirsToWatch.forEach((dirToWatch) => {
52
- const interval = typeof (options === null || options === void 0 ? void 0 : options.poll) === 'number' ? options.poll : undefined;
53
- const dirWatcher = chokidar_1.default.watch(dirToWatch, {
54
- ignoreInitial: true,
55
- ignorePermissionErrors: true,
56
- ignored: (path) => isIgnored(path),
57
- usePolling: (options === null || options === void 0 ? void 0 : options.poll) ? true : undefined,
58
- interval: interval,
59
- binaryInterval: interval,
60
- alwaysStat: true,
61
- atomic: true,
62
- awaitWriteFinish: true,
63
- });
64
- dirWatcher.on('add', (file, stats) => {
65
- var _a, _b;
66
- if (this.paused) {
67
- return;
39
+ this.watch = (files, dirs, missing, startTime, options, callback, callbackUndelayed) => {
40
+ var _a, _b, _c, _d;
41
+ reporter_1.clearFilesChange(this.compiler);
42
+ const isIgnored = createIsIgnored(options === null || options === void 0 ? void 0 : options.ignored, ((_a = this.pluginState.lastDependencies) === null || _a === void 0 ? void 0 : _a.excluded) || []);
43
+ // use standard watch file system for files and missing
44
+ const standardWatcher = this.watchFileSystem.watch(files, dirs, missing, startTime, options, callback, callbackUndelayed);
45
+ (_b = this.watcher) === null || _b === void 0 ? void 0 : _b.on('change', (file) => {
46
+ if (typeof file === 'string' && !isIgnored(file)) {
47
+ reporter_1.updateFilesChange(this.compiler, { changedFiles: [file] });
68
48
  }
69
- const extension = path_1.extname(file);
70
- const supportedExtensions = ((_a = this.pluginState.lastDependencies) === null || _a === void 0 ? void 0 : _a.extensions) || [];
71
- if (!supportedExtensions.includes(extension)) {
72
- return;
73
- }
74
- reporter_1.updateFilesChange(this.compiler, { changedFiles: [file] });
75
- const mtime = (stats === null || stats === void 0 ? void 0 : stats.mtimeMs) || (stats === null || stats === void 0 ? void 0 : stats.ctimeMs) || 1;
76
- (_b = this.watcher) === null || _b === void 0 ? void 0 : _b._onChange(dirToWatch, mtime, file, 'rename');
77
49
  });
78
- dirWatcher.on('unlink', (file) => {
79
- var _a, _b;
80
- if (this.paused) {
81
- return;
82
- }
83
- const extension = path_1.extname(file);
84
- const supportedExtensions = ((_a = this.pluginState.lastDependencies) === null || _a === void 0 ? void 0 : _a.extensions) || [];
85
- if (!supportedExtensions.includes(extension)) {
86
- return;
50
+ (_c = this.watcher) === null || _c === void 0 ? void 0 : _c.on('remove', (file) => {
51
+ if (typeof file === 'string' && !isIgnored(file)) {
52
+ reporter_1.updateFilesChange(this.compiler, { deletedFiles: [file] });
87
53
  }
88
- reporter_1.updateFilesChange(this.compiler, { deletedFiles: [file] });
89
- (_b = this.watcher) === null || _b === void 0 ? void 0 : _b._onRemove(dirToWatch, file, 'rename');
90
54
  });
91
- this.dirsWatchers.set(dirToWatch, dirWatcher);
92
- });
93
- this.paused = false;
94
- return Object.assign(Object.assign({}, standardWatcher), { close: () => {
95
- reporter_1.clearFilesChange(this.compiler);
96
- if (standardWatcher) {
97
- standardWatcher.close();
98
- }
99
- this.dirsWatchers.forEach((dirWatcher) => {
100
- dirWatcher === null || dirWatcher === void 0 ? void 0 : dirWatcher.close();
55
+ // calculate what to change
56
+ const prevDirs = Array.from(this.dirsWatchers.keys());
57
+ const nextDirs = Array.from(((_d = this.pluginState.lastDependencies) === null || _d === void 0 ? void 0 : _d.dirs) || []);
58
+ const dirsToUnwatch = prevDirs.filter((prevDir) => !nextDirs.includes(prevDir));
59
+ const dirsToWatch = nextDirs.filter((nextDir) => !prevDirs.includes(nextDir) && !isIgnored(nextDir));
60
+ // update dirs watcher
61
+ dirsToUnwatch.forEach((dirToUnwatch) => {
62
+ var _a;
63
+ (_a = this.dirsWatchers.get(dirToUnwatch)) === null || _a === void 0 ? void 0 : _a.close();
64
+ this.dirsWatchers.delete(dirToUnwatch);
65
+ });
66
+ dirsToWatch.forEach((dirToWatch) => {
67
+ const interval = typeof (options === null || options === void 0 ? void 0 : options.poll) === 'number' ? options.poll : undefined;
68
+ const dirWatcher = chokidar_1.default.watch(dirToWatch, {
69
+ ignoreInitial: true,
70
+ ignorePermissionErrors: true,
71
+ ignored: (path) => isIgnored(path),
72
+ usePolling: (options === null || options === void 0 ? void 0 : options.poll) ? true : undefined,
73
+ interval: interval,
74
+ binaryInterval: interval,
75
+ alwaysStat: true,
76
+ atomic: true,
77
+ awaitWriteFinish: true,
101
78
  });
102
- this.dirsWatchers.clear();
103
- this.paused = true;
104
- }, pause: () => {
105
- if (standardWatcher) {
106
- standardWatcher.pause();
107
- }
108
- this.paused = true;
109
- } });
79
+ dirWatcher.on('add', (file, stats) => {
80
+ var _a, _b;
81
+ if (this.paused) {
82
+ return;
83
+ }
84
+ const extension = path_1.extname(file);
85
+ const supportedExtensions = ((_a = this.pluginState.lastDependencies) === null || _a === void 0 ? void 0 : _a.extensions) || [];
86
+ if (!supportedExtensions.includes(extension)) {
87
+ return;
88
+ }
89
+ reporter_1.updateFilesChange(this.compiler, { changedFiles: [file] });
90
+ const mtime = (stats === null || stats === void 0 ? void 0 : stats.mtimeMs) || (stats === null || stats === void 0 ? void 0 : stats.ctimeMs) || 1;
91
+ (_b = this.watcher) === null || _b === void 0 ? void 0 : _b._onChange(dirToWatch, mtime, file, 'rename');
92
+ });
93
+ dirWatcher.on('unlink', (file) => {
94
+ var _a, _b;
95
+ if (this.paused) {
96
+ return;
97
+ }
98
+ const extension = path_1.extname(file);
99
+ const supportedExtensions = ((_a = this.pluginState.lastDependencies) === null || _a === void 0 ? void 0 : _a.extensions) || [];
100
+ if (!supportedExtensions.includes(extension)) {
101
+ return;
102
+ }
103
+ reporter_1.updateFilesChange(this.compiler, { deletedFiles: [file] });
104
+ (_b = this.watcher) === null || _b === void 0 ? void 0 : _b._onRemove(dirToWatch, file, 'rename');
105
+ });
106
+ this.dirsWatchers.set(dirToWatch, dirWatcher);
107
+ });
108
+ this.paused = false;
109
+ return Object.assign(Object.assign({}, standardWatcher), { close: () => {
110
+ reporter_1.clearFilesChange(this.compiler);
111
+ if (standardWatcher) {
112
+ standardWatcher.close();
113
+ }
114
+ this.dirsWatchers.forEach((dirWatcher) => {
115
+ dirWatcher === null || dirWatcher === void 0 ? void 0 : dirWatcher.close();
116
+ });
117
+ this.dirsWatchers.clear();
118
+ this.paused = true;
119
+ }, pause: () => {
120
+ if (standardWatcher) {
121
+ standardWatcher.pause();
122
+ }
123
+ this.paused = true;
124
+ } });
125
+ };
126
+ this.dirsWatchers = new Map();
127
+ }
128
+ get watcher() {
129
+ var _a;
130
+ return this.watchFileSystem.watcher || ((_a = this.watchFileSystem.wfs) === null || _a === void 0 ? void 0 : _a.watcher);
110
131
  }
111
132
  }
112
133
  exports.InclusiveNodeWatchFileSystem = InclusiveNodeWatchFileSystem;
@@ -1,33 +1,16 @@
1
1
  /// <reference types="node" />
2
- import { EventEmitter } from 'events';
3
- interface WatchFileSystemOptions {
4
- aggregateTimeout: number;
5
- poll: boolean;
6
- followSymlinks: boolean;
7
- ignored: string | RegExp | (string | RegExp)[];
8
- }
2
+ import type { EventEmitter } from 'events';
3
+ import type webpack from 'webpack';
9
4
  interface Watchpack extends EventEmitter {
10
5
  _onChange(item: string, mtime: number, file: string, type?: string): void;
11
6
  _onRemove(item: string, file: string, type?: string): void;
12
7
  }
13
- interface WatcherV4 {
14
- close(): void;
15
- pause(): void;
16
- getFileTimestamps(): Map<string, number>;
17
- getContextTimestamps(): Map<string, number>;
18
- }
19
- interface WatcherV5 {
20
- close(): void;
21
- pause(): void;
22
- getFileTimeInfoEntries(): Map<string, number>;
23
- getContextTimeInfoEntries(): Map<string, number>;
24
- }
25
- declare type Watcher = WatcherV4 | WatcherV5;
8
+ declare type Watch = webpack.Compiler['watchFileSystem']['watch'];
26
9
  interface WatchFileSystem {
27
10
  watcher: Watchpack;
28
11
  wfs?: {
29
12
  watcher: Watchpack;
30
13
  };
31
- watch(files: Iterable<string>, dirs: Iterable<string>, missing: Iterable<string>, startTime?: number, options?: Partial<WatchFileSystemOptions>, callback?: Function, callbackUndelayed?: Function): Watcher;
14
+ watch: Watch;
32
15
  }
33
- export { WatchFileSystem, WatchFileSystemOptions, Watchpack, WatcherV4, WatcherV5, Watcher };
16
+ export { WatchFileSystem, Watchpack };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fork-ts-checker-webpack-plugin",
3
- "version": "7.0.0-alpha.1",
3
+ "version": "7.0.0-alpha.10",
4
4
  "description": "Runs typescript type checker and linter on separate process.",
5
5
  "keywords": [
6
6
  "fast",
@@ -38,13 +38,8 @@
38
38
  "test:e2e": "npm pack && cross-env jest --config=test/e2e/jest.config.js --ci -i -b",
39
39
  "precommit": "cross-env lint-staged && yarn build && yarn test:unit",
40
40
  "commit": "cross-env git-cz",
41
- "semantic-release": "semantic-release"
42
- },
43
- "husky": {
44
- "hooks": {
45
- "pre-commit": "lint-staged && yarn build && yarn test:unit",
46
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
47
- }
41
+ "semantic-release": "semantic-release",
42
+ "prepare": "husky install"
48
43
  },
49
44
  "commitlint": {
50
45
  "extends": [
@@ -60,64 +55,67 @@
60
55
  }
61
56
  },
62
57
  "dependencies": {
63
- "@babel/code-frame": "^7.8.3",
64
- "@types/json-schema": "^7.0.5",
65
- "chalk": "^4.1.0",
66
- "chokidar": "^3.4.2",
67
- "cosmiconfig": "^6.0.0",
58
+ "@babel/code-frame": "^7.14.5",
59
+ "chalk": "^4.1.2",
60
+ "chokidar": "^3.5.2",
61
+ "cosmiconfig": "^7.0.0",
68
62
  "deepmerge": "^4.2.2",
69
- "fs-extra": "^9.0.0",
70
- "memfs": "^3.1.2",
63
+ "fs-extra": "^10.0.0",
64
+ "glob": "^7.1.7",
65
+ "memfs": "^3.2.2",
71
66
  "minimatch": "^3.0.4",
72
- "schema-utils": "2.7.0",
73
- "semver": "^7.3.2",
74
- "tapable": "^1.0.0"
67
+ "schema-utils": "3.1.1",
68
+ "semver": "^7.3.5",
69
+ "tapable": "^2.0.0"
70
+ },
71
+ "peerDependencies": {
72
+ "typescript": ">3.6.0",
73
+ "webpack": "^5.11.0"
75
74
  },
76
75
  "devDependencies": {
77
- "@commitlint/config-conventional": "^11.0.0",
76
+ "@commitlint/config-conventional": "^13.1.0",
78
77
  "@semantic-release/commit-analyzer": "^8.0.1",
79
78
  "@semantic-release/exec": "^5.0.0",
80
- "@semantic-release/github": "^7.1.1",
81
- "@semantic-release/npm": "^7.0.6",
82
- "@semantic-release/release-notes-generator": "^9.0.1",
83
- "@types/babel__code-frame": "^7.0.2",
79
+ "@semantic-release/github": "^7.2.3",
80
+ "@semantic-release/npm": "^7.1.3",
81
+ "@semantic-release/release-notes-generator": "^9.0.3",
82
+ "@types/babel__code-frame": "^7.0.3",
84
83
  "@types/cross-spawn": "^6.0.2",
85
- "@types/eslint": "^7.2.4",
86
- "@types/fs-extra": "^9.0.2",
87
- "@types/jest": "^26.0.14",
88
- "@types/minimatch": "^3.0.1",
89
- "@types/mock-fs": "^4.13.0",
90
- "@types/node": "^14.11.10",
91
- "@types/rimraf": "^3.0.0",
92
- "@types/semver": "^7.3.4",
93
- "@types/webpack": "^4.41.22",
94
- "@typescript-eslint/eslint-plugin": "^2.27.0",
95
- "@typescript-eslint/parser": "^2.27.0",
96
- "commitlint": "^11.0.0",
97
- "cross-env": "^7.0.2",
98
- "cross-spawn": "^7.0.3",
99
- "eslint": "^6.8.0",
100
- "eslint-config-prettier": "^6.13.0",
84
+ "@types/fs-extra": "^9.0.12",
85
+ "@types/jest": "^26.0.24",
86
+ "@types/json-schema": "^7.0.9",
87
+ "@types/minimatch": "^3.0.5",
88
+ "@types/mock-fs": "^4.13.1",
89
+ "@types/node": "^16.4.13",
90
+ "@types/rimraf": "^3.0.1",
91
+ "@types/semver": "^7.3.8",
92
+ "@typescript-eslint/eslint-plugin": "^5.1.0",
93
+ "@typescript-eslint/parser": "^5.1.0",
94
+ "commitlint": "^13.1.0",
95
+ "cross-env": "^7.0.3",
96
+ "eslint": "^7.32.0",
97
+ "eslint-plugin-import": "^2.25.2",
101
98
  "eslint-plugin-node": "^11.1.0",
102
- "eslint-plugin-prettier": "^3.1.4",
103
- "git-cz": "^4.7.1",
104
- "husky": "^4.3.0",
105
- "jest": "^26.5.3",
106
- "jest-circus": "^26.5.3",
107
- "jest-environment-node": "^26.5.2",
108
- "lint-staged": "^10.4.2",
109
- "mock-fs": "^4.13.0",
110
- "prettier": "^2.1.2",
99
+ "eslint-plugin-prettier": "^4.0.0",
100
+ "git-cz": "^4.7.6",
101
+ "husky": "^7.0.0",
102
+ "jest": "^27.0.6",
103
+ "jest-circus": "^27.0.6",
104
+ "jest-environment-node": "^27.0.6",
105
+ "json-schema": "^0.3.0",
106
+ "karton": "^0.4.1",
107
+ "lint-staged": "^11.1.2",
108
+ "mock-fs": "^5.0.0",
109
+ "prettier": "^2.3.2",
111
110
  "rimraf": "^3.0.2",
112
- "semantic-release": "^17.2.1",
111
+ "semantic-release": "^17.4.4",
113
112
  "strip-ansi": "^6.0.0",
114
- "tree-kill": "^1.2.2",
115
- "ts-jest": "^26.4.1",
116
- "typescript": "^3.8.3",
117
- "webpack": "^4.42.1"
113
+ "ts-jest": "^27.0.4",
114
+ "typescript": "^4.3.5",
115
+ "webpack": "^5.49.0"
118
116
  },
119
117
  "engines": {
120
- "node": ">=10",
118
+ "node": ">=12.13.0",
121
119
  "yarn": ">=1.0.0"
122
120
  }
123
121
  }