@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,232 @@
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.system = void 0;
13
+ const path_1 = require("path");
14
+ const forward_slash_1 = require("../../../utils/path/forward-slash");
15
+ const mem_file_system_1 = require("./file-system/mem-file-system");
16
+ const passive_file_system_1 = require("./file-system/passive-file-system");
17
+ const real_file_system_1 = require("./file-system/real-file-system");
18
+ const typescript_1 = require("./typescript");
19
+ const worker_config_1 = require("./worker-config");
20
+ const mode = worker_config_1.config.mode;
21
+ let artifacts = {
22
+ files: [],
23
+ dirs: [],
24
+ excluded: [],
25
+ extensions: [],
26
+ };
27
+ let isInitialRun = true;
28
+ // watchers
29
+ const fileWatcherCallbacksMap = new Map();
30
+ const directoryWatcherCallbacksMap = new Map();
31
+ const recursiveDirectoryWatcherCallbacksMap = new Map();
32
+ const deletedFiles = new Map();
33
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
+ const timeoutCallbacks = new Set();
35
+ // based on the ts.ignorePaths
36
+ const ignoredPaths = ['/node_modules/.', '/.git', '/.#'];
37
+ exports.system = Object.assign(Object.assign({}, typescript_1.typescript.sys), { useCaseSensitiveFileNames: true, realpath(path) {
38
+ return getReadFileSystem(path).realPath(path);
39
+ },
40
+ fileExists(path) {
41
+ const stats = getReadFileSystem(path).readStats(path);
42
+ return !!stats && stats.isFile();
43
+ },
44
+ readFile(path, encoding) {
45
+ return getReadFileSystem(path).readFile(path, encoding);
46
+ },
47
+ getFileSize(path) {
48
+ const stats = getReadFileSystem(path).readStats(path);
49
+ return stats ? stats.size : 0;
50
+ },
51
+ writeFile(path, data) {
52
+ getWriteFileSystem(path).writeFile(path, data);
53
+ exports.system.invokeFileChanged(path);
54
+ },
55
+ deleteFile(path) {
56
+ getWriteFileSystem(path).deleteFile(path);
57
+ exports.system.invokeFileDeleted(path);
58
+ },
59
+ directoryExists(path) {
60
+ var _a;
61
+ return Boolean((_a = getReadFileSystem(path).readStats(path)) === null || _a === void 0 ? void 0 : _a.isDirectory());
62
+ },
63
+ createDirectory(path) {
64
+ getWriteFileSystem(path).createDir(path);
65
+ invokeDirectoryWatchers(path);
66
+ },
67
+ getDirectories(path) {
68
+ const dirents = getReadFileSystem(path).readDir(path);
69
+ return dirents
70
+ .filter((dirent) => dirent.isDirectory() ||
71
+ (dirent.isSymbolicLink() && exports.system.directoryExists((0, path_1.join)(path, dirent.name))))
72
+ .map((dirent) => dirent.name);
73
+ },
74
+ getModifiedTime(path) {
75
+ const stats = getReadFileSystem(path).readStats(path);
76
+ if (stats) {
77
+ return stats.mtime;
78
+ }
79
+ },
80
+ setModifiedTime(path, date) {
81
+ getWriteFileSystem(path).updateTimes(path, date, date);
82
+ invokeDirectoryWatchers(path);
83
+ invokeFileWatchers(path, typescript_1.typescript.FileWatcherEventKind.Changed);
84
+ },
85
+ watchFile(path, callback) {
86
+ return createWatcher(fileWatcherCallbacksMap, path, callback);
87
+ },
88
+ watchDirectory(path, callback, recursive = false) {
89
+ return createWatcher(recursive ? recursiveDirectoryWatcherCallbacksMap : directoryWatcherCallbacksMap, path, callback);
90
+ },
91
+ // use immediate instead of timeout to avoid waiting 250ms for batching files changes
92
+ setTimeout: (callback, timeout, ...args) => {
93
+ const timeoutId = setImmediate(() => {
94
+ callback(...args);
95
+ timeoutCallbacks.delete(timeoutId);
96
+ });
97
+ timeoutCallbacks.add(timeoutId);
98
+ return timeoutId;
99
+ }, clearTimeout: (timeoutId) => {
100
+ clearImmediate(timeoutId);
101
+ timeoutCallbacks.delete(timeoutId);
102
+ }, waitForQueued() {
103
+ return __awaiter(this, void 0, void 0, function* () {
104
+ while (timeoutCallbacks.size > 0) {
105
+ yield new Promise((resolve) => setImmediate(resolve));
106
+ }
107
+ isInitialRun = false;
108
+ });
109
+ },
110
+ invokeFileCreated(path) {
111
+ const normalizedPath = normalizeAndResolvePath(path);
112
+ invokeFileWatchers(path, typescript_1.typescript.FileWatcherEventKind.Created);
113
+ invokeDirectoryWatchers(normalizedPath);
114
+ deletedFiles.set(normalizedPath, false);
115
+ },
116
+ invokeFileChanged(path) {
117
+ const normalizedPath = normalizeAndResolvePath(path);
118
+ if (deletedFiles.get(normalizedPath) || !fileWatcherCallbacksMap.has(normalizedPath)) {
119
+ invokeFileWatchers(path, typescript_1.typescript.FileWatcherEventKind.Created);
120
+ invokeDirectoryWatchers(normalizedPath);
121
+ deletedFiles.set(normalizedPath, false);
122
+ }
123
+ else {
124
+ invokeFileWatchers(path, typescript_1.typescript.FileWatcherEventKind.Changed);
125
+ }
126
+ },
127
+ invokeFileDeleted(path) {
128
+ const normalizedPath = normalizeAndResolvePath(path);
129
+ if (!deletedFiles.get(normalizedPath)) {
130
+ invokeFileWatchers(path, typescript_1.typescript.FileWatcherEventKind.Deleted);
131
+ invokeDirectoryWatchers(path);
132
+ deletedFiles.set(normalizedPath, true);
133
+ }
134
+ },
135
+ invalidateCache() {
136
+ real_file_system_1.realFileSystem.clearCache();
137
+ mem_file_system_1.memFileSystem.clearCache();
138
+ passive_file_system_1.passiveFileSystem.clearCache();
139
+ },
140
+ setArtifacts(nextArtifacts) {
141
+ artifacts = nextArtifacts;
142
+ } });
143
+ function createWatcher(watchersMap, path, callback) {
144
+ const normalizedPath = normalizeAndResolvePath(path);
145
+ const watchers = watchersMap.get(normalizedPath) || [];
146
+ const nextWatchers = [...watchers, callback];
147
+ watchersMap.set(normalizedPath, nextWatchers);
148
+ return {
149
+ close: () => {
150
+ const watchers = watchersMap.get(normalizedPath) || [];
151
+ const nextWatchers = watchers.filter((watcher) => watcher !== callback);
152
+ if (nextWatchers.length > 0) {
153
+ watchersMap.set(normalizedPath, nextWatchers);
154
+ }
155
+ else {
156
+ watchersMap.delete(normalizedPath);
157
+ }
158
+ },
159
+ };
160
+ }
161
+ function invokeFileWatchers(path, event) {
162
+ const normalizedPath = normalizeAndResolvePath(path);
163
+ if (normalizedPath.endsWith('.js')) {
164
+ // trigger relevant .d.ts file watcher - handles the case, when we have webpack watcher
165
+ // that points to a symlinked package
166
+ invokeFileWatchers(normalizedPath.slice(0, -3) + '.d.ts', event);
167
+ }
168
+ const fileWatcherCallbacks = fileWatcherCallbacksMap.get(normalizedPath);
169
+ if (fileWatcherCallbacks) {
170
+ // typescript expects normalized paths with posix forward slash
171
+ fileWatcherCallbacks.forEach((fileWatcherCallback) => fileWatcherCallback((0, forward_slash_1.forwardSlash)(normalizedPath), event));
172
+ }
173
+ }
174
+ function invokeDirectoryWatchers(path) {
175
+ const normalizedPath = normalizeAndResolvePath(path);
176
+ const directory = (0, path_1.dirname)(normalizedPath);
177
+ if (ignoredPaths.some((ignoredPath) => (0, forward_slash_1.forwardSlash)(normalizedPath).includes(ignoredPath))) {
178
+ return;
179
+ }
180
+ const directoryWatcherCallbacks = directoryWatcherCallbacksMap.get(directory);
181
+ if (directoryWatcherCallbacks) {
182
+ directoryWatcherCallbacks.forEach((directoryWatcherCallback) => directoryWatcherCallback((0, forward_slash_1.forwardSlash)(normalizedPath)));
183
+ }
184
+ recursiveDirectoryWatcherCallbacksMap.forEach((recursiveDirectoryWatcherCallbacks, watchedDirectory) => {
185
+ if (watchedDirectory === directory ||
186
+ (directory.startsWith(watchedDirectory) &&
187
+ (0, forward_slash_1.forwardSlash)(directory)[watchedDirectory.length] === '/')) {
188
+ recursiveDirectoryWatcherCallbacks.forEach((recursiveDirectoryWatcherCallback) => recursiveDirectoryWatcherCallback((0, forward_slash_1.forwardSlash)(normalizedPath)));
189
+ }
190
+ });
191
+ }
192
+ function normalizeAndResolvePath(path) {
193
+ let normalizedPath = real_file_system_1.realFileSystem.normalizePath(path);
194
+ try {
195
+ normalizedPath = real_file_system_1.realFileSystem.realPath(normalizedPath);
196
+ }
197
+ catch (error) {
198
+ // ignore error - maybe file doesn't exist
199
+ }
200
+ return normalizedPath;
201
+ }
202
+ function isArtifact(path) {
203
+ return ((artifacts.dirs.some((dir) => path.includes(dir)) ||
204
+ artifacts.files.some((file) => path === file)) &&
205
+ artifacts.extensions.some((extension) => path.endsWith(extension)));
206
+ }
207
+ function getReadFileSystem(path) {
208
+ if ((mode === 'readonly' || mode === 'write-tsbuildinfo') && isArtifact(path)) {
209
+ if (isInitialRun && !mem_file_system_1.memFileSystem.exists(path) && passive_file_system_1.passiveFileSystem.exists(path)) {
210
+ // copy file to memory on initial run
211
+ const stats = passive_file_system_1.passiveFileSystem.readStats(path);
212
+ if (stats === null || stats === void 0 ? void 0 : stats.isFile()) {
213
+ const content = passive_file_system_1.passiveFileSystem.readFile(path);
214
+ if (content) {
215
+ mem_file_system_1.memFileSystem.writeFile(path, content);
216
+ mem_file_system_1.memFileSystem.updateTimes(path, stats.atime, stats.mtime);
217
+ }
218
+ }
219
+ return mem_file_system_1.memFileSystem;
220
+ }
221
+ }
222
+ return passive_file_system_1.passiveFileSystem;
223
+ }
224
+ function getWriteFileSystem(path) {
225
+ if (mode === 'write-references' ||
226
+ (mode === 'write-tsbuildinfo' && path.endsWith('.tsbuildinfo')) ||
227
+ (mode === 'write-dts' &&
228
+ ['.tsbuildinfo', '.d.ts', '.d.ts.map'].some((suffix) => path.endsWith(suffix)))) {
229
+ return real_file_system_1.realFileSystem;
230
+ }
231
+ return passive_file_system_1.passiveFileSystem;
232
+ }
@@ -0,0 +1,4 @@
1
+ import type * as ts from 'typescript';
2
+ export declare function startTracingIfNeeded(compilerOptions: ts.CompilerOptions): void;
3
+ export declare function stopTracingIfNeeded(program: ts.Program | ts.BuilderProgram): void;
4
+ export declare function dumpTracingLegendIfNeeded(): void;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dumpTracingLegendIfNeeded = exports.stopTracingIfNeeded = exports.startTracingIfNeeded = void 0;
4
+ const config_1 = require("./config");
5
+ const typescript_1 = require("./typescript");
6
+ const worker_config_1 = require("./worker-config");
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ const traceableTypescript = typescript_1.typescript;
9
+ function startTracingIfNeeded(compilerOptions) {
10
+ if (typeof compilerOptions.generateTrace === 'string' &&
11
+ typeof traceableTypescript.startTracing === 'function') {
12
+ traceableTypescript.startTracing(worker_config_1.config.build ? 'build' : 'project', compilerOptions.generateTrace, (0, config_1.getConfigFilePathFromCompilerOptions)(compilerOptions));
13
+ }
14
+ }
15
+ exports.startTracingIfNeeded = startTracingIfNeeded;
16
+ function stopTracingIfNeeded(program) {
17
+ var _a;
18
+ const compilerOptions = program.getCompilerOptions();
19
+ if (typeof compilerOptions.generateTrace === 'string' &&
20
+ typeof ((_a = traceableTypescript.tracing) === null || _a === void 0 ? void 0 : _a.stopTracing) === 'function') {
21
+ traceableTypescript.tracing.stopTracing();
22
+ }
23
+ }
24
+ exports.stopTracingIfNeeded = stopTracingIfNeeded;
25
+ function dumpTracingLegendIfNeeded() {
26
+ var _a;
27
+ (_a = traceableTypescript.tracing) === null || _a === void 0 ? void 0 : _a.dumpLegend();
28
+ }
29
+ exports.dumpTracingLegendIfNeeded = dumpTracingLegendIfNeeded;
@@ -0,0 +1,4 @@
1
+ import type * as ts from 'typescript';
2
+ export declare function invalidateTsBuildInfo(): void;
3
+ export declare function emitTsBuildInfoIfNeeded(builderProgram: ts.BuilderProgram): void;
4
+ export declare function getTsBuildInfoEmitPath(compilerOptions: ts.CompilerOptions): string | undefined;
@@ -0,0 +1,96 @@
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.getTsBuildInfoEmitPath = exports.emitTsBuildInfoIfNeeded = exports.invalidateTsBuildInfo = void 0;
27
+ const path = __importStar(require("path"));
28
+ const config_1 = require("./config");
29
+ const system_1 = require("./system");
30
+ const typescript_1 = require("./typescript");
31
+ const worker_config_1 = require("./worker-config");
32
+ function invalidateTsBuildInfo() {
33
+ const parsedConfig = (0, config_1.getParsedConfig)();
34
+ // try to remove outdated .tsbuildinfo file for incremental mode
35
+ if (typeof typescript_1.typescript.getTsBuildInfoEmitOutputFilePath === 'function' &&
36
+ worker_config_1.config.mode !== 'readonly' &&
37
+ parsedConfig.options.incremental) {
38
+ const tsBuildInfoPath = typescript_1.typescript.getTsBuildInfoEmitOutputFilePath(parsedConfig.options);
39
+ if (tsBuildInfoPath) {
40
+ try {
41
+ system_1.system.deleteFile(tsBuildInfoPath);
42
+ }
43
+ catch (error) {
44
+ // silent
45
+ }
46
+ }
47
+ }
48
+ }
49
+ exports.invalidateTsBuildInfo = invalidateTsBuildInfo;
50
+ function emitTsBuildInfoIfNeeded(builderProgram) {
51
+ const parsedConfig = (0, config_1.getParsedConfig)();
52
+ if (worker_config_1.config.mode !== 'readonly' && parsedConfig && isIncrementalEnabled(parsedConfig.options)) {
53
+ const program = builderProgram.getProgram();
54
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
+ if (typeof program.emitBuildInfo === 'function') {
56
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
+ program.emitBuildInfo();
58
+ }
59
+ }
60
+ }
61
+ exports.emitTsBuildInfoIfNeeded = emitTsBuildInfoIfNeeded;
62
+ function getTsBuildInfoEmitPath(compilerOptions) {
63
+ if (typeof typescript_1.typescript.getTsBuildInfoEmitOutputFilePath === 'function') {
64
+ return typescript_1.typescript.getTsBuildInfoEmitOutputFilePath(compilerOptions);
65
+ }
66
+ const removeJsonExtension = (filePath) => filePath.endsWith('.json') ? filePath.slice(0, -'.json'.length) : filePath;
67
+ // based on the implementation from typescript
68
+ const configFile = compilerOptions.configFilePath;
69
+ if (!isIncrementalEnabled(compilerOptions)) {
70
+ return undefined;
71
+ }
72
+ if (compilerOptions.tsBuildInfoFile) {
73
+ return compilerOptions.tsBuildInfoFile;
74
+ }
75
+ const outPath = compilerOptions.outFile || compilerOptions.out;
76
+ let buildInfoExtensionLess;
77
+ if (outPath) {
78
+ buildInfoExtensionLess = removeJsonExtension(outPath);
79
+ }
80
+ else {
81
+ if (!configFile) {
82
+ return undefined;
83
+ }
84
+ const configFileExtensionLess = removeJsonExtension(configFile);
85
+ buildInfoExtensionLess = compilerOptions.outDir
86
+ ? compilerOptions.rootDir
87
+ ? path.resolve(compilerOptions.outDir, path.relative(compilerOptions.rootDir, configFileExtensionLess))
88
+ : path.resolve(compilerOptions.outDir, path.basename(configFileExtensionLess))
89
+ : configFileExtensionLess;
90
+ }
91
+ return buildInfoExtensionLess + '.tsbuildinfo';
92
+ }
93
+ exports.getTsBuildInfoEmitPath = getTsBuildInfoEmitPath;
94
+ function isIncrementalEnabled(compilerOptions) {
95
+ return Boolean((compilerOptions.incremental || compilerOptions.composite) && !compilerOptions.outFile);
96
+ }
@@ -0,0 +1,2 @@
1
+ import type * as ts from 'typescript';
2
+ export declare const typescript: typeof ts;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.typescript = void 0;
4
+ const worker_config_1 = require("./worker-config");
5
+ // eslint-disable-next-line
6
+ exports.typescript = require(worker_config_1.config.typescriptPath);
@@ -0,0 +1,2 @@
1
+ import type { TypeScriptWorkerConfig } from '../../type-script-worker-config';
2
+ export declare const config: TypeScriptWorkerConfig;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.config = void 0;
4
+ const rpc_1 = require("../../../rpc");
5
+ exports.config = (0, rpc_1.getRpcWorkerData)();
@@ -0,0 +1,6 @@
1
+ import type { AbortSignal } from 'node-abort-controller';
2
+ declare class AbortError extends Error {
3
+ constructor(message?: string);
4
+ static throwIfAborted(signal: AbortSignal | undefined): void;
5
+ }
6
+ export { AbortError };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AbortError = void 0;
4
+ class AbortError extends Error {
5
+ constructor(message = 'Task aborted.') {
6
+ super(message);
7
+ this.name = 'AbortError';
8
+ }
9
+ static throwIfAborted(signal) {
10
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
11
+ throw new AbortError();
12
+ }
13
+ }
14
+ }
15
+ exports.AbortError = AbortError;
@@ -0,0 +1,6 @@
1
+ declare function createControlledPromise<T = unknown>(): {
2
+ promise: Promise<T>;
3
+ resolve: (value: T) => void;
4
+ reject: (error: unknown) => void;
5
+ };
6
+ export { createControlledPromise };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createControlledPromise = void 0;
4
+ function createControlledPromise() {
5
+ let resolve = () => undefined;
6
+ let reject = () => undefined;
7
+ const promise = new Promise((aResolve, aReject) => {
8
+ resolve = aResolve;
9
+ reject = aReject;
10
+ });
11
+ return {
12
+ promise,
13
+ resolve,
14
+ reject,
15
+ };
16
+ }
17
+ exports.createControlledPromise = createControlledPromise;
@@ -0,0 +1,2 @@
1
+ declare function isPending(promise: Promise<unknown>, timeout?: number): Promise<unknown>;
2
+ export { isPending };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPending = void 0;
4
+ function isPending(promise, timeout = 100) {
5
+ return Promise.race([
6
+ promise.then(() => false).catch(() => false),
7
+ new Promise((resolve) => setTimeout(() => resolve(true), timeout)),
8
+ ]);
9
+ }
10
+ exports.isPending = isPending;
@@ -0,0 +1,10 @@
1
+ import type { AbortSignal } from 'node-abort-controller';
2
+ type Task<T> = (signal?: AbortSignal) => Promise<T>;
3
+ interface Pool {
4
+ submit<T>(task: Task<T>, signal?: AbortSignal): Promise<T>;
5
+ size: number;
6
+ readonly pending: number;
7
+ readonly drained: Promise<void>;
8
+ }
9
+ declare function createPool(size: number): Pool;
10
+ export { Pool, createPool };
@@ -0,0 +1,47 @@
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.createPool = void 0;
13
+ const abort_error_1 = require("./abort-error");
14
+ function createPool(size) {
15
+ let pendingPromises = [];
16
+ const pool = {
17
+ submit(task, signal) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ while (pendingPromises.length >= pool.size) {
20
+ abort_error_1.AbortError.throwIfAborted(signal);
21
+ yield Promise.race(pendingPromises).catch(() => undefined);
22
+ }
23
+ abort_error_1.AbortError.throwIfAborted(signal);
24
+ const taskPromise = task(signal).finally(() => {
25
+ pendingPromises = pendingPromises.filter((pendingPromise) => pendingPromise !== taskPromise);
26
+ });
27
+ pendingPromises.push(taskPromise);
28
+ return taskPromise;
29
+ });
30
+ },
31
+ size,
32
+ get pending() {
33
+ return pendingPromises.length;
34
+ },
35
+ get drained() {
36
+ // eslint-disable-next-line no-async-promise-executor
37
+ return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
38
+ while (pendingPromises.length > 0) {
39
+ yield Promise.race(pendingPromises).catch(() => undefined);
40
+ }
41
+ resolve(undefined);
42
+ }));
43
+ },
44
+ };
45
+ return pool;
46
+ }
47
+ exports.createPool = createPool;
@@ -0,0 +1,2 @@
1
+ declare function wait(timeout: number): Promise<unknown>;
2
+ export { wait };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.wait = void 0;
4
+ function wait(timeout) {
5
+ return new Promise((resolve) => setTimeout(resolve, timeout));
6
+ }
7
+ exports.wait = wait;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Replaces backslashes with one forward slash
3
+ * @param input
4
+ */
5
+ declare function forwardSlash(input: string): string;
6
+ export { forwardSlash };
@@ -0,0 +1,15 @@
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.forwardSlash = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ /**
9
+ * Replaces backslashes with one forward slash
10
+ * @param input
11
+ */
12
+ function forwardSlash(input) {
13
+ return path_1.default.normalize(input).replace(/\\+/g, '/');
14
+ }
15
+ exports.forwardSlash = forwardSlash;
@@ -0,0 +1,2 @@
1
+ declare function isInsideAnotherPath(parent: string, directory: string): boolean;
2
+ export { isInsideAnotherPath };
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isInsideAnotherPath = void 0;
4
+ const path_1 = require("path");
5
+ function isInsideAnotherPath(parent, directory) {
6
+ const relativePart = (0, path_1.relative)(parent, directory);
7
+ // Tested folder is above parent.
8
+ if (relativePart.startsWith('..')) {
9
+ return false;
10
+ }
11
+ // Tested folder is the same as parent.
12
+ if (relativePart.length === 0) {
13
+ return false;
14
+ }
15
+ // Tested directory has nothing in common with parent.
16
+ if ((0, path_1.isAbsolute)(relativePart)) {
17
+ return false;
18
+ }
19
+ // Last option, must be subfolder.
20
+ return true;
21
+ }
22
+ exports.isInsideAnotherPath = isInsideAnotherPath;
@@ -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 forward_slash_1 = require("./forward-slash");
9
+ function relativeToContext(file, context) {
10
+ let fileInContext = (0, forward_slash_1.forwardSlash)(path_1.default.relative(context, file));
11
+ if (!fileInContext.startsWith('../')) {
12
+ fileInContext = './' + fileInContext;
13
+ }
14
+ return fileInContext;
15
+ }
16
+ exports.relativeToContext = relativeToContext;
@@ -0,0 +1,15 @@
1
+ import type { Compiler } from 'webpack';
2
+ import type { ForkTsCheckerWebpackPluginState } from '../plugin-state';
3
+ import type { WatchFileSystem } from './watch-file-system';
4
+ declare class InclusiveNodeWatchFileSystem implements WatchFileSystem {
5
+ private watchFileSystem;
6
+ private compiler;
7
+ private pluginState;
8
+ get watcher(): import("./watch-file-system").Watchpack | undefined;
9
+ private readonly dirsWatchers;
10
+ private paused;
11
+ private deletedFiles;
12
+ constructor(watchFileSystem: WatchFileSystem, compiler: Compiler, pluginState: ForkTsCheckerWebpackPluginState);
13
+ watch: WatchFileSystem['watch'];
14
+ }
15
+ export { InclusiveNodeWatchFileSystem };