ts-checker-rspack-plugin 1.2.2 → 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/lib/formatter/index.d.ts +1 -1
- package/lib/formatter/rspack-formatter.d.ts +3 -0
- package/lib/getDependenciesWorker.js +43 -38
- package/lib/getIssuesWorker.js +63 -48
- package/lib/index.js +40 -42
- package/lib/issue/{issue-webpack-error.d.ts → issue-rspack-error.d.ts} +2 -2
- package/lib/rpc/rpc-worker.d.ts +1 -1
- package/lib/rpc/wrap-rpc.d.ts +1 -1
- package/lib/typescript/worker/lib/file-system/file-system.d.ts +1 -1
- package/lib/watch/watch-file-system.d.ts +1 -1
- package/package.json +3 -9
- package/lib/formatter/webpack-formatter.d.ts +0 -3
package/lib/formatter/index.d.ts
CHANGED
|
@@ -72,18 +72,17 @@ function exposeRpc(fn) {
|
|
|
72
72
|
};
|
|
73
73
|
external_node_process_default().on('message', handleMessage);
|
|
74
74
|
}
|
|
75
|
-
require("child_process");
|
|
76
|
-
const external_process_namespaceObject = require("process");
|
|
75
|
+
require("node:child_process");
|
|
77
76
|
const WORKER_DATA_ENV_KEY = 'WORKER_DATA';
|
|
78
77
|
function getRpcWorkerData() {
|
|
79
|
-
return JSON.parse(
|
|
78
|
+
return JSON.parse(external_node_process_namespaceObject.env[WORKER_DATA_ENV_KEY] || '{}');
|
|
80
79
|
}
|
|
81
|
-
const
|
|
82
|
-
var
|
|
80
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
81
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
83
82
|
function forwardSlash(input) {
|
|
84
|
-
return
|
|
83
|
+
return external_node_path_default().normalize(input).replace(/\\+/g, '/');
|
|
85
84
|
}
|
|
86
|
-
require("os");
|
|
85
|
+
require("node:os");
|
|
87
86
|
const worker_config_config = getRpcWorkerData();
|
|
88
87
|
const typescript_typescript = require(worker_config_config.typescriptPath);
|
|
89
88
|
new Map();
|
|
@@ -112,7 +111,7 @@ const realFileSystem = {
|
|
|
112
111
|
return getRealPath(path);
|
|
113
112
|
},
|
|
114
113
|
normalizePath (path) {
|
|
115
|
-
return (0,
|
|
114
|
+
return (0, external_node_path_namespaceObject.normalize)(path);
|
|
116
115
|
},
|
|
117
116
|
writeFile (path, data) {
|
|
118
117
|
writeFile(getRealPath(path), data);
|
|
@@ -135,19 +134,19 @@ const realFileSystem = {
|
|
|
135
134
|
}
|
|
136
135
|
};
|
|
137
136
|
function exists(path) {
|
|
138
|
-
const normalizedPath = (0,
|
|
137
|
+
const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
|
|
139
138
|
if (!existsCache.has(normalizedPath)) existsCache.set(normalizedPath, external_node_fs_default().existsSync(normalizedPath));
|
|
140
139
|
return !!existsCache.get(normalizedPath);
|
|
141
140
|
}
|
|
142
141
|
function readStats(path) {
|
|
143
|
-
const normalizedPath = (0,
|
|
142
|
+
const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
|
|
144
143
|
if (!readStatsCache.has(normalizedPath)) {
|
|
145
144
|
if (exists(normalizedPath)) readStatsCache.set(normalizedPath, external_node_fs_default().statSync(normalizedPath));
|
|
146
145
|
}
|
|
147
146
|
return readStatsCache.get(normalizedPath);
|
|
148
147
|
}
|
|
149
148
|
function readFile(path, encoding) {
|
|
150
|
-
const normalizedPath = (0,
|
|
149
|
+
const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
|
|
151
150
|
if (!readFileCache.has(normalizedPath)) {
|
|
152
151
|
const stats = readStats(normalizedPath);
|
|
153
152
|
if (stats && stats.isFile()) readFileCache.set(normalizedPath, external_node_fs_default().readFileSync(normalizedPath, {
|
|
@@ -158,7 +157,7 @@ function readFile(path, encoding) {
|
|
|
158
157
|
return readFileCache.get(normalizedPath);
|
|
159
158
|
}
|
|
160
159
|
function readDir(path) {
|
|
161
|
-
const normalizedPath = (0,
|
|
160
|
+
const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
|
|
162
161
|
if (!readDirCache.has(normalizedPath)) {
|
|
163
162
|
const stats = readStats(normalizedPath);
|
|
164
163
|
if (stats && stats.isDirectory()) readDirCache.set(normalizedPath, external_node_fs_default().readdirSync(normalizedPath, {
|
|
@@ -169,53 +168,53 @@ function readDir(path) {
|
|
|
169
168
|
return readDirCache.get(normalizedPath) || [];
|
|
170
169
|
}
|
|
171
170
|
function getRealPath(path) {
|
|
172
|
-
const normalizedPath = (0,
|
|
171
|
+
const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
|
|
173
172
|
if (!realPathCache.has(normalizedPath)) {
|
|
174
173
|
let base = normalizedPath;
|
|
175
174
|
let nested = '';
|
|
176
|
-
while(base !== (0,
|
|
175
|
+
while(base !== (0, external_node_path_namespaceObject.dirname)(base)){
|
|
177
176
|
if (exists(base)) {
|
|
178
|
-
realPathCache.set(normalizedPath, (0,
|
|
177
|
+
realPathCache.set(normalizedPath, (0, external_node_path_namespaceObject.normalize)((0, external_node_path_namespaceObject.join)(external_node_fs_default().realpathSync(base), nested)));
|
|
179
178
|
break;
|
|
180
179
|
}
|
|
181
|
-
nested = (0,
|
|
182
|
-
base = (0,
|
|
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);
|
|
183
182
|
}
|
|
184
183
|
}
|
|
185
184
|
return realPathCache.get(normalizedPath) || normalizedPath;
|
|
186
185
|
}
|
|
187
186
|
function createDir(path) {
|
|
188
|
-
const normalizedPath = (0,
|
|
187
|
+
const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
|
|
189
188
|
external_node_fs_default().mkdirSync(normalizedPath, {
|
|
190
189
|
recursive: true
|
|
191
190
|
});
|
|
192
191
|
existsCache.set(normalizedPath, true);
|
|
193
|
-
if (readDirCache.has((0,
|
|
192
|
+
if (readDirCache.has((0, external_node_path_namespaceObject.dirname)(normalizedPath))) readDirCache.delete((0, external_node_path_namespaceObject.dirname)(normalizedPath));
|
|
194
193
|
if (readStatsCache.has(normalizedPath)) readStatsCache.delete(normalizedPath);
|
|
195
194
|
}
|
|
196
195
|
function writeFile(path, data) {
|
|
197
|
-
const normalizedPath = (0,
|
|
198
|
-
if (!exists((0,
|
|
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));
|
|
199
198
|
external_node_fs_default().writeFileSync(normalizedPath, data);
|
|
200
199
|
existsCache.set(normalizedPath, true);
|
|
201
|
-
if (readDirCache.has((0,
|
|
200
|
+
if (readDirCache.has((0, external_node_path_namespaceObject.dirname)(normalizedPath))) readDirCache.delete((0, external_node_path_namespaceObject.dirname)(normalizedPath));
|
|
202
201
|
if (readStatsCache.has(normalizedPath)) readStatsCache.delete(normalizedPath);
|
|
203
202
|
if (readFileCache.has(normalizedPath)) readFileCache.delete(normalizedPath);
|
|
204
203
|
}
|
|
205
204
|
function deleteFile(path) {
|
|
206
205
|
if (exists(path)) {
|
|
207
|
-
const normalizedPath = (0,
|
|
206
|
+
const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
|
|
208
207
|
external_node_fs_default().unlinkSync(normalizedPath);
|
|
209
208
|
existsCache.set(normalizedPath, false);
|
|
210
|
-
if (readDirCache.has((0,
|
|
209
|
+
if (readDirCache.has((0, external_node_path_namespaceObject.dirname)(normalizedPath))) readDirCache.delete((0, external_node_path_namespaceObject.dirname)(normalizedPath));
|
|
211
210
|
if (readStatsCache.has(normalizedPath)) readStatsCache.delete(normalizedPath);
|
|
212
211
|
if (readFileCache.has(normalizedPath)) readFileCache.delete(normalizedPath);
|
|
213
212
|
}
|
|
214
213
|
}
|
|
215
214
|
function updateTimes(path, atime, mtime) {
|
|
216
215
|
if (exists(path)) {
|
|
217
|
-
const normalizedPath = (0,
|
|
218
|
-
external_node_fs_default().utimesSync((0,
|
|
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);
|
|
219
218
|
if (readStatsCache.has(normalizedPath)) readStatsCache.delete(normalizedPath);
|
|
220
219
|
}
|
|
221
220
|
}
|
|
@@ -274,7 +273,7 @@ function mem_file_system_createDir(path) {
|
|
|
274
273
|
});
|
|
275
274
|
}
|
|
276
275
|
function mem_file_system_writeFile(path, data) {
|
|
277
|
-
if (!mem_file_system_exists((0,
|
|
276
|
+
if (!mem_file_system_exists((0, external_node_path_namespaceObject.dirname)(path))) mem_file_system_createDir((0, external_node_path_namespaceObject.dirname)(path));
|
|
278
277
|
external_memfs_namespaceObject.fs.writeFileSync(realFileSystem.normalizePath(path), data);
|
|
279
278
|
}
|
|
280
279
|
function mem_file_system_deleteFile(path) {
|
|
@@ -378,7 +377,7 @@ const system = {
|
|
|
378
377
|
},
|
|
379
378
|
getDirectories (path) {
|
|
380
379
|
const dirents = getReadFileSystem(path).readDir(path);
|
|
381
|
-
return dirents.filter((dirent)=>dirent.isDirectory() || dirent.isSymbolicLink() && system.directoryExists((0,
|
|
380
|
+
return dirents.filter((dirent)=>dirent.isDirectory() || dirent.isSymbolicLink() && system.directoryExists((0, external_node_path_namespaceObject.join)(path, dirent.name))).map((dirent)=>dirent.name);
|
|
382
381
|
},
|
|
383
382
|
getModifiedTime (path) {
|
|
384
383
|
if (void 0 === path) return;
|
|
@@ -464,16 +463,22 @@ function invokeFileWatchers(path, event) {
|
|
|
464
463
|
const normalizedPath = normalizeAndResolvePath(path);
|
|
465
464
|
if (normalizedPath.endsWith('.js')) invokeFileWatchers(normalizedPath.slice(0, -3) + '.d.ts', event);
|
|
466
465
|
const fileWatcherCallbacks = fileWatcherCallbacksMap.get(normalizedPath);
|
|
467
|
-
if (fileWatcherCallbacks) fileWatcherCallbacks.forEach((fileWatcherCallback)=>
|
|
466
|
+
if (fileWatcherCallbacks) fileWatcherCallbacks.forEach((fileWatcherCallback)=>{
|
|
467
|
+
fileWatcherCallback(forwardSlash(normalizedPath), event);
|
|
468
|
+
});
|
|
468
469
|
}
|
|
469
470
|
function invokeDirectoryWatchers(path) {
|
|
470
471
|
const normalizedPath = normalizeAndResolvePath(path);
|
|
471
|
-
const directory = (0,
|
|
472
|
+
const directory = (0, external_node_path_namespaceObject.dirname)(normalizedPath);
|
|
472
473
|
if (ignoredPaths.some((ignoredPath)=>forwardSlash(normalizedPath).includes(ignoredPath))) return;
|
|
473
474
|
const directoryWatcherCallbacks = directoryWatcherCallbacksMap.get(directory);
|
|
474
|
-
if (directoryWatcherCallbacks) directoryWatcherCallbacks.forEach((directoryWatcherCallback)=>
|
|
475
|
+
if (directoryWatcherCallbacks) directoryWatcherCallbacks.forEach((directoryWatcherCallback)=>{
|
|
476
|
+
directoryWatcherCallback(forwardSlash(normalizedPath));
|
|
477
|
+
});
|
|
475
478
|
recursiveDirectoryWatcherCallbacksMap.forEach((recursiveDirectoryWatcherCallbacks, watchedDirectory)=>{
|
|
476
|
-
if (watchedDirectory === directory || directory.startsWith(watchedDirectory) && '/' === forwardSlash(directory)[watchedDirectory.length]) recursiveDirectoryWatcherCallbacks.forEach((recursiveDirectoryWatcherCallback)=>
|
|
479
|
+
if (watchedDirectory === directory || directory.startsWith(watchedDirectory) && '/' === forwardSlash(directory)[watchedDirectory.length]) recursiveDirectoryWatcherCallbacks.forEach((recursiveDirectoryWatcherCallback)=>{
|
|
480
|
+
recursiveDirectoryWatcherCallback(forwardSlash(normalizedPath));
|
|
481
|
+
});
|
|
477
482
|
});
|
|
478
483
|
}
|
|
479
484
|
function normalizeAndResolvePath(path) {
|
|
@@ -595,7 +600,7 @@ function didConfigFileChanged({ changedFiles = [], deletedFiles = [] }) {
|
|
|
595
600
|
return [
|
|
596
601
|
...changedFiles,
|
|
597
602
|
...deletedFiles
|
|
598
|
-
].map((file)=>
|
|
603
|
+
].map((file)=>external_node_path_namespaceObject.normalize(file)).includes(external_node_path_namespaceObject.normalize(worker_config_config.configFile));
|
|
599
604
|
}
|
|
600
605
|
function didDependenciesProbablyChanged(dependencies, { changedFiles = [], deletedFiles = [] }) {
|
|
601
606
|
const didSomeDependencyHasBeenAdded = changedFiles.some((changeFile)=>!dependencies.files.includes(changeFile));
|
|
@@ -618,10 +623,10 @@ function getDependenciesWorker(parsedConfig, configFileContext, processedConfigF
|
|
|
618
623
|
const configFilePath = parsedConfig.options.configFilePath;
|
|
619
624
|
if ('string' == typeof configFilePath) files.add(configFilePath);
|
|
620
625
|
const dirs = new Set(Object.keys(parsedConfig.wildcardDirectories || {}));
|
|
621
|
-
const excluded = new Set((parsedConfig.raw?.exclude || []).map((filePath)=>
|
|
626
|
+
const excluded = new Set((parsedConfig.raw?.exclude || []).map((filePath)=>external_node_path_namespaceObject.resolve(configFileContext, filePath)));
|
|
622
627
|
for (const projectReference of parsedConfig.projectReferences || []){
|
|
623
628
|
const childConfigFilePath = typescript_typescript.resolveProjectReferencePath(projectReference);
|
|
624
|
-
const childConfigContext =
|
|
629
|
+
const childConfigContext = external_node_path_namespaceObject.dirname(childConfigFilePath);
|
|
625
630
|
if (processedConfigFiles.includes(childConfigFilePath)) continue;
|
|
626
631
|
const childParsedConfig = parseConfig(childConfigFilePath, childConfigContext);
|
|
627
632
|
const childDependencies = getDependenciesWorker(childParsedConfig, childConfigContext, [
|
|
@@ -643,9 +648,9 @@ function getDependenciesWorker(parsedConfig, configFileContext, processedConfigF
|
|
|
643
648
|
typescript_typescript.Extension.TsBuildInfo
|
|
644
649
|
];
|
|
645
650
|
return {
|
|
646
|
-
files: Array.from(files).map((file)=>
|
|
647
|
-
dirs: Array.from(dirs).map((dir)=>
|
|
648
|
-
excluded: Array.from(excluded).map((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)),
|
|
649
654
|
extensions: extensions
|
|
650
655
|
};
|
|
651
656
|
}
|
package/lib/getIssuesWorker.js
CHANGED
|
@@ -72,18 +72,17 @@ function exposeRpc(fn) {
|
|
|
72
72
|
};
|
|
73
73
|
external_node_process_default().on('message', handleMessage);
|
|
74
74
|
}
|
|
75
|
-
require("child_process");
|
|
76
|
-
const external_process_namespaceObject = require("process");
|
|
75
|
+
require("node:child_process");
|
|
77
76
|
const WORKER_DATA_ENV_KEY = 'WORKER_DATA';
|
|
78
77
|
function getRpcWorkerData() {
|
|
79
|
-
return JSON.parse(
|
|
78
|
+
return JSON.parse(external_node_process_namespaceObject.env[WORKER_DATA_ENV_KEY] || '{}');
|
|
80
79
|
}
|
|
81
|
-
const
|
|
82
|
-
var
|
|
80
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
81
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
83
82
|
function forwardSlash(input) {
|
|
84
|
-
return
|
|
83
|
+
return external_node_path_default().normalize(input).replace(/\\+/g, '/');
|
|
85
84
|
}
|
|
86
|
-
const
|
|
85
|
+
const external_node_os_namespaceObject = require("node:os");
|
|
87
86
|
function compareIssuePositions(positionA, positionB) {
|
|
88
87
|
if (positionA === positionB) return 0;
|
|
89
88
|
if (!positionA) return -1;
|
|
@@ -194,7 +193,7 @@ function createIssueFromDiagnostic(diagnostic, defaultSeverity) {
|
|
|
194
193
|
return {
|
|
195
194
|
code: 'TS' + String(diagnostic.code),
|
|
196
195
|
severity: getSeverity(),
|
|
197
|
-
message: typescript.flattenDiagnosticMessageText(diagnostic.messageText,
|
|
196
|
+
message: typescript.flattenDiagnosticMessageText(diagnostic.messageText, external_node_os_namespaceObject.EOL),
|
|
198
197
|
file,
|
|
199
198
|
location
|
|
200
199
|
};
|
|
@@ -227,7 +226,7 @@ const realFileSystem = {
|
|
|
227
226
|
return getRealPath(path);
|
|
228
227
|
},
|
|
229
228
|
normalizePath (path) {
|
|
230
|
-
return (0,
|
|
229
|
+
return (0, external_node_path_namespaceObject.normalize)(path);
|
|
231
230
|
},
|
|
232
231
|
writeFile (path, data) {
|
|
233
232
|
writeFile(getRealPath(path), data);
|
|
@@ -250,19 +249,19 @@ const realFileSystem = {
|
|
|
250
249
|
}
|
|
251
250
|
};
|
|
252
251
|
function exists(path) {
|
|
253
|
-
const normalizedPath = (0,
|
|
252
|
+
const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
|
|
254
253
|
if (!existsCache.has(normalizedPath)) existsCache.set(normalizedPath, external_node_fs_default().existsSync(normalizedPath));
|
|
255
254
|
return !!existsCache.get(normalizedPath);
|
|
256
255
|
}
|
|
257
256
|
function readStats(path) {
|
|
258
|
-
const normalizedPath = (0,
|
|
257
|
+
const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
|
|
259
258
|
if (!readStatsCache.has(normalizedPath)) {
|
|
260
259
|
if (exists(normalizedPath)) readStatsCache.set(normalizedPath, external_node_fs_default().statSync(normalizedPath));
|
|
261
260
|
}
|
|
262
261
|
return readStatsCache.get(normalizedPath);
|
|
263
262
|
}
|
|
264
263
|
function readFile(path, encoding) {
|
|
265
|
-
const normalizedPath = (0,
|
|
264
|
+
const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
|
|
266
265
|
if (!readFileCache.has(normalizedPath)) {
|
|
267
266
|
const stats = readStats(normalizedPath);
|
|
268
267
|
if (stats && stats.isFile()) readFileCache.set(normalizedPath, external_node_fs_default().readFileSync(normalizedPath, {
|
|
@@ -273,7 +272,7 @@ function readFile(path, encoding) {
|
|
|
273
272
|
return readFileCache.get(normalizedPath);
|
|
274
273
|
}
|
|
275
274
|
function readDir(path) {
|
|
276
|
-
const normalizedPath = (0,
|
|
275
|
+
const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
|
|
277
276
|
if (!readDirCache.has(normalizedPath)) {
|
|
278
277
|
const stats = readStats(normalizedPath);
|
|
279
278
|
if (stats && stats.isDirectory()) readDirCache.set(normalizedPath, external_node_fs_default().readdirSync(normalizedPath, {
|
|
@@ -284,53 +283,53 @@ function readDir(path) {
|
|
|
284
283
|
return readDirCache.get(normalizedPath) || [];
|
|
285
284
|
}
|
|
286
285
|
function getRealPath(path) {
|
|
287
|
-
const normalizedPath = (0,
|
|
286
|
+
const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
|
|
288
287
|
if (!realPathCache.has(normalizedPath)) {
|
|
289
288
|
let base = normalizedPath;
|
|
290
289
|
let nested = '';
|
|
291
|
-
while(base !== (0,
|
|
290
|
+
while(base !== (0, external_node_path_namespaceObject.dirname)(base)){
|
|
292
291
|
if (exists(base)) {
|
|
293
|
-
realPathCache.set(normalizedPath, (0,
|
|
292
|
+
realPathCache.set(normalizedPath, (0, external_node_path_namespaceObject.normalize)((0, external_node_path_namespaceObject.join)(external_node_fs_default().realpathSync(base), nested)));
|
|
294
293
|
break;
|
|
295
294
|
}
|
|
296
|
-
nested = (0,
|
|
297
|
-
base = (0,
|
|
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);
|
|
298
297
|
}
|
|
299
298
|
}
|
|
300
299
|
return realPathCache.get(normalizedPath) || normalizedPath;
|
|
301
300
|
}
|
|
302
301
|
function createDir(path) {
|
|
303
|
-
const normalizedPath = (0,
|
|
302
|
+
const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
|
|
304
303
|
external_node_fs_default().mkdirSync(normalizedPath, {
|
|
305
304
|
recursive: true
|
|
306
305
|
});
|
|
307
306
|
existsCache.set(normalizedPath, true);
|
|
308
|
-
if (readDirCache.has((0,
|
|
307
|
+
if (readDirCache.has((0, external_node_path_namespaceObject.dirname)(normalizedPath))) readDirCache.delete((0, external_node_path_namespaceObject.dirname)(normalizedPath));
|
|
309
308
|
if (readStatsCache.has(normalizedPath)) readStatsCache.delete(normalizedPath);
|
|
310
309
|
}
|
|
311
310
|
function writeFile(path, data) {
|
|
312
|
-
const normalizedPath = (0,
|
|
313
|
-
if (!exists((0,
|
|
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));
|
|
314
313
|
external_node_fs_default().writeFileSync(normalizedPath, data);
|
|
315
314
|
existsCache.set(normalizedPath, true);
|
|
316
|
-
if (readDirCache.has((0,
|
|
315
|
+
if (readDirCache.has((0, external_node_path_namespaceObject.dirname)(normalizedPath))) readDirCache.delete((0, external_node_path_namespaceObject.dirname)(normalizedPath));
|
|
317
316
|
if (readStatsCache.has(normalizedPath)) readStatsCache.delete(normalizedPath);
|
|
318
317
|
if (readFileCache.has(normalizedPath)) readFileCache.delete(normalizedPath);
|
|
319
318
|
}
|
|
320
319
|
function deleteFile(path) {
|
|
321
320
|
if (exists(path)) {
|
|
322
|
-
const normalizedPath = (0,
|
|
321
|
+
const normalizedPath = (0, external_node_path_namespaceObject.normalize)(path);
|
|
323
322
|
external_node_fs_default().unlinkSync(normalizedPath);
|
|
324
323
|
existsCache.set(normalizedPath, false);
|
|
325
|
-
if (readDirCache.has((0,
|
|
324
|
+
if (readDirCache.has((0, external_node_path_namespaceObject.dirname)(normalizedPath))) readDirCache.delete((0, external_node_path_namespaceObject.dirname)(normalizedPath));
|
|
326
325
|
if (readStatsCache.has(normalizedPath)) readStatsCache.delete(normalizedPath);
|
|
327
326
|
if (readFileCache.has(normalizedPath)) readFileCache.delete(normalizedPath);
|
|
328
327
|
}
|
|
329
328
|
}
|
|
330
329
|
function updateTimes(path, atime, mtime) {
|
|
331
330
|
if (exists(path)) {
|
|
332
|
-
const normalizedPath = (0,
|
|
333
|
-
external_node_fs_default().utimesSync((0,
|
|
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);
|
|
334
333
|
if (readStatsCache.has(normalizedPath)) readStatsCache.delete(normalizedPath);
|
|
335
334
|
}
|
|
336
335
|
}
|
|
@@ -389,7 +388,7 @@ function mem_file_system_createDir(path) {
|
|
|
389
388
|
});
|
|
390
389
|
}
|
|
391
390
|
function mem_file_system_writeFile(path, data) {
|
|
392
|
-
if (!mem_file_system_exists((0,
|
|
391
|
+
if (!mem_file_system_exists((0, external_node_path_namespaceObject.dirname)(path))) mem_file_system_createDir((0, external_node_path_namespaceObject.dirname)(path));
|
|
393
392
|
external_memfs_namespaceObject.fs.writeFileSync(realFileSystem.normalizePath(path), data);
|
|
394
393
|
}
|
|
395
394
|
function mem_file_system_deleteFile(path) {
|
|
@@ -493,7 +492,7 @@ const system = {
|
|
|
493
492
|
},
|
|
494
493
|
getDirectories (path) {
|
|
495
494
|
const dirents = getReadFileSystem(path).readDir(path);
|
|
496
|
-
return dirents.filter((dirent)=>dirent.isDirectory() || dirent.isSymbolicLink() && system.directoryExists((0,
|
|
495
|
+
return dirents.filter((dirent)=>dirent.isDirectory() || dirent.isSymbolicLink() && system.directoryExists((0, external_node_path_namespaceObject.join)(path, dirent.name))).map((dirent)=>dirent.name);
|
|
497
496
|
},
|
|
498
497
|
getModifiedTime (path) {
|
|
499
498
|
if (void 0 === path) return;
|
|
@@ -579,16 +578,22 @@ function invokeFileWatchers(path, event) {
|
|
|
579
578
|
const normalizedPath = normalizeAndResolvePath(path);
|
|
580
579
|
if (normalizedPath.endsWith('.js')) invokeFileWatchers(normalizedPath.slice(0, -3) + '.d.ts', event);
|
|
581
580
|
const fileWatcherCallbacks = fileWatcherCallbacksMap.get(normalizedPath);
|
|
582
|
-
if (fileWatcherCallbacks) fileWatcherCallbacks.forEach((fileWatcherCallback)=>
|
|
581
|
+
if (fileWatcherCallbacks) fileWatcherCallbacks.forEach((fileWatcherCallback)=>{
|
|
582
|
+
fileWatcherCallback(forwardSlash(normalizedPath), event);
|
|
583
|
+
});
|
|
583
584
|
}
|
|
584
585
|
function invokeDirectoryWatchers(path) {
|
|
585
586
|
const normalizedPath = normalizeAndResolvePath(path);
|
|
586
|
-
const directory = (0,
|
|
587
|
+
const directory = (0, external_node_path_namespaceObject.dirname)(normalizedPath);
|
|
587
588
|
if (ignoredPaths.some((ignoredPath)=>forwardSlash(normalizedPath).includes(ignoredPath))) return;
|
|
588
589
|
const directoryWatcherCallbacks = directoryWatcherCallbacksMap.get(directory);
|
|
589
|
-
if (directoryWatcherCallbacks) directoryWatcherCallbacks.forEach((directoryWatcherCallback)=>
|
|
590
|
+
if (directoryWatcherCallbacks) directoryWatcherCallbacks.forEach((directoryWatcherCallback)=>{
|
|
591
|
+
directoryWatcherCallback(forwardSlash(normalizedPath));
|
|
592
|
+
});
|
|
590
593
|
recursiveDirectoryWatcherCallbacksMap.forEach((recursiveDirectoryWatcherCallbacks, watchedDirectory)=>{
|
|
591
|
-
if (watchedDirectory === directory || directory.startsWith(watchedDirectory) && '/' === forwardSlash(directory)[watchedDirectory.length]) recursiveDirectoryWatcherCallbacks.forEach((recursiveDirectoryWatcherCallback)=>
|
|
594
|
+
if (watchedDirectory === directory || directory.startsWith(watchedDirectory) && '/' === forwardSlash(directory)[watchedDirectory.length]) recursiveDirectoryWatcherCallbacks.forEach((recursiveDirectoryWatcherCallback)=>{
|
|
595
|
+
recursiveDirectoryWatcherCallback(forwardSlash(normalizedPath));
|
|
596
|
+
});
|
|
592
597
|
});
|
|
593
598
|
}
|
|
594
599
|
function normalizeAndResolvePath(path) {
|
|
@@ -734,7 +739,7 @@ function didConfigFileChanged({ changedFiles = [], deletedFiles = [] }) {
|
|
|
734
739
|
return [
|
|
735
740
|
...changedFiles,
|
|
736
741
|
...deletedFiles
|
|
737
|
-
].map((file)=>
|
|
742
|
+
].map((file)=>external_node_path_namespaceObject.normalize(file)).includes(external_node_path_namespaceObject.normalize(worker_config_config.configFile));
|
|
738
743
|
}
|
|
739
744
|
function didDependenciesProbablyChanged(dependencies, { changedFiles = [], deletedFiles = [] }) {
|
|
740
745
|
const didSomeDependencyHasBeenAdded = changedFiles.some((changeFile)=>!dependencies.files.includes(changeFile));
|
|
@@ -773,7 +778,7 @@ function getTsBuildInfoEmitPath(compilerOptions) {
|
|
|
773
778
|
else {
|
|
774
779
|
if (!configFile) return;
|
|
775
780
|
const configFileExtensionLess = removeJsonExtension(configFile);
|
|
776
|
-
buildInfoExtensionLess = compilerOptions.outDir ? compilerOptions.rootDir ?
|
|
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;
|
|
777
782
|
}
|
|
778
783
|
return buildInfoExtensionLess + '.tsbuildinfo';
|
|
779
784
|
}
|
|
@@ -798,15 +803,15 @@ function getArtifactsWorker(parsedConfig, configFileContext, processedConfigFile
|
|
|
798
803
|
const files = new Set();
|
|
799
804
|
const dirs = new Set();
|
|
800
805
|
if (parsedConfig.fileNames.length > 0) {
|
|
801
|
-
if (parsedConfig.options.outFile) files.add(
|
|
806
|
+
if (parsedConfig.options.outFile) files.add(external_node_path_namespaceObject.resolve(configFileContext, parsedConfig.options.outFile));
|
|
802
807
|
const tsBuildInfoPath = getTsBuildInfoEmitPath(parsedConfig.options);
|
|
803
|
-
if (tsBuildInfoPath) files.add(
|
|
804
|
-
if (parsedConfig.options.outDir) dirs.add(
|
|
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));
|
|
805
810
|
}
|
|
806
811
|
for (const projectReference of parsedConfig.projectReferences || []){
|
|
807
812
|
const configFile = typescript.resolveProjectReferencePath(projectReference);
|
|
808
813
|
if (processedConfigFiles.includes(configFile)) continue;
|
|
809
|
-
const parsedConfig = parseConfig(configFile,
|
|
814
|
+
const parsedConfig = parseConfig(configFile, external_node_path_namespaceObject.dirname(configFile));
|
|
810
815
|
const childArtifacts = getArtifactsWorker(parsedConfig, configFileContext, [
|
|
811
816
|
...processedConfigFiles,
|
|
812
817
|
configFile
|
|
@@ -824,8 +829,8 @@ function getArtifactsWorker(parsedConfig, configFileContext, processedConfigFile
|
|
|
824
829
|
typescript.Extension.TsBuildInfo
|
|
825
830
|
];
|
|
826
831
|
return {
|
|
827
|
-
files: Array.from(files).map((file)=>
|
|
828
|
-
dirs: Array.from(dirs).map((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)),
|
|
829
834
|
excluded: [],
|
|
830
835
|
extensions
|
|
831
836
|
};
|
|
@@ -846,10 +851,10 @@ function getDependenciesWorker(parsedConfig, configFileContext, processedConfigF
|
|
|
846
851
|
const configFilePath = parsedConfig.options.configFilePath;
|
|
847
852
|
if ('string' == typeof configFilePath) files.add(configFilePath);
|
|
848
853
|
const dirs = new Set(Object.keys(parsedConfig.wildcardDirectories || {}));
|
|
849
|
-
const excluded = new Set((parsedConfig.raw?.exclude || []).map((filePath)=>
|
|
854
|
+
const excluded = new Set((parsedConfig.raw?.exclude || []).map((filePath)=>external_node_path_namespaceObject.resolve(configFileContext, filePath)));
|
|
850
855
|
for (const projectReference of parsedConfig.projectReferences || []){
|
|
851
856
|
const childConfigFilePath = typescript.resolveProjectReferencePath(projectReference);
|
|
852
|
-
const childConfigContext =
|
|
857
|
+
const childConfigContext = external_node_path_namespaceObject.dirname(childConfigFilePath);
|
|
853
858
|
if (processedConfigFiles.includes(childConfigFilePath)) continue;
|
|
854
859
|
const childParsedConfig = parseConfig(childConfigFilePath, childConfigContext);
|
|
855
860
|
const childDependencies = getDependenciesWorker(childParsedConfig, childConfigContext, [
|
|
@@ -871,9 +876,9 @@ function getDependenciesWorker(parsedConfig, configFileContext, processedConfigF
|
|
|
871
876
|
typescript.Extension.TsBuildInfo
|
|
872
877
|
];
|
|
873
878
|
return {
|
|
874
|
-
files: Array.from(files).map((file)=>
|
|
875
|
-
dirs: Array.from(dirs).map((dir)=>
|
|
876
|
-
excluded: Array.from(excluded).map((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)),
|
|
877
882
|
extensions: extensions
|
|
878
883
|
};
|
|
879
884
|
}
|
|
@@ -1005,14 +1010,23 @@ function createWatchSolutionBuilderHost(parsedConfig, createProgram, reportDiagn
|
|
|
1005
1010
|
}
|
|
1006
1011
|
let solutionBuilderHost;
|
|
1007
1012
|
let solutionBuilder;
|
|
1013
|
+
let hostDiagnostics = [];
|
|
1008
1014
|
function useSolutionBuilder() {
|
|
1009
1015
|
if (!solutionBuilderHost) {
|
|
1010
1016
|
const parsedConfig = getParsedConfig();
|
|
1011
1017
|
solutionBuilderHost = createWatchSolutionBuilderHost(parsedConfig, (rootNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences)=>{
|
|
1012
1018
|
if (compilerOptions) startTracingIfNeeded(compilerOptions);
|
|
1013
1019
|
return typescript.createSemanticDiagnosticsBuilderProgram(rootNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences);
|
|
1014
|
-
},
|
|
1015
|
-
|
|
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);
|
|
1016
1030
|
emitTsBuildInfoIfNeeded(builderProgram);
|
|
1017
1031
|
stopTracingIfNeeded(builderProgram);
|
|
1018
1032
|
});
|
|
@@ -1029,6 +1043,7 @@ function useSolutionBuilder() {
|
|
|
1029
1043
|
function invalidateSolutionBuilder(withHost = false) {
|
|
1030
1044
|
if (withHost) solutionBuilderHost = void 0;
|
|
1031
1045
|
solutionBuilder = void 0;
|
|
1046
|
+
hostDiagnostics = [];
|
|
1032
1047
|
}
|
|
1033
1048
|
let watchCompilerHost;
|
|
1034
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
|
|
39
|
-
var
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
|
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
|
-
require("node: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,13 +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
|
|
435
|
-
const external_process_namespaceObject = require("process");
|
|
433
|
+
const external_node_child_process_namespaceObject = require("node:child_process");
|
|
436
434
|
const WORKER_DATA_ENV_KEY = 'WORKER_DATA';
|
|
437
435
|
function createRpcWorker(modulePath, data, memoryLimit) {
|
|
438
436
|
const options = {
|
|
439
437
|
env: {
|
|
440
|
-
...
|
|
438
|
+
...external_node_process_namespaceObject.env,
|
|
441
439
|
[WORKER_DATA_ENV_KEY]: JSON.stringify(data || {})
|
|
442
440
|
},
|
|
443
441
|
stdio: [
|
|
@@ -461,7 +459,7 @@ function createRpcWorker(modulePath, data, memoryLimit) {
|
|
|
461
459
|
remoteMethod = void 0;
|
|
462
460
|
}
|
|
463
461
|
if (!childProcess?.connected) {
|
|
464
|
-
childProcess =
|
|
462
|
+
childProcess = external_node_child_process_namespaceObject.fork(modulePath, options);
|
|
465
463
|
remoteMethod = wrapRpc(childProcess);
|
|
466
464
|
}
|
|
467
465
|
},
|
|
@@ -503,8 +501,8 @@ function tapErrorToLogMessage(compiler, config) {
|
|
|
503
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."));
|
|
504
502
|
});
|
|
505
503
|
}
|
|
506
|
-
const
|
|
507
|
-
var
|
|
504
|
+
const external_node_os_namespaceObject = require("node:os");
|
|
505
|
+
var external_node_os_default = /*#__PURE__*/ __webpack_require__.n(external_node_os_namespaceObject);
|
|
508
506
|
function createPool(size) {
|
|
509
507
|
let pendingPromises = [];
|
|
510
508
|
const pool = {
|
|
@@ -533,8 +531,8 @@ function createPool(size) {
|
|
|
533
531
|
};
|
|
534
532
|
return pool;
|
|
535
533
|
}
|
|
536
|
-
const issuesPool = createPool(Math.max(1,
|
|
537
|
-
const dependenciesPool = createPool(Math.max(1,
|
|
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));
|
|
538
536
|
function interceptDoneToGetDevServerTap(compiler, config, state) {
|
|
539
537
|
const { debug } = getInfrastructureLogger(compiler);
|
|
540
538
|
compiler.hooks.done.intercept({
|
|
@@ -551,17 +549,17 @@ function interceptDoneToGetDevServerTap(compiler, config, state) {
|
|
|
551
549
|
});
|
|
552
550
|
}
|
|
553
551
|
function forwardSlash(input) {
|
|
554
|
-
return
|
|
552
|
+
return external_node_path_default().normalize(input).replace(/\\+/g, '/');
|
|
555
553
|
}
|
|
556
554
|
function relativeToContext(file, context) {
|
|
557
|
-
let fileInContext = forwardSlash(
|
|
555
|
+
let fileInContext = forwardSlash(external_node_path_default().relative(context, file));
|
|
558
556
|
if (!fileInContext.startsWith('../')) fileInContext = './' + fileInContext;
|
|
559
557
|
return fileInContext;
|
|
560
558
|
}
|
|
561
559
|
function formatIssueLocation(location) {
|
|
562
560
|
return `${location.start.line}:${location.start.column}`;
|
|
563
561
|
}
|
|
564
|
-
function
|
|
562
|
+
function issue_rspack_error_define_property(obj, key, value) {
|
|
565
563
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
566
564
|
value: value,
|
|
567
565
|
enumerable: true,
|
|
@@ -571,11 +569,11 @@ function issue_webpack_error_define_property(obj, key, value) {
|
|
|
571
569
|
else obj[key] = value;
|
|
572
570
|
return obj;
|
|
573
571
|
}
|
|
574
|
-
class
|
|
572
|
+
class IssueRspackError extends Error {
|
|
575
573
|
constructor(message, pathType, issue){
|
|
576
|
-
super(message),
|
|
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;
|
|
577
575
|
if (issue.file) {
|
|
578
|
-
this.file = 'absolute' === pathType ? forwardSlash(
|
|
576
|
+
this.file = 'absolute' === pathType ? forwardSlash(external_node_path_default().resolve(issue.file)) : relativeToContext(issue.file, process.cwd());
|
|
579
577
|
if (issue.location) this.file += `:${formatIssueLocation(issue.location)}`;
|
|
580
578
|
}
|
|
581
579
|
Error.captureStackTrace(this, this.constructor);
|
|
@@ -598,7 +596,7 @@ function tapAfterCompileToGetIssues(compiler, config, state) {
|
|
|
598
596
|
issues = issues.filter(config.issue.predicate);
|
|
599
597
|
issues = hooks.issues.call(issues, compilation);
|
|
600
598
|
issues.forEach((issue)=>{
|
|
601
|
-
const error = new
|
|
599
|
+
const error = new IssueRspackError(config.formatter.format(issue), config.formatter.pathType, issue);
|
|
602
600
|
if ('warning' === issue.severity) compilation.warnings.push(error);
|
|
603
601
|
else compilation.errors.push(error);
|
|
604
602
|
});
|
|
@@ -619,22 +617,22 @@ function statsFormatter(issues, stats) {
|
|
|
619
617
|
timeFormatted ? ` in ${timeFormatted} ms` : ''
|
|
620
618
|
].join('');
|
|
621
619
|
}
|
|
622
|
-
function
|
|
620
|
+
function createRspackFormatter(formatter, pathType) {
|
|
623
621
|
return function(issue) {
|
|
624
622
|
const color = 'warning' === issue.severity ? external_picocolors_default().yellow : external_picocolors_default().red;
|
|
625
623
|
const severity = issue.severity.toUpperCase();
|
|
626
624
|
if (!issue.file) return [
|
|
627
625
|
`${external_picocolors_default().bold(color(severity))} in ` + formatter(issue),
|
|
628
626
|
''
|
|
629
|
-
].join(
|
|
627
|
+
].join(external_node_os_default().EOL);
|
|
630
628
|
{
|
|
631
|
-
let location = external_picocolors_default().bold('absolute' === pathType ? forwardSlash(
|
|
629
|
+
let location = external_picocolors_default().bold('absolute' === pathType ? forwardSlash(external_node_path_default().resolve(issue.file)) : relativeToContext(issue.file, process.cwd()));
|
|
632
630
|
if (issue.location) location += `:${external_picocolors_default().bold(external_picocolors_default().green(formatIssueLocation(issue.location)))}`;
|
|
633
631
|
return [
|
|
634
632
|
`${external_picocolors_default().bold(color(severity))} in ${location}`,
|
|
635
633
|
formatter(issue),
|
|
636
634
|
''
|
|
637
|
-
].join(
|
|
635
|
+
].join(external_node_os_default().EOL);
|
|
638
636
|
}
|
|
639
637
|
};
|
|
640
638
|
}
|
|
@@ -668,12 +666,12 @@ function tapDoneToAsyncGetIssues(compiler, config, state) {
|
|
|
668
666
|
debug(`Got ${issues?.length || 0} issues from getIssuesWorker.`);
|
|
669
667
|
issues = issues.filter(config.issue.predicate);
|
|
670
668
|
issues = hooks.issues.call(issues, stats.compilation);
|
|
671
|
-
const formatter =
|
|
669
|
+
const formatter = createRspackFormatter(config.formatter.format, config.formatter.pathType);
|
|
672
670
|
if (issues.length) config.logger.error(issues.map((issue)=>formatter(issue)).join('\n'));
|
|
673
671
|
config.logger.log(statsFormatter(issues, stats));
|
|
674
672
|
if (issues.length && state.DevServerDoneTap) {
|
|
675
673
|
issues.forEach((issue)=>{
|
|
676
|
-
const error = new
|
|
674
|
+
const error = new IssueRspackError(config.formatter.format(issue), config.formatter.pathType, issue);
|
|
677
675
|
if ('warning' === issue.severity) stats.compilation.warnings.push(error);
|
|
678
676
|
else stats.compilation.errors.push(error);
|
|
679
677
|
});
|
|
@@ -804,12 +802,12 @@ function createCodeFrameFormatter(options) {
|
|
|
804
802
|
if (source && issue.location) frame = (0, code_frame_namespaceObject.codeFrameColumns)(source, issue.location, {
|
|
805
803
|
highlightCode: true,
|
|
806
804
|
...options || {}
|
|
807
|
-
}).split('\n').map((line)=>' ' + line).join(
|
|
805
|
+
}).split('\n').map((line)=>' ' + line).join(external_node_os_default().EOL);
|
|
808
806
|
const lines = [
|
|
809
807
|
basicFormatter(issue)
|
|
810
808
|
];
|
|
811
809
|
if (frame) lines.push(frame);
|
|
812
|
-
return lines.join(
|
|
810
|
+
return lines.join(external_node_os_default().EOL);
|
|
813
811
|
};
|
|
814
812
|
}
|
|
815
813
|
function createFormatterConfig(options) {
|
|
@@ -836,7 +834,7 @@ function createIssuePredicateFromIssueMatch(context, match) {
|
|
|
836
834
|
return (issue)=>{
|
|
837
835
|
const matchesSeverity = !match.severity || match.severity === issue.severity;
|
|
838
836
|
const matchesCode = !match.code || match.code === issue.code;
|
|
839
|
-
const matchesFile = !issue.file || !!issue.file && (!match.file || (0, external_minimatch_namespaceObject.minimatch)(forwardSlash(
|
|
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));
|
|
840
838
|
return matchesSeverity && matchesCode && matchesFile;
|
|
841
839
|
};
|
|
842
840
|
}
|
|
@@ -863,7 +861,7 @@ function createIssueConfig(compiler, options) {
|
|
|
863
861
|
}
|
|
864
862
|
function createTypeScriptWorkerConfig(compiler, options) {
|
|
865
863
|
let configFile = 'object' == typeof options ? options.configFile || 'tsconfig.json' : 'tsconfig.json';
|
|
866
|
-
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));
|
|
867
865
|
const optionsAsObject = 'object' == typeof options ? options : {};
|
|
868
866
|
const typescriptPath = optionsAsObject.typescriptPath || require.resolve("typescript");
|
|
869
867
|
return {
|
|
@@ -875,7 +873,7 @@ function createTypeScriptWorkerConfig(compiler, options) {
|
|
|
875
873
|
...optionsAsObject,
|
|
876
874
|
configFile: configFile,
|
|
877
875
|
configOverwrite: optionsAsObject.configOverwrite || {},
|
|
878
|
-
context: optionsAsObject.context ||
|
|
876
|
+
context: optionsAsObject.context || external_node_path_default().dirname(configFile),
|
|
879
877
|
diagnosticOptions: {
|
|
880
878
|
syntactic: false,
|
|
881
879
|
semantic: true,
|
|
@@ -919,15 +917,15 @@ function assertTypeScriptSupport(config) {
|
|
|
919
917
|
let typescriptVersion;
|
|
920
918
|
try {
|
|
921
919
|
typescriptVersion = require(config.typescriptPath).version;
|
|
922
|
-
} catch
|
|
920
|
+
} catch {}
|
|
923
921
|
if (!typescriptVersion) throw new Error("When you use TsCheckerRspackPlugin with typescript reporter enabled, you must install `typescript` package.");
|
|
924
922
|
if (!external_node_fs_default().existsSync(config.configFile)) throw new Error([
|
|
925
923
|
`Cannot find the "${config.configFile}" file.`,
|
|
926
|
-
"Please check
|
|
924
|
+
"Please check Rspack and TsCheckerRspackPlugin configuration.",
|
|
927
925
|
"Possible errors:",
|
|
928
|
-
' - wrong `context` directory in
|
|
926
|
+
' - wrong `context` directory in Rspack configuration (if `configFile` is not set or is a relative path in the fork plugin configuration)',
|
|
929
927
|
" - wrong `typescript.configFile` path in the plugin configuration (should be a relative or absolute path)"
|
|
930
|
-
].join(
|
|
928
|
+
].join(external_node_os_default().EOL));
|
|
931
929
|
}
|
|
932
930
|
function plugin_define_property(obj, key, value) {
|
|
933
931
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
@@ -939,7 +937,7 @@ function plugin_define_property(obj, key, value) {
|
|
|
939
937
|
else obj[key] = value;
|
|
940
938
|
return obj;
|
|
941
939
|
}
|
|
942
|
-
const pkgJson = JSON.parse((0, external_node_fs_namespaceObject.readFileSync)(
|
|
940
|
+
const pkgJson = JSON.parse((0, external_node_fs_namespaceObject.readFileSync)(external_node_path_namespaceObject.join(__dirname, '../package.json'), 'utf-8'));
|
|
943
941
|
class TsCheckerRspackPlugin {
|
|
944
942
|
static getCompilerHooks(compiler) {
|
|
945
943
|
return getPluginHooks(compiler);
|
|
@@ -948,8 +946,8 @@ class TsCheckerRspackPlugin {
|
|
|
948
946
|
const config = createPluginConfig(compiler, this.options);
|
|
949
947
|
const state = createPluginState();
|
|
950
948
|
assertTypeScriptSupport(config.typescript);
|
|
951
|
-
const getIssuesWorker = createRpcWorker(
|
|
952
|
-
const getDependenciesWorker = createRpcWorker(
|
|
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);
|
|
953
951
|
tapAfterEnvironmentToPatchWatching(compiler, state);
|
|
954
952
|
tapStartToRunWorkers(compiler, getIssuesWorker, getDependenciesWorker, config, state);
|
|
955
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
|
|
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 {
|
|
9
|
+
export { IssueRspackError };
|
package/lib/rpc/rpc-worker.d.ts
CHANGED
package/lib/rpc/wrap-rpc.d.ts
CHANGED
|
@@ -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>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-checker-rspack-plugin",
|
|
3
|
-
"version": "1.2.
|
|
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": "
|
|
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": {
|