ts-checker-rspack-plugin 1.1.7 → 1.2.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 (93) hide show
  1. package/lib/getDependenciesWorker.js +652 -0
  2. package/lib/getIssuesWorker.js +1091 -0
  3. package/lib/index.js +970 -4
  4. package/lib/plugin-state.d.ts +0 -1
  5. package/lib/plugin.d.ts +1 -1
  6. package/lib/rpc/rpc-worker.d.ts +0 -1
  7. package/lib/rpc/wrap-rpc.d.ts +0 -1
  8. package/lib/typescript/worker/lib/file-system/file-system.d.ts +0 -1
  9. package/lib/utils/async/abort-error.d.ts +0 -1
  10. package/lib/utils/async/pool.d.ts +0 -1
  11. package/lib/watch/watch-file-system.d.ts +0 -1
  12. package/package.json +9 -8
  13. package/lib/files-change.js +0 -57
  14. package/lib/files-match.js +0 -2
  15. package/lib/formatter/basic-formatter.js +0 -13
  16. package/lib/formatter/code-frame-formatter.js +0 -32
  17. package/lib/formatter/formatter-config.js +0 -36
  18. package/lib/formatter/formatter-options.js +0 -2
  19. package/lib/formatter/formatter.js +0 -2
  20. package/lib/formatter/index.js +0 -22
  21. package/lib/formatter/stats-formatter.js +0 -30
  22. package/lib/formatter/types/babel__code-frame.js +0 -7
  23. package/lib/formatter/webpack-formatter.js +0 -32
  24. package/lib/hooks/intercept-done-to-get-dev-server-tap.js +0 -18
  25. package/lib/hooks/tap-after-compile-to-add-dependencies.js +0 -59
  26. package/lib/hooks/tap-after-compile-to-get-issues.js +0 -43
  27. package/lib/hooks/tap-after-environment-to-patch-watching.js +0 -22
  28. package/lib/hooks/tap-done-to-async-get-issues.js +0 -74
  29. package/lib/hooks/tap-error-to-log-message.js +0 -32
  30. package/lib/hooks/tap-start-to-run-workers.js +0 -122
  31. package/lib/hooks/tap-stop-to-terminate-workers.js +0 -26
  32. package/lib/infrastructure-logger.js +0 -14
  33. package/lib/issue/index.js +0 -19
  34. package/lib/issue/issue-config.js +0 -29
  35. package/lib/issue/issue-location.js +0 -22
  36. package/lib/issue/issue-match.js +0 -20
  37. package/lib/issue/issue-options.js +0 -2
  38. package/lib/issue/issue-position.js +0 -16
  39. package/lib/issue/issue-predicate.js +0 -11
  40. package/lib/issue/issue-severity.js +0 -12
  41. package/lib/issue/issue-webpack-error.js +0 -31
  42. package/lib/issue/issue.js +0 -41
  43. package/lib/logger.js +0 -2
  44. package/lib/plugin-config.js +0 -26
  45. package/lib/plugin-hooks.js +0 -45
  46. package/lib/plugin-options.js +0 -2
  47. package/lib/plugin-pools.js +0 -32
  48. package/lib/plugin-state.js +0 -17
  49. package/lib/plugin.js +0 -74
  50. package/lib/rpc/expose-rpc.js +0 -69
  51. package/lib/rpc/index.js +0 -12
  52. package/lib/rpc/rpc-error.js +0 -12
  53. package/lib/rpc/rpc-worker.js +0 -86
  54. package/lib/rpc/types.js +0 -2
  55. package/lib/rpc/wrap-rpc.js +0 -70
  56. package/lib/typescript/type-script-config-overwrite.js +0 -2
  57. package/lib/typescript/type-script-diagnostics-options.js +0 -2
  58. package/lib/typescript/type-script-support.js +0 -31
  59. package/lib/typescript/type-script-worker-config.js +0 -36
  60. package/lib/typescript/type-script-worker-options.js +0 -2
  61. package/lib/typescript/worker/get-dependencies-worker.js +0 -15
  62. package/lib/typescript/worker/get-issues-worker.js +0 -70
  63. package/lib/typescript/worker/lib/artifacts.js +0 -94
  64. package/lib/typescript/worker/lib/config.js +0 -162
  65. package/lib/typescript/worker/lib/dependencies.js +0 -84
  66. package/lib/typescript/worker/lib/diagnostics.js +0 -112
  67. package/lib/typescript/worker/lib/emit.js +0 -13
  68. package/lib/typescript/worker/lib/file-system/file-system.js +0 -2
  69. package/lib/typescript/worker/lib/file-system/mem-file-system.js +0 -81
  70. package/lib/typescript/worker/lib/file-system/passive-file-system.js +0 -68
  71. package/lib/typescript/worker/lib/file-system/real-file-system.js +0 -171
  72. package/lib/typescript/worker/lib/host/compiler-host.js +0 -17
  73. package/lib/typescript/worker/lib/host/watch-compiler-host.js +0 -32
  74. package/lib/typescript/worker/lib/host/watch-solution-builder-host.js +0 -53
  75. package/lib/typescript/worker/lib/performance.js +0 -29
  76. package/lib/typescript/worker/lib/program/program.js +0 -37
  77. package/lib/typescript/worker/lib/program/solution-builder.js +0 -39
  78. package/lib/typescript/worker/lib/program/watch-program.js +0 -51
  79. package/lib/typescript/worker/lib/system.js +0 -229
  80. package/lib/typescript/worker/lib/tracing.js +0 -27
  81. package/lib/typescript/worker/lib/tsbuildinfo.js +0 -96
  82. package/lib/typescript/worker/lib/typescript.js +0 -6
  83. package/lib/typescript/worker/lib/worker-config.js +0 -5
  84. package/lib/utils/async/abort-error.js +0 -15
  85. package/lib/utils/async/controlled-promise.js +0 -17
  86. package/lib/utils/async/is-pending.js +0 -10
  87. package/lib/utils/async/pool.js +0 -36
  88. package/lib/utils/async/wait.js +0 -7
  89. package/lib/utils/path/forward-slash.js +0 -15
  90. package/lib/utils/path/is-inside-another-path.js +0 -22
  91. package/lib/utils/path/relative-to-context.js +0 -16
  92. package/lib/watch/inclusive-node-watch-file-system.js +0 -183
  93. package/lib/watch/watch-file-system.js +0 -2
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.invalidateProgram = exports.useProgram = void 0;
4
- const config_1 = require("../config");
5
- const diagnostics_1 = require("../diagnostics");
6
- const emit_1 = require("../emit");
7
- const compiler_host_1 = require("../host/compiler-host");
8
- const tracing_1 = require("../tracing");
9
- const typescript_1 = require("../typescript");
10
- let compilerHost;
11
- let program;
12
- function useProgram() {
13
- const parsedConfig = (0, config_1.getParsedConfig)();
14
- if (!compilerHost) {
15
- compilerHost = (0, compiler_host_1.createCompilerHost)(parsedConfig);
16
- }
17
- if (!program) {
18
- (0, tracing_1.startTracingIfNeeded)(parsedConfig.options);
19
- program = typescript_1.typescript.createProgram({
20
- rootNames: parsedConfig.fileNames,
21
- options: parsedConfig.options,
22
- projectReferences: parsedConfig.projectReferences,
23
- host: compilerHost,
24
- });
25
- }
26
- (0, diagnostics_1.updateDiagnostics)((0, config_1.getConfigFilePathFromProgram)(program), (0, diagnostics_1.getDiagnosticsOfProgram)(program));
27
- (0, emit_1.emitDtsIfNeeded)(program);
28
- (0, tracing_1.stopTracingIfNeeded)(program);
29
- }
30
- exports.useProgram = useProgram;
31
- function invalidateProgram(withHost = false) {
32
- if (withHost) {
33
- compilerHost = undefined;
34
- }
35
- program = undefined;
36
- }
37
- exports.invalidateProgram = invalidateProgram;
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.invalidateSolutionBuilder = exports.useSolutionBuilder = void 0;
4
- const config_1 = require("../config");
5
- const diagnostics_1 = require("../diagnostics");
6
- const watch_solution_builder_host_1 = require("../host/watch-solution-builder-host");
7
- const tracing_1 = require("../tracing");
8
- const tsbuildinfo_1 = require("../tsbuildinfo");
9
- const typescript_1 = require("../typescript");
10
- const worker_config_1 = require("../worker-config");
11
- let solutionBuilderHost;
12
- let solutionBuilder;
13
- function useSolutionBuilder() {
14
- if (!solutionBuilderHost) {
15
- const parsedConfig = (0, config_1.getParsedConfig)();
16
- solutionBuilderHost = (0, watch_solution_builder_host_1.createWatchSolutionBuilderHost)(parsedConfig, (rootNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences) => {
17
- if (compilerOptions) {
18
- (0, tracing_1.startTracingIfNeeded)(compilerOptions);
19
- }
20
- return typescript_1.typescript.createSemanticDiagnosticsBuilderProgram(rootNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences);
21
- }, undefined, undefined, undefined, undefined, (builderProgram) => {
22
- (0, diagnostics_1.updateDiagnostics)((0, config_1.getConfigFilePathFromBuilderProgram)(builderProgram), (0, diagnostics_1.getDiagnosticsOfProgram)(builderProgram));
23
- (0, tsbuildinfo_1.emitTsBuildInfoIfNeeded)(builderProgram);
24
- (0, tracing_1.stopTracingIfNeeded)(builderProgram);
25
- });
26
- }
27
- if (!solutionBuilder) {
28
- solutionBuilder = typescript_1.typescript.createSolutionBuilderWithWatch(solutionBuilderHost, [worker_config_1.config.configFile], { watch: true });
29
- solutionBuilder.build();
30
- }
31
- }
32
- exports.useSolutionBuilder = useSolutionBuilder;
33
- function invalidateSolutionBuilder(withHost = false) {
34
- if (withHost) {
35
- solutionBuilderHost = undefined;
36
- }
37
- solutionBuilder = undefined;
38
- }
39
- exports.invalidateSolutionBuilder = invalidateSolutionBuilder;
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.invalidateWatchProgramRootFileNames = exports.invalidateWatchProgram = exports.useWatchProgram = void 0;
4
- const config_1 = require("../config");
5
- const dependencies_1 = require("../dependencies");
6
- const diagnostics_1 = require("../diagnostics");
7
- const emit_1 = require("../emit");
8
- const watch_compiler_host_1 = require("../host/watch-compiler-host");
9
- const tracing_1 = require("../tracing");
10
- const tsbuildinfo_1 = require("../tsbuildinfo");
11
- const typescript_1 = require("../typescript");
12
- let watchCompilerHost;
13
- let watchProgram;
14
- let shouldUpdateRootFiles = false;
15
- function useWatchProgram() {
16
- if (!watchCompilerHost) {
17
- const parsedConfig = (0, config_1.getParsedConfig)();
18
- watchCompilerHost = (0, watch_compiler_host_1.createWatchCompilerHost)(parsedConfig, (rootNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences) => {
19
- if (compilerOptions) {
20
- (0, tracing_1.startTracingIfNeeded)(compilerOptions);
21
- }
22
- return typescript_1.typescript.createSemanticDiagnosticsBuilderProgram(rootNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences);
23
- }, undefined, undefined, (builderProgram) => {
24
- (0, diagnostics_1.updateDiagnostics)((0, config_1.getConfigFilePathFromBuilderProgram)(builderProgram), (0, diagnostics_1.getDiagnosticsOfProgram)(builderProgram));
25
- (0, emit_1.emitDtsIfNeeded)(builderProgram);
26
- (0, tsbuildinfo_1.emitTsBuildInfoIfNeeded)(builderProgram);
27
- (0, tracing_1.stopTracingIfNeeded)(builderProgram);
28
- });
29
- watchProgram = undefined;
30
- }
31
- if (!watchProgram) {
32
- watchProgram = typescript_1.typescript.createWatchProgram(watchCompilerHost);
33
- }
34
- if (shouldUpdateRootFiles) {
35
- // we have to update root files manually as don't use config file as a program input
36
- watchProgram.updateRootFileNames((0, dependencies_1.getDependencies)().files);
37
- shouldUpdateRootFiles = false;
38
- }
39
- }
40
- exports.useWatchProgram = useWatchProgram;
41
- function invalidateWatchProgram(withHost = false) {
42
- if (withHost) {
43
- watchCompilerHost = undefined;
44
- }
45
- watchProgram = undefined;
46
- }
47
- exports.invalidateWatchProgram = invalidateWatchProgram;
48
- function invalidateWatchProgramRootFileNames() {
49
- shouldUpdateRootFiles = true;
50
- }
51
- exports.invalidateWatchProgramRootFileNames = invalidateWatchProgramRootFileNames;
@@ -1,229 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.system = void 0;
4
- const path_1 = require("path");
5
- const forward_slash_1 = require("../../../utils/path/forward-slash");
6
- const mem_file_system_1 = require("./file-system/mem-file-system");
7
- const passive_file_system_1 = require("./file-system/passive-file-system");
8
- const real_file_system_1 = require("./file-system/real-file-system");
9
- const typescript_1 = require("./typescript");
10
- const worker_config_1 = require("./worker-config");
11
- const mode = worker_config_1.config.mode;
12
- let artifacts = {
13
- files: [],
14
- dirs: [],
15
- excluded: [],
16
- extensions: [],
17
- };
18
- let isInitialRun = true;
19
- // watchers
20
- const fileWatcherCallbacksMap = new Map();
21
- const directoryWatcherCallbacksMap = new Map();
22
- const recursiveDirectoryWatcherCallbacksMap = new Map();
23
- const deletedFiles = new Map();
24
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
- const timeoutCallbacks = new Set();
26
- // based on the ts.ignorePaths
27
- const ignoredPaths = ['/node_modules/.', '/.git', '/.#'];
28
- exports.system = {
29
- ...typescript_1.typescript.sys,
30
- useCaseSensitiveFileNames: true,
31
- realpath(path) {
32
- return getReadFileSystem(path).realPath(path);
33
- },
34
- fileExists(path) {
35
- const stats = getReadFileSystem(path).readStats(path);
36
- return !!stats && stats.isFile();
37
- },
38
- readFile(path, encoding) {
39
- return getReadFileSystem(path).readFile(path, encoding);
40
- },
41
- getFileSize(path) {
42
- const stats = getReadFileSystem(path).readStats(path);
43
- return stats ? stats.size : 0;
44
- },
45
- writeFile(path, data) {
46
- getWriteFileSystem(path).writeFile(path, data);
47
- exports.system.invokeFileChanged(path);
48
- },
49
- deleteFile(path) {
50
- getWriteFileSystem(path).deleteFile(path);
51
- exports.system.invokeFileDeleted(path);
52
- },
53
- directoryExists(path) {
54
- return Boolean(getReadFileSystem(path).readStats(path)?.isDirectory());
55
- },
56
- createDirectory(path) {
57
- getWriteFileSystem(path).createDir(path);
58
- invokeDirectoryWatchers(path);
59
- },
60
- getDirectories(path) {
61
- const dirents = getReadFileSystem(path).readDir(path);
62
- return dirents
63
- .filter((dirent) => dirent.isDirectory() ||
64
- (dirent.isSymbolicLink() && exports.system.directoryExists((0, path_1.join)(path, dirent.name))))
65
- .map((dirent) => dirent.name);
66
- },
67
- getModifiedTime(path) {
68
- if (path === undefined) {
69
- return undefined;
70
- }
71
- const stats = getReadFileSystem(path).readStats(path);
72
- if (stats) {
73
- return stats.mtime;
74
- }
75
- },
76
- setModifiedTime(path, date) {
77
- getWriteFileSystem(path).updateTimes(path, date, date);
78
- invokeDirectoryWatchers(path);
79
- invokeFileWatchers(path, typescript_1.typescript.FileWatcherEventKind.Changed);
80
- },
81
- watchFile(path, callback) {
82
- return createWatcher(fileWatcherCallbacksMap, path, callback);
83
- },
84
- watchDirectory(path, callback, recursive = false) {
85
- return createWatcher(recursive ? recursiveDirectoryWatcherCallbacksMap : directoryWatcherCallbacksMap, path, callback);
86
- },
87
- // use immediate instead of timeout to avoid waiting 250ms for batching files changes
88
- setTimeout: (callback, timeout, ...args) => {
89
- const timeoutId = setImmediate(() => {
90
- callback(...args);
91
- timeoutCallbacks.delete(timeoutId);
92
- });
93
- timeoutCallbacks.add(timeoutId);
94
- return timeoutId;
95
- },
96
- clearTimeout: (timeoutId) => {
97
- clearImmediate(timeoutId);
98
- timeoutCallbacks.delete(timeoutId);
99
- },
100
- async waitForQueued() {
101
- while (timeoutCallbacks.size > 0) {
102
- await new Promise((resolve) => setImmediate(resolve));
103
- }
104
- isInitialRun = false;
105
- },
106
- invokeFileCreated(path) {
107
- const normalizedPath = normalizeAndResolvePath(path);
108
- invokeFileWatchers(path, typescript_1.typescript.FileWatcherEventKind.Created);
109
- invokeDirectoryWatchers(normalizedPath);
110
- deletedFiles.set(normalizedPath, false);
111
- },
112
- invokeFileChanged(path) {
113
- const normalizedPath = normalizeAndResolvePath(path);
114
- if (deletedFiles.get(normalizedPath) || !fileWatcherCallbacksMap.has(normalizedPath)) {
115
- invokeFileWatchers(path, typescript_1.typescript.FileWatcherEventKind.Created);
116
- invokeDirectoryWatchers(normalizedPath);
117
- deletedFiles.set(normalizedPath, false);
118
- }
119
- else {
120
- invokeFileWatchers(path, typescript_1.typescript.FileWatcherEventKind.Changed);
121
- }
122
- },
123
- invokeFileDeleted(path) {
124
- const normalizedPath = normalizeAndResolvePath(path);
125
- if (!deletedFiles.get(normalizedPath)) {
126
- invokeFileWatchers(path, typescript_1.typescript.FileWatcherEventKind.Deleted);
127
- invokeDirectoryWatchers(path);
128
- deletedFiles.set(normalizedPath, true);
129
- }
130
- },
131
- invalidateCache() {
132
- real_file_system_1.realFileSystem.clearCache();
133
- mem_file_system_1.memFileSystem.clearCache();
134
- passive_file_system_1.passiveFileSystem.clearCache();
135
- },
136
- setArtifacts(nextArtifacts) {
137
- artifacts = nextArtifacts;
138
- },
139
- };
140
- function createWatcher(watchersMap, path, callback) {
141
- const normalizedPath = normalizeAndResolvePath(path);
142
- const watchers = watchersMap.get(normalizedPath) || [];
143
- const nextWatchers = [...watchers, callback];
144
- watchersMap.set(normalizedPath, nextWatchers);
145
- return {
146
- close: () => {
147
- const watchers = watchersMap.get(normalizedPath) || [];
148
- const nextWatchers = watchers.filter((watcher) => watcher !== callback);
149
- if (nextWatchers.length > 0) {
150
- watchersMap.set(normalizedPath, nextWatchers);
151
- }
152
- else {
153
- watchersMap.delete(normalizedPath);
154
- }
155
- },
156
- };
157
- }
158
- function invokeFileWatchers(path, event) {
159
- const normalizedPath = normalizeAndResolvePath(path);
160
- if (normalizedPath.endsWith('.js')) {
161
- // trigger relevant .d.ts file watcher - handles the case, when we have webpack watcher
162
- // that points to a symlinked package
163
- invokeFileWatchers(normalizedPath.slice(0, -3) + '.d.ts', event);
164
- }
165
- const fileWatcherCallbacks = fileWatcherCallbacksMap.get(normalizedPath);
166
- if (fileWatcherCallbacks) {
167
- // typescript expects normalized paths with posix forward slash
168
- fileWatcherCallbacks.forEach((fileWatcherCallback) => fileWatcherCallback((0, forward_slash_1.forwardSlash)(normalizedPath), event));
169
- }
170
- }
171
- function invokeDirectoryWatchers(path) {
172
- const normalizedPath = normalizeAndResolvePath(path);
173
- const directory = (0, path_1.dirname)(normalizedPath);
174
- if (ignoredPaths.some((ignoredPath) => (0, forward_slash_1.forwardSlash)(normalizedPath).includes(ignoredPath))) {
175
- return;
176
- }
177
- const directoryWatcherCallbacks = directoryWatcherCallbacksMap.get(directory);
178
- if (directoryWatcherCallbacks) {
179
- directoryWatcherCallbacks.forEach((directoryWatcherCallback) => directoryWatcherCallback((0, forward_slash_1.forwardSlash)(normalizedPath)));
180
- }
181
- recursiveDirectoryWatcherCallbacksMap.forEach((recursiveDirectoryWatcherCallbacks, watchedDirectory) => {
182
- if (watchedDirectory === directory ||
183
- (directory.startsWith(watchedDirectory) &&
184
- (0, forward_slash_1.forwardSlash)(directory)[watchedDirectory.length] === '/')) {
185
- recursiveDirectoryWatcherCallbacks.forEach((recursiveDirectoryWatcherCallback) => recursiveDirectoryWatcherCallback((0, forward_slash_1.forwardSlash)(normalizedPath)));
186
- }
187
- });
188
- }
189
- function normalizeAndResolvePath(path) {
190
- let normalizedPath = real_file_system_1.realFileSystem.normalizePath(path);
191
- try {
192
- normalizedPath = real_file_system_1.realFileSystem.realPath(normalizedPath);
193
- }
194
- catch (error) {
195
- // ignore error - maybe file doesn't exist
196
- }
197
- return normalizedPath;
198
- }
199
- function isArtifact(path) {
200
- return ((artifacts.dirs.some((dir) => path.includes(dir)) ||
201
- artifacts.files.some((file) => path === file)) &&
202
- artifacts.extensions.some((extension) => path.endsWith(extension)));
203
- }
204
- function getReadFileSystem(path) {
205
- if ((mode === 'readonly' || mode === 'write-tsbuildinfo') && isArtifact(path)) {
206
- if (isInitialRun && !mem_file_system_1.memFileSystem.exists(path) && passive_file_system_1.passiveFileSystem.exists(path)) {
207
- // copy file to memory on initial run
208
- const stats = passive_file_system_1.passiveFileSystem.readStats(path);
209
- if (stats?.isFile()) {
210
- const content = passive_file_system_1.passiveFileSystem.readFile(path);
211
- if (content) {
212
- mem_file_system_1.memFileSystem.writeFile(path, content);
213
- mem_file_system_1.memFileSystem.updateTimes(path, stats.atime, stats.mtime);
214
- }
215
- }
216
- return mem_file_system_1.memFileSystem;
217
- }
218
- }
219
- return passive_file_system_1.passiveFileSystem;
220
- }
221
- function getWriteFileSystem(path) {
222
- if (mode === 'write-references' ||
223
- (mode === 'write-tsbuildinfo' && path.endsWith('.tsbuildinfo')) ||
224
- (mode === 'write-dts' &&
225
- ['.tsbuildinfo', '.d.ts', '.d.ts.map'].some((suffix) => path.endsWith(suffix)))) {
226
- return real_file_system_1.realFileSystem;
227
- }
228
- return passive_file_system_1.passiveFileSystem;
229
- }
@@ -1,27 +0,0 @@
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
- const compilerOptions = program.getCompilerOptions();
18
- if (typeof compilerOptions.generateTrace === 'string' &&
19
- typeof traceableTypescript.tracing?.stopTracing === 'function') {
20
- traceableTypescript.tracing.stopTracing();
21
- }
22
- }
23
- exports.stopTracingIfNeeded = stopTracingIfNeeded;
24
- function dumpTracingLegendIfNeeded() {
25
- traceableTypescript.tracing?.dumpLegend();
26
- }
27
- exports.dumpTracingLegendIfNeeded = dumpTracingLegendIfNeeded;
@@ -1,96 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
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);
@@ -1,5 +0,0 @@
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)();
@@ -1,15 +0,0 @@
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?.aborted) {
11
- throw new AbortError();
12
- }
13
- }
14
- }
15
- exports.AbortError = AbortError;
@@ -1,17 +0,0 @@
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;
@@ -1,10 +0,0 @@
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;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createPool = void 0;
4
- const abort_error_1 = require("./abort-error");
5
- function createPool(size) {
6
- let pendingPromises = [];
7
- const pool = {
8
- async submit(task, signal) {
9
- while (pendingPromises.length >= pool.size) {
10
- abort_error_1.AbortError.throwIfAborted(signal);
11
- await Promise.race(pendingPromises).catch(() => undefined);
12
- }
13
- abort_error_1.AbortError.throwIfAborted(signal);
14
- const taskPromise = task(signal).finally(() => {
15
- pendingPromises = pendingPromises.filter((pendingPromise) => pendingPromise !== taskPromise);
16
- });
17
- pendingPromises.push(taskPromise);
18
- return taskPromise;
19
- },
20
- size,
21
- get pending() {
22
- return pendingPromises.length;
23
- },
24
- get drained() {
25
- // eslint-disable-next-line no-async-promise-executor
26
- return new Promise(async (resolve) => {
27
- while (pendingPromises.length > 0) {
28
- await Promise.race(pendingPromises).catch(() => undefined);
29
- }
30
- resolve(undefined);
31
- });
32
- },
33
- };
34
- return pool;
35
- }
36
- exports.createPool = createPool;
@@ -1,7 +0,0 @@
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;
@@ -1,15 +0,0 @@
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;
@@ -1,22 +0,0 @@
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;
@@ -1,16 +0,0 @@
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;