ts-checker-rspack-plugin 1.1.7 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -22
- package/lib/getDependenciesWorker.js +652 -0
- package/lib/getIssuesWorker.js +1095 -0
- package/lib/index.js +972 -4
- package/lib/issue/issue-config.d.ts +2 -0
- package/lib/issue/issue-options.d.ts +2 -0
- package/lib/issue/issue-severity.d.ts +4 -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/get-issues-worker.d.ts +2 -2
- package/lib/typescript/worker/lib/config.d.ts +2 -2
- package/lib/typescript/worker/lib/diagnostics.d.ts +3 -3
- 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 +12 -11
- 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 -59
- 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
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.realFileSystem = void 0;
|
|
7
|
-
const path_1 = require("path");
|
|
8
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
|
-
const existsCache = new Map();
|
|
10
|
-
const readStatsCache = new Map();
|
|
11
|
-
const readFileCache = new Map();
|
|
12
|
-
const readDirCache = new Map();
|
|
13
|
-
const realPathCache = new Map();
|
|
14
|
-
/**
|
|
15
|
-
* It's an implementation of the FileSystem interface which reads and writes directly to the real file system.
|
|
16
|
-
*/
|
|
17
|
-
exports.realFileSystem = {
|
|
18
|
-
exists(path) {
|
|
19
|
-
return exists(getRealPath(path));
|
|
20
|
-
},
|
|
21
|
-
readFile(path, encoding) {
|
|
22
|
-
return readFile(getRealPath(path), encoding);
|
|
23
|
-
},
|
|
24
|
-
readDir(path) {
|
|
25
|
-
return readDir(getRealPath(path));
|
|
26
|
-
},
|
|
27
|
-
readStats(path) {
|
|
28
|
-
return readStats(getRealPath(path));
|
|
29
|
-
},
|
|
30
|
-
realPath(path) {
|
|
31
|
-
return getRealPath(path);
|
|
32
|
-
},
|
|
33
|
-
normalizePath(path) {
|
|
34
|
-
return (0, path_1.normalize)(path);
|
|
35
|
-
},
|
|
36
|
-
writeFile(path, data) {
|
|
37
|
-
writeFile(getRealPath(path), data);
|
|
38
|
-
},
|
|
39
|
-
deleteFile(path) {
|
|
40
|
-
deleteFile(getRealPath(path));
|
|
41
|
-
},
|
|
42
|
-
createDir(path) {
|
|
43
|
-
createDir(getRealPath(path));
|
|
44
|
-
},
|
|
45
|
-
updateTimes(path, atime, mtime) {
|
|
46
|
-
updateTimes(getRealPath(path), atime, mtime);
|
|
47
|
-
},
|
|
48
|
-
clearCache() {
|
|
49
|
-
existsCache.clear();
|
|
50
|
-
readStatsCache.clear();
|
|
51
|
-
readFileCache.clear();
|
|
52
|
-
readDirCache.clear();
|
|
53
|
-
realPathCache.clear();
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
// read methods
|
|
57
|
-
function exists(path) {
|
|
58
|
-
const normalizedPath = (0, path_1.normalize)(path);
|
|
59
|
-
if (!existsCache.has(normalizedPath)) {
|
|
60
|
-
existsCache.set(normalizedPath, node_fs_1.default.existsSync(normalizedPath));
|
|
61
|
-
}
|
|
62
|
-
return !!existsCache.get(normalizedPath);
|
|
63
|
-
}
|
|
64
|
-
function readStats(path) {
|
|
65
|
-
const normalizedPath = (0, path_1.normalize)(path);
|
|
66
|
-
if (!readStatsCache.has(normalizedPath)) {
|
|
67
|
-
if (exists(normalizedPath)) {
|
|
68
|
-
readStatsCache.set(normalizedPath, node_fs_1.default.statSync(normalizedPath));
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return readStatsCache.get(normalizedPath);
|
|
72
|
-
}
|
|
73
|
-
function readFile(path, encoding) {
|
|
74
|
-
const normalizedPath = (0, path_1.normalize)(path);
|
|
75
|
-
if (!readFileCache.has(normalizedPath)) {
|
|
76
|
-
const stats = readStats(normalizedPath);
|
|
77
|
-
if (stats && stats.isFile()) {
|
|
78
|
-
readFileCache.set(normalizedPath, node_fs_1.default.readFileSync(normalizedPath, { encoding: encoding }).toString());
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
readFileCache.set(normalizedPath, undefined);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return readFileCache.get(normalizedPath);
|
|
85
|
-
}
|
|
86
|
-
function readDir(path) {
|
|
87
|
-
const normalizedPath = (0, path_1.normalize)(path);
|
|
88
|
-
if (!readDirCache.has(normalizedPath)) {
|
|
89
|
-
const stats = readStats(normalizedPath);
|
|
90
|
-
if (stats && stats.isDirectory()) {
|
|
91
|
-
readDirCache.set(normalizedPath, node_fs_1.default.readdirSync(normalizedPath, { withFileTypes: true }));
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
readDirCache.set(normalizedPath, []);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return readDirCache.get(normalizedPath) || [];
|
|
98
|
-
}
|
|
99
|
-
function getRealPath(path) {
|
|
100
|
-
const normalizedPath = (0, path_1.normalize)(path);
|
|
101
|
-
if (!realPathCache.has(normalizedPath)) {
|
|
102
|
-
let base = normalizedPath;
|
|
103
|
-
let nested = '';
|
|
104
|
-
while (base !== (0, path_1.dirname)(base)) {
|
|
105
|
-
if (exists(base)) {
|
|
106
|
-
realPathCache.set(normalizedPath, (0, path_1.normalize)((0, path_1.join)(node_fs_1.default.realpathSync(base), nested)));
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
nested = (0, path_1.join)((0, path_1.basename)(base), nested);
|
|
110
|
-
base = (0, path_1.dirname)(base);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return realPathCache.get(normalizedPath) || normalizedPath;
|
|
114
|
-
}
|
|
115
|
-
function createDir(path) {
|
|
116
|
-
const normalizedPath = (0, path_1.normalize)(path);
|
|
117
|
-
node_fs_1.default.mkdirSync(normalizedPath, { recursive: true });
|
|
118
|
-
// update cache
|
|
119
|
-
existsCache.set(normalizedPath, true);
|
|
120
|
-
if (readDirCache.has((0, path_1.dirname)(normalizedPath))) {
|
|
121
|
-
readDirCache.delete((0, path_1.dirname)(normalizedPath));
|
|
122
|
-
}
|
|
123
|
-
if (readStatsCache.has(normalizedPath)) {
|
|
124
|
-
readStatsCache.delete(normalizedPath);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
function writeFile(path, data) {
|
|
128
|
-
const normalizedPath = (0, path_1.normalize)(path);
|
|
129
|
-
if (!exists((0, path_1.dirname)(normalizedPath))) {
|
|
130
|
-
createDir((0, path_1.dirname)(normalizedPath));
|
|
131
|
-
}
|
|
132
|
-
node_fs_1.default.writeFileSync(normalizedPath, data);
|
|
133
|
-
// update cache
|
|
134
|
-
existsCache.set(normalizedPath, true);
|
|
135
|
-
if (readDirCache.has((0, path_1.dirname)(normalizedPath))) {
|
|
136
|
-
readDirCache.delete((0, path_1.dirname)(normalizedPath));
|
|
137
|
-
}
|
|
138
|
-
if (readStatsCache.has(normalizedPath)) {
|
|
139
|
-
readStatsCache.delete(normalizedPath);
|
|
140
|
-
}
|
|
141
|
-
if (readFileCache.has(normalizedPath)) {
|
|
142
|
-
readFileCache.delete(normalizedPath);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
function deleteFile(path) {
|
|
146
|
-
if (exists(path)) {
|
|
147
|
-
const normalizedPath = (0, path_1.normalize)(path);
|
|
148
|
-
node_fs_1.default.unlinkSync(normalizedPath);
|
|
149
|
-
// update cache
|
|
150
|
-
existsCache.set(normalizedPath, false);
|
|
151
|
-
if (readDirCache.has((0, path_1.dirname)(normalizedPath))) {
|
|
152
|
-
readDirCache.delete((0, path_1.dirname)(normalizedPath));
|
|
153
|
-
}
|
|
154
|
-
if (readStatsCache.has(normalizedPath)) {
|
|
155
|
-
readStatsCache.delete(normalizedPath);
|
|
156
|
-
}
|
|
157
|
-
if (readFileCache.has(normalizedPath)) {
|
|
158
|
-
readFileCache.delete(normalizedPath);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
function updateTimes(path, atime, mtime) {
|
|
163
|
-
if (exists(path)) {
|
|
164
|
-
const normalizedPath = (0, path_1.normalize)(path);
|
|
165
|
-
node_fs_1.default.utimesSync((0, path_1.normalize)(path), atime, mtime);
|
|
166
|
-
// update cache
|
|
167
|
-
if (readStatsCache.has(normalizedPath)) {
|
|
168
|
-
readStatsCache.delete(normalizedPath);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createCompilerHost = void 0;
|
|
4
|
-
const system_1 = require("../system");
|
|
5
|
-
const typescript_1 = require("../typescript");
|
|
6
|
-
function createCompilerHost(parsedConfig) {
|
|
7
|
-
const baseCompilerHost = typescript_1.typescript.createCompilerHost(parsedConfig.options);
|
|
8
|
-
return {
|
|
9
|
-
...baseCompilerHost,
|
|
10
|
-
fileExists: system_1.system.fileExists,
|
|
11
|
-
readFile: system_1.system.readFile,
|
|
12
|
-
directoryExists: system_1.system.directoryExists,
|
|
13
|
-
getDirectories: system_1.system.getDirectories,
|
|
14
|
-
realpath: system_1.system.realpath,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
exports.createCompilerHost = createCompilerHost;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createWatchCompilerHost = void 0;
|
|
4
|
-
const system_1 = require("../system");
|
|
5
|
-
const typescript_1 = require("../typescript");
|
|
6
|
-
function createWatchCompilerHost(parsedConfig, createProgram, reportDiagnostic, reportWatchStatus, afterProgramCreate) {
|
|
7
|
-
const baseWatchCompilerHost = typescript_1.typescript.createWatchCompilerHost(parsedConfig.fileNames, parsedConfig.options, system_1.system, createProgram, reportDiagnostic, reportWatchStatus, parsedConfig.projectReferences);
|
|
8
|
-
return {
|
|
9
|
-
...baseWatchCompilerHost,
|
|
10
|
-
createProgram(rootNames, options, compilerHost, oldProgram, configFileParsingDiagnostics, projectReferences) {
|
|
11
|
-
return baseWatchCompilerHost.createProgram(rootNames, options, compilerHost, oldProgram, configFileParsingDiagnostics, projectReferences);
|
|
12
|
-
},
|
|
13
|
-
afterProgramCreate(program) {
|
|
14
|
-
if (afterProgramCreate) {
|
|
15
|
-
afterProgramCreate(program);
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
onWatchStatusChange() {
|
|
19
|
-
// do nothing
|
|
20
|
-
},
|
|
21
|
-
watchFile: system_1.system.watchFile,
|
|
22
|
-
watchDirectory: system_1.system.watchDirectory,
|
|
23
|
-
setTimeout: system_1.system.setTimeout,
|
|
24
|
-
clearTimeout: system_1.system.clearTimeout,
|
|
25
|
-
fileExists: system_1.system.fileExists,
|
|
26
|
-
readFile: system_1.system.readFile,
|
|
27
|
-
directoryExists: system_1.system.directoryExists,
|
|
28
|
-
getDirectories: system_1.system.getDirectories,
|
|
29
|
-
realpath: system_1.system.realpath,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
exports.createWatchCompilerHost = createWatchCompilerHost;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createWatchSolutionBuilderHost = void 0;
|
|
4
|
-
const system_1 = require("../system");
|
|
5
|
-
const typescript_1 = require("../typescript");
|
|
6
|
-
const watch_compiler_host_1 = require("./watch-compiler-host");
|
|
7
|
-
function createWatchSolutionBuilderHost(parsedConfig, createProgram, reportDiagnostic, reportWatchStatus, reportSolutionBuilderStatus, afterProgramCreate, afterProgramEmitAndDiagnostics) {
|
|
8
|
-
const controlledWatchCompilerHost = (0, watch_compiler_host_1.createWatchCompilerHost)(parsedConfig, createProgram, reportDiagnostic, reportWatchStatus, afterProgramCreate);
|
|
9
|
-
return {
|
|
10
|
-
...controlledWatchCompilerHost,
|
|
11
|
-
reportDiagnostic(diagnostic) {
|
|
12
|
-
if (reportDiagnostic) {
|
|
13
|
-
reportDiagnostic(diagnostic);
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
reportSolutionBuilderStatus(diagnostic) {
|
|
17
|
-
if (reportSolutionBuilderStatus) {
|
|
18
|
-
reportSolutionBuilderStatus(diagnostic);
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
afterProgramEmitAndDiagnostics(program) {
|
|
22
|
-
if (afterProgramEmitAndDiagnostics) {
|
|
23
|
-
afterProgramEmitAndDiagnostics(program);
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
createDirectory(path) {
|
|
27
|
-
system_1.system.createDirectory(path);
|
|
28
|
-
},
|
|
29
|
-
writeFile(path, data) {
|
|
30
|
-
system_1.system.writeFile(path, data);
|
|
31
|
-
},
|
|
32
|
-
getModifiedTime(fileName) {
|
|
33
|
-
return system_1.system.getModifiedTime(fileName);
|
|
34
|
-
},
|
|
35
|
-
setModifiedTime(fileName, date) {
|
|
36
|
-
system_1.system.setModifiedTime(fileName, date);
|
|
37
|
-
},
|
|
38
|
-
deleteFile(fileName) {
|
|
39
|
-
system_1.system.deleteFile(fileName);
|
|
40
|
-
},
|
|
41
|
-
getParsedCommandLine(fileName) {
|
|
42
|
-
return typescript_1.typescript.getParsedCommandLineOfConfigFile(fileName, { skipLibCheck: true }, {
|
|
43
|
-
...system_1.system,
|
|
44
|
-
onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
|
|
45
|
-
if (reportDiagnostic) {
|
|
46
|
-
reportDiagnostic(diagnostic);
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
exports.createWatchSolutionBuilderHost = createWatchSolutionBuilderHost;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.printPerformanceMeasuresIfNeeded = exports.disablePerformanceIfNeeded = exports.enablePerformanceIfNeeded = void 0;
|
|
4
|
-
const typescript_1 = require("./typescript");
|
|
5
|
-
const worker_config_1 = require("./worker-config");
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
-
const performance = typescript_1.typescript.performance;
|
|
8
|
-
function enablePerformanceIfNeeded() {
|
|
9
|
-
if (worker_config_1.config.profile) {
|
|
10
|
-
performance?.enable?.();
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.enablePerformanceIfNeeded = enablePerformanceIfNeeded;
|
|
14
|
-
function disablePerformanceIfNeeded() {
|
|
15
|
-
if (worker_config_1.config.profile) {
|
|
16
|
-
performance?.disable?.();
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.disablePerformanceIfNeeded = disablePerformanceIfNeeded;
|
|
20
|
-
function printPerformanceMeasuresIfNeeded() {
|
|
21
|
-
if (worker_config_1.config.profile) {
|
|
22
|
-
const measures = {};
|
|
23
|
-
performance?.forEachMeasure?.((measureName, duration) => {
|
|
24
|
-
measures[measureName] = duration;
|
|
25
|
-
});
|
|
26
|
-
console.table(measures);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.printPerformanceMeasuresIfNeeded = printPerformanceMeasuresIfNeeded;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.invalidateProgram = exports.useProgram = void 0;
|
|
4
|
-
const config_1 = require("../config");
|
|
5
|
-
const diagnostics_1 = require("../diagnostics");
|
|
6
|
-
const emit_1 = require("../emit");
|
|
7
|
-
const compiler_host_1 = require("../host/compiler-host");
|
|
8
|
-
const tracing_1 = require("../tracing");
|
|
9
|
-
const typescript_1 = require("../typescript");
|
|
10
|
-
let compilerHost;
|
|
11
|
-
let program;
|
|
12
|
-
function useProgram() {
|
|
13
|
-
const parsedConfig = (0, config_1.getParsedConfig)();
|
|
14
|
-
if (!compilerHost) {
|
|
15
|
-
compilerHost = (0, compiler_host_1.createCompilerHost)(parsedConfig);
|
|
16
|
-
}
|
|
17
|
-
if (!program) {
|
|
18
|
-
(0, tracing_1.startTracingIfNeeded)(parsedConfig.options);
|
|
19
|
-
program = typescript_1.typescript.createProgram({
|
|
20
|
-
rootNames: parsedConfig.fileNames,
|
|
21
|
-
options: parsedConfig.options,
|
|
22
|
-
projectReferences: parsedConfig.projectReferences,
|
|
23
|
-
host: compilerHost,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
(0, diagnostics_1.updateDiagnostics)((0, config_1.getConfigFilePathFromProgram)(program), (0, diagnostics_1.getDiagnosticsOfProgram)(program));
|
|
27
|
-
(0, emit_1.emitDtsIfNeeded)(program);
|
|
28
|
-
(0, tracing_1.stopTracingIfNeeded)(program);
|
|
29
|
-
}
|
|
30
|
-
exports.useProgram = useProgram;
|
|
31
|
-
function invalidateProgram(withHost = false) {
|
|
32
|
-
if (withHost) {
|
|
33
|
-
compilerHost = undefined;
|
|
34
|
-
}
|
|
35
|
-
program = undefined;
|
|
36
|
-
}
|
|
37
|
-
exports.invalidateProgram = invalidateProgram;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.invalidateSolutionBuilder = exports.useSolutionBuilder = void 0;
|
|
4
|
-
const config_1 = require("../config");
|
|
5
|
-
const diagnostics_1 = require("../diagnostics");
|
|
6
|
-
const watch_solution_builder_host_1 = require("../host/watch-solution-builder-host");
|
|
7
|
-
const tracing_1 = require("../tracing");
|
|
8
|
-
const tsbuildinfo_1 = require("../tsbuildinfo");
|
|
9
|
-
const typescript_1 = require("../typescript");
|
|
10
|
-
const worker_config_1 = require("../worker-config");
|
|
11
|
-
let solutionBuilderHost;
|
|
12
|
-
let solutionBuilder;
|
|
13
|
-
function useSolutionBuilder() {
|
|
14
|
-
if (!solutionBuilderHost) {
|
|
15
|
-
const parsedConfig = (0, config_1.getParsedConfig)();
|
|
16
|
-
solutionBuilderHost = (0, watch_solution_builder_host_1.createWatchSolutionBuilderHost)(parsedConfig, (rootNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences) => {
|
|
17
|
-
if (compilerOptions) {
|
|
18
|
-
(0, tracing_1.startTracingIfNeeded)(compilerOptions);
|
|
19
|
-
}
|
|
20
|
-
return typescript_1.typescript.createSemanticDiagnosticsBuilderProgram(rootNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences);
|
|
21
|
-
}, undefined, undefined, undefined, undefined, (builderProgram) => {
|
|
22
|
-
(0, diagnostics_1.updateDiagnostics)((0, config_1.getConfigFilePathFromBuilderProgram)(builderProgram), (0, diagnostics_1.getDiagnosticsOfProgram)(builderProgram));
|
|
23
|
-
(0, tsbuildinfo_1.emitTsBuildInfoIfNeeded)(builderProgram);
|
|
24
|
-
(0, tracing_1.stopTracingIfNeeded)(builderProgram);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
if (!solutionBuilder) {
|
|
28
|
-
solutionBuilder = typescript_1.typescript.createSolutionBuilderWithWatch(solutionBuilderHost, [worker_config_1.config.configFile], { watch: true });
|
|
29
|
-
solutionBuilder.build();
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.useSolutionBuilder = useSolutionBuilder;
|
|
33
|
-
function invalidateSolutionBuilder(withHost = false) {
|
|
34
|
-
if (withHost) {
|
|
35
|
-
solutionBuilderHost = undefined;
|
|
36
|
-
}
|
|
37
|
-
solutionBuilder = undefined;
|
|
38
|
-
}
|
|
39
|
-
exports.invalidateSolutionBuilder = invalidateSolutionBuilder;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.invalidateWatchProgramRootFileNames = exports.invalidateWatchProgram = exports.useWatchProgram = void 0;
|
|
4
|
-
const config_1 = require("../config");
|
|
5
|
-
const dependencies_1 = require("../dependencies");
|
|
6
|
-
const diagnostics_1 = require("../diagnostics");
|
|
7
|
-
const emit_1 = require("../emit");
|
|
8
|
-
const watch_compiler_host_1 = require("../host/watch-compiler-host");
|
|
9
|
-
const tracing_1 = require("../tracing");
|
|
10
|
-
const tsbuildinfo_1 = require("../tsbuildinfo");
|
|
11
|
-
const typescript_1 = require("../typescript");
|
|
12
|
-
let watchCompilerHost;
|
|
13
|
-
let watchProgram;
|
|
14
|
-
let shouldUpdateRootFiles = false;
|
|
15
|
-
function useWatchProgram() {
|
|
16
|
-
if (!watchCompilerHost) {
|
|
17
|
-
const parsedConfig = (0, config_1.getParsedConfig)();
|
|
18
|
-
watchCompilerHost = (0, watch_compiler_host_1.createWatchCompilerHost)(parsedConfig, (rootNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences) => {
|
|
19
|
-
if (compilerOptions) {
|
|
20
|
-
(0, tracing_1.startTracingIfNeeded)(compilerOptions);
|
|
21
|
-
}
|
|
22
|
-
return typescript_1.typescript.createSemanticDiagnosticsBuilderProgram(rootNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences);
|
|
23
|
-
}, undefined, undefined, (builderProgram) => {
|
|
24
|
-
(0, diagnostics_1.updateDiagnostics)((0, config_1.getConfigFilePathFromBuilderProgram)(builderProgram), (0, diagnostics_1.getDiagnosticsOfProgram)(builderProgram));
|
|
25
|
-
(0, emit_1.emitDtsIfNeeded)(builderProgram);
|
|
26
|
-
(0, tsbuildinfo_1.emitTsBuildInfoIfNeeded)(builderProgram);
|
|
27
|
-
(0, tracing_1.stopTracingIfNeeded)(builderProgram);
|
|
28
|
-
});
|
|
29
|
-
watchProgram = undefined;
|
|
30
|
-
}
|
|
31
|
-
if (!watchProgram) {
|
|
32
|
-
watchProgram = typescript_1.typescript.createWatchProgram(watchCompilerHost);
|
|
33
|
-
}
|
|
34
|
-
if (shouldUpdateRootFiles) {
|
|
35
|
-
// we have to update root files manually as don't use config file as a program input
|
|
36
|
-
watchProgram.updateRootFileNames((0, dependencies_1.getDependencies)().files);
|
|
37
|
-
shouldUpdateRootFiles = false;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.useWatchProgram = useWatchProgram;
|
|
41
|
-
function invalidateWatchProgram(withHost = false) {
|
|
42
|
-
if (withHost) {
|
|
43
|
-
watchCompilerHost = undefined;
|
|
44
|
-
}
|
|
45
|
-
watchProgram = undefined;
|
|
46
|
-
}
|
|
47
|
-
exports.invalidateWatchProgram = invalidateWatchProgram;
|
|
48
|
-
function invalidateWatchProgramRootFileNames() {
|
|
49
|
-
shouldUpdateRootFiles = true;
|
|
50
|
-
}
|
|
51
|
-
exports.invalidateWatchProgramRootFileNames = invalidateWatchProgramRootFileNames;
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.system = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const forward_slash_1 = require("../../../utils/path/forward-slash");
|
|
6
|
-
const mem_file_system_1 = require("./file-system/mem-file-system");
|
|
7
|
-
const passive_file_system_1 = require("./file-system/passive-file-system");
|
|
8
|
-
const real_file_system_1 = require("./file-system/real-file-system");
|
|
9
|
-
const typescript_1 = require("./typescript");
|
|
10
|
-
const worker_config_1 = require("./worker-config");
|
|
11
|
-
const mode = worker_config_1.config.mode;
|
|
12
|
-
let artifacts = {
|
|
13
|
-
files: [],
|
|
14
|
-
dirs: [],
|
|
15
|
-
excluded: [],
|
|
16
|
-
extensions: [],
|
|
17
|
-
};
|
|
18
|
-
let isInitialRun = true;
|
|
19
|
-
// watchers
|
|
20
|
-
const fileWatcherCallbacksMap = new Map();
|
|
21
|
-
const directoryWatcherCallbacksMap = new Map();
|
|
22
|
-
const recursiveDirectoryWatcherCallbacksMap = new Map();
|
|
23
|
-
const deletedFiles = new Map();
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
-
const timeoutCallbacks = new Set();
|
|
26
|
-
// based on the ts.ignorePaths
|
|
27
|
-
const ignoredPaths = ['/node_modules/.', '/.git', '/.#'];
|
|
28
|
-
exports.system = {
|
|
29
|
-
...typescript_1.typescript.sys,
|
|
30
|
-
useCaseSensitiveFileNames: true,
|
|
31
|
-
realpath(path) {
|
|
32
|
-
return getReadFileSystem(path).realPath(path);
|
|
33
|
-
},
|
|
34
|
-
fileExists(path) {
|
|
35
|
-
const stats = getReadFileSystem(path).readStats(path);
|
|
36
|
-
return !!stats && stats.isFile();
|
|
37
|
-
},
|
|
38
|
-
readFile(path, encoding) {
|
|
39
|
-
return getReadFileSystem(path).readFile(path, encoding);
|
|
40
|
-
},
|
|
41
|
-
getFileSize(path) {
|
|
42
|
-
const stats = getReadFileSystem(path).readStats(path);
|
|
43
|
-
return stats ? stats.size : 0;
|
|
44
|
-
},
|
|
45
|
-
writeFile(path, data) {
|
|
46
|
-
getWriteFileSystem(path).writeFile(path, data);
|
|
47
|
-
exports.system.invokeFileChanged(path);
|
|
48
|
-
},
|
|
49
|
-
deleteFile(path) {
|
|
50
|
-
getWriteFileSystem(path).deleteFile(path);
|
|
51
|
-
exports.system.invokeFileDeleted(path);
|
|
52
|
-
},
|
|
53
|
-
directoryExists(path) {
|
|
54
|
-
return Boolean(getReadFileSystem(path).readStats(path)?.isDirectory());
|
|
55
|
-
},
|
|
56
|
-
createDirectory(path) {
|
|
57
|
-
getWriteFileSystem(path).createDir(path);
|
|
58
|
-
invokeDirectoryWatchers(path);
|
|
59
|
-
},
|
|
60
|
-
getDirectories(path) {
|
|
61
|
-
const dirents = getReadFileSystem(path).readDir(path);
|
|
62
|
-
return dirents
|
|
63
|
-
.filter((dirent) => dirent.isDirectory() ||
|
|
64
|
-
(dirent.isSymbolicLink() && exports.system.directoryExists((0, path_1.join)(path, dirent.name))))
|
|
65
|
-
.map((dirent) => dirent.name);
|
|
66
|
-
},
|
|
67
|
-
getModifiedTime(path) {
|
|
68
|
-
if (path === undefined) {
|
|
69
|
-
return undefined;
|
|
70
|
-
}
|
|
71
|
-
const stats = getReadFileSystem(path).readStats(path);
|
|
72
|
-
if (stats) {
|
|
73
|
-
return stats.mtime;
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
setModifiedTime(path, date) {
|
|
77
|
-
getWriteFileSystem(path).updateTimes(path, date, date);
|
|
78
|
-
invokeDirectoryWatchers(path);
|
|
79
|
-
invokeFileWatchers(path, typescript_1.typescript.FileWatcherEventKind.Changed);
|
|
80
|
-
},
|
|
81
|
-
watchFile(path, callback) {
|
|
82
|
-
return createWatcher(fileWatcherCallbacksMap, path, callback);
|
|
83
|
-
},
|
|
84
|
-
watchDirectory(path, callback, recursive = false) {
|
|
85
|
-
return createWatcher(recursive ? recursiveDirectoryWatcherCallbacksMap : directoryWatcherCallbacksMap, path, callback);
|
|
86
|
-
},
|
|
87
|
-
// use immediate instead of timeout to avoid waiting 250ms for batching files changes
|
|
88
|
-
setTimeout: (callback, timeout, ...args) => {
|
|
89
|
-
const timeoutId = setImmediate(() => {
|
|
90
|
-
callback(...args);
|
|
91
|
-
timeoutCallbacks.delete(timeoutId);
|
|
92
|
-
});
|
|
93
|
-
timeoutCallbacks.add(timeoutId);
|
|
94
|
-
return timeoutId;
|
|
95
|
-
},
|
|
96
|
-
clearTimeout: (timeoutId) => {
|
|
97
|
-
clearImmediate(timeoutId);
|
|
98
|
-
timeoutCallbacks.delete(timeoutId);
|
|
99
|
-
},
|
|
100
|
-
async waitForQueued() {
|
|
101
|
-
while (timeoutCallbacks.size > 0) {
|
|
102
|
-
await new Promise((resolve) => setImmediate(resolve));
|
|
103
|
-
}
|
|
104
|
-
isInitialRun = false;
|
|
105
|
-
},
|
|
106
|
-
invokeFileCreated(path) {
|
|
107
|
-
const normalizedPath = normalizeAndResolvePath(path);
|
|
108
|
-
invokeFileWatchers(path, typescript_1.typescript.FileWatcherEventKind.Created);
|
|
109
|
-
invokeDirectoryWatchers(normalizedPath);
|
|
110
|
-
deletedFiles.set(normalizedPath, false);
|
|
111
|
-
},
|
|
112
|
-
invokeFileChanged(path) {
|
|
113
|
-
const normalizedPath = normalizeAndResolvePath(path);
|
|
114
|
-
if (deletedFiles.get(normalizedPath) || !fileWatcherCallbacksMap.has(normalizedPath)) {
|
|
115
|
-
invokeFileWatchers(path, typescript_1.typescript.FileWatcherEventKind.Created);
|
|
116
|
-
invokeDirectoryWatchers(normalizedPath);
|
|
117
|
-
deletedFiles.set(normalizedPath, false);
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
invokeFileWatchers(path, typescript_1.typescript.FileWatcherEventKind.Changed);
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
invokeFileDeleted(path) {
|
|
124
|
-
const normalizedPath = normalizeAndResolvePath(path);
|
|
125
|
-
if (!deletedFiles.get(normalizedPath)) {
|
|
126
|
-
invokeFileWatchers(path, typescript_1.typescript.FileWatcherEventKind.Deleted);
|
|
127
|
-
invokeDirectoryWatchers(path);
|
|
128
|
-
deletedFiles.set(normalizedPath, true);
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
invalidateCache() {
|
|
132
|
-
real_file_system_1.realFileSystem.clearCache();
|
|
133
|
-
mem_file_system_1.memFileSystem.clearCache();
|
|
134
|
-
passive_file_system_1.passiveFileSystem.clearCache();
|
|
135
|
-
},
|
|
136
|
-
setArtifacts(nextArtifacts) {
|
|
137
|
-
artifacts = nextArtifacts;
|
|
138
|
-
},
|
|
139
|
-
};
|
|
140
|
-
function createWatcher(watchersMap, path, callback) {
|
|
141
|
-
const normalizedPath = normalizeAndResolvePath(path);
|
|
142
|
-
const watchers = watchersMap.get(normalizedPath) || [];
|
|
143
|
-
const nextWatchers = [...watchers, callback];
|
|
144
|
-
watchersMap.set(normalizedPath, nextWatchers);
|
|
145
|
-
return {
|
|
146
|
-
close: () => {
|
|
147
|
-
const watchers = watchersMap.get(normalizedPath) || [];
|
|
148
|
-
const nextWatchers = watchers.filter((watcher) => watcher !== callback);
|
|
149
|
-
if (nextWatchers.length > 0) {
|
|
150
|
-
watchersMap.set(normalizedPath, nextWatchers);
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
watchersMap.delete(normalizedPath);
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
function invokeFileWatchers(path, event) {
|
|
159
|
-
const normalizedPath = normalizeAndResolvePath(path);
|
|
160
|
-
if (normalizedPath.endsWith('.js')) {
|
|
161
|
-
// trigger relevant .d.ts file watcher - handles the case, when we have webpack watcher
|
|
162
|
-
// that points to a symlinked package
|
|
163
|
-
invokeFileWatchers(normalizedPath.slice(0, -3) + '.d.ts', event);
|
|
164
|
-
}
|
|
165
|
-
const fileWatcherCallbacks = fileWatcherCallbacksMap.get(normalizedPath);
|
|
166
|
-
if (fileWatcherCallbacks) {
|
|
167
|
-
// typescript expects normalized paths with posix forward slash
|
|
168
|
-
fileWatcherCallbacks.forEach((fileWatcherCallback) => fileWatcherCallback((0, forward_slash_1.forwardSlash)(normalizedPath), event));
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
function invokeDirectoryWatchers(path) {
|
|
172
|
-
const normalizedPath = normalizeAndResolvePath(path);
|
|
173
|
-
const directory = (0, path_1.dirname)(normalizedPath);
|
|
174
|
-
if (ignoredPaths.some((ignoredPath) => (0, forward_slash_1.forwardSlash)(normalizedPath).includes(ignoredPath))) {
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
const directoryWatcherCallbacks = directoryWatcherCallbacksMap.get(directory);
|
|
178
|
-
if (directoryWatcherCallbacks) {
|
|
179
|
-
directoryWatcherCallbacks.forEach((directoryWatcherCallback) => directoryWatcherCallback((0, forward_slash_1.forwardSlash)(normalizedPath)));
|
|
180
|
-
}
|
|
181
|
-
recursiveDirectoryWatcherCallbacksMap.forEach((recursiveDirectoryWatcherCallbacks, watchedDirectory) => {
|
|
182
|
-
if (watchedDirectory === directory ||
|
|
183
|
-
(directory.startsWith(watchedDirectory) &&
|
|
184
|
-
(0, forward_slash_1.forwardSlash)(directory)[watchedDirectory.length] === '/')) {
|
|
185
|
-
recursiveDirectoryWatcherCallbacks.forEach((recursiveDirectoryWatcherCallback) => recursiveDirectoryWatcherCallback((0, forward_slash_1.forwardSlash)(normalizedPath)));
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
function normalizeAndResolvePath(path) {
|
|
190
|
-
let normalizedPath = real_file_system_1.realFileSystem.normalizePath(path);
|
|
191
|
-
try {
|
|
192
|
-
normalizedPath = real_file_system_1.realFileSystem.realPath(normalizedPath);
|
|
193
|
-
}
|
|
194
|
-
catch (error) {
|
|
195
|
-
// ignore error - maybe file doesn't exist
|
|
196
|
-
}
|
|
197
|
-
return normalizedPath;
|
|
198
|
-
}
|
|
199
|
-
function isArtifact(path) {
|
|
200
|
-
return ((artifacts.dirs.some((dir) => path.includes(dir)) ||
|
|
201
|
-
artifacts.files.some((file) => path === file)) &&
|
|
202
|
-
artifacts.extensions.some((extension) => path.endsWith(extension)));
|
|
203
|
-
}
|
|
204
|
-
function getReadFileSystem(path) {
|
|
205
|
-
if ((mode === 'readonly' || mode === 'write-tsbuildinfo') && isArtifact(path)) {
|
|
206
|
-
if (isInitialRun && !mem_file_system_1.memFileSystem.exists(path) && passive_file_system_1.passiveFileSystem.exists(path)) {
|
|
207
|
-
// copy file to memory on initial run
|
|
208
|
-
const stats = passive_file_system_1.passiveFileSystem.readStats(path);
|
|
209
|
-
if (stats?.isFile()) {
|
|
210
|
-
const content = passive_file_system_1.passiveFileSystem.readFile(path);
|
|
211
|
-
if (content) {
|
|
212
|
-
mem_file_system_1.memFileSystem.writeFile(path, content);
|
|
213
|
-
mem_file_system_1.memFileSystem.updateTimes(path, stats.atime, stats.mtime);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
return mem_file_system_1.memFileSystem;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
return passive_file_system_1.passiveFileSystem;
|
|
220
|
-
}
|
|
221
|
-
function getWriteFileSystem(path) {
|
|
222
|
-
if (mode === 'write-references' ||
|
|
223
|
-
(mode === 'write-tsbuildinfo' && path.endsWith('.tsbuildinfo')) ||
|
|
224
|
-
(mode === 'write-dts' &&
|
|
225
|
-
['.tsbuildinfo', '.d.ts', '.d.ts.map'].some((suffix) => path.endsWith(suffix)))) {
|
|
226
|
-
return real_file_system_1.realFileSystem;
|
|
227
|
-
}
|
|
228
|
-
return passive_file_system_1.passiveFileSystem;
|
|
229
|
-
}
|