ts-checker-rspack-plugin 1.2.1 → 1.2.3

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.
package/README.md CHANGED
@@ -39,7 +39,7 @@ yarn add -D ts-checker-rspack-plugin
39
39
  pnpm add -D ts-checker-rspack-plugin
40
40
  ```
41
41
 
42
- The minimal Rspack config with [builtin:swc-loader](https://rspack.dev/guide/features/builtin-swc-loader).
42
+ The minimal Rspack config with [builtin:swc-loader](https://rspack.rs/guide/features/builtin-swc-loader).
43
43
 
44
44
  ```js
45
45
  // rspack.config.mjs
@@ -199,7 +199,7 @@ This plugin provides some custom Rspack hooks:
199
199
  | `issues` | `SyncWaterfallHook` | `issues, compilation` | Issues have been received and will be reported. It's a waterfall hook, so you can modify the list of received issues. |
200
200
 
201
201
  To access plugin hooks and tap into the event, we need to use the `getCompilerHooks` static method.
202
- When we call this method with a [Rspack compiler instance](https://rspack.dev/api/javascript-api/compiler), it returns the object with
202
+ When we call this method with a [Rspack compiler instance](https://rspack.rs/api/javascript-api/compiler), it returns the object with
203
203
  [tapable](https://github.com/webpack/tapable) hooks where you can pass in your callbacks.
204
204
 
205
205
  ```js
@@ -1,6 +1,6 @@
1
1
  export * from './formatter';
2
2
  export * from './basic-formatter';
3
3
  export * from './code-frame-formatter';
4
- export * from './webpack-formatter';
4
+ export * from './rspack-formatter';
5
5
  export * from './formatter-options';
6
6
  export * from './formatter-config';
@@ -0,0 +1,3 @@
1
+ import type { Formatter, FormatterPathType } from './formatter';
2
+ declare function createRspackFormatter(formatter: Formatter, pathType: FormatterPathType): Formatter;
3
+ export { createRspackFormatter };
@@ -21,20 +21,30 @@ var __webpack_require__ = {};
21
21
  __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
22
  })();
23
23
  var __webpack_exports__ = {};
24
- const external_process_namespaceObject = require("process");
25
- var external_process_default = /*#__PURE__*/ __webpack_require__.n(external_process_namespaceObject);
24
+ const external_node_process_namespaceObject = require("node:process");
25
+ var external_node_process_default = /*#__PURE__*/ __webpack_require__.n(external_node_process_namespaceObject);
26
+ function isClosedIpcChannelError(error) {
27
+ if ('object' == typeof error && null !== error && 'code' in error) {
28
+ const CLOSED_IPC_ERROR_CODES = new Set([
29
+ 'ERR_IPC_CHANNEL_CLOSED',
30
+ 'EPIPE'
31
+ ]);
32
+ return CLOSED_IPC_ERROR_CODES.has(error.code);
33
+ }
34
+ return false;
35
+ }
26
36
  function exposeRpc(fn) {
27
37
  const sendMessage = (message)=>new Promise((resolve, reject)=>{
28
- if (external_process_default().send) if (external_process_default().connected) external_process_default().send(message, void 0, void 0, (error)=>{
38
+ if (external_node_process_default().send) if (external_node_process_default().connected) external_node_process_default().send(message, void 0, void 0, (error)=>{
29
39
  if (error) reject(error);
30
40
  else resolve(void 0);
31
41
  });
32
- else reject(new Error(`Process ${external_process_default().pid} doesn't have open IPC channels`));
33
- else reject(new Error(`Process ${external_process_default().pid} doesn't have IPC channels`));
42
+ else reject(new Error(`Process ${external_node_process_default().pid} doesn't have open IPC channels`));
43
+ else reject(new Error(`Process ${external_node_process_default().pid} doesn't have IPC channels`));
34
44
  });
35
45
  const handleMessage = async (message)=>{
36
46
  if ('call' === message.type) {
37
- if (!external_process_default().send) return;
47
+ if (!external_node_process_default().send) return;
38
48
  let value;
39
49
  let error;
40
50
  try {
@@ -54,24 +64,25 @@ function exposeRpc(fn) {
54
64
  value
55
65
  });
56
66
  } catch (sendError) {
67
+ if (isClosedIpcChannelError(sendError)) return void console.warn('[type-check] Skipped because the parent process exited. Build may have failed or been interrupted.');
57
68
  if (error) console.error(error);
58
69
  console.error(sendError);
59
70
  }
60
71
  }
61
72
  };
62
- external_process_default().on('message', handleMessage);
73
+ external_node_process_default().on('message', handleMessage);
63
74
  }
64
- require("child_process");
75
+ require("node:child_process");
65
76
  const WORKER_DATA_ENV_KEY = 'WORKER_DATA';
66
77
  function getRpcWorkerData() {
67
- return JSON.parse(external_process_namespaceObject.env[WORKER_DATA_ENV_KEY] || '{}');
78
+ return JSON.parse(external_node_process_namespaceObject.env[WORKER_DATA_ENV_KEY] || '{}');
68
79
  }
69
- const external_path_namespaceObject = require("path");
70
- var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
80
+ const external_node_path_namespaceObject = require("node:path");
81
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
71
82
  function forwardSlash(input) {
72
- return external_path_default().normalize(input).replace(/\\+/g, '/');
83
+ return external_node_path_default().normalize(input).replace(/\\+/g, '/');
73
84
  }
74
- require("os");
85
+ require("node:os");
75
86
  const worker_config_config = getRpcWorkerData();
76
87
  const typescript_typescript = require(worker_config_config.typescriptPath);
77
88
  new Map();
@@ -100,7 +111,7 @@ const realFileSystem = {
100
111
  return getRealPath(path);
101
112
  },
102
113
  normalizePath (path) {
103
- return (0, external_path_namespaceObject.normalize)(path);
114
+ return (0, external_node_path_namespaceObject.normalize)(path);
104
115
  },
105
116
  writeFile (path, data) {
106
117
  writeFile(getRealPath(path), data);
@@ -123,19 +134,19 @@ const realFileSystem = {
123
134
  }
124
135
  };
125
136
  function exists(path) {
126
- const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
137
+ const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
127
138
  if (!existsCache.has(normalizedPath)) existsCache.set(normalizedPath, external_node_fs_default().existsSync(normalizedPath));
128
139
  return !!existsCache.get(normalizedPath);
129
140
  }
130
141
  function readStats(path) {
131
- const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
142
+ const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
132
143
  if (!readStatsCache.has(normalizedPath)) {
133
144
  if (exists(normalizedPath)) readStatsCache.set(normalizedPath, external_node_fs_default().statSync(normalizedPath));
134
145
  }
135
146
  return readStatsCache.get(normalizedPath);
136
147
  }
137
148
  function readFile(path, encoding) {
138
- const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
149
+ const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
139
150
  if (!readFileCache.has(normalizedPath)) {
140
151
  const stats = readStats(normalizedPath);
141
152
  if (stats && stats.isFile()) readFileCache.set(normalizedPath, external_node_fs_default().readFileSync(normalizedPath, {
@@ -146,7 +157,7 @@ function readFile(path, encoding) {
146
157
  return readFileCache.get(normalizedPath);
147
158
  }
148
159
  function readDir(path) {
149
- const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
160
+ const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
150
161
  if (!readDirCache.has(normalizedPath)) {
151
162
  const stats = readStats(normalizedPath);
152
163
  if (stats && stats.isDirectory()) readDirCache.set(normalizedPath, external_node_fs_default().readdirSync(normalizedPath, {
@@ -157,53 +168,53 @@ function readDir(path) {
157
168
  return readDirCache.get(normalizedPath) || [];
158
169
  }
159
170
  function getRealPath(path) {
160
- const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
171
+ const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
161
172
  if (!realPathCache.has(normalizedPath)) {
162
173
  let base = normalizedPath;
163
174
  let nested = '';
164
- while(base !== (0, external_path_namespaceObject.dirname)(base)){
175
+ while(base !== (0, external_node_path_namespaceObject.dirname)(base)){
165
176
  if (exists(base)) {
166
- realPathCache.set(normalizedPath, (0, external_path_namespaceObject.normalize)((0, external_path_namespaceObject.join)(external_node_fs_default().realpathSync(base), nested)));
177
+ realPathCache.set(normalizedPath, (0, external_node_path_namespaceObject.normalize)((0, external_node_path_namespaceObject.join)(external_node_fs_default().realpathSync(base), nested)));
167
178
  break;
168
179
  }
169
- nested = (0, external_path_namespaceObject.join)((0, external_path_namespaceObject.basename)(base), nested);
170
- base = (0, external_path_namespaceObject.dirname)(base);
180
+ nested = (0, external_node_path_namespaceObject.join)((0, external_node_path_namespaceObject.basename)(base), nested);
181
+ base = (0, external_node_path_namespaceObject.dirname)(base);
171
182
  }
172
183
  }
173
184
  return realPathCache.get(normalizedPath) || normalizedPath;
174
185
  }
175
186
  function createDir(path) {
176
- const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
187
+ const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
177
188
  external_node_fs_default().mkdirSync(normalizedPath, {
178
189
  recursive: true
179
190
  });
180
191
  existsCache.set(normalizedPath, true);
181
- if (readDirCache.has((0, external_path_namespaceObject.dirname)(normalizedPath))) readDirCache.delete((0, external_path_namespaceObject.dirname)(normalizedPath));
192
+ if (readDirCache.has((0, external_node_path_namespaceObject.dirname)(normalizedPath))) readDirCache.delete((0, external_node_path_namespaceObject.dirname)(normalizedPath));
182
193
  if (readStatsCache.has(normalizedPath)) readStatsCache.delete(normalizedPath);
183
194
  }
184
195
  function writeFile(path, data) {
185
- const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
186
- if (!exists((0, external_path_namespaceObject.dirname)(normalizedPath))) createDir((0, external_path_namespaceObject.dirname)(normalizedPath));
196
+ const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
197
+ if (!exists((0, external_node_path_namespaceObject.dirname)(normalizedPath))) createDir((0, external_node_path_namespaceObject.dirname)(normalizedPath));
187
198
  external_node_fs_default().writeFileSync(normalizedPath, data);
188
199
  existsCache.set(normalizedPath, true);
189
- if (readDirCache.has((0, external_path_namespaceObject.dirname)(normalizedPath))) readDirCache.delete((0, external_path_namespaceObject.dirname)(normalizedPath));
200
+ if (readDirCache.has((0, external_node_path_namespaceObject.dirname)(normalizedPath))) readDirCache.delete((0, external_node_path_namespaceObject.dirname)(normalizedPath));
190
201
  if (readStatsCache.has(normalizedPath)) readStatsCache.delete(normalizedPath);
191
202
  if (readFileCache.has(normalizedPath)) readFileCache.delete(normalizedPath);
192
203
  }
193
204
  function deleteFile(path) {
194
205
  if (exists(path)) {
195
- const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
206
+ const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
196
207
  external_node_fs_default().unlinkSync(normalizedPath);
197
208
  existsCache.set(normalizedPath, false);
198
- if (readDirCache.has((0, external_path_namespaceObject.dirname)(normalizedPath))) readDirCache.delete((0, external_path_namespaceObject.dirname)(normalizedPath));
209
+ if (readDirCache.has((0, external_node_path_namespaceObject.dirname)(normalizedPath))) readDirCache.delete((0, external_node_path_namespaceObject.dirname)(normalizedPath));
199
210
  if (readStatsCache.has(normalizedPath)) readStatsCache.delete(normalizedPath);
200
211
  if (readFileCache.has(normalizedPath)) readFileCache.delete(normalizedPath);
201
212
  }
202
213
  }
203
214
  function updateTimes(path, atime, mtime) {
204
215
  if (exists(path)) {
205
- const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
206
- external_node_fs_default().utimesSync((0, external_path_namespaceObject.normalize)(path), atime, mtime);
216
+ const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
217
+ external_node_fs_default().utimesSync((0, external_node_path_namespaceObject.normalize)(path), atime, mtime);
207
218
  if (readStatsCache.has(normalizedPath)) readStatsCache.delete(normalizedPath);
208
219
  }
209
220
  }
@@ -262,7 +273,7 @@ function mem_file_system_createDir(path) {
262
273
  });
263
274
  }
264
275
  function mem_file_system_writeFile(path, data) {
265
- if (!mem_file_system_exists((0, external_path_namespaceObject.dirname)(path))) mem_file_system_createDir((0, external_path_namespaceObject.dirname)(path));
276
+ if (!mem_file_system_exists((0, external_node_path_namespaceObject.dirname)(path))) mem_file_system_createDir((0, external_node_path_namespaceObject.dirname)(path));
266
277
  external_memfs_namespaceObject.fs.writeFileSync(realFileSystem.normalizePath(path), data);
267
278
  }
268
279
  function mem_file_system_deleteFile(path) {
@@ -366,7 +377,7 @@ const system = {
366
377
  },
367
378
  getDirectories (path) {
368
379
  const dirents = getReadFileSystem(path).readDir(path);
369
- return dirents.filter((dirent)=>dirent.isDirectory() || dirent.isSymbolicLink() && system.directoryExists((0, external_path_namespaceObject.join)(path, dirent.name))).map((dirent)=>dirent.name);
380
+ return dirents.filter((dirent)=>dirent.isDirectory() || dirent.isSymbolicLink() && system.directoryExists((0, external_node_path_namespaceObject.join)(path, dirent.name))).map((dirent)=>dirent.name);
370
381
  },
371
382
  getModifiedTime (path) {
372
383
  if (void 0 === path) return;
@@ -452,16 +463,22 @@ function invokeFileWatchers(path, event) {
452
463
  const normalizedPath = normalizeAndResolvePath(path);
453
464
  if (normalizedPath.endsWith('.js')) invokeFileWatchers(normalizedPath.slice(0, -3) + '.d.ts', event);
454
465
  const fileWatcherCallbacks = fileWatcherCallbacksMap.get(normalizedPath);
455
- if (fileWatcherCallbacks) fileWatcherCallbacks.forEach((fileWatcherCallback)=>fileWatcherCallback(forwardSlash(normalizedPath), event));
466
+ if (fileWatcherCallbacks) fileWatcherCallbacks.forEach((fileWatcherCallback)=>{
467
+ fileWatcherCallback(forwardSlash(normalizedPath), event);
468
+ });
456
469
  }
457
470
  function invokeDirectoryWatchers(path) {
458
471
  const normalizedPath = normalizeAndResolvePath(path);
459
- const directory = (0, external_path_namespaceObject.dirname)(normalizedPath);
472
+ const directory = (0, external_node_path_namespaceObject.dirname)(normalizedPath);
460
473
  if (ignoredPaths.some((ignoredPath)=>forwardSlash(normalizedPath).includes(ignoredPath))) return;
461
474
  const directoryWatcherCallbacks = directoryWatcherCallbacksMap.get(directory);
462
- if (directoryWatcherCallbacks) directoryWatcherCallbacks.forEach((directoryWatcherCallback)=>directoryWatcherCallback(forwardSlash(normalizedPath)));
475
+ if (directoryWatcherCallbacks) directoryWatcherCallbacks.forEach((directoryWatcherCallback)=>{
476
+ directoryWatcherCallback(forwardSlash(normalizedPath));
477
+ });
463
478
  recursiveDirectoryWatcherCallbacksMap.forEach((recursiveDirectoryWatcherCallbacks, watchedDirectory)=>{
464
- if (watchedDirectory === directory || directory.startsWith(watchedDirectory) && '/' === forwardSlash(directory)[watchedDirectory.length]) recursiveDirectoryWatcherCallbacks.forEach((recursiveDirectoryWatcherCallback)=>recursiveDirectoryWatcherCallback(forwardSlash(normalizedPath)));
479
+ if (watchedDirectory === directory || directory.startsWith(watchedDirectory) && '/' === forwardSlash(directory)[watchedDirectory.length]) recursiveDirectoryWatcherCallbacks.forEach((recursiveDirectoryWatcherCallback)=>{
480
+ recursiveDirectoryWatcherCallback(forwardSlash(normalizedPath));
481
+ });
465
482
  });
466
483
  }
467
484
  function normalizeAndResolvePath(path) {
@@ -583,7 +600,7 @@ function didConfigFileChanged({ changedFiles = [], deletedFiles = [] }) {
583
600
  return [
584
601
  ...changedFiles,
585
602
  ...deletedFiles
586
- ].map((file)=>external_path_namespaceObject.normalize(file)).includes(external_path_namespaceObject.normalize(worker_config_config.configFile));
603
+ ].map((file)=>external_node_path_namespaceObject.normalize(file)).includes(external_node_path_namespaceObject.normalize(worker_config_config.configFile));
587
604
  }
588
605
  function didDependenciesProbablyChanged(dependencies, { changedFiles = [], deletedFiles = [] }) {
589
606
  const didSomeDependencyHasBeenAdded = changedFiles.some((changeFile)=>!dependencies.files.includes(changeFile));
@@ -606,10 +623,10 @@ function getDependenciesWorker(parsedConfig, configFileContext, processedConfigF
606
623
  const configFilePath = parsedConfig.options.configFilePath;
607
624
  if ('string' == typeof configFilePath) files.add(configFilePath);
608
625
  const dirs = new Set(Object.keys(parsedConfig.wildcardDirectories || {}));
609
- const excluded = new Set((parsedConfig.raw?.exclude || []).map((filePath)=>external_path_namespaceObject.resolve(configFileContext, filePath)));
626
+ const excluded = new Set((parsedConfig.raw?.exclude || []).map((filePath)=>external_node_path_namespaceObject.resolve(configFileContext, filePath)));
610
627
  for (const projectReference of parsedConfig.projectReferences || []){
611
628
  const childConfigFilePath = typescript_typescript.resolveProjectReferencePath(projectReference);
612
- const childConfigContext = external_path_namespaceObject.dirname(childConfigFilePath);
629
+ const childConfigContext = external_node_path_namespaceObject.dirname(childConfigFilePath);
613
630
  if (processedConfigFiles.includes(childConfigFilePath)) continue;
614
631
  const childParsedConfig = parseConfig(childConfigFilePath, childConfigContext);
615
632
  const childDependencies = getDependenciesWorker(childParsedConfig, childConfigContext, [
@@ -631,9 +648,9 @@ function getDependenciesWorker(parsedConfig, configFileContext, processedConfigF
631
648
  typescript_typescript.Extension.TsBuildInfo
632
649
  ];
633
650
  return {
634
- files: Array.from(files).map((file)=>external_path_namespaceObject.normalize(file)),
635
- dirs: Array.from(dirs).map((dir)=>external_path_namespaceObject.normalize(dir)),
636
- excluded: Array.from(excluded).map((aPath)=>external_path_namespaceObject.normalize(aPath)),
651
+ files: Array.from(files).map((file)=>external_node_path_namespaceObject.normalize(file)),
652
+ dirs: Array.from(dirs).map((dir)=>external_node_path_namespaceObject.normalize(dir)),
653
+ excluded: Array.from(excluded).map((aPath)=>external_node_path_namespaceObject.normalize(aPath)),
637
654
  extensions: extensions
638
655
  };
639
656
  }
@@ -21,20 +21,30 @@ var __webpack_require__ = {};
21
21
  __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
22
  })();
23
23
  var __webpack_exports__ = {};
24
- const external_process_namespaceObject = require("process");
25
- var external_process_default = /*#__PURE__*/ __webpack_require__.n(external_process_namespaceObject);
24
+ const external_node_process_namespaceObject = require("node:process");
25
+ var external_node_process_default = /*#__PURE__*/ __webpack_require__.n(external_node_process_namespaceObject);
26
+ function isClosedIpcChannelError(error) {
27
+ if ('object' == typeof error && null !== error && 'code' in error) {
28
+ const CLOSED_IPC_ERROR_CODES = new Set([
29
+ 'ERR_IPC_CHANNEL_CLOSED',
30
+ 'EPIPE'
31
+ ]);
32
+ return CLOSED_IPC_ERROR_CODES.has(error.code);
33
+ }
34
+ return false;
35
+ }
26
36
  function exposeRpc(fn) {
27
37
  const sendMessage = (message)=>new Promise((resolve, reject)=>{
28
- if (external_process_default().send) if (external_process_default().connected) external_process_default().send(message, void 0, void 0, (error)=>{
38
+ if (external_node_process_default().send) if (external_node_process_default().connected) external_node_process_default().send(message, void 0, void 0, (error)=>{
29
39
  if (error) reject(error);
30
40
  else resolve(void 0);
31
41
  });
32
- else reject(new Error(`Process ${external_process_default().pid} doesn't have open IPC channels`));
33
- else reject(new Error(`Process ${external_process_default().pid} doesn't have IPC channels`));
42
+ else reject(new Error(`Process ${external_node_process_default().pid} doesn't have open IPC channels`));
43
+ else reject(new Error(`Process ${external_node_process_default().pid} doesn't have IPC channels`));
34
44
  });
35
45
  const handleMessage = async (message)=>{
36
46
  if ('call' === message.type) {
37
- if (!external_process_default().send) return;
47
+ if (!external_node_process_default().send) return;
38
48
  let value;
39
49
  let error;
40
50
  try {
@@ -54,24 +64,25 @@ function exposeRpc(fn) {
54
64
  value
55
65
  });
56
66
  } catch (sendError) {
67
+ if (isClosedIpcChannelError(sendError)) return void console.warn('[type-check] Skipped because the parent process exited. Build may have failed or been interrupted.');
57
68
  if (error) console.error(error);
58
69
  console.error(sendError);
59
70
  }
60
71
  }
61
72
  };
62
- external_process_default().on('message', handleMessage);
73
+ external_node_process_default().on('message', handleMessage);
63
74
  }
64
- require("child_process");
75
+ require("node:child_process");
65
76
  const WORKER_DATA_ENV_KEY = 'WORKER_DATA';
66
77
  function getRpcWorkerData() {
67
- return JSON.parse(external_process_namespaceObject.env[WORKER_DATA_ENV_KEY] || '{}');
78
+ return JSON.parse(external_node_process_namespaceObject.env[WORKER_DATA_ENV_KEY] || '{}');
68
79
  }
69
- const external_path_namespaceObject = require("path");
70
- var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
80
+ const external_node_path_namespaceObject = require("node:path");
81
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
71
82
  function forwardSlash(input) {
72
- return external_path_default().normalize(input).replace(/\\+/g, '/');
83
+ return external_node_path_default().normalize(input).replace(/\\+/g, '/');
73
84
  }
74
- const external_os_namespaceObject = require("os");
85
+ const external_node_os_namespaceObject = require("node:os");
75
86
  function compareIssuePositions(positionA, positionB) {
76
87
  if (positionA === positionB) return 0;
77
88
  if (!positionA) return -1;
@@ -182,7 +193,7 @@ function createIssueFromDiagnostic(diagnostic, defaultSeverity) {
182
193
  return {
183
194
  code: 'TS' + String(diagnostic.code),
184
195
  severity: getSeverity(),
185
- message: typescript.flattenDiagnosticMessageText(diagnostic.messageText, external_os_namespaceObject.EOL),
196
+ message: typescript.flattenDiagnosticMessageText(diagnostic.messageText, external_node_os_namespaceObject.EOL),
186
197
  file,
187
198
  location
188
199
  };
@@ -215,7 +226,7 @@ const realFileSystem = {
215
226
  return getRealPath(path);
216
227
  },
217
228
  normalizePath (path) {
218
- return (0, external_path_namespaceObject.normalize)(path);
229
+ return (0, external_node_path_namespaceObject.normalize)(path);
219
230
  },
220
231
  writeFile (path, data) {
221
232
  writeFile(getRealPath(path), data);
@@ -238,19 +249,19 @@ const realFileSystem = {
238
249
  }
239
250
  };
240
251
  function exists(path) {
241
- const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
252
+ const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
242
253
  if (!existsCache.has(normalizedPath)) existsCache.set(normalizedPath, external_node_fs_default().existsSync(normalizedPath));
243
254
  return !!existsCache.get(normalizedPath);
244
255
  }
245
256
  function readStats(path) {
246
- const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
257
+ const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
247
258
  if (!readStatsCache.has(normalizedPath)) {
248
259
  if (exists(normalizedPath)) readStatsCache.set(normalizedPath, external_node_fs_default().statSync(normalizedPath));
249
260
  }
250
261
  return readStatsCache.get(normalizedPath);
251
262
  }
252
263
  function readFile(path, encoding) {
253
- const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
264
+ const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
254
265
  if (!readFileCache.has(normalizedPath)) {
255
266
  const stats = readStats(normalizedPath);
256
267
  if (stats && stats.isFile()) readFileCache.set(normalizedPath, external_node_fs_default().readFileSync(normalizedPath, {
@@ -261,7 +272,7 @@ function readFile(path, encoding) {
261
272
  return readFileCache.get(normalizedPath);
262
273
  }
263
274
  function readDir(path) {
264
- const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
275
+ const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
265
276
  if (!readDirCache.has(normalizedPath)) {
266
277
  const stats = readStats(normalizedPath);
267
278
  if (stats && stats.isDirectory()) readDirCache.set(normalizedPath, external_node_fs_default().readdirSync(normalizedPath, {
@@ -272,53 +283,53 @@ function readDir(path) {
272
283
  return readDirCache.get(normalizedPath) || [];
273
284
  }
274
285
  function getRealPath(path) {
275
- const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
286
+ const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
276
287
  if (!realPathCache.has(normalizedPath)) {
277
288
  let base = normalizedPath;
278
289
  let nested = '';
279
- while(base !== (0, external_path_namespaceObject.dirname)(base)){
290
+ while(base !== (0, external_node_path_namespaceObject.dirname)(base)){
280
291
  if (exists(base)) {
281
- realPathCache.set(normalizedPath, (0, external_path_namespaceObject.normalize)((0, external_path_namespaceObject.join)(external_node_fs_default().realpathSync(base), nested)));
292
+ realPathCache.set(normalizedPath, (0, external_node_path_namespaceObject.normalize)((0, external_node_path_namespaceObject.join)(external_node_fs_default().realpathSync(base), nested)));
282
293
  break;
283
294
  }
284
- nested = (0, external_path_namespaceObject.join)((0, external_path_namespaceObject.basename)(base), nested);
285
- base = (0, external_path_namespaceObject.dirname)(base);
295
+ nested = (0, external_node_path_namespaceObject.join)((0, external_node_path_namespaceObject.basename)(base), nested);
296
+ base = (0, external_node_path_namespaceObject.dirname)(base);
286
297
  }
287
298
  }
288
299
  return realPathCache.get(normalizedPath) || normalizedPath;
289
300
  }
290
301
  function createDir(path) {
291
- const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
302
+ const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
292
303
  external_node_fs_default().mkdirSync(normalizedPath, {
293
304
  recursive: true
294
305
  });
295
306
  existsCache.set(normalizedPath, true);
296
- if (readDirCache.has((0, external_path_namespaceObject.dirname)(normalizedPath))) readDirCache.delete((0, external_path_namespaceObject.dirname)(normalizedPath));
307
+ if (readDirCache.has((0, external_node_path_namespaceObject.dirname)(normalizedPath))) readDirCache.delete((0, external_node_path_namespaceObject.dirname)(normalizedPath));
297
308
  if (readStatsCache.has(normalizedPath)) readStatsCache.delete(normalizedPath);
298
309
  }
299
310
  function writeFile(path, data) {
300
- const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
301
- if (!exists((0, external_path_namespaceObject.dirname)(normalizedPath))) createDir((0, external_path_namespaceObject.dirname)(normalizedPath));
311
+ const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
312
+ if (!exists((0, external_node_path_namespaceObject.dirname)(normalizedPath))) createDir((0, external_node_path_namespaceObject.dirname)(normalizedPath));
302
313
  external_node_fs_default().writeFileSync(normalizedPath, data);
303
314
  existsCache.set(normalizedPath, true);
304
- if (readDirCache.has((0, external_path_namespaceObject.dirname)(normalizedPath))) readDirCache.delete((0, external_path_namespaceObject.dirname)(normalizedPath));
315
+ if (readDirCache.has((0, external_node_path_namespaceObject.dirname)(normalizedPath))) readDirCache.delete((0, external_node_path_namespaceObject.dirname)(normalizedPath));
305
316
  if (readStatsCache.has(normalizedPath)) readStatsCache.delete(normalizedPath);
306
317
  if (readFileCache.has(normalizedPath)) readFileCache.delete(normalizedPath);
307
318
  }
308
319
  function deleteFile(path) {
309
320
  if (exists(path)) {
310
- const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
321
+ const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
311
322
  external_node_fs_default().unlinkSync(normalizedPath);
312
323
  existsCache.set(normalizedPath, false);
313
- if (readDirCache.has((0, external_path_namespaceObject.dirname)(normalizedPath))) readDirCache.delete((0, external_path_namespaceObject.dirname)(normalizedPath));
324
+ if (readDirCache.has((0, external_node_path_namespaceObject.dirname)(normalizedPath))) readDirCache.delete((0, external_node_path_namespaceObject.dirname)(normalizedPath));
314
325
  if (readStatsCache.has(normalizedPath)) readStatsCache.delete(normalizedPath);
315
326
  if (readFileCache.has(normalizedPath)) readFileCache.delete(normalizedPath);
316
327
  }
317
328
  }
318
329
  function updateTimes(path, atime, mtime) {
319
330
  if (exists(path)) {
320
- const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
321
- external_node_fs_default().utimesSync((0, external_path_namespaceObject.normalize)(path), atime, mtime);
331
+ const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
332
+ external_node_fs_default().utimesSync((0, external_node_path_namespaceObject.normalize)(path), atime, mtime);
322
333
  if (readStatsCache.has(normalizedPath)) readStatsCache.delete(normalizedPath);
323
334
  }
324
335
  }
@@ -377,7 +388,7 @@ function mem_file_system_createDir(path) {
377
388
  });
378
389
  }
379
390
  function mem_file_system_writeFile(path, data) {
380
- if (!mem_file_system_exists((0, external_path_namespaceObject.dirname)(path))) mem_file_system_createDir((0, external_path_namespaceObject.dirname)(path));
391
+ if (!mem_file_system_exists((0, external_node_path_namespaceObject.dirname)(path))) mem_file_system_createDir((0, external_node_path_namespaceObject.dirname)(path));
381
392
  external_memfs_namespaceObject.fs.writeFileSync(realFileSystem.normalizePath(path), data);
382
393
  }
383
394
  function mem_file_system_deleteFile(path) {
@@ -481,7 +492,7 @@ const system = {
481
492
  },
482
493
  getDirectories (path) {
483
494
  const dirents = getReadFileSystem(path).readDir(path);
484
- return dirents.filter((dirent)=>dirent.isDirectory() || dirent.isSymbolicLink() && system.directoryExists((0, external_path_namespaceObject.join)(path, dirent.name))).map((dirent)=>dirent.name);
495
+ return dirents.filter((dirent)=>dirent.isDirectory() || dirent.isSymbolicLink() && system.directoryExists((0, external_node_path_namespaceObject.join)(path, dirent.name))).map((dirent)=>dirent.name);
485
496
  },
486
497
  getModifiedTime (path) {
487
498
  if (void 0 === path) return;
@@ -567,16 +578,22 @@ function invokeFileWatchers(path, event) {
567
578
  const normalizedPath = normalizeAndResolvePath(path);
568
579
  if (normalizedPath.endsWith('.js')) invokeFileWatchers(normalizedPath.slice(0, -3) + '.d.ts', event);
569
580
  const fileWatcherCallbacks = fileWatcherCallbacksMap.get(normalizedPath);
570
- if (fileWatcherCallbacks) fileWatcherCallbacks.forEach((fileWatcherCallback)=>fileWatcherCallback(forwardSlash(normalizedPath), event));
581
+ if (fileWatcherCallbacks) fileWatcherCallbacks.forEach((fileWatcherCallback)=>{
582
+ fileWatcherCallback(forwardSlash(normalizedPath), event);
583
+ });
571
584
  }
572
585
  function invokeDirectoryWatchers(path) {
573
586
  const normalizedPath = normalizeAndResolvePath(path);
574
- const directory = (0, external_path_namespaceObject.dirname)(normalizedPath);
587
+ const directory = (0, external_node_path_namespaceObject.dirname)(normalizedPath);
575
588
  if (ignoredPaths.some((ignoredPath)=>forwardSlash(normalizedPath).includes(ignoredPath))) return;
576
589
  const directoryWatcherCallbacks = directoryWatcherCallbacksMap.get(directory);
577
- if (directoryWatcherCallbacks) directoryWatcherCallbacks.forEach((directoryWatcherCallback)=>directoryWatcherCallback(forwardSlash(normalizedPath)));
590
+ if (directoryWatcherCallbacks) directoryWatcherCallbacks.forEach((directoryWatcherCallback)=>{
591
+ directoryWatcherCallback(forwardSlash(normalizedPath));
592
+ });
578
593
  recursiveDirectoryWatcherCallbacksMap.forEach((recursiveDirectoryWatcherCallbacks, watchedDirectory)=>{
579
- if (watchedDirectory === directory || directory.startsWith(watchedDirectory) && '/' === forwardSlash(directory)[watchedDirectory.length]) recursiveDirectoryWatcherCallbacks.forEach((recursiveDirectoryWatcherCallback)=>recursiveDirectoryWatcherCallback(forwardSlash(normalizedPath)));
594
+ if (watchedDirectory === directory || directory.startsWith(watchedDirectory) && '/' === forwardSlash(directory)[watchedDirectory.length]) recursiveDirectoryWatcherCallbacks.forEach((recursiveDirectoryWatcherCallback)=>{
595
+ recursiveDirectoryWatcherCallback(forwardSlash(normalizedPath));
596
+ });
580
597
  });
581
598
  }
582
599
  function normalizeAndResolvePath(path) {
@@ -722,7 +739,7 @@ function didConfigFileChanged({ changedFiles = [], deletedFiles = [] }) {
722
739
  return [
723
740
  ...changedFiles,
724
741
  ...deletedFiles
725
- ].map((file)=>external_path_namespaceObject.normalize(file)).includes(external_path_namespaceObject.normalize(worker_config_config.configFile));
742
+ ].map((file)=>external_node_path_namespaceObject.normalize(file)).includes(external_node_path_namespaceObject.normalize(worker_config_config.configFile));
726
743
  }
727
744
  function didDependenciesProbablyChanged(dependencies, { changedFiles = [], deletedFiles = [] }) {
728
745
  const didSomeDependencyHasBeenAdded = changedFiles.some((changeFile)=>!dependencies.files.includes(changeFile));
@@ -761,7 +778,7 @@ function getTsBuildInfoEmitPath(compilerOptions) {
761
778
  else {
762
779
  if (!configFile) return;
763
780
  const configFileExtensionLess = removeJsonExtension(configFile);
764
- buildInfoExtensionLess = compilerOptions.outDir ? compilerOptions.rootDir ? external_path_namespaceObject.resolve(compilerOptions.outDir, external_path_namespaceObject.relative(compilerOptions.rootDir, configFileExtensionLess)) : external_path_namespaceObject.resolve(compilerOptions.outDir, external_path_namespaceObject.basename(configFileExtensionLess)) : configFileExtensionLess;
781
+ buildInfoExtensionLess = compilerOptions.outDir ? compilerOptions.rootDir ? external_node_path_namespaceObject.resolve(compilerOptions.outDir, external_node_path_namespaceObject.relative(compilerOptions.rootDir, configFileExtensionLess)) : external_node_path_namespaceObject.resolve(compilerOptions.outDir, external_node_path_namespaceObject.basename(configFileExtensionLess)) : configFileExtensionLess;
765
782
  }
766
783
  return buildInfoExtensionLess + '.tsbuildinfo';
767
784
  }
@@ -786,15 +803,15 @@ function getArtifactsWorker(parsedConfig, configFileContext, processedConfigFile
786
803
  const files = new Set();
787
804
  const dirs = new Set();
788
805
  if (parsedConfig.fileNames.length > 0) {
789
- if (parsedConfig.options.outFile) files.add(external_path_namespaceObject.resolve(configFileContext, parsedConfig.options.outFile));
806
+ if (parsedConfig.options.outFile) files.add(external_node_path_namespaceObject.resolve(configFileContext, parsedConfig.options.outFile));
790
807
  const tsBuildInfoPath = getTsBuildInfoEmitPath(parsedConfig.options);
791
- if (tsBuildInfoPath) files.add(external_path_namespaceObject.resolve(configFileContext, tsBuildInfoPath));
792
- if (parsedConfig.options.outDir) dirs.add(external_path_namespaceObject.resolve(configFileContext, parsedConfig.options.outDir));
808
+ if (tsBuildInfoPath) files.add(external_node_path_namespaceObject.resolve(configFileContext, tsBuildInfoPath));
809
+ if (parsedConfig.options.outDir) dirs.add(external_node_path_namespaceObject.resolve(configFileContext, parsedConfig.options.outDir));
793
810
  }
794
811
  for (const projectReference of parsedConfig.projectReferences || []){
795
812
  const configFile = typescript.resolveProjectReferencePath(projectReference);
796
813
  if (processedConfigFiles.includes(configFile)) continue;
797
- const parsedConfig = parseConfig(configFile, external_path_namespaceObject.dirname(configFile));
814
+ const parsedConfig = parseConfig(configFile, external_node_path_namespaceObject.dirname(configFile));
798
815
  const childArtifacts = getArtifactsWorker(parsedConfig, configFileContext, [
799
816
  ...processedConfigFiles,
800
817
  configFile
@@ -812,8 +829,8 @@ function getArtifactsWorker(parsedConfig, configFileContext, processedConfigFile
812
829
  typescript.Extension.TsBuildInfo
813
830
  ];
814
831
  return {
815
- files: Array.from(files).map((file)=>external_path_namespaceObject.normalize(file)),
816
- dirs: Array.from(dirs).map((dir)=>external_path_namespaceObject.normalize(dir)),
832
+ files: Array.from(files).map((file)=>external_node_path_namespaceObject.normalize(file)),
833
+ dirs: Array.from(dirs).map((dir)=>external_node_path_namespaceObject.normalize(dir)),
817
834
  excluded: [],
818
835
  extensions
819
836
  };
@@ -834,10 +851,10 @@ function getDependenciesWorker(parsedConfig, configFileContext, processedConfigF
834
851
  const configFilePath = parsedConfig.options.configFilePath;
835
852
  if ('string' == typeof configFilePath) files.add(configFilePath);
836
853
  const dirs = new Set(Object.keys(parsedConfig.wildcardDirectories || {}));
837
- const excluded = new Set((parsedConfig.raw?.exclude || []).map((filePath)=>external_path_namespaceObject.resolve(configFileContext, filePath)));
854
+ const excluded = new Set((parsedConfig.raw?.exclude || []).map((filePath)=>external_node_path_namespaceObject.resolve(configFileContext, filePath)));
838
855
  for (const projectReference of parsedConfig.projectReferences || []){
839
856
  const childConfigFilePath = typescript.resolveProjectReferencePath(projectReference);
840
- const childConfigContext = external_path_namespaceObject.dirname(childConfigFilePath);
857
+ const childConfigContext = external_node_path_namespaceObject.dirname(childConfigFilePath);
841
858
  if (processedConfigFiles.includes(childConfigFilePath)) continue;
842
859
  const childParsedConfig = parseConfig(childConfigFilePath, childConfigContext);
843
860
  const childDependencies = getDependenciesWorker(childParsedConfig, childConfigContext, [
@@ -859,9 +876,9 @@ function getDependenciesWorker(parsedConfig, configFileContext, processedConfigF
859
876
  typescript.Extension.TsBuildInfo
860
877
  ];
861
878
  return {
862
- files: Array.from(files).map((file)=>external_path_namespaceObject.normalize(file)),
863
- dirs: Array.from(dirs).map((dir)=>external_path_namespaceObject.normalize(dir)),
864
- excluded: Array.from(excluded).map((aPath)=>external_path_namespaceObject.normalize(aPath)),
879
+ files: Array.from(files).map((file)=>external_node_path_namespaceObject.normalize(file)),
880
+ dirs: Array.from(dirs).map((dir)=>external_node_path_namespaceObject.normalize(dir)),
881
+ excluded: Array.from(excluded).map((aPath)=>external_node_path_namespaceObject.normalize(aPath)),
865
882
  extensions: extensions
866
883
  };
867
884
  }
@@ -993,14 +1010,23 @@ function createWatchSolutionBuilderHost(parsedConfig, createProgram, reportDiagn
993
1010
  }
994
1011
  let solutionBuilderHost;
995
1012
  let solutionBuilder;
1013
+ let hostDiagnostics = [];
996
1014
  function useSolutionBuilder() {
997
1015
  if (!solutionBuilderHost) {
998
1016
  const parsedConfig = getParsedConfig();
999
1017
  solutionBuilderHost = createWatchSolutionBuilderHost(parsedConfig, (rootNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences)=>{
1000
1018
  if (compilerOptions) startTracingIfNeeded(compilerOptions);
1001
1019
  return typescript.createSemanticDiagnosticsBuilderProgram(rootNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences);
1002
- }, void 0, void 0, void 0, void 0, (builderProgram)=>{
1003
- updateDiagnostics(getConfigFilePathFromBuilderProgram(builderProgram), getDiagnosticsOfProgram(builderProgram));
1020
+ }, (diagnostic)=>{
1021
+ hostDiagnostics.push(diagnostic);
1022
+ updateDiagnostics(worker_config_config.configFile, hostDiagnostics);
1023
+ }, void 0, void 0, void 0, (builderProgram)=>{
1024
+ const programConfigFile = getConfigFilePathFromBuilderProgram(builderProgram);
1025
+ const programDiagnostics = getDiagnosticsOfProgram(builderProgram);
1026
+ updateDiagnostics(programConfigFile, programConfigFile === worker_config_config.configFile ? [
1027
+ ...programDiagnostics,
1028
+ ...hostDiagnostics
1029
+ ] : programDiagnostics);
1004
1030
  emitTsBuildInfoIfNeeded(builderProgram);
1005
1031
  stopTracingIfNeeded(builderProgram);
1006
1032
  });
@@ -1017,6 +1043,7 @@ function useSolutionBuilder() {
1017
1043
  function invalidateSolutionBuilder(withHost = false) {
1018
1044
  if (withHost) solutionBuilderHost = void 0;
1019
1045
  solutionBuilder = void 0;
1046
+ hostDiagnostics = [];
1020
1047
  }
1021
1048
  let watchCompilerHost;
1022
1049
  let watchProgram;
package/lib/index.js CHANGED
@@ -35,8 +35,8 @@ __webpack_require__.r(__webpack_exports__);
35
35
  __webpack_require__.d(__webpack_exports__, {
36
36
  TsCheckerRspackPlugin: ()=>TsCheckerRspackPlugin
37
37
  });
38
- const external_path_namespaceObject = require("path");
39
- var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
38
+ const external_node_path_namespaceObject = require("node:path");
39
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
40
40
  function getInfrastructureLogger(compiler) {
41
41
  const logger = compiler.getInfrastructureLogger('TsCheckerRspackPlugin');
42
42
  return {
@@ -47,7 +47,6 @@ function getInfrastructureLogger(compiler) {
47
47
  info: logger.info.bind(logger)
48
48
  };
49
49
  }
50
- const external_node_path_namespaceObject = require("node:path");
51
50
  const addTrailingSep = (dir)=>dir.endsWith(external_node_path_namespaceObject.sep) ? dir : dir + external_node_path_namespaceObject.sep;
52
51
  const isStrictSubdir = (parent, child)=>{
53
52
  const parentDir = addTrailingSep(parent);
@@ -134,10 +133,10 @@ function aggregateFilesChanges(changes) {
134
133
  };
135
134
  }
136
135
  function isInsideAnotherPath(parent, directory) {
137
- const relativePart = (0, external_path_namespaceObject.relative)(parent, directory);
136
+ const relativePart = (0, external_node_path_namespaceObject.relative)(parent, directory);
138
137
  if (relativePart.startsWith('..')) return false;
139
138
  if (0 === relativePart.length) return false;
140
- if ((0, external_path_namespaceObject.isAbsolute)(relativePart)) return false;
139
+ if ((0, external_node_path_namespaceObject.isAbsolute)(relativePart)) return false;
141
140
  return true;
142
141
  }
143
142
  function _define_property(obj, key, value) {
@@ -250,7 +249,7 @@ class InclusiveNodeWatchFileSystem {
250
249
  });
251
250
  dirWatcher.on('add', (file, stats)=>{
252
251
  if (this.paused) return;
253
- const extension = (0, external_path_namespaceObject.extname)(file);
252
+ const extension = (0, external_node_path_namespaceObject.extname)(file);
254
253
  const supportedExtensions = this.pluginState.lastDependencies?.extensions || [];
255
254
  if (!supportedExtensions.includes(extension)) return void debug('Detected new file add but extension is not supported', file);
256
255
  debug('Detected new file add', file);
@@ -264,7 +263,7 @@ class InclusiveNodeWatchFileSystem {
264
263
  });
265
264
  dirWatcher.on('unlink', (file)=>{
266
265
  if (this.paused) return;
267
- const extension = (0, external_path_namespaceObject.extname)(file);
266
+ const extension = (0, external_node_path_namespaceObject.extname)(file);
268
267
  const supportedExtensions = this.pluginState.lastDependencies?.extensions || [];
269
268
  if (!supportedExtensions.includes(extension)) return void debug('Detected new file remove but extension is not supported', file);
270
269
  if (this.deletedFiles.has(file)) return void debug('Skipping duplicated unlink event.');
@@ -306,7 +305,7 @@ function tapAfterEnvironmentToPatchWatching(compiler, state) {
306
305
  compiler.hooks.afterEnvironment.tap('TsCheckerRspackPlugin', ()=>{
307
306
  const watchFileSystem = compiler.watchFileSystem;
308
307
  if (watchFileSystem) {
309
- debug("Overwriting webpack's watch file system.");
308
+ debug("Overwriting Rspack's watch file system.");
310
309
  compiler.watchFileSystem = new InclusiveNodeWatchFileSystem(watchFileSystem, compiler, state);
311
310
  } else debug('No watch file system found - plugin may not work correctly.');
312
311
  });
@@ -356,7 +355,7 @@ function getPluginHooks(compiler) {
356
355
  }
357
356
  return hooks;
358
357
  }
359
- const external_process_namespaceObject = require("process");
358
+ const external_node_process_namespaceObject = require("node:process");
360
359
  function createControlledPromise() {
361
360
  let resolve = ()=>void 0;
362
361
  let reject = ()=>void 0;
@@ -431,12 +430,12 @@ function wrapRpc(childProcess) {
431
430
  function uuid() {
432
431
  return new Array(4).fill(0).map(()=>Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join('-');
433
432
  }
434
- const external_child_process_namespaceObject = require("child_process");
433
+ const external_node_child_process_namespaceObject = require("node:child_process");
435
434
  const WORKER_DATA_ENV_KEY = 'WORKER_DATA';
436
435
  function createRpcWorker(modulePath, data, memoryLimit) {
437
436
  const options = {
438
437
  env: {
439
- ...external_process_namespaceObject.env,
438
+ ...external_node_process_namespaceObject.env,
440
439
  [WORKER_DATA_ENV_KEY]: JSON.stringify(data || {})
441
440
  },
442
441
  stdio: [
@@ -460,7 +459,7 @@ function createRpcWorker(modulePath, data, memoryLimit) {
460
459
  remoteMethod = void 0;
461
460
  }
462
461
  if (!childProcess?.connected) {
463
- childProcess = external_child_process_namespaceObject.fork(modulePath, options);
462
+ childProcess = external_node_child_process_namespaceObject.fork(modulePath, options);
464
463
  remoteMethod = wrapRpc(childProcess);
465
464
  }
466
465
  },
@@ -502,8 +501,8 @@ function tapErrorToLogMessage(compiler, config) {
502
501
  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
502
  });
504
503
  }
505
- const external_os_namespaceObject = require("os");
506
- var external_os_default = /*#__PURE__*/ __webpack_require__.n(external_os_namespaceObject);
504
+ const external_node_os_namespaceObject = require("node:os");
505
+ var external_node_os_default = /*#__PURE__*/ __webpack_require__.n(external_node_os_namespaceObject);
507
506
  function createPool(size) {
508
507
  let pendingPromises = [];
509
508
  const pool = {
@@ -532,8 +531,8 @@ function createPool(size) {
532
531
  };
533
532
  return pool;
534
533
  }
535
- const issuesPool = createPool(Math.max(1, external_os_namespaceObject.cpus().length));
536
- const dependenciesPool = createPool(Math.max(1, external_os_namespaceObject.cpus().length));
534
+ const issuesPool = createPool(Math.max(1, external_node_os_namespaceObject.cpus().length));
535
+ const dependenciesPool = createPool(Math.max(1, external_node_os_namespaceObject.cpus().length));
537
536
  function interceptDoneToGetDevServerTap(compiler, config, state) {
538
537
  const { debug } = getInfrastructureLogger(compiler);
539
538
  compiler.hooks.done.intercept({
@@ -550,17 +549,17 @@ function interceptDoneToGetDevServerTap(compiler, config, state) {
550
549
  });
551
550
  }
552
551
  function forwardSlash(input) {
553
- return external_path_default().normalize(input).replace(/\\+/g, '/');
552
+ return external_node_path_default().normalize(input).replace(/\\+/g, '/');
554
553
  }
555
554
  function relativeToContext(file, context) {
556
- let fileInContext = forwardSlash(external_path_default().relative(context, file));
555
+ let fileInContext = forwardSlash(external_node_path_default().relative(context, file));
557
556
  if (!fileInContext.startsWith('../')) fileInContext = './' + fileInContext;
558
557
  return fileInContext;
559
558
  }
560
559
  function formatIssueLocation(location) {
561
560
  return `${location.start.line}:${location.start.column}`;
562
561
  }
563
- function issue_webpack_error_define_property(obj, key, value) {
562
+ function issue_rspack_error_define_property(obj, key, value) {
564
563
  if (key in obj) Object.defineProperty(obj, key, {
565
564
  value: value,
566
565
  enumerable: true,
@@ -570,11 +569,11 @@ function issue_webpack_error_define_property(obj, key, value) {
570
569
  else obj[key] = value;
571
570
  return obj;
572
571
  }
573
- class IssueWebpackError extends Error {
572
+ class IssueRspackError extends Error {
574
573
  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;
574
+ super(message), issue_rspack_error_define_property(this, "issue", void 0), issue_rspack_error_define_property(this, "hideStack", void 0), issue_rspack_error_define_property(this, "file", void 0), this.issue = issue, this.hideStack = true;
576
575
  if (issue.file) {
577
- this.file = 'absolute' === pathType ? forwardSlash(external_path_default().resolve(issue.file)) : relativeToContext(issue.file, process.cwd());
576
+ this.file = 'absolute' === pathType ? forwardSlash(external_node_path_default().resolve(issue.file)) : relativeToContext(issue.file, process.cwd());
578
577
  if (issue.location) this.file += `:${formatIssueLocation(issue.location)}`;
579
578
  }
580
579
  Error.captureStackTrace(this, this.constructor);
@@ -597,7 +596,7 @@ function tapAfterCompileToGetIssues(compiler, config, state) {
597
596
  issues = issues.filter(config.issue.predicate);
598
597
  issues = hooks.issues.call(issues, compilation);
599
598
  issues.forEach((issue)=>{
600
- const error = new IssueWebpackError(config.formatter.format(issue), config.formatter.pathType, issue);
599
+ const error = new IssueRspackError(config.formatter.format(issue), config.formatter.pathType, issue);
601
600
  if ('warning' === issue.severity) compilation.warnings.push(error);
602
601
  else compilation.errors.push(error);
603
602
  });
@@ -618,22 +617,22 @@ function statsFormatter(issues, stats) {
618
617
  timeFormatted ? ` in ${timeFormatted} ms` : ''
619
618
  ].join('');
620
619
  }
621
- function createWebpackFormatter(formatter, pathType) {
620
+ function createRspackFormatter(formatter, pathType) {
622
621
  return function(issue) {
623
622
  const color = 'warning' === issue.severity ? external_picocolors_default().yellow : external_picocolors_default().red;
624
623
  const severity = issue.severity.toUpperCase();
625
624
  if (!issue.file) return [
626
625
  `${external_picocolors_default().bold(color(severity))} in ` + formatter(issue),
627
626
  ''
628
- ].join(external_os_default().EOL);
627
+ ].join(external_node_os_default().EOL);
629
628
  {
630
- let location = external_picocolors_default().bold('absolute' === pathType ? forwardSlash(external_path_default().resolve(issue.file)) : relativeToContext(issue.file, process.cwd()));
629
+ let location = external_picocolors_default().bold('absolute' === pathType ? forwardSlash(external_node_path_default().resolve(issue.file)) : relativeToContext(issue.file, process.cwd()));
631
630
  if (issue.location) location += `:${external_picocolors_default().bold(external_picocolors_default().green(formatIssueLocation(issue.location)))}`;
632
631
  return [
633
632
  `${external_picocolors_default().bold(color(severity))} in ${location}`,
634
633
  formatter(issue),
635
634
  ''
636
- ].join(external_os_default().EOL);
635
+ ].join(external_node_os_default().EOL);
637
636
  }
638
637
  };
639
638
  }
@@ -667,12 +666,12 @@ function tapDoneToAsyncGetIssues(compiler, config, state) {
667
666
  debug(`Got ${issues?.length || 0} issues from getIssuesWorker.`);
668
667
  issues = issues.filter(config.issue.predicate);
669
668
  issues = hooks.issues.call(issues, stats.compilation);
670
- const formatter = createWebpackFormatter(config.formatter.format, config.formatter.pathType);
669
+ const formatter = createRspackFormatter(config.formatter.format, config.formatter.pathType);
671
670
  if (issues.length) config.logger.error(issues.map((issue)=>formatter(issue)).join('\n'));
672
671
  config.logger.log(statsFormatter(issues, stats));
673
672
  if (issues.length && state.DevServerDoneTap) {
674
673
  issues.forEach((issue)=>{
675
- const error = new IssueWebpackError(config.formatter.format(issue), config.formatter.pathType, issue);
674
+ const error = new IssueRspackError(config.formatter.format(issue), config.formatter.pathType, issue);
676
675
  if ('warning' === issue.severity) stats.compilation.warnings.push(error);
677
676
  else stats.compilation.errors.push(error);
678
677
  });
@@ -803,12 +802,12 @@ function createCodeFrameFormatter(options) {
803
802
  if (source && issue.location) frame = (0, code_frame_namespaceObject.codeFrameColumns)(source, issue.location, {
804
803
  highlightCode: true,
805
804
  ...options || {}
806
- }).split('\n').map((line)=>' ' + line).join(external_os_default().EOL);
805
+ }).split('\n').map((line)=>' ' + line).join(external_node_os_default().EOL);
807
806
  const lines = [
808
807
  basicFormatter(issue)
809
808
  ];
810
809
  if (frame) lines.push(frame);
811
- return lines.join(external_os_default().EOL);
810
+ return lines.join(external_node_os_default().EOL);
812
811
  };
813
812
  }
814
813
  function createFormatterConfig(options) {
@@ -835,7 +834,7 @@ function createIssuePredicateFromIssueMatch(context, match) {
835
834
  return (issue)=>{
836
835
  const matchesSeverity = !match.severity || match.severity === issue.severity;
837
836
  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));
837
+ const matchesFile = !issue.file || !!issue.file && (!match.file || (0, external_minimatch_namespaceObject.minimatch)(forwardSlash(external_node_path_default().relative(context, issue.file)), match.file));
839
838
  return matchesSeverity && matchesCode && matchesFile;
840
839
  };
841
840
  }
@@ -862,7 +861,7 @@ function createIssueConfig(compiler, options) {
862
861
  }
863
862
  function createTypeScriptWorkerConfig(compiler, options) {
864
863
  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));
864
+ configFile = external_node_path_default().normalize(external_node_path_default().isAbsolute(configFile) ? configFile : external_node_path_default().resolve(compiler.options.context || process.cwd(), configFile));
866
865
  const optionsAsObject = 'object' == typeof options ? options : {};
867
866
  const typescriptPath = optionsAsObject.typescriptPath || require.resolve("typescript");
868
867
  return {
@@ -874,7 +873,7 @@ function createTypeScriptWorkerConfig(compiler, options) {
874
873
  ...optionsAsObject,
875
874
  configFile: configFile,
876
875
  configOverwrite: optionsAsObject.configOverwrite || {},
877
- context: optionsAsObject.context || external_path_default().dirname(configFile),
876
+ context: optionsAsObject.context || external_node_path_default().dirname(configFile),
878
877
  diagnosticOptions: {
879
878
  syntactic: false,
880
879
  semantic: true,
@@ -918,15 +917,15 @@ function assertTypeScriptSupport(config) {
918
917
  let typescriptVersion;
919
918
  try {
920
919
  typescriptVersion = require(config.typescriptPath).version;
921
- } catch (error) {}
920
+ } catch {}
922
921
  if (!typescriptVersion) throw new Error("When you use TsCheckerRspackPlugin with typescript reporter enabled, you must install `typescript` package.");
923
922
  if (!external_node_fs_default().existsSync(config.configFile)) throw new Error([
924
923
  `Cannot find the "${config.configFile}" file.`,
925
- "Please check webpack and TsCheckerRspackPlugin configuration.",
924
+ "Please check Rspack and TsCheckerRspackPlugin configuration.",
926
925
  "Possible errors:",
927
- ' - wrong `context` directory in webpack configuration (if `configFile` is not set or is a relative path in the fork plugin configuration)',
926
+ ' - wrong `context` directory in Rspack configuration (if `configFile` is not set or is a relative path in the fork plugin configuration)',
928
927
  " - wrong `typescript.configFile` path in the plugin configuration (should be a relative or absolute path)"
929
- ].join(external_os_default().EOL));
928
+ ].join(external_node_os_default().EOL));
930
929
  }
931
930
  function plugin_define_property(obj, key, value) {
932
931
  if (key in obj) Object.defineProperty(obj, key, {
@@ -938,7 +937,7 @@ function plugin_define_property(obj, key, value) {
938
937
  else obj[key] = value;
939
938
  return obj;
940
939
  }
941
- const pkgJson = JSON.parse((0, external_node_fs_namespaceObject.readFileSync)(external_path_namespaceObject.join(__dirname, '../package.json'), 'utf-8'));
940
+ const pkgJson = JSON.parse((0, external_node_fs_namespaceObject.readFileSync)(external_node_path_namespaceObject.join(__dirname, '../package.json'), 'utf-8'));
942
941
  class TsCheckerRspackPlugin {
943
942
  static getCompilerHooks(compiler) {
944
943
  return getPluginHooks(compiler);
@@ -947,8 +946,8 @@ class TsCheckerRspackPlugin {
947
946
  const config = createPluginConfig(compiler, this.options);
948
947
  const state = createPluginState();
949
948
  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);
949
+ const getIssuesWorker = createRpcWorker(external_node_path_namespaceObject.resolve(__dirname, './getIssuesWorker.js'), config.typescript, config.typescript.memoryLimit);
950
+ const getDependenciesWorker = createRpcWorker(external_node_path_namespaceObject.resolve(__dirname, './getDependenciesWorker.js'), config.typescript);
952
951
  tapAfterEnvironmentToPatchWatching(compiler, state);
953
952
  tapStartToRunWorkers(compiler, getIssuesWorker, getDependenciesWorker, config, state);
954
953
  tapAfterCompileToAddDependencies(compiler, config, state);
@@ -1,9 +1,9 @@
1
1
  import type { FormatterPathType } from '../formatter';
2
2
  import type { Issue } from './issue';
3
- declare class IssueWebpackError extends Error {
3
+ declare class IssueRspackError extends Error {
4
4
  readonly issue: Issue;
5
5
  readonly hideStack = true;
6
6
  file?: string;
7
7
  constructor(message: string, pathType: FormatterPathType, issue: Issue);
8
8
  }
9
- export { IssueWebpackError };
9
+ export { IssueRspackError };
@@ -1,4 +1,4 @@
1
- import type { ChildProcess } from 'child_process';
1
+ import type { ChildProcess } from 'node:child_process';
2
2
  import type { RpcMethod, RpcRemoteMethod } from './types';
3
3
  interface RpcWorkerBase {
4
4
  connect(): void;
@@ -1,3 +1,3 @@
1
- import type { ChildProcess } from 'child_process';
1
+ import type { ChildProcess } from 'node:child_process';
2
2
  import type { RpcRemoteMethod } from './types';
3
3
  export declare function wrapRpc<T extends (...args: any[]) => any>(childProcess: ChildProcess): RpcRemoteMethod<T>;
@@ -1,4 +1,4 @@
1
- import type { Dirent, Stats } from 'fs';
1
+ import type { Dirent, Stats } from 'node:fs';
2
2
  /**
3
3
  * Interface to abstract file system implementation details.
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { EventEmitter } from 'events';
1
+ import type { EventEmitter } from 'node:events';
2
2
  import type * as rspack from '@rspack/core';
3
3
  interface Watchpack extends EventEmitter {
4
4
  _onChange(item: string, mtime: number, file: string, type?: string): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-checker-rspack-plugin",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "Runs typescript type checker and linter on separate process.",
5
5
  "keywords": [
6
6
  "rspack",
@@ -26,7 +26,7 @@
26
26
  "dev": "rslib build -w",
27
27
  "lint": "echo lint",
28
28
  "test": "pnpm build && pnpm test:unit && pnpm test:e2e",
29
- "test:unit": "cross-env jest --config=test/unit/jest.config.js",
29
+ "test:unit": "rstest --config=test/unit/rstest.config.ts",
30
30
  "test:e2e": "cd test/e2e && pnpm test",
31
31
  "test:e2e:setup": "cd test/e2e && pnpm run setup",
32
32
  "precommit": "pnpm build && pnpm test:unit",
@@ -52,24 +52,18 @@
52
52
  }
53
53
  },
54
54
  "devDependencies": {
55
- "@jest/console": "^27.5.1",
56
55
  "@rslib/core": "^0.18.2",
57
56
  "@rspack/core": "^1.6.5",
57
+ "@rstest/core": "^0.7.5",
58
58
  "@types/babel__code-frame": "^7.0.6",
59
59
  "@types/is-glob": "^4.0.4",
60
- "@types/jest": "^27.5.2",
61
60
  "@types/mock-fs": "^4.13.4",
62
61
  "@types/node": "^16.18.126",
63
62
  "cross-env": "^10.1.0",
64
63
  "husky": "^9.1.7",
65
- "jest": "^27.5.1",
66
- "jest-circus": "^27.5.1",
67
- "jest-environment-node": "^27.5.1",
68
- "jest-runner": "^27.5.1",
69
64
  "mock-fs": "^5.5.0",
70
65
  "prettier": "^3.7.3",
71
66
  "strip-ansi": "^6.0.1",
72
- "ts-jest": "^27.1.5",
73
67
  "typescript": "^5.9.3"
74
68
  },
75
69
  "publishConfig": {
@@ -1,3 +0,0 @@
1
- import type { Formatter, FormatterPathType } from './formatter';
2
- declare function createWebpackFormatter(formatter: Formatter, pathType: FormatterPathType): Formatter;
3
- export { createWebpackFormatter };