ts-checker-rspack-plugin 1.1.6 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/getDependenciesWorker.js +652 -0
- package/lib/getIssuesWorker.js +1091 -0
- package/lib/index.js +970 -4
- package/lib/plugin-state.d.ts +0 -1
- package/lib/plugin.d.ts +1 -1
- package/lib/rpc/rpc-worker.d.ts +0 -1
- package/lib/rpc/wrap-rpc.d.ts +0 -1
- package/lib/typescript/worker/lib/file-system/file-system.d.ts +0 -1
- package/lib/utils/async/abort-error.d.ts +0 -1
- package/lib/utils/async/pool.d.ts +0 -1
- package/lib/watch/watch-file-system.d.ts +0 -1
- package/package.json +11 -10
- package/lib/files-change.js +0 -57
- package/lib/files-match.js +0 -2
- package/lib/formatter/basic-formatter.js +0 -13
- package/lib/formatter/code-frame-formatter.js +0 -32
- package/lib/formatter/formatter-config.js +0 -36
- package/lib/formatter/formatter-options.js +0 -2
- package/lib/formatter/formatter.js +0 -2
- package/lib/formatter/index.js +0 -22
- package/lib/formatter/stats-formatter.js +0 -30
- package/lib/formatter/types/babel__code-frame.js +0 -7
- package/lib/formatter/webpack-formatter.js +0 -32
- package/lib/hooks/intercept-done-to-get-dev-server-tap.js +0 -18
- package/lib/hooks/tap-after-compile-to-add-dependencies.js +0 -22
- package/lib/hooks/tap-after-compile-to-get-issues.js +0 -43
- package/lib/hooks/tap-after-environment-to-patch-watching.js +0 -22
- package/lib/hooks/tap-done-to-async-get-issues.js +0 -74
- package/lib/hooks/tap-error-to-log-message.js +0 -32
- package/lib/hooks/tap-start-to-run-workers.js +0 -122
- package/lib/hooks/tap-stop-to-terminate-workers.js +0 -26
- package/lib/infrastructure-logger.js +0 -14
- package/lib/issue/index.js +0 -19
- package/lib/issue/issue-config.js +0 -29
- package/lib/issue/issue-location.js +0 -22
- package/lib/issue/issue-match.js +0 -20
- package/lib/issue/issue-options.js +0 -2
- package/lib/issue/issue-position.js +0 -16
- package/lib/issue/issue-predicate.js +0 -11
- package/lib/issue/issue-severity.js +0 -12
- package/lib/issue/issue-webpack-error.js +0 -31
- package/lib/issue/issue.js +0 -41
- package/lib/logger.js +0 -2
- package/lib/plugin-config.js +0 -26
- package/lib/plugin-hooks.js +0 -45
- package/lib/plugin-options.js +0 -2
- package/lib/plugin-pools.js +0 -32
- package/lib/plugin-state.js +0 -17
- package/lib/plugin.js +0 -74
- package/lib/rpc/expose-rpc.js +0 -69
- package/lib/rpc/index.js +0 -12
- package/lib/rpc/rpc-error.js +0 -12
- package/lib/rpc/rpc-worker.js +0 -86
- package/lib/rpc/types.js +0 -2
- package/lib/rpc/wrap-rpc.js +0 -70
- package/lib/typescript/type-script-config-overwrite.js +0 -2
- package/lib/typescript/type-script-diagnostics-options.js +0 -2
- package/lib/typescript/type-script-support.js +0 -31
- package/lib/typescript/type-script-worker-config.js +0 -36
- package/lib/typescript/type-script-worker-options.js +0 -2
- package/lib/typescript/worker/get-dependencies-worker.js +0 -15
- package/lib/typescript/worker/get-issues-worker.js +0 -70
- package/lib/typescript/worker/lib/artifacts.js +0 -94
- package/lib/typescript/worker/lib/config.js +0 -162
- package/lib/typescript/worker/lib/dependencies.js +0 -84
- package/lib/typescript/worker/lib/diagnostics.js +0 -112
- package/lib/typescript/worker/lib/emit.js +0 -13
- package/lib/typescript/worker/lib/file-system/file-system.js +0 -2
- package/lib/typescript/worker/lib/file-system/mem-file-system.js +0 -81
- package/lib/typescript/worker/lib/file-system/passive-file-system.js +0 -68
- package/lib/typescript/worker/lib/file-system/real-file-system.js +0 -171
- package/lib/typescript/worker/lib/host/compiler-host.js +0 -17
- package/lib/typescript/worker/lib/host/watch-compiler-host.js +0 -32
- package/lib/typescript/worker/lib/host/watch-solution-builder-host.js +0 -53
- package/lib/typescript/worker/lib/performance.js +0 -29
- package/lib/typescript/worker/lib/program/program.js +0 -37
- package/lib/typescript/worker/lib/program/solution-builder.js +0 -39
- package/lib/typescript/worker/lib/program/watch-program.js +0 -51
- package/lib/typescript/worker/lib/system.js +0 -229
- package/lib/typescript/worker/lib/tracing.js +0 -27
- package/lib/typescript/worker/lib/tsbuildinfo.js +0 -96
- package/lib/typescript/worker/lib/typescript.js +0 -6
- package/lib/typescript/worker/lib/worker-config.js +0 -5
- package/lib/utils/async/abort-error.js +0 -15
- package/lib/utils/async/controlled-promise.js +0 -17
- package/lib/utils/async/is-pending.js +0 -10
- package/lib/utils/async/pool.js +0 -36
- package/lib/utils/async/wait.js +0 -7
- package/lib/utils/path/forward-slash.js +0 -15
- package/lib/utils/path/is-inside-another-path.js +0 -22
- package/lib/utils/path/relative-to-context.js +0 -16
- package/lib/watch/inclusive-node-watch-file-system.js +0 -183
- package/lib/watch/watch-file-system.js +0 -2
|
@@ -0,0 +1,652 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
var __webpack_exports__ = {};
|
|
24
|
+
const external_process_namespaceObject = require("process");
|
|
25
|
+
var external_process_default = /*#__PURE__*/ __webpack_require__.n(external_process_namespaceObject);
|
|
26
|
+
function exposeRpc(fn) {
|
|
27
|
+
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)=>{
|
|
29
|
+
if (error) reject(error);
|
|
30
|
+
else resolve(void 0);
|
|
31
|
+
});
|
|
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`));
|
|
34
|
+
});
|
|
35
|
+
const handleMessage = async (message)=>{
|
|
36
|
+
if ('call' === message.type) {
|
|
37
|
+
if (!external_process_default().send) return;
|
|
38
|
+
let value;
|
|
39
|
+
let error;
|
|
40
|
+
try {
|
|
41
|
+
value = await fn(...message.args);
|
|
42
|
+
} catch (fnError) {
|
|
43
|
+
error = fnError;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
if (error) await sendMessage({
|
|
47
|
+
type: 'reject',
|
|
48
|
+
id: message.id,
|
|
49
|
+
error
|
|
50
|
+
});
|
|
51
|
+
else await sendMessage({
|
|
52
|
+
type: 'resolve',
|
|
53
|
+
id: message.id,
|
|
54
|
+
value
|
|
55
|
+
});
|
|
56
|
+
} catch (sendError) {
|
|
57
|
+
if (error) console.error(error);
|
|
58
|
+
console.error(sendError);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
external_process_default().on('message', handleMessage);
|
|
63
|
+
}
|
|
64
|
+
require("child_process");
|
|
65
|
+
const WORKER_DATA_ENV_KEY = 'WORKER_DATA';
|
|
66
|
+
function getRpcWorkerData() {
|
|
67
|
+
return JSON.parse(external_process_namespaceObject.env[WORKER_DATA_ENV_KEY] || '{}');
|
|
68
|
+
}
|
|
69
|
+
const external_path_namespaceObject = require("path");
|
|
70
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
71
|
+
function forwardSlash(input) {
|
|
72
|
+
return external_path_default().normalize(input).replace(/\\+/g, '/');
|
|
73
|
+
}
|
|
74
|
+
require("os");
|
|
75
|
+
const worker_config_config = getRpcWorkerData();
|
|
76
|
+
const typescript_typescript = require(worker_config_config.typescriptPath);
|
|
77
|
+
new Map();
|
|
78
|
+
const external_memfs_namespaceObject = require("memfs");
|
|
79
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
80
|
+
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
81
|
+
const existsCache = new Map();
|
|
82
|
+
const readStatsCache = new Map();
|
|
83
|
+
const readFileCache = new Map();
|
|
84
|
+
const readDirCache = new Map();
|
|
85
|
+
const realPathCache = new Map();
|
|
86
|
+
const realFileSystem = {
|
|
87
|
+
exists (path) {
|
|
88
|
+
return exists(getRealPath(path));
|
|
89
|
+
},
|
|
90
|
+
readFile (path, encoding) {
|
|
91
|
+
return readFile(getRealPath(path), encoding);
|
|
92
|
+
},
|
|
93
|
+
readDir (path) {
|
|
94
|
+
return readDir(getRealPath(path));
|
|
95
|
+
},
|
|
96
|
+
readStats (path) {
|
|
97
|
+
return readStats(getRealPath(path));
|
|
98
|
+
},
|
|
99
|
+
realPath (path) {
|
|
100
|
+
return getRealPath(path);
|
|
101
|
+
},
|
|
102
|
+
normalizePath (path) {
|
|
103
|
+
return (0, external_path_namespaceObject.normalize)(path);
|
|
104
|
+
},
|
|
105
|
+
writeFile (path, data) {
|
|
106
|
+
writeFile(getRealPath(path), data);
|
|
107
|
+
},
|
|
108
|
+
deleteFile (path) {
|
|
109
|
+
deleteFile(getRealPath(path));
|
|
110
|
+
},
|
|
111
|
+
createDir (path) {
|
|
112
|
+
createDir(getRealPath(path));
|
|
113
|
+
},
|
|
114
|
+
updateTimes (path, atime, mtime) {
|
|
115
|
+
updateTimes(getRealPath(path), atime, mtime);
|
|
116
|
+
},
|
|
117
|
+
clearCache () {
|
|
118
|
+
existsCache.clear();
|
|
119
|
+
readStatsCache.clear();
|
|
120
|
+
readFileCache.clear();
|
|
121
|
+
readDirCache.clear();
|
|
122
|
+
realPathCache.clear();
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
function exists(path) {
|
|
126
|
+
const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
|
|
127
|
+
if (!existsCache.has(normalizedPath)) existsCache.set(normalizedPath, external_node_fs_default().existsSync(normalizedPath));
|
|
128
|
+
return !!existsCache.get(normalizedPath);
|
|
129
|
+
}
|
|
130
|
+
function readStats(path) {
|
|
131
|
+
const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
|
|
132
|
+
if (!readStatsCache.has(normalizedPath)) {
|
|
133
|
+
if (exists(normalizedPath)) readStatsCache.set(normalizedPath, external_node_fs_default().statSync(normalizedPath));
|
|
134
|
+
}
|
|
135
|
+
return readStatsCache.get(normalizedPath);
|
|
136
|
+
}
|
|
137
|
+
function readFile(path, encoding) {
|
|
138
|
+
const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
|
|
139
|
+
if (!readFileCache.has(normalizedPath)) {
|
|
140
|
+
const stats = readStats(normalizedPath);
|
|
141
|
+
if (stats && stats.isFile()) readFileCache.set(normalizedPath, external_node_fs_default().readFileSync(normalizedPath, {
|
|
142
|
+
encoding: encoding
|
|
143
|
+
}).toString());
|
|
144
|
+
else readFileCache.set(normalizedPath, void 0);
|
|
145
|
+
}
|
|
146
|
+
return readFileCache.get(normalizedPath);
|
|
147
|
+
}
|
|
148
|
+
function readDir(path) {
|
|
149
|
+
const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
|
|
150
|
+
if (!readDirCache.has(normalizedPath)) {
|
|
151
|
+
const stats = readStats(normalizedPath);
|
|
152
|
+
if (stats && stats.isDirectory()) readDirCache.set(normalizedPath, external_node_fs_default().readdirSync(normalizedPath, {
|
|
153
|
+
withFileTypes: true
|
|
154
|
+
}));
|
|
155
|
+
else readDirCache.set(normalizedPath, []);
|
|
156
|
+
}
|
|
157
|
+
return readDirCache.get(normalizedPath) || [];
|
|
158
|
+
}
|
|
159
|
+
function getRealPath(path) {
|
|
160
|
+
const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
|
|
161
|
+
if (!realPathCache.has(normalizedPath)) {
|
|
162
|
+
let base = normalizedPath;
|
|
163
|
+
let nested = '';
|
|
164
|
+
while(base !== (0, external_path_namespaceObject.dirname)(base)){
|
|
165
|
+
if (exists(base)) {
|
|
166
|
+
realPathCache.set(normalizedPath, (0, external_path_namespaceObject.normalize)((0, external_path_namespaceObject.join)(external_node_fs_default().realpathSync(base), nested)));
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
nested = (0, external_path_namespaceObject.join)((0, external_path_namespaceObject.basename)(base), nested);
|
|
170
|
+
base = (0, external_path_namespaceObject.dirname)(base);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return realPathCache.get(normalizedPath) || normalizedPath;
|
|
174
|
+
}
|
|
175
|
+
function createDir(path) {
|
|
176
|
+
const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
|
|
177
|
+
external_node_fs_default().mkdirSync(normalizedPath, {
|
|
178
|
+
recursive: true
|
|
179
|
+
});
|
|
180
|
+
existsCache.set(normalizedPath, true);
|
|
181
|
+
if (readDirCache.has((0, external_path_namespaceObject.dirname)(normalizedPath))) readDirCache.delete((0, external_path_namespaceObject.dirname)(normalizedPath));
|
|
182
|
+
if (readStatsCache.has(normalizedPath)) readStatsCache.delete(normalizedPath);
|
|
183
|
+
}
|
|
184
|
+
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));
|
|
187
|
+
external_node_fs_default().writeFileSync(normalizedPath, data);
|
|
188
|
+
existsCache.set(normalizedPath, true);
|
|
189
|
+
if (readDirCache.has((0, external_path_namespaceObject.dirname)(normalizedPath))) readDirCache.delete((0, external_path_namespaceObject.dirname)(normalizedPath));
|
|
190
|
+
if (readStatsCache.has(normalizedPath)) readStatsCache.delete(normalizedPath);
|
|
191
|
+
if (readFileCache.has(normalizedPath)) readFileCache.delete(normalizedPath);
|
|
192
|
+
}
|
|
193
|
+
function deleteFile(path) {
|
|
194
|
+
if (exists(path)) {
|
|
195
|
+
const normalizedPath = (0, external_path_namespaceObject.normalize)(path);
|
|
196
|
+
external_node_fs_default().unlinkSync(normalizedPath);
|
|
197
|
+
existsCache.set(normalizedPath, false);
|
|
198
|
+
if (readDirCache.has((0, external_path_namespaceObject.dirname)(normalizedPath))) readDirCache.delete((0, external_path_namespaceObject.dirname)(normalizedPath));
|
|
199
|
+
if (readStatsCache.has(normalizedPath)) readStatsCache.delete(normalizedPath);
|
|
200
|
+
if (readFileCache.has(normalizedPath)) readFileCache.delete(normalizedPath);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
function updateTimes(path, atime, mtime) {
|
|
204
|
+
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);
|
|
207
|
+
if (readStatsCache.has(normalizedPath)) readStatsCache.delete(normalizedPath);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
const memFileSystem = {
|
|
211
|
+
...realFileSystem,
|
|
212
|
+
exists (path) {
|
|
213
|
+
return mem_file_system_exists(realFileSystem.realPath(path));
|
|
214
|
+
},
|
|
215
|
+
readFile (path, encoding) {
|
|
216
|
+
return mem_file_system_readFile(realFileSystem.realPath(path), encoding);
|
|
217
|
+
},
|
|
218
|
+
readDir (path) {
|
|
219
|
+
return mem_file_system_readDir(realFileSystem.realPath(path));
|
|
220
|
+
},
|
|
221
|
+
readStats (path) {
|
|
222
|
+
return mem_file_system_readStats(realFileSystem.realPath(path));
|
|
223
|
+
},
|
|
224
|
+
writeFile (path, data) {
|
|
225
|
+
mem_file_system_writeFile(realFileSystem.realPath(path), data);
|
|
226
|
+
},
|
|
227
|
+
deleteFile (path) {
|
|
228
|
+
mem_file_system_deleteFile(realFileSystem.realPath(path));
|
|
229
|
+
},
|
|
230
|
+
createDir (path) {
|
|
231
|
+
mem_file_system_createDir(realFileSystem.realPath(path));
|
|
232
|
+
},
|
|
233
|
+
updateTimes (path, atime, mtime) {
|
|
234
|
+
mem_file_system_updateTimes(realFileSystem.realPath(path), atime, mtime);
|
|
235
|
+
},
|
|
236
|
+
clearCache () {
|
|
237
|
+
realFileSystem.clearCache();
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
function mem_file_system_exists(path) {
|
|
241
|
+
return external_memfs_namespaceObject.fs.existsSync(realFileSystem.normalizePath(path));
|
|
242
|
+
}
|
|
243
|
+
function mem_file_system_readStats(path) {
|
|
244
|
+
return mem_file_system_exists(path) ? external_memfs_namespaceObject.fs.statSync(realFileSystem.normalizePath(path)) : void 0;
|
|
245
|
+
}
|
|
246
|
+
function mem_file_system_readFile(path, encoding) {
|
|
247
|
+
const stats = mem_file_system_readStats(path);
|
|
248
|
+
if (stats && stats.isFile()) return external_memfs_namespaceObject.fs.readFileSync(realFileSystem.normalizePath(path), {
|
|
249
|
+
encoding: encoding
|
|
250
|
+
}).toString();
|
|
251
|
+
}
|
|
252
|
+
function mem_file_system_readDir(path) {
|
|
253
|
+
const stats = mem_file_system_readStats(path);
|
|
254
|
+
if (stats && stats.isDirectory()) return external_memfs_namespaceObject.fs.readdirSync(realFileSystem.normalizePath(path), {
|
|
255
|
+
withFileTypes: true
|
|
256
|
+
});
|
|
257
|
+
return [];
|
|
258
|
+
}
|
|
259
|
+
function mem_file_system_createDir(path) {
|
|
260
|
+
external_memfs_namespaceObject.fs.mkdirSync(realFileSystem.normalizePath(path), {
|
|
261
|
+
recursive: true
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
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));
|
|
266
|
+
external_memfs_namespaceObject.fs.writeFileSync(realFileSystem.normalizePath(path), data);
|
|
267
|
+
}
|
|
268
|
+
function mem_file_system_deleteFile(path) {
|
|
269
|
+
if (mem_file_system_exists(path)) external_memfs_namespaceObject.fs.unlinkSync(realFileSystem.normalizePath(path));
|
|
270
|
+
}
|
|
271
|
+
function mem_file_system_updateTimes(path, atime, mtime) {
|
|
272
|
+
if (mem_file_system_exists(path)) external_memfs_namespaceObject.fs.utimesSync(realFileSystem.normalizePath(path), atime, mtime);
|
|
273
|
+
}
|
|
274
|
+
const passiveFileSystem = {
|
|
275
|
+
...memFileSystem,
|
|
276
|
+
exists (path) {
|
|
277
|
+
return passive_file_system_exists(realFileSystem.realPath(path));
|
|
278
|
+
},
|
|
279
|
+
readFile (path, encoding) {
|
|
280
|
+
return passive_file_system_readFile(realFileSystem.realPath(path), encoding);
|
|
281
|
+
},
|
|
282
|
+
readDir (path) {
|
|
283
|
+
return passive_file_system_readDir(realFileSystem.realPath(path));
|
|
284
|
+
},
|
|
285
|
+
readStats (path) {
|
|
286
|
+
return passive_file_system_readStats(realFileSystem.realPath(path));
|
|
287
|
+
},
|
|
288
|
+
realPath (path) {
|
|
289
|
+
return realFileSystem.realPath(path);
|
|
290
|
+
},
|
|
291
|
+
clearCache () {
|
|
292
|
+
realFileSystem.clearCache();
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
function passive_file_system_exists(path) {
|
|
296
|
+
return realFileSystem.exists(path) || memFileSystem.exists(path);
|
|
297
|
+
}
|
|
298
|
+
function passive_file_system_readFile(path, encoding) {
|
|
299
|
+
const fsStats = realFileSystem.readStats(path);
|
|
300
|
+
const memStats = memFileSystem.readStats(path);
|
|
301
|
+
if (fsStats && memStats) return fsStats.mtimeMs > memStats.mtimeMs ? realFileSystem.readFile(path, encoding) : memFileSystem.readFile(path, encoding);
|
|
302
|
+
if (fsStats) return realFileSystem.readFile(path, encoding);
|
|
303
|
+
if (memStats) return memFileSystem.readFile(path, encoding);
|
|
304
|
+
}
|
|
305
|
+
function passive_file_system_readDir(path) {
|
|
306
|
+
const fsDirents = realFileSystem.readDir(path);
|
|
307
|
+
const memDirents = memFileSystem.readDir(path);
|
|
308
|
+
return fsDirents.filter((fsDirent)=>!memDirents.some((memDirent)=>memDirent.name === fsDirent.name)).concat(memDirents);
|
|
309
|
+
}
|
|
310
|
+
function passive_file_system_readStats(path) {
|
|
311
|
+
const fsStats = realFileSystem.readStats(path);
|
|
312
|
+
const memStats = memFileSystem.readStats(path);
|
|
313
|
+
if (fsStats && memStats) return fsStats.mtimeMs > memStats.mtimeMs ? fsStats : memStats;
|
|
314
|
+
if (fsStats) return fsStats;
|
|
315
|
+
if (memStats) return memStats;
|
|
316
|
+
}
|
|
317
|
+
const mode = worker_config_config.mode;
|
|
318
|
+
let artifacts = {
|
|
319
|
+
files: [],
|
|
320
|
+
dirs: [],
|
|
321
|
+
excluded: [],
|
|
322
|
+
extensions: []
|
|
323
|
+
};
|
|
324
|
+
let isInitialRun = true;
|
|
325
|
+
const fileWatcherCallbacksMap = new Map();
|
|
326
|
+
const directoryWatcherCallbacksMap = new Map();
|
|
327
|
+
const recursiveDirectoryWatcherCallbacksMap = new Map();
|
|
328
|
+
const system_deletedFiles = new Map();
|
|
329
|
+
const timeoutCallbacks = new Set();
|
|
330
|
+
const ignoredPaths = [
|
|
331
|
+
'/node_modules/.',
|
|
332
|
+
'/.git',
|
|
333
|
+
'/.#'
|
|
334
|
+
];
|
|
335
|
+
const system = {
|
|
336
|
+
...typescript_typescript.sys,
|
|
337
|
+
useCaseSensitiveFileNames: true,
|
|
338
|
+
realpath (path) {
|
|
339
|
+
return getReadFileSystem(path).realPath(path);
|
|
340
|
+
},
|
|
341
|
+
fileExists (path) {
|
|
342
|
+
const stats = getReadFileSystem(path).readStats(path);
|
|
343
|
+
return !!stats && stats.isFile();
|
|
344
|
+
},
|
|
345
|
+
readFile (path, encoding) {
|
|
346
|
+
return getReadFileSystem(path).readFile(path, encoding);
|
|
347
|
+
},
|
|
348
|
+
getFileSize (path) {
|
|
349
|
+
const stats = getReadFileSystem(path).readStats(path);
|
|
350
|
+
return stats ? stats.size : 0;
|
|
351
|
+
},
|
|
352
|
+
writeFile (path, data) {
|
|
353
|
+
getWriteFileSystem(path).writeFile(path, data);
|
|
354
|
+
system.invokeFileChanged(path);
|
|
355
|
+
},
|
|
356
|
+
deleteFile (path) {
|
|
357
|
+
getWriteFileSystem(path).deleteFile(path);
|
|
358
|
+
system.invokeFileDeleted(path);
|
|
359
|
+
},
|
|
360
|
+
directoryExists (path) {
|
|
361
|
+
return Boolean(getReadFileSystem(path).readStats(path)?.isDirectory());
|
|
362
|
+
},
|
|
363
|
+
createDirectory (path) {
|
|
364
|
+
getWriteFileSystem(path).createDir(path);
|
|
365
|
+
invokeDirectoryWatchers(path);
|
|
366
|
+
},
|
|
367
|
+
getDirectories (path) {
|
|
368
|
+
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);
|
|
370
|
+
},
|
|
371
|
+
getModifiedTime (path) {
|
|
372
|
+
if (void 0 === path) return;
|
|
373
|
+
const stats = getReadFileSystem(path).readStats(path);
|
|
374
|
+
if (stats) return stats.mtime;
|
|
375
|
+
},
|
|
376
|
+
setModifiedTime (path, date) {
|
|
377
|
+
getWriteFileSystem(path).updateTimes(path, date, date);
|
|
378
|
+
invokeDirectoryWatchers(path);
|
|
379
|
+
invokeFileWatchers(path, typescript_typescript.FileWatcherEventKind.Changed);
|
|
380
|
+
},
|
|
381
|
+
watchFile (path, callback) {
|
|
382
|
+
return createWatcher(fileWatcherCallbacksMap, path, callback);
|
|
383
|
+
},
|
|
384
|
+
watchDirectory (path, callback, recursive = false) {
|
|
385
|
+
return createWatcher(recursive ? recursiveDirectoryWatcherCallbacksMap : directoryWatcherCallbacksMap, path, callback);
|
|
386
|
+
},
|
|
387
|
+
setTimeout: (callback, timeout, ...args)=>{
|
|
388
|
+
const timeoutId = setImmediate(()=>{
|
|
389
|
+
callback(...args);
|
|
390
|
+
timeoutCallbacks.delete(timeoutId);
|
|
391
|
+
});
|
|
392
|
+
timeoutCallbacks.add(timeoutId);
|
|
393
|
+
return timeoutId;
|
|
394
|
+
},
|
|
395
|
+
clearTimeout: (timeoutId)=>{
|
|
396
|
+
clearImmediate(timeoutId);
|
|
397
|
+
timeoutCallbacks.delete(timeoutId);
|
|
398
|
+
},
|
|
399
|
+
async waitForQueued () {
|
|
400
|
+
while(timeoutCallbacks.size > 0)await new Promise((resolve)=>setImmediate(resolve));
|
|
401
|
+
isInitialRun = false;
|
|
402
|
+
},
|
|
403
|
+
invokeFileCreated (path) {
|
|
404
|
+
const normalizedPath = normalizeAndResolvePath(path);
|
|
405
|
+
invokeFileWatchers(path, typescript_typescript.FileWatcherEventKind.Created);
|
|
406
|
+
invokeDirectoryWatchers(normalizedPath);
|
|
407
|
+
system_deletedFiles.set(normalizedPath, false);
|
|
408
|
+
},
|
|
409
|
+
invokeFileChanged (path) {
|
|
410
|
+
const normalizedPath = normalizeAndResolvePath(path);
|
|
411
|
+
if (system_deletedFiles.get(normalizedPath) || !fileWatcherCallbacksMap.has(normalizedPath)) {
|
|
412
|
+
invokeFileWatchers(path, typescript_typescript.FileWatcherEventKind.Created);
|
|
413
|
+
invokeDirectoryWatchers(normalizedPath);
|
|
414
|
+
system_deletedFiles.set(normalizedPath, false);
|
|
415
|
+
} else invokeFileWatchers(path, typescript_typescript.FileWatcherEventKind.Changed);
|
|
416
|
+
},
|
|
417
|
+
invokeFileDeleted (path) {
|
|
418
|
+
const normalizedPath = normalizeAndResolvePath(path);
|
|
419
|
+
if (!system_deletedFiles.get(normalizedPath)) {
|
|
420
|
+
invokeFileWatchers(path, typescript_typescript.FileWatcherEventKind.Deleted);
|
|
421
|
+
invokeDirectoryWatchers(path);
|
|
422
|
+
system_deletedFiles.set(normalizedPath, true);
|
|
423
|
+
}
|
|
424
|
+
},
|
|
425
|
+
invalidateCache () {
|
|
426
|
+
realFileSystem.clearCache();
|
|
427
|
+
memFileSystem.clearCache();
|
|
428
|
+
passiveFileSystem.clearCache();
|
|
429
|
+
},
|
|
430
|
+
setArtifacts (nextArtifacts) {
|
|
431
|
+
artifacts = nextArtifacts;
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
function createWatcher(watchersMap, path, callback) {
|
|
435
|
+
const normalizedPath = normalizeAndResolvePath(path);
|
|
436
|
+
const watchers = watchersMap.get(normalizedPath) || [];
|
|
437
|
+
const nextWatchers = [
|
|
438
|
+
...watchers,
|
|
439
|
+
callback
|
|
440
|
+
];
|
|
441
|
+
watchersMap.set(normalizedPath, nextWatchers);
|
|
442
|
+
return {
|
|
443
|
+
close: ()=>{
|
|
444
|
+
const watchers = watchersMap.get(normalizedPath) || [];
|
|
445
|
+
const nextWatchers = watchers.filter((watcher)=>watcher !== callback);
|
|
446
|
+
if (nextWatchers.length > 0) watchersMap.set(normalizedPath, nextWatchers);
|
|
447
|
+
else watchersMap.delete(normalizedPath);
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
function invokeFileWatchers(path, event) {
|
|
452
|
+
const normalizedPath = normalizeAndResolvePath(path);
|
|
453
|
+
if (normalizedPath.endsWith('.js')) invokeFileWatchers(normalizedPath.slice(0, -3) + '.d.ts', event);
|
|
454
|
+
const fileWatcherCallbacks = fileWatcherCallbacksMap.get(normalizedPath);
|
|
455
|
+
if (fileWatcherCallbacks) fileWatcherCallbacks.forEach((fileWatcherCallback)=>fileWatcherCallback(forwardSlash(normalizedPath), event));
|
|
456
|
+
}
|
|
457
|
+
function invokeDirectoryWatchers(path) {
|
|
458
|
+
const normalizedPath = normalizeAndResolvePath(path);
|
|
459
|
+
const directory = (0, external_path_namespaceObject.dirname)(normalizedPath);
|
|
460
|
+
if (ignoredPaths.some((ignoredPath)=>forwardSlash(normalizedPath).includes(ignoredPath))) return;
|
|
461
|
+
const directoryWatcherCallbacks = directoryWatcherCallbacksMap.get(directory);
|
|
462
|
+
if (directoryWatcherCallbacks) directoryWatcherCallbacks.forEach((directoryWatcherCallback)=>directoryWatcherCallback(forwardSlash(normalizedPath)));
|
|
463
|
+
recursiveDirectoryWatcherCallbacksMap.forEach((recursiveDirectoryWatcherCallbacks, watchedDirectory)=>{
|
|
464
|
+
if (watchedDirectory === directory || directory.startsWith(watchedDirectory) && '/' === forwardSlash(directory)[watchedDirectory.length]) recursiveDirectoryWatcherCallbacks.forEach((recursiveDirectoryWatcherCallback)=>recursiveDirectoryWatcherCallback(forwardSlash(normalizedPath)));
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
function normalizeAndResolvePath(path) {
|
|
468
|
+
let normalizedPath = realFileSystem.normalizePath(path);
|
|
469
|
+
try {
|
|
470
|
+
normalizedPath = realFileSystem.realPath(normalizedPath);
|
|
471
|
+
} catch (error) {}
|
|
472
|
+
return normalizedPath;
|
|
473
|
+
}
|
|
474
|
+
function isArtifact(path) {
|
|
475
|
+
return (artifacts.dirs.some((dir)=>path.includes(dir)) || artifacts.files.some((file)=>path === file)) && artifacts.extensions.some((extension)=>path.endsWith(extension));
|
|
476
|
+
}
|
|
477
|
+
function getReadFileSystem(path) {
|
|
478
|
+
if (('readonly' === mode || 'write-tsbuildinfo' === mode) && isArtifact(path)) {
|
|
479
|
+
if (isInitialRun && !memFileSystem.exists(path) && passiveFileSystem.exists(path)) {
|
|
480
|
+
const stats = passiveFileSystem.readStats(path);
|
|
481
|
+
if (stats?.isFile()) {
|
|
482
|
+
const content = passiveFileSystem.readFile(path);
|
|
483
|
+
if (content) {
|
|
484
|
+
memFileSystem.writeFile(path, content);
|
|
485
|
+
memFileSystem.updateTimes(path, stats.atime, stats.mtime);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
return memFileSystem;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
return passiveFileSystem;
|
|
492
|
+
}
|
|
493
|
+
function getWriteFileSystem(path) {
|
|
494
|
+
if ('write-references' === mode || 'write-tsbuildinfo' === mode && path.endsWith('.tsbuildinfo') || 'write-dts' === mode && [
|
|
495
|
+
'.tsbuildinfo',
|
|
496
|
+
'.d.ts',
|
|
497
|
+
'.d.ts.map'
|
|
498
|
+
].some((suffix)=>path.endsWith(suffix))) return realFileSystem;
|
|
499
|
+
return passiveFileSystem;
|
|
500
|
+
}
|
|
501
|
+
let config_parsedConfig;
|
|
502
|
+
let parseConfigDiagnostics = [];
|
|
503
|
+
const parseConfigFileHost = {
|
|
504
|
+
...system,
|
|
505
|
+
onUnRecoverableConfigFileDiagnostic: (diagnostic)=>{
|
|
506
|
+
parseConfigDiagnostics.push(diagnostic);
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
function getUserProvidedConfigOverwrite() {
|
|
510
|
+
return worker_config_config.configOverwrite || {};
|
|
511
|
+
}
|
|
512
|
+
function getImplicitConfigOverwrite() {
|
|
513
|
+
const baseCompilerOptionsOverwrite = {
|
|
514
|
+
skipLibCheck: true,
|
|
515
|
+
sourceMap: false,
|
|
516
|
+
inlineSourceMap: false
|
|
517
|
+
};
|
|
518
|
+
switch(worker_config_config.mode){
|
|
519
|
+
case 'write-dts':
|
|
520
|
+
return {
|
|
521
|
+
compilerOptions: {
|
|
522
|
+
...baseCompilerOptionsOverwrite,
|
|
523
|
+
declaration: true,
|
|
524
|
+
emitDeclarationOnly: true,
|
|
525
|
+
noEmit: false
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
case 'write-tsbuildinfo':
|
|
529
|
+
case 'write-references':
|
|
530
|
+
return {
|
|
531
|
+
compilerOptions: {
|
|
532
|
+
...baseCompilerOptionsOverwrite,
|
|
533
|
+
declaration: true,
|
|
534
|
+
emitDeclarationOnly: false,
|
|
535
|
+
noEmit: false
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
return {
|
|
540
|
+
compilerOptions: baseCompilerOptionsOverwrite
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
function applyConfigOverwrite(baseConfig, ...overwriteConfigs) {
|
|
544
|
+
let config = baseConfig;
|
|
545
|
+
for (const overwriteConfig of overwriteConfigs)config = {
|
|
546
|
+
...config || {},
|
|
547
|
+
...overwriteConfig || {},
|
|
548
|
+
compilerOptions: {
|
|
549
|
+
...config?.compilerOptions || {},
|
|
550
|
+
...overwriteConfig?.compilerOptions || {}
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
return config;
|
|
554
|
+
}
|
|
555
|
+
function parseConfig(configFileName, configFileContext) {
|
|
556
|
+
const configFilePath = forwardSlash(configFileName);
|
|
557
|
+
const { config: baseConfig, error: readConfigError } = typescript_typescript.readConfigFile(configFilePath, parseConfigFileHost.readFile);
|
|
558
|
+
const overwrittenConfig = applyConfigOverwrite(baseConfig || {}, getImplicitConfigOverwrite(), getUserProvidedConfigOverwrite());
|
|
559
|
+
const parsedConfigFile = typescript_typescript.parseJsonConfigFileContent(overwrittenConfig, parseConfigFileHost, configFileContext);
|
|
560
|
+
return {
|
|
561
|
+
...parsedConfigFile,
|
|
562
|
+
options: {
|
|
563
|
+
...parsedConfigFile.options,
|
|
564
|
+
configFilePath: configFilePath
|
|
565
|
+
},
|
|
566
|
+
errors: readConfigError ? [
|
|
567
|
+
readConfigError
|
|
568
|
+
] : parsedConfigFile.errors
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
function getParsedConfig(force = false) {
|
|
572
|
+
if (!config_parsedConfig || force) {
|
|
573
|
+
config_parsedConfig = parseConfig(worker_config_config.configFile, worker_config_config.context);
|
|
574
|
+
parseConfigDiagnostics = config_parsedConfig.errors || [];
|
|
575
|
+
}
|
|
576
|
+
return config_parsedConfig;
|
|
577
|
+
}
|
|
578
|
+
function invalidateConfig() {
|
|
579
|
+
config_parsedConfig = void 0;
|
|
580
|
+
parseConfigDiagnostics = [];
|
|
581
|
+
}
|
|
582
|
+
function didConfigFileChanged({ changedFiles = [], deletedFiles = [] }) {
|
|
583
|
+
return [
|
|
584
|
+
...changedFiles,
|
|
585
|
+
...deletedFiles
|
|
586
|
+
].map((file)=>external_path_namespaceObject.normalize(file)).includes(external_path_namespaceObject.normalize(worker_config_config.configFile));
|
|
587
|
+
}
|
|
588
|
+
function didDependenciesProbablyChanged(dependencies, { changedFiles = [], deletedFiles = [] }) {
|
|
589
|
+
const didSomeDependencyHasBeenAdded = changedFiles.some((changeFile)=>!dependencies.files.includes(changeFile));
|
|
590
|
+
const didSomeDependencyHasBeenDeleted = deletedFiles.some((deletedFile)=>dependencies.files.includes(deletedFile));
|
|
591
|
+
return didSomeDependencyHasBeenAdded || didSomeDependencyHasBeenDeleted;
|
|
592
|
+
}
|
|
593
|
+
let dependencies_dependencies;
|
|
594
|
+
function getDependencies(force = false) {
|
|
595
|
+
if (!dependencies_dependencies || force) {
|
|
596
|
+
const parsedConfig = getParsedConfig();
|
|
597
|
+
dependencies_dependencies = getDependenciesWorker(parsedConfig, worker_config_config.context);
|
|
598
|
+
}
|
|
599
|
+
return dependencies_dependencies;
|
|
600
|
+
}
|
|
601
|
+
function invalidateDependencies() {
|
|
602
|
+
dependencies_dependencies = void 0;
|
|
603
|
+
}
|
|
604
|
+
function getDependenciesWorker(parsedConfig, configFileContext, processedConfigFiles = []) {
|
|
605
|
+
const files = new Set(parsedConfig.fileNames);
|
|
606
|
+
const configFilePath = parsedConfig.options.configFilePath;
|
|
607
|
+
if ('string' == typeof configFilePath) files.add(configFilePath);
|
|
608
|
+
const dirs = new Set(Object.keys(parsedConfig.wildcardDirectories || {}));
|
|
609
|
+
const excluded = new Set((parsedConfig.raw?.exclude || []).map((filePath)=>external_path_namespaceObject.resolve(configFileContext, filePath)));
|
|
610
|
+
for (const projectReference of parsedConfig.projectReferences || []){
|
|
611
|
+
const childConfigFilePath = typescript_typescript.resolveProjectReferencePath(projectReference);
|
|
612
|
+
const childConfigContext = external_path_namespaceObject.dirname(childConfigFilePath);
|
|
613
|
+
if (processedConfigFiles.includes(childConfigFilePath)) continue;
|
|
614
|
+
const childParsedConfig = parseConfig(childConfigFilePath, childConfigContext);
|
|
615
|
+
const childDependencies = getDependenciesWorker(childParsedConfig, childConfigContext, [
|
|
616
|
+
...processedConfigFiles,
|
|
617
|
+
childConfigFilePath
|
|
618
|
+
]);
|
|
619
|
+
childDependencies.files.forEach((file)=>{
|
|
620
|
+
files.add(file);
|
|
621
|
+
});
|
|
622
|
+
childDependencies.dirs.forEach((dir)=>{
|
|
623
|
+
dirs.add(dir);
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
const extensions = [
|
|
627
|
+
typescript_typescript.Extension.Ts,
|
|
628
|
+
typescript_typescript.Extension.Tsx,
|
|
629
|
+
typescript_typescript.Extension.Js,
|
|
630
|
+
typescript_typescript.Extension.Jsx,
|
|
631
|
+
typescript_typescript.Extension.TsBuildInfo
|
|
632
|
+
];
|
|
633
|
+
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)),
|
|
637
|
+
extensions: extensions
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
const get_dependencies_worker_getDependenciesWorker = (change)=>{
|
|
641
|
+
system.invalidateCache();
|
|
642
|
+
if (didConfigFileChanged(change) || didDependenciesProbablyChanged(getDependencies(), change)) {
|
|
643
|
+
invalidateConfig();
|
|
644
|
+
invalidateDependencies();
|
|
645
|
+
}
|
|
646
|
+
return getDependencies();
|
|
647
|
+
};
|
|
648
|
+
exposeRpc(get_dependencies_worker_getDependenciesWorker);
|
|
649
|
+
for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
650
|
+
Object.defineProperty(exports, '__esModule', {
|
|
651
|
+
value: true
|
|
652
|
+
});
|