ts-checker-rspack-plugin 1.1.7 → 1.2.1

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 (100) hide show
  1. package/README.md +69 -22
  2. package/lib/getDependenciesWorker.js +652 -0
  3. package/lib/getIssuesWorker.js +1095 -0
  4. package/lib/index.js +972 -4
  5. package/lib/issue/issue-config.d.ts +2 -0
  6. package/lib/issue/issue-options.d.ts +2 -0
  7. package/lib/issue/issue-severity.d.ts +4 -4
  8. package/lib/plugin-state.d.ts +0 -1
  9. package/lib/plugin.d.ts +1 -1
  10. package/lib/rpc/rpc-worker.d.ts +0 -1
  11. package/lib/rpc/wrap-rpc.d.ts +0 -1
  12. package/lib/typescript/worker/get-issues-worker.d.ts +2 -2
  13. package/lib/typescript/worker/lib/config.d.ts +2 -2
  14. package/lib/typescript/worker/lib/diagnostics.d.ts +3 -3
  15. package/lib/typescript/worker/lib/file-system/file-system.d.ts +0 -1
  16. package/lib/utils/async/abort-error.d.ts +0 -1
  17. package/lib/utils/async/pool.d.ts +0 -1
  18. package/lib/watch/watch-file-system.d.ts +0 -1
  19. package/package.json +12 -11
  20. package/lib/files-change.js +0 -57
  21. package/lib/files-match.js +0 -2
  22. package/lib/formatter/basic-formatter.js +0 -13
  23. package/lib/formatter/code-frame-formatter.js +0 -32
  24. package/lib/formatter/formatter-config.js +0 -36
  25. package/lib/formatter/formatter-options.js +0 -2
  26. package/lib/formatter/formatter.js +0 -2
  27. package/lib/formatter/index.js +0 -22
  28. package/lib/formatter/stats-formatter.js +0 -30
  29. package/lib/formatter/types/babel__code-frame.js +0 -7
  30. package/lib/formatter/webpack-formatter.js +0 -32
  31. package/lib/hooks/intercept-done-to-get-dev-server-tap.js +0 -18
  32. package/lib/hooks/tap-after-compile-to-add-dependencies.js +0 -59
  33. package/lib/hooks/tap-after-compile-to-get-issues.js +0 -43
  34. package/lib/hooks/tap-after-environment-to-patch-watching.js +0 -22
  35. package/lib/hooks/tap-done-to-async-get-issues.js +0 -74
  36. package/lib/hooks/tap-error-to-log-message.js +0 -32
  37. package/lib/hooks/tap-start-to-run-workers.js +0 -122
  38. package/lib/hooks/tap-stop-to-terminate-workers.js +0 -26
  39. package/lib/infrastructure-logger.js +0 -14
  40. package/lib/issue/index.js +0 -19
  41. package/lib/issue/issue-config.js +0 -29
  42. package/lib/issue/issue-location.js +0 -22
  43. package/lib/issue/issue-match.js +0 -20
  44. package/lib/issue/issue-options.js +0 -2
  45. package/lib/issue/issue-position.js +0 -16
  46. package/lib/issue/issue-predicate.js +0 -11
  47. package/lib/issue/issue-severity.js +0 -12
  48. package/lib/issue/issue-webpack-error.js +0 -31
  49. package/lib/issue/issue.js +0 -41
  50. package/lib/logger.js +0 -2
  51. package/lib/plugin-config.js +0 -26
  52. package/lib/plugin-hooks.js +0 -45
  53. package/lib/plugin-options.js +0 -2
  54. package/lib/plugin-pools.js +0 -32
  55. package/lib/plugin-state.js +0 -17
  56. package/lib/plugin.js +0 -74
  57. package/lib/rpc/expose-rpc.js +0 -69
  58. package/lib/rpc/index.js +0 -12
  59. package/lib/rpc/rpc-error.js +0 -12
  60. package/lib/rpc/rpc-worker.js +0 -86
  61. package/lib/rpc/types.js +0 -2
  62. package/lib/rpc/wrap-rpc.js +0 -70
  63. package/lib/typescript/type-script-config-overwrite.js +0 -2
  64. package/lib/typescript/type-script-diagnostics-options.js +0 -2
  65. package/lib/typescript/type-script-support.js +0 -31
  66. package/lib/typescript/type-script-worker-config.js +0 -36
  67. package/lib/typescript/type-script-worker-options.js +0 -2
  68. package/lib/typescript/worker/get-dependencies-worker.js +0 -15
  69. package/lib/typescript/worker/get-issues-worker.js +0 -70
  70. package/lib/typescript/worker/lib/artifacts.js +0 -94
  71. package/lib/typescript/worker/lib/config.js +0 -162
  72. package/lib/typescript/worker/lib/dependencies.js +0 -84
  73. package/lib/typescript/worker/lib/diagnostics.js +0 -112
  74. package/lib/typescript/worker/lib/emit.js +0 -13
  75. package/lib/typescript/worker/lib/file-system/file-system.js +0 -2
  76. package/lib/typescript/worker/lib/file-system/mem-file-system.js +0 -81
  77. package/lib/typescript/worker/lib/file-system/passive-file-system.js +0 -68
  78. package/lib/typescript/worker/lib/file-system/real-file-system.js +0 -171
  79. package/lib/typescript/worker/lib/host/compiler-host.js +0 -17
  80. package/lib/typescript/worker/lib/host/watch-compiler-host.js +0 -32
  81. package/lib/typescript/worker/lib/host/watch-solution-builder-host.js +0 -53
  82. package/lib/typescript/worker/lib/performance.js +0 -29
  83. package/lib/typescript/worker/lib/program/program.js +0 -37
  84. package/lib/typescript/worker/lib/program/solution-builder.js +0 -39
  85. package/lib/typescript/worker/lib/program/watch-program.js +0 -51
  86. package/lib/typescript/worker/lib/system.js +0 -229
  87. package/lib/typescript/worker/lib/tracing.js +0 -27
  88. package/lib/typescript/worker/lib/tsbuildinfo.js +0 -96
  89. package/lib/typescript/worker/lib/typescript.js +0 -6
  90. package/lib/typescript/worker/lib/worker-config.js +0 -5
  91. package/lib/utils/async/abort-error.js +0 -15
  92. package/lib/utils/async/controlled-promise.js +0 -17
  93. package/lib/utils/async/is-pending.js +0 -10
  94. package/lib/utils/async/pool.js +0 -36
  95. package/lib/utils/async/wait.js +0 -7
  96. package/lib/utils/path/forward-slash.js +0 -15
  97. package/lib/utils/path/is-inside-another-path.js +0 -22
  98. package/lib/utils/path/relative-to-context.js +0 -16
  99. package/lib/watch/inclusive-node-watch-file-system.js +0 -183
  100. package/lib/watch/watch-file-system.js +0 -2
package/lib/index.js CHANGED
@@ -1,5 +1,973 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TsCheckerRspackPlugin = void 0;
4
- const plugin_1 = require("./plugin");
5
- Object.defineProperty(exports, "TsCheckerRspackPlugin", { enumerable: true, get: function () { return plugin_1.TsCheckerRspackPlugin; } });
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ TsCheckerRspackPlugin: ()=>TsCheckerRspackPlugin
37
+ });
38
+ const external_path_namespaceObject = require("path");
39
+ var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
40
+ function getInfrastructureLogger(compiler) {
41
+ const logger = compiler.getInfrastructureLogger('TsCheckerRspackPlugin');
42
+ return {
43
+ log: logger.log.bind(logger),
44
+ debug: logger.debug.bind(logger),
45
+ error: logger.error.bind(logger),
46
+ warn: logger.warn.bind(logger),
47
+ info: logger.info.bind(logger)
48
+ };
49
+ }
50
+ const external_node_path_namespaceObject = require("node:path");
51
+ const addTrailingSep = (dir)=>dir.endsWith(external_node_path_namespaceObject.sep) ? dir : dir + external_node_path_namespaceObject.sep;
52
+ const isStrictSubdir = (parent, child)=>{
53
+ const parentDir = addTrailingSep(parent);
54
+ const childDir = addTrailingSep(child);
55
+ return parentDir !== childDir && childDir.startsWith(parentDir);
56
+ };
57
+ function excludeOutputPath(dependencies, compiler) {
58
+ const isContextIncluded = dependencies.dirs.includes(compiler.context);
59
+ if (!isContextIncluded) return dependencies;
60
+ const outputPath = 'string' == typeof compiler.options.output?.path ? compiler.options.output.path : compiler.outputPath;
61
+ if (!outputPath || !isStrictSubdir(compiler.context, outputPath) || dependencies.dirs.includes(outputPath)) return dependencies;
62
+ const excluded = new Set(dependencies.excluded);
63
+ excluded.add(outputPath);
64
+ return {
65
+ ...dependencies,
66
+ excluded: Array.from(excluded)
67
+ };
68
+ }
69
+ function tapAfterCompileToAddDependencies(compiler, config, state) {
70
+ const { debug } = getInfrastructureLogger(compiler);
71
+ compiler.hooks.afterCompile.tapPromise('TsCheckerRspackPlugin', async (compilation)=>{
72
+ if (compilation.compiler !== compiler) return;
73
+ const dependencies = await state.dependenciesPromise;
74
+ debug("Got dependencies from the getDependenciesWorker.", dependencies);
75
+ if (dependencies) {
76
+ const sanitizedDependencies = excludeOutputPath(dependencies, compiler);
77
+ state.lastDependencies = sanitizedDependencies;
78
+ sanitizedDependencies.files.forEach((file)=>{
79
+ compilation.fileDependencies.add(file);
80
+ });
81
+ }
82
+ });
83
+ }
84
+ const external_chokidar_namespaceObject = require("chokidar");
85
+ var external_chokidar_default = /*#__PURE__*/ __webpack_require__.n(external_chokidar_namespaceObject);
86
+ const external_minimatch_namespaceObject = require("minimatch");
87
+ const external_is_glob_namespaceObject = require("is-glob");
88
+ var external_is_glob_default = /*#__PURE__*/ __webpack_require__.n(external_is_glob_namespaceObject);
89
+ const IGNORED_FILES = [
90
+ 'package.json'
91
+ ];
92
+ const isIgnoredFile = (file)=>IGNORED_FILES.some((ignoredFile)=>file.endsWith(`/${ignoredFile}`) || file.endsWith(`\\${ignoredFile}`));
93
+ const compilerFilesChangeMap = new WeakMap();
94
+ function getFilesChange(compiler) {
95
+ const { changedFiles = [], deletedFiles = [] } = compilerFilesChangeMap.get(compiler) || {
96
+ changedFiles: [],
97
+ deletedFiles: []
98
+ };
99
+ return {
100
+ changedFiles: changedFiles.filter((changedFile)=>!isIgnoredFile(changedFile)),
101
+ deletedFiles: deletedFiles.filter((deletedFile)=>!isIgnoredFile(deletedFile))
102
+ };
103
+ }
104
+ function consumeFilesChange(compiler) {
105
+ const change = getFilesChange(compiler);
106
+ clearFilesChange(compiler);
107
+ return change;
108
+ }
109
+ function updateFilesChange(compiler, change) {
110
+ compilerFilesChangeMap.set(compiler, aggregateFilesChanges([
111
+ getFilesChange(compiler),
112
+ change
113
+ ]));
114
+ }
115
+ function clearFilesChange(compiler) {
116
+ compilerFilesChangeMap.delete(compiler);
117
+ }
118
+ function aggregateFilesChanges(changes) {
119
+ const changedFilesSet = new Set();
120
+ const deletedFilesSet = new Set();
121
+ for (const { changedFiles = [], deletedFiles = [] } of changes){
122
+ for (const changedFile of changedFiles){
123
+ changedFilesSet.add(changedFile);
124
+ deletedFilesSet.delete(changedFile);
125
+ }
126
+ for (const deletedFile of deletedFiles){
127
+ changedFilesSet.delete(deletedFile);
128
+ deletedFilesSet.add(deletedFile);
129
+ }
130
+ }
131
+ return {
132
+ changedFiles: Array.from(changedFilesSet),
133
+ deletedFiles: Array.from(deletedFilesSet)
134
+ };
135
+ }
136
+ function isInsideAnotherPath(parent, directory) {
137
+ const relativePart = (0, external_path_namespaceObject.relative)(parent, directory);
138
+ if (relativePart.startsWith('..')) return false;
139
+ if (0 === relativePart.length) return false;
140
+ if ((0, external_path_namespaceObject.isAbsolute)(relativePart)) return false;
141
+ return true;
142
+ }
143
+ function _define_property(obj, key, value) {
144
+ if (key in obj) Object.defineProperty(obj, key, {
145
+ value: value,
146
+ enumerable: true,
147
+ configurable: true,
148
+ writable: true
149
+ });
150
+ else obj[key] = value;
151
+ return obj;
152
+ }
153
+ const BUILTIN_IGNORED_DIRS = [
154
+ '.git'
155
+ ];
156
+ function createIsIgnored(ignored, excluded) {
157
+ const ignoredPatterns = ignored ? Array.isArray(ignored) ? [
158
+ ...ignored
159
+ ] : [
160
+ ignored
161
+ ] : [];
162
+ const filteredExcluded = excluded.filter((pattern)=>{
163
+ if (external_is_glob_default()(pattern)) {
164
+ const shouldAppendStar = pattern.includes('**') && !pattern.endsWith('*');
165
+ if (shouldAppendStar) ignoredPatterns.push(pattern.endsWith('/') ? `${pattern}**` : `${pattern}/**`);
166
+ else ignoredPatterns.push(pattern);
167
+ return false;
168
+ }
169
+ return true;
170
+ });
171
+ const ignoredFunctions = ignoredPatterns.map((pattern)=>{
172
+ if ('string' == typeof pattern) return (path)=>(0, external_minimatch_namespaceObject.minimatch)(path, pattern);
173
+ if (pattern instanceof RegExp) return (path)=>pattern.test(path);
174
+ return ()=>false;
175
+ });
176
+ ignoredFunctions.push((path)=>filteredExcluded.some((excludedPath)=>isInsideAnotherPath(excludedPath, path)));
177
+ ignoredFunctions.push((path)=>BUILTIN_IGNORED_DIRS.some((ignoredDir)=>path.includes(`/${ignoredDir}/`) || path.includes(`\\${ignoredDir}\\`)));
178
+ return function(path) {
179
+ return ignoredFunctions.some((ignoredFunction)=>ignoredFunction(path));
180
+ };
181
+ }
182
+ class InclusiveNodeWatchFileSystem {
183
+ get watcher() {
184
+ return this.watchFileSystem.watcher || this.watchFileSystem.wfs?.watcher;
185
+ }
186
+ constructor(watchFileSystem, compiler, pluginState){
187
+ _define_property(this, "watchFileSystem", void 0);
188
+ _define_property(this, "compiler", void 0);
189
+ _define_property(this, "pluginState", void 0);
190
+ _define_property(this, "dirsWatchers", void 0);
191
+ _define_property(this, "paused", void 0);
192
+ _define_property(this, "deletedFiles", void 0);
193
+ _define_property(this, "watch", void 0);
194
+ this.watchFileSystem = watchFileSystem;
195
+ this.compiler = compiler;
196
+ this.pluginState = pluginState;
197
+ this.paused = true;
198
+ this.watch = (files, dirs, missing, startTime, options, callback, callbackUndelayed)=>{
199
+ const { debug } = getInfrastructureLogger(this.compiler);
200
+ clearFilesChange(this.compiler);
201
+ const isIgnored = createIsIgnored(options?.ignored, this.pluginState.lastDependencies?.excluded || []);
202
+ const standardWatcher = this.watchFileSystem.watch(files, dirs, missing, startTime, options, callback, callbackUndelayed);
203
+ this.watcher?.on('change', (file)=>{
204
+ if ('string' != typeof file) return;
205
+ if (isIgnored(file)) debug("Detected file change but it's ignored", file);
206
+ else {
207
+ debug('Detected file change', file);
208
+ this.deletedFiles.delete(file);
209
+ updateFilesChange(this.compiler, {
210
+ changedFiles: [
211
+ file
212
+ ]
213
+ });
214
+ }
215
+ });
216
+ this.watcher?.on('remove', (file)=>{
217
+ if ('string' != typeof file) return;
218
+ if (this.deletedFiles.has(file)) return void debug('Skipping duplicated remove event.');
219
+ if (isIgnored(file)) debug("Detected file remove but it's ignored", file);
220
+ else {
221
+ debug('Detected file remove', file);
222
+ this.deletedFiles.add(file);
223
+ updateFilesChange(this.compiler, {
224
+ deletedFiles: [
225
+ file
226
+ ]
227
+ });
228
+ }
229
+ });
230
+ const prevDirs = Array.from(this.dirsWatchers.keys());
231
+ const nextDirs = Array.from(this.pluginState.lastDependencies?.dirs || []);
232
+ const dirsToUnwatch = prevDirs.filter((prevDir)=>!nextDirs.includes(prevDir));
233
+ const dirsToWatch = nextDirs.filter((nextDir)=>!prevDirs.includes(nextDir) && !isIgnored(nextDir));
234
+ dirsToUnwatch.forEach((dirToUnwatch)=>{
235
+ this.dirsWatchers.get(dirToUnwatch)?.close();
236
+ this.dirsWatchers.delete(dirToUnwatch);
237
+ });
238
+ dirsToWatch.forEach((dirToWatch)=>{
239
+ const interval = 'number' == typeof options?.poll ? options.poll : void 0;
240
+ const dirWatcher = external_chokidar_default().watch(dirToWatch, {
241
+ ignoreInitial: true,
242
+ ignorePermissionErrors: true,
243
+ ignored: (path)=>isIgnored(path),
244
+ usePolling: options?.poll ? true : void 0,
245
+ interval: interval,
246
+ binaryInterval: interval,
247
+ alwaysStat: true,
248
+ atomic: true,
249
+ awaitWriteFinish: true
250
+ });
251
+ dirWatcher.on('add', (file, stats)=>{
252
+ if (this.paused) return;
253
+ const extension = (0, external_path_namespaceObject.extname)(file);
254
+ const supportedExtensions = this.pluginState.lastDependencies?.extensions || [];
255
+ if (!supportedExtensions.includes(extension)) return void debug('Detected new file add but extension is not supported', file);
256
+ debug('Detected new file add', file);
257
+ this.deletedFiles.delete(file);
258
+ updateFilesChange(this.compiler, {
259
+ changedFiles: [
260
+ file
261
+ ]
262
+ });
263
+ this.watcher?._onChange(file, stats?.mtimeMs || stats?.ctimeMs || 1, file, 'rename');
264
+ });
265
+ dirWatcher.on('unlink', (file)=>{
266
+ if (this.paused) return;
267
+ const extension = (0, external_path_namespaceObject.extname)(file);
268
+ const supportedExtensions = this.pluginState.lastDependencies?.extensions || [];
269
+ if (!supportedExtensions.includes(extension)) return void debug('Detected new file remove but extension is not supported', file);
270
+ if (this.deletedFiles.has(file)) return void debug('Skipping duplicated unlink event.');
271
+ debug('Detected new file remove', file);
272
+ this.deletedFiles.add(file);
273
+ updateFilesChange(this.compiler, {
274
+ deletedFiles: [
275
+ file
276
+ ]
277
+ });
278
+ this.watcher?._onRemove(dirToWatch, file, 'rename');
279
+ });
280
+ this.dirsWatchers.set(dirToWatch, dirWatcher);
281
+ });
282
+ this.paused = false;
283
+ return {
284
+ ...standardWatcher,
285
+ close: ()=>{
286
+ clearFilesChange(this.compiler);
287
+ if (standardWatcher) standardWatcher.close();
288
+ this.dirsWatchers.forEach((dirWatcher)=>{
289
+ dirWatcher?.close();
290
+ });
291
+ this.dirsWatchers.clear();
292
+ this.paused = true;
293
+ },
294
+ pause: ()=>{
295
+ if (standardWatcher) standardWatcher.pause();
296
+ this.paused = true;
297
+ }
298
+ };
299
+ };
300
+ this.dirsWatchers = new Map();
301
+ this.deletedFiles = new Set();
302
+ }
303
+ }
304
+ function tapAfterEnvironmentToPatchWatching(compiler, state) {
305
+ const { debug } = getInfrastructureLogger(compiler);
306
+ compiler.hooks.afterEnvironment.tap('TsCheckerRspackPlugin', ()=>{
307
+ const watchFileSystem = compiler.watchFileSystem;
308
+ if (watchFileSystem) {
309
+ debug("Overwriting webpack's watch file system.");
310
+ compiler.watchFileSystem = new InclusiveNodeWatchFileSystem(watchFileSystem, compiler, state);
311
+ } else debug('No watch file system found - plugin may not work correctly.');
312
+ });
313
+ }
314
+ const external_picocolors_namespaceObject = require("picocolors");
315
+ var external_picocolors_default = /*#__PURE__*/ __webpack_require__.n(external_picocolors_namespaceObject);
316
+ const lite_tapable_namespaceObject = require("@rspack/lite-tapable");
317
+ const compilerHookMap = new WeakMap();
318
+ function createPluginHooks() {
319
+ return {
320
+ start: new lite_tapable_namespaceObject.AsyncSeriesWaterfallHook([
321
+ 'change',
322
+ 'compilation'
323
+ ]),
324
+ waiting: new lite_tapable_namespaceObject.SyncHook([
325
+ 'compilation'
326
+ ]),
327
+ canceled: new lite_tapable_namespaceObject.SyncHook([
328
+ 'compilation'
329
+ ]),
330
+ error: new lite_tapable_namespaceObject.SyncHook([
331
+ 'error',
332
+ 'compilation'
333
+ ]),
334
+ issues: new lite_tapable_namespaceObject.SyncWaterfallHook([
335
+ 'issues',
336
+ 'compilation'
337
+ ])
338
+ };
339
+ }
340
+ function forwardPluginHooks(source, target) {
341
+ source.start.tapPromise('TsCheckerRspackPlugin', target.start.promise);
342
+ source.waiting.tap('TsCheckerRspackPlugin', target.waiting.call);
343
+ source.canceled.tap('TsCheckerRspackPlugin', target.canceled.call);
344
+ source.error.tap('TsCheckerRspackPlugin', target.error.call);
345
+ source.issues.tap('TsCheckerRspackPlugin', target.issues.call);
346
+ }
347
+ function getPluginHooks(compiler) {
348
+ let hooks = compilerHookMap.get(compiler);
349
+ if (void 0 === hooks) {
350
+ hooks = createPluginHooks();
351
+ compilerHookMap.set(compiler, hooks);
352
+ if ('compilers' in compiler) compiler.compilers.forEach((childCompiler)=>{
353
+ const childHooks = getPluginHooks(childCompiler);
354
+ if (hooks) forwardPluginHooks(childHooks, hooks);
355
+ });
356
+ }
357
+ return hooks;
358
+ }
359
+ const external_process_namespaceObject = require("process");
360
+ function createControlledPromise() {
361
+ let resolve = ()=>void 0;
362
+ let reject = ()=>void 0;
363
+ const promise = new Promise((aResolve, aReject)=>{
364
+ resolve = aResolve;
365
+ reject = aReject;
366
+ });
367
+ return {
368
+ promise,
369
+ resolve,
370
+ reject
371
+ };
372
+ }
373
+ function rpc_error_define_property(obj, key, value) {
374
+ if (key in obj) Object.defineProperty(obj, key, {
375
+ value: value,
376
+ enumerable: true,
377
+ configurable: true,
378
+ writable: true
379
+ });
380
+ else obj[key] = value;
381
+ return obj;
382
+ }
383
+ class RpcExitError extends Error {
384
+ constructor(message, code, signal){
385
+ super(message), rpc_error_define_property(this, "code", void 0), rpc_error_define_property(this, "signal", void 0), this.code = code, this.signal = signal;
386
+ this.name = 'RpcExitError';
387
+ }
388
+ }
389
+ function wrapRpc(childProcess) {
390
+ return async (...args)=>{
391
+ if (childProcess.send) {
392
+ if (!childProcess.connected) throw new Error(`Process ${childProcess.pid} doesn't have open IPC channels`);
393
+ } else throw new Error(`Process ${childProcess.pid} doesn't have IPC channels`);
394
+ const id = uuid();
395
+ const { promise: resultPromise, resolve: resolveResult, reject: rejectResult } = createControlledPromise();
396
+ const { promise: sendPromise, resolve: resolveSend, reject: rejectSend } = createControlledPromise();
397
+ const handleMessage = (message)=>{
398
+ if (message?.id === id) {
399
+ if ('resolve' === message.type) {
400
+ resolveResult(message.value);
401
+ removeHandlers();
402
+ } else if ('reject' === message.type) {
403
+ rejectResult(message.error);
404
+ removeHandlers();
405
+ }
406
+ }
407
+ };
408
+ const handleClose = (code, signal)=>{
409
+ rejectResult(new RpcExitError(code ? `Process ${childProcess.pid} exited with code ${code}` + (signal ? ` [${signal}]` : '') : `Process ${childProcess.pid} exited` + (signal ? ` [${signal}]` : ''), code, signal));
410
+ removeHandlers();
411
+ };
412
+ const removeHandlers = ()=>{
413
+ childProcess.off('message', handleMessage);
414
+ childProcess.off('close', handleClose);
415
+ };
416
+ childProcess.on('message', handleMessage);
417
+ childProcess.on('close', handleClose);
418
+ childProcess.send({
419
+ type: 'call',
420
+ id,
421
+ args
422
+ }, (error)=>{
423
+ if (error) {
424
+ rejectSend(error);
425
+ removeHandlers();
426
+ } else resolveSend(void 0);
427
+ });
428
+ return sendPromise.then(()=>resultPromise);
429
+ };
430
+ }
431
+ function uuid() {
432
+ return new Array(4).fill(0).map(()=>Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join('-');
433
+ }
434
+ const external_child_process_namespaceObject = require("child_process");
435
+ const WORKER_DATA_ENV_KEY = 'WORKER_DATA';
436
+ function createRpcWorker(modulePath, data, memoryLimit) {
437
+ const options = {
438
+ env: {
439
+ ...external_process_namespaceObject.env,
440
+ [WORKER_DATA_ENV_KEY]: JSON.stringify(data || {})
441
+ },
442
+ stdio: [
443
+ 'inherit',
444
+ 'inherit',
445
+ 'inherit',
446
+ 'ipc'
447
+ ],
448
+ serialization: 'advanced'
449
+ };
450
+ if (memoryLimit) options.execArgv = [
451
+ `--max-old-space-size=${memoryLimit}`
452
+ ];
453
+ let childProcess;
454
+ let remoteMethod;
455
+ const worker = {
456
+ connect () {
457
+ if (childProcess && !childProcess.connected) {
458
+ childProcess.kill('SIGTERM');
459
+ childProcess = void 0;
460
+ remoteMethod = void 0;
461
+ }
462
+ if (!childProcess?.connected) {
463
+ childProcess = external_child_process_namespaceObject.fork(modulePath, options);
464
+ remoteMethod = wrapRpc(childProcess);
465
+ }
466
+ },
467
+ terminate () {
468
+ if (childProcess) {
469
+ childProcess.kill('SIGTERM');
470
+ childProcess = void 0;
471
+ remoteMethod = void 0;
472
+ }
473
+ },
474
+ get connected () {
475
+ return Boolean(childProcess?.connected);
476
+ },
477
+ get process () {
478
+ return childProcess;
479
+ }
480
+ };
481
+ return Object.assign((...args)=>{
482
+ if (!worker.connected) worker.connect();
483
+ if (!remoteMethod) return Promise.reject('Worker is not connected - cannot perform RPC.');
484
+ return remoteMethod(...args);
485
+ }, worker);
486
+ }
487
+ class AbortError extends Error {
488
+ static throwIfAborted(signal) {
489
+ if (signal?.aborted) throw new AbortError();
490
+ }
491
+ constructor(message = 'Task aborted.'){
492
+ super(message);
493
+ this.name = 'AbortError';
494
+ }
495
+ }
496
+ function tapErrorToLogMessage(compiler, config) {
497
+ const hooks = getPluginHooks(compiler);
498
+ hooks.error.tap('TsCheckerRspackPlugin', (error)=>{
499
+ if (error instanceof AbortError) return;
500
+ config.logger.error(String(error));
501
+ if (error instanceof RpcExitError) if ('SIGINT' === error.signal) config.logger.error(external_picocolors_default().red("[type-check] Issues checking service interrupted - If running in a docker container, this may be caused by the container running out of memory. If so, try increasing the container's memory limit or lowering the `memoryLimit` value in the TsCheckerRspackPlugin configuration."));
502
+ else config.logger.error(external_picocolors_default().red("[type-check] Issues checking service aborted - probably out of memory. Check the `memoryLimit` option in the TsCheckerRspackPlugin configuration.\nIf increasing the memory doesn't solve the issue, it's most probably a bug in the TypeScript."));
503
+ });
504
+ }
505
+ const external_os_namespaceObject = require("os");
506
+ var external_os_default = /*#__PURE__*/ __webpack_require__.n(external_os_namespaceObject);
507
+ function createPool(size) {
508
+ let pendingPromises = [];
509
+ const pool = {
510
+ async submit (task, signal) {
511
+ while(pendingPromises.length >= pool.size){
512
+ AbortError.throwIfAborted(signal);
513
+ await Promise.race(pendingPromises).catch(()=>void 0);
514
+ }
515
+ AbortError.throwIfAborted(signal);
516
+ const taskPromise = task(signal).finally(()=>{
517
+ pendingPromises = pendingPromises.filter((pendingPromise)=>pendingPromise !== taskPromise);
518
+ });
519
+ pendingPromises.push(taskPromise);
520
+ return taskPromise;
521
+ },
522
+ size,
523
+ get pending () {
524
+ return pendingPromises.length;
525
+ },
526
+ get drained () {
527
+ return new Promise(async (resolve)=>{
528
+ while(pendingPromises.length > 0)await Promise.race(pendingPromises).catch(()=>void 0);
529
+ resolve(void 0);
530
+ });
531
+ }
532
+ };
533
+ return pool;
534
+ }
535
+ const issuesPool = createPool(Math.max(1, external_os_namespaceObject.cpus().length));
536
+ const dependenciesPool = createPool(Math.max(1, external_os_namespaceObject.cpus().length));
537
+ function interceptDoneToGetDevServerTap(compiler, config, state) {
538
+ const { debug } = getInfrastructureLogger(compiler);
539
+ compiler.hooks.done.intercept({
540
+ register: (tap)=>{
541
+ if ([
542
+ 'webpack-dev-server',
543
+ 'rsbuild-dev-server'
544
+ ].includes(tap.name) && 'sync' === tap.type && config.devServer) {
545
+ debug('Intercepting dev-server tap.');
546
+ state.DevServerDoneTap = tap;
547
+ }
548
+ return tap;
549
+ }
550
+ });
551
+ }
552
+ function forwardSlash(input) {
553
+ return external_path_default().normalize(input).replace(/\\+/g, '/');
554
+ }
555
+ function relativeToContext(file, context) {
556
+ let fileInContext = forwardSlash(external_path_default().relative(context, file));
557
+ if (!fileInContext.startsWith('../')) fileInContext = './' + fileInContext;
558
+ return fileInContext;
559
+ }
560
+ function formatIssueLocation(location) {
561
+ return `${location.start.line}:${location.start.column}`;
562
+ }
563
+ function issue_webpack_error_define_property(obj, key, value) {
564
+ if (key in obj) Object.defineProperty(obj, key, {
565
+ value: value,
566
+ enumerable: true,
567
+ configurable: true,
568
+ writable: true
569
+ });
570
+ else obj[key] = value;
571
+ return obj;
572
+ }
573
+ class IssueWebpackError extends Error {
574
+ constructor(message, pathType, issue){
575
+ super(message), issue_webpack_error_define_property(this, "issue", void 0), issue_webpack_error_define_property(this, "hideStack", void 0), issue_webpack_error_define_property(this, "file", void 0), this.issue = issue, this.hideStack = true;
576
+ if (issue.file) {
577
+ this.file = 'absolute' === pathType ? forwardSlash(external_path_default().resolve(issue.file)) : relativeToContext(issue.file, process.cwd());
578
+ if (issue.location) this.file += `:${formatIssueLocation(issue.location)}`;
579
+ }
580
+ Error.captureStackTrace(this, this.constructor);
581
+ }
582
+ }
583
+ function tapAfterCompileToGetIssues(compiler, config, state) {
584
+ const hooks = getPluginHooks(compiler);
585
+ const { debug } = getInfrastructureLogger(compiler);
586
+ compiler.hooks.afterCompile.tapPromise('TsCheckerRspackPlugin', async (compilation)=>{
587
+ if (compilation.compiler !== compiler) return;
588
+ let issues = [];
589
+ try {
590
+ issues = await state.issuesPromise;
591
+ } catch (error) {
592
+ hooks.error.call(error, compilation);
593
+ return;
594
+ }
595
+ debug('Got issues from getIssuesWorker.', issues?.length);
596
+ if (!issues) return;
597
+ issues = issues.filter(config.issue.predicate);
598
+ issues = hooks.issues.call(issues, compilation);
599
+ issues.forEach((issue)=>{
600
+ const error = new IssueWebpackError(config.formatter.format(issue), config.formatter.pathType, issue);
601
+ if ('warning' === issue.severity) compilation.warnings.push(error);
602
+ else compilation.errors.push(error);
603
+ });
604
+ });
605
+ }
606
+ function statsFormatter(issues, stats) {
607
+ const errorsNumber = issues.filter((issue)=>'error' === issue.severity).length;
608
+ const warningsNumber = issues.filter((issue)=>'warning' === issue.severity).length;
609
+ const errorsFormatted = errorsNumber ? external_picocolors_default().bold(external_picocolors_default().red(`${errorsNumber} ${1 === errorsNumber ? 'error' : 'errors'}`)) : '';
610
+ const warningsFormatted = warningsNumber ? external_picocolors_default().bold(external_picocolors_default().yellow(`${warningsNumber} ${1 === warningsNumber ? 'warning' : 'warnings'}`)) : '';
611
+ const timeFormatted = stats.startTime ? Math.round(Date.now() - stats.startTime) : 0;
612
+ if (!errorsFormatted && !warningsFormatted) return external_picocolors_default().green(`[type-check] no errors found in ${timeFormatted} ms`);
613
+ return [
614
+ '[type-check] found ',
615
+ errorsFormatted,
616
+ errorsFormatted && warningsFormatted ? ' and ' : '',
617
+ warningsFormatted,
618
+ timeFormatted ? ` in ${timeFormatted} ms` : ''
619
+ ].join('');
620
+ }
621
+ function createWebpackFormatter(formatter, pathType) {
622
+ return function(issue) {
623
+ const color = 'warning' === issue.severity ? external_picocolors_default().yellow : external_picocolors_default().red;
624
+ const severity = issue.severity.toUpperCase();
625
+ if (!issue.file) return [
626
+ `${external_picocolors_default().bold(color(severity))} in ` + formatter(issue),
627
+ ''
628
+ ].join(external_os_default().EOL);
629
+ {
630
+ let location = external_picocolors_default().bold('absolute' === pathType ? forwardSlash(external_path_default().resolve(issue.file)) : relativeToContext(issue.file, process.cwd()));
631
+ if (issue.location) location += `:${external_picocolors_default().bold(external_picocolors_default().green(formatIssueLocation(issue.location)))}`;
632
+ return [
633
+ `${external_picocolors_default().bold(color(severity))} in ${location}`,
634
+ formatter(issue),
635
+ ''
636
+ ].join(external_os_default().EOL);
637
+ }
638
+ };
639
+ }
640
+ function isPending(promise, timeout = 100) {
641
+ return Promise.race([
642
+ promise.then(()=>false).catch(()=>false),
643
+ new Promise((resolve)=>setTimeout(()=>resolve(true), timeout))
644
+ ]);
645
+ }
646
+ function wait(timeout) {
647
+ return new Promise((resolve)=>setTimeout(resolve, timeout));
648
+ }
649
+ function tapDoneToAsyncGetIssues(compiler, config, state) {
650
+ const hooks = getPluginHooks(compiler);
651
+ const { debug } = getInfrastructureLogger(compiler);
652
+ compiler.hooks.done.tap('TsCheckerRspackPlugin', async (stats)=>{
653
+ if (stats.compilation.compiler !== compiler) return;
654
+ const issuesPromise = state.issuesPromise;
655
+ let issues;
656
+ try {
657
+ if (await isPending(issuesPromise)) {
658
+ hooks.waiting.call(stats.compilation);
659
+ config.logger.log(external_picocolors_default().cyan('[type-check] in progress...'));
660
+ } else await wait(10);
661
+ issues = await issuesPromise;
662
+ } catch (error) {
663
+ hooks.error.call(error, stats.compilation);
664
+ return;
665
+ }
666
+ if (!issues || state.issuesPromise !== issuesPromise) return;
667
+ debug(`Got ${issues?.length || 0} issues from getIssuesWorker.`);
668
+ issues = issues.filter(config.issue.predicate);
669
+ issues = hooks.issues.call(issues, stats.compilation);
670
+ const formatter = createWebpackFormatter(config.formatter.format, config.formatter.pathType);
671
+ if (issues.length) config.logger.error(issues.map((issue)=>formatter(issue)).join('\n'));
672
+ config.logger.log(statsFormatter(issues, stats));
673
+ if (issues.length && state.DevServerDoneTap) {
674
+ issues.forEach((issue)=>{
675
+ const error = new IssueWebpackError(config.formatter.format(issue), config.formatter.pathType, issue);
676
+ if ('warning' === issue.severity) stats.compilation.warnings.push(error);
677
+ else stats.compilation.errors.push(error);
678
+ });
679
+ debug('Sending issues to the dev-server.');
680
+ state.DevServerDoneTap.fn(stats);
681
+ }
682
+ });
683
+ }
684
+ function tapStartToRunWorkers(compiler, getIssuesWorker, getDependenciesWorker, config, state) {
685
+ const hooks = getPluginHooks(compiler);
686
+ const { log, debug } = getInfrastructureLogger(compiler);
687
+ compiler.hooks.run.tap('TsCheckerRspackPlugin', ()=>{
688
+ if (!state.initialized) {
689
+ debug('Initializing plugin for single run (not async).');
690
+ state.initialized = true;
691
+ state.watching = false;
692
+ tapAfterCompileToGetIssues(compiler, config, state);
693
+ }
694
+ });
695
+ compiler.hooks.watchRun.tap('TsCheckerRspackPlugin', async ()=>{
696
+ if (!state.initialized) {
697
+ state.initialized = true;
698
+ state.watching = true;
699
+ if (config.async) {
700
+ debug('Initializing plugin for watch run (async).');
701
+ tapDoneToAsyncGetIssues(compiler, config, state);
702
+ interceptDoneToGetDevServerTap(compiler, config, state);
703
+ } else {
704
+ debug('Initializing plugin for watch run (not async).');
705
+ tapAfterCompileToGetIssues(compiler, config, state);
706
+ }
707
+ }
708
+ });
709
+ compiler.hooks.compilation.tap('TsCheckerRspackPlugin', async (compilation)=>{
710
+ if (compilation.compiler !== compiler) return;
711
+ const iteration = ++state.iteration;
712
+ if (state.abortController) {
713
+ debug(`Aborting iteration ${iteration - 1}.`);
714
+ state.abortController.abort();
715
+ }
716
+ const abortController = new AbortController();
717
+ state.abortController = abortController;
718
+ let filesChange = {};
719
+ if (state.watching) {
720
+ filesChange = consumeFilesChange(compiler);
721
+ log([
722
+ 'Calling reporter service for incremental check.',
723
+ ` Changed files: ${JSON.stringify(filesChange.changedFiles)}`,
724
+ ` Deleted files: ${JSON.stringify(filesChange.deletedFiles)}`
725
+ ].join('\n'));
726
+ } else log('Calling reporter service for single check.');
727
+ filesChange = await hooks.start.promise(filesChange, compilation);
728
+ let aggregatedFilesChange = filesChange;
729
+ if (state.aggregatedFilesChange) {
730
+ aggregatedFilesChange = aggregateFilesChanges([
731
+ aggregatedFilesChange,
732
+ filesChange
733
+ ]);
734
+ debug([
735
+ `Aggregating with previous files change, iteration ${iteration}.`,
736
+ ` Changed files: ${JSON.stringify(aggregatedFilesChange.changedFiles)}`,
737
+ ` Deleted files: ${JSON.stringify(aggregatedFilesChange.deletedFiles)}`
738
+ ].join('\n'));
739
+ }
740
+ state.aggregatedFilesChange = aggregatedFilesChange;
741
+ state.issuesPromise = (state.issuesPromise || Promise.resolve()).catch(()=>void 0).then(()=>{
742
+ if (abortController.signal.aborted) return;
743
+ debug(`Submitting the getIssuesWorker to the pool, iteration ${iteration}.`);
744
+ return issuesPool.submit(async ()=>{
745
+ try {
746
+ debug(`Running the getIssuesWorker, iteration ${iteration}.`);
747
+ const issues = await getIssuesWorker(aggregatedFilesChange, state.watching, config.issue.defaultSeverity);
748
+ if (state.aggregatedFilesChange === aggregatedFilesChange) state.aggregatedFilesChange = void 0;
749
+ if (state.abortController === abortController) state.abortController = void 0;
750
+ return issues;
751
+ } catch (error) {
752
+ hooks.error.call(error, compilation);
753
+ return;
754
+ } finally{
755
+ debug(`The getIssuesWorker finished its job, iteration ${iteration}.`);
756
+ }
757
+ }, abortController.signal);
758
+ });
759
+ debug(`Submitting the getDependenciesWorker to the pool, iteration ${iteration}.`);
760
+ state.dependenciesPromise = dependenciesPool.submit(async ()=>{
761
+ try {
762
+ debug(`Running the getDependenciesWorker, iteration ${iteration}.`);
763
+ return await getDependenciesWorker(filesChange);
764
+ } catch (error) {
765
+ hooks.error.call(error, compilation);
766
+ return;
767
+ } finally{
768
+ debug(`The getDependenciesWorker finished its job, iteration ${iteration}.`);
769
+ }
770
+ });
771
+ });
772
+ }
773
+ function tapStopToTerminateWorkers(compiler, getIssuesWorker, getDependenciesWorker, state) {
774
+ const { debug } = getInfrastructureLogger(compiler);
775
+ const terminateWorkers = ()=>{
776
+ debug('Compiler is going to close - terminating workers...');
777
+ getIssuesWorker.terminate();
778
+ getDependenciesWorker.terminate();
779
+ };
780
+ compiler.hooks.watchClose.tap('TsCheckerRspackPlugin', ()=>{
781
+ terminateWorkers();
782
+ });
783
+ compiler.hooks.done.tap('TsCheckerRspackPlugin', ()=>{
784
+ if (!state.watching) terminateWorkers();
785
+ });
786
+ compiler.hooks.failed.tap('TsCheckerRspackPlugin', ()=>{
787
+ if (!state.watching) terminateWorkers();
788
+ });
789
+ }
790
+ function createBasicFormatter() {
791
+ return function(issue) {
792
+ return external_picocolors_default().gray(issue.code + ': ') + issue.message;
793
+ };
794
+ }
795
+ const code_frame_namespaceObject = require("@babel/code-frame");
796
+ const external_node_fs_namespaceObject = require("node:fs");
797
+ var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
798
+ function createCodeFrameFormatter(options) {
799
+ const basicFormatter = createBasicFormatter();
800
+ return function(issue) {
801
+ const source = issue.file && external_node_fs_default().existsSync(issue.file) && external_node_fs_default().readFileSync(issue.file, 'utf-8');
802
+ let frame = '';
803
+ if (source && issue.location) frame = (0, code_frame_namespaceObject.codeFrameColumns)(source, issue.location, {
804
+ highlightCode: true,
805
+ ...options || {}
806
+ }).split('\n').map((line)=>' ' + line).join(external_os_default().EOL);
807
+ const lines = [
808
+ basicFormatter(issue)
809
+ ];
810
+ if (frame) lines.push(frame);
811
+ return lines.join(external_os_default().EOL);
812
+ };
813
+ }
814
+ function createFormatterConfig(options) {
815
+ if ('function' == typeof options) return {
816
+ format: options,
817
+ pathType: 'relative'
818
+ };
819
+ const type = options ? 'object' == typeof options ? options.type || 'codeframe' : options : 'codeframe';
820
+ const pathType = options && 'object' == typeof options ? options.pathType || 'relative' : 'relative';
821
+ if (!type || 'basic' === type) return {
822
+ format: createBasicFormatter(),
823
+ pathType
824
+ };
825
+ if ('codeframe' === type) {
826
+ const config = options && 'object' == typeof options ? options.options || {} : {};
827
+ return {
828
+ format: createCodeFrameFormatter(config),
829
+ pathType
830
+ };
831
+ }
832
+ throw new Error(`Unknown "${type}" formatter. Available types are: "basic", "codeframe" or a custom function.`);
833
+ }
834
+ function createIssuePredicateFromIssueMatch(context, match) {
835
+ return (issue)=>{
836
+ const matchesSeverity = !match.severity || match.severity === issue.severity;
837
+ const matchesCode = !match.code || match.code === issue.code;
838
+ const matchesFile = !issue.file || !!issue.file && (!match.file || (0, external_minimatch_namespaceObject.minimatch)(forwardSlash(external_path_default().relative(context, issue.file)), match.file));
839
+ return matchesSeverity && matchesCode && matchesFile;
840
+ };
841
+ }
842
+ function createTrivialIssuePredicate(result) {
843
+ return ()=>result;
844
+ }
845
+ function composeIssuePredicates(predicates) {
846
+ return (issue)=>predicates.some((predicate)=>predicate(issue));
847
+ }
848
+ function createIssuePredicateFromOption(context, option) {
849
+ if (Array.isArray(option)) return composeIssuePredicates(option.map((option)=>'function' == typeof option ? option : createIssuePredicateFromIssueMatch(context, option)));
850
+ return 'function' == typeof option ? option : createIssuePredicateFromIssueMatch(context, option);
851
+ }
852
+ function createIssueConfig(compiler, options) {
853
+ const context = compiler.options.context || process.cwd();
854
+ if (!options) options = {};
855
+ const include = options.include ? createIssuePredicateFromOption(context, options.include) : createTrivialIssuePredicate(true);
856
+ const exclude = options.exclude ? createIssuePredicateFromOption(context, options.exclude) : createTrivialIssuePredicate(false);
857
+ const defaultSeverity = options.defaultSeverity ?? 'auto';
858
+ return {
859
+ predicate: (issue)=>include(issue) && !exclude(issue),
860
+ defaultSeverity
861
+ };
862
+ }
863
+ function createTypeScriptWorkerConfig(compiler, options) {
864
+ let configFile = 'object' == typeof options ? options.configFile || 'tsconfig.json' : 'tsconfig.json';
865
+ configFile = external_path_default().normalize(external_path_default().isAbsolute(configFile) ? configFile : external_path_default().resolve(compiler.options.context || process.cwd(), configFile));
866
+ const optionsAsObject = 'object' == typeof options ? options : {};
867
+ const typescriptPath = optionsAsObject.typescriptPath || require.resolve("typescript");
868
+ return {
869
+ enabled: Boolean(options) || void 0 === options,
870
+ memoryLimit: 8192,
871
+ build: false,
872
+ mode: optionsAsObject.build ? 'write-tsbuildinfo' : 'readonly',
873
+ profile: false,
874
+ ...optionsAsObject,
875
+ configFile: configFile,
876
+ configOverwrite: optionsAsObject.configOverwrite || {},
877
+ context: optionsAsObject.context || external_path_default().dirname(configFile),
878
+ diagnosticOptions: {
879
+ syntactic: false,
880
+ semantic: true,
881
+ declaration: false,
882
+ global: false,
883
+ ...optionsAsObject.diagnosticOptions || {}
884
+ },
885
+ typescriptPath: typescriptPath
886
+ };
887
+ }
888
+ function createPluginConfig(compiler, options = {}) {
889
+ return {
890
+ async: void 0 === options.async ? 'development' === compiler.options.mode : options.async,
891
+ typescript: createTypeScriptWorkerConfig(compiler, options.typescript),
892
+ issue: createIssueConfig(compiler, options.issue),
893
+ formatter: createFormatterConfig(options.formatter),
894
+ logger: 'webpack-infrastructure' === options.logger ? (()=>{
895
+ const { info, error } = getInfrastructureLogger(compiler);
896
+ return {
897
+ log: info,
898
+ error
899
+ };
900
+ })() : options.logger || console,
901
+ devServer: false !== options.devServer
902
+ };
903
+ }
904
+ function createPluginState() {
905
+ return {
906
+ issuesPromise: Promise.resolve(void 0),
907
+ dependenciesPromise: Promise.resolve(void 0),
908
+ abortController: void 0,
909
+ aggregatedFilesChange: void 0,
910
+ lastDependencies: void 0,
911
+ watching: false,
912
+ initialized: false,
913
+ iteration: 0,
914
+ DevServerDoneTap: void 0
915
+ };
916
+ }
917
+ function assertTypeScriptSupport(config) {
918
+ let typescriptVersion;
919
+ try {
920
+ typescriptVersion = require(config.typescriptPath).version;
921
+ } catch (error) {}
922
+ if (!typescriptVersion) throw new Error("When you use TsCheckerRspackPlugin with typescript reporter enabled, you must install `typescript` package.");
923
+ if (!external_node_fs_default().existsSync(config.configFile)) throw new Error([
924
+ `Cannot find the "${config.configFile}" file.`,
925
+ "Please check webpack and TsCheckerRspackPlugin configuration.",
926
+ "Possible errors:",
927
+ ' - wrong `context` directory in webpack configuration (if `configFile` is not set or is a relative path in the fork plugin configuration)',
928
+ " - wrong `typescript.configFile` path in the plugin configuration (should be a relative or absolute path)"
929
+ ].join(external_os_default().EOL));
930
+ }
931
+ function plugin_define_property(obj, key, value) {
932
+ if (key in obj) Object.defineProperty(obj, key, {
933
+ value: value,
934
+ enumerable: true,
935
+ configurable: true,
936
+ writable: true
937
+ });
938
+ else obj[key] = value;
939
+ return obj;
940
+ }
941
+ const pkgJson = JSON.parse((0, external_node_fs_namespaceObject.readFileSync)(external_path_namespaceObject.join(__dirname, '../package.json'), 'utf-8'));
942
+ class TsCheckerRspackPlugin {
943
+ static getCompilerHooks(compiler) {
944
+ return getPluginHooks(compiler);
945
+ }
946
+ apply(compiler) {
947
+ const config = createPluginConfig(compiler, this.options);
948
+ const state = createPluginState();
949
+ assertTypeScriptSupport(config.typescript);
950
+ const getIssuesWorker = createRpcWorker(external_path_namespaceObject.resolve(__dirname, './getIssuesWorker.js'), config.typescript, config.typescript.memoryLimit);
951
+ const getDependenciesWorker = createRpcWorker(external_path_namespaceObject.resolve(__dirname, './getDependenciesWorker.js'), config.typescript);
952
+ tapAfterEnvironmentToPatchWatching(compiler, state);
953
+ tapStartToRunWorkers(compiler, getIssuesWorker, getDependenciesWorker, config, state);
954
+ tapAfterCompileToAddDependencies(compiler, config, state);
955
+ tapStopToTerminateWorkers(compiler, getIssuesWorker, getDependenciesWorker, state);
956
+ tapErrorToLogMessage(compiler, config);
957
+ }
958
+ constructor(options = {}){
959
+ plugin_define_property(this, "options", void 0);
960
+ this.options = options;
961
+ }
962
+ }
963
+ plugin_define_property(TsCheckerRspackPlugin, "version", pkgJson.version);
964
+ plugin_define_property(TsCheckerRspackPlugin, "issuesPool", issuesPool);
965
+ plugin_define_property(TsCheckerRspackPlugin, "dependenciesPool", dependenciesPool);
966
+ plugin_define_property(TsCheckerRspackPlugin, "pool", issuesPool);
967
+ exports.TsCheckerRspackPlugin = __webpack_exports__.TsCheckerRspackPlugin;
968
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
969
+ "TsCheckerRspackPlugin"
970
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
971
+ Object.defineProperty(exports, '__esModule', {
972
+ value: true
973
+ });