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
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.invalidateDependencies = exports.getDependencies = void 0;
|
|
27
|
-
const path = __importStar(require("path"));
|
|
28
|
-
const config_1 = require("./config");
|
|
29
|
-
const typescript_1 = require("./typescript");
|
|
30
|
-
const worker_config_1 = require("./worker-config");
|
|
31
|
-
let dependencies;
|
|
32
|
-
function getDependencies(force = false) {
|
|
33
|
-
if (!dependencies || force) {
|
|
34
|
-
const parsedConfig = (0, config_1.getParsedConfig)();
|
|
35
|
-
dependencies = getDependenciesWorker(parsedConfig, worker_config_1.config.context);
|
|
36
|
-
}
|
|
37
|
-
return dependencies;
|
|
38
|
-
}
|
|
39
|
-
exports.getDependencies = getDependencies;
|
|
40
|
-
function invalidateDependencies() {
|
|
41
|
-
dependencies = undefined;
|
|
42
|
-
}
|
|
43
|
-
exports.invalidateDependencies = invalidateDependencies;
|
|
44
|
-
function getDependenciesWorker(parsedConfig, configFileContext, processedConfigFiles = []) {
|
|
45
|
-
const files = new Set(parsedConfig.fileNames);
|
|
46
|
-
const configFilePath = parsedConfig.options.configFilePath;
|
|
47
|
-
if (typeof configFilePath === 'string') {
|
|
48
|
-
files.add(configFilePath);
|
|
49
|
-
}
|
|
50
|
-
const dirs = new Set(Object.keys(parsedConfig.wildcardDirectories || {}));
|
|
51
|
-
const excluded = new Set((parsedConfig.raw?.exclude || []).map((filePath) => path.resolve(configFileContext, filePath)));
|
|
52
|
-
for (const projectReference of parsedConfig.projectReferences || []) {
|
|
53
|
-
const childConfigFilePath = typescript_1.typescript.resolveProjectReferencePath(projectReference);
|
|
54
|
-
const childConfigContext = path.dirname(childConfigFilePath);
|
|
55
|
-
if (processedConfigFiles.includes(childConfigFilePath)) {
|
|
56
|
-
// handle circular dependencies
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
const childParsedConfig = (0, config_1.parseConfig)(childConfigFilePath, childConfigContext);
|
|
60
|
-
const childDependencies = getDependenciesWorker(childParsedConfig, childConfigContext, [
|
|
61
|
-
...processedConfigFiles,
|
|
62
|
-
childConfigFilePath,
|
|
63
|
-
]);
|
|
64
|
-
childDependencies.files.forEach((file) => {
|
|
65
|
-
files.add(file);
|
|
66
|
-
});
|
|
67
|
-
childDependencies.dirs.forEach((dir) => {
|
|
68
|
-
dirs.add(dir);
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
const extensions = [
|
|
72
|
-
typescript_1.typescript.Extension.Ts,
|
|
73
|
-
typescript_1.typescript.Extension.Tsx,
|
|
74
|
-
typescript_1.typescript.Extension.Js,
|
|
75
|
-
typescript_1.typescript.Extension.Jsx,
|
|
76
|
-
typescript_1.typescript.Extension.TsBuildInfo,
|
|
77
|
-
];
|
|
78
|
-
return {
|
|
79
|
-
files: Array.from(files).map((file) => path.normalize(file)),
|
|
80
|
-
dirs: Array.from(dirs).map((dir) => path.normalize(dir)),
|
|
81
|
-
excluded: Array.from(excluded).map((aPath) => path.normalize(aPath)),
|
|
82
|
-
extensions: extensions,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.createIssuesFromDiagnostics = exports.getDiagnosticsOfProgram = exports.invalidateDiagnostics = exports.getIssues = exports.updateDiagnostics = void 0;
|
|
27
|
-
const os = __importStar(require("os"));
|
|
28
|
-
const issue_1 = require("../../../issue");
|
|
29
|
-
const typescript_1 = require("./typescript");
|
|
30
|
-
const worker_config_1 = require("./worker-config");
|
|
31
|
-
const diagnosticsPerConfigFile = new Map();
|
|
32
|
-
function updateDiagnostics(configFile, diagnostics) {
|
|
33
|
-
diagnosticsPerConfigFile.set(configFile, diagnostics);
|
|
34
|
-
}
|
|
35
|
-
exports.updateDiagnostics = updateDiagnostics;
|
|
36
|
-
function getIssues() {
|
|
37
|
-
const allDiagnostics = [];
|
|
38
|
-
diagnosticsPerConfigFile.forEach((diagnostics) => {
|
|
39
|
-
allDiagnostics.push(...diagnostics);
|
|
40
|
-
});
|
|
41
|
-
return createIssuesFromDiagnostics(allDiagnostics);
|
|
42
|
-
}
|
|
43
|
-
exports.getIssues = getIssues;
|
|
44
|
-
function invalidateDiagnostics() {
|
|
45
|
-
diagnosticsPerConfigFile.clear();
|
|
46
|
-
}
|
|
47
|
-
exports.invalidateDiagnostics = invalidateDiagnostics;
|
|
48
|
-
function getDiagnosticsOfProgram(program) {
|
|
49
|
-
const programDiagnostics = [];
|
|
50
|
-
try {
|
|
51
|
-
if (worker_config_1.config.diagnosticOptions.syntactic) {
|
|
52
|
-
programDiagnostics.push(...program.getSyntacticDiagnostics());
|
|
53
|
-
}
|
|
54
|
-
if (worker_config_1.config.diagnosticOptions.global) {
|
|
55
|
-
programDiagnostics.push(...program.getGlobalDiagnostics());
|
|
56
|
-
}
|
|
57
|
-
if (worker_config_1.config.diagnosticOptions.semantic) {
|
|
58
|
-
programDiagnostics.push(...program.getSemanticDiagnostics());
|
|
59
|
-
}
|
|
60
|
-
if (worker_config_1.config.diagnosticOptions.declaration) {
|
|
61
|
-
programDiagnostics.push(...program.getDeclarationDiagnostics());
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
catch (e) {
|
|
65
|
-
if (e instanceof Error) {
|
|
66
|
-
programDiagnostics.push({
|
|
67
|
-
code: 1,
|
|
68
|
-
category: 1,
|
|
69
|
-
messageText: `TSC compiler crashed: ${e.message}
|
|
70
|
-
${e.stack}`,
|
|
71
|
-
file: undefined,
|
|
72
|
-
start: undefined,
|
|
73
|
-
length: undefined,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return programDiagnostics;
|
|
78
|
-
}
|
|
79
|
-
exports.getDiagnosticsOfProgram = getDiagnosticsOfProgram;
|
|
80
|
-
function createIssueFromDiagnostic(diagnostic) {
|
|
81
|
-
let file;
|
|
82
|
-
let location;
|
|
83
|
-
if (diagnostic.file) {
|
|
84
|
-
file = diagnostic.file.fileName;
|
|
85
|
-
if (diagnostic.start && diagnostic.length) {
|
|
86
|
-
const { line: startLine, character: startCharacter } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
|
87
|
-
const { line: endLine, character: endCharacter } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start + diagnostic.length);
|
|
88
|
-
location = {
|
|
89
|
-
start: {
|
|
90
|
-
line: startLine + 1,
|
|
91
|
-
column: startCharacter + 1,
|
|
92
|
-
},
|
|
93
|
-
end: {
|
|
94
|
-
line: endLine + 1,
|
|
95
|
-
column: endCharacter + 1,
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return {
|
|
101
|
-
code: 'TS' + String(diagnostic.code),
|
|
102
|
-
// we don't handle Suggestion and Message diagnostics
|
|
103
|
-
severity: diagnostic.category === 0 ? 'warning' : 'error',
|
|
104
|
-
message: typescript_1.typescript.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL),
|
|
105
|
-
file,
|
|
106
|
-
location,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
function createIssuesFromDiagnostics(diagnostics) {
|
|
110
|
-
return (0, issue_1.deduplicateAndSortIssues)(diagnostics.map((diagnostic) => createIssueFromDiagnostic(diagnostic)));
|
|
111
|
-
}
|
|
112
|
-
exports.createIssuesFromDiagnostics = createIssuesFromDiagnostics;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.emitDtsIfNeeded = void 0;
|
|
4
|
-
const config_1 = require("./config");
|
|
5
|
-
const worker_config_1 = require("./worker-config");
|
|
6
|
-
function emitDtsIfNeeded(program) {
|
|
7
|
-
const parsedConfig = (0, config_1.getParsedConfig)();
|
|
8
|
-
if (worker_config_1.config.mode === 'write-dts' && parsedConfig.options.declaration) {
|
|
9
|
-
// emit .d.ts files only
|
|
10
|
-
program.emit(undefined, undefined, undefined, true);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.emitDtsIfNeeded = emitDtsIfNeeded;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.memFileSystem = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const memfs_1 = require("memfs");
|
|
6
|
-
const real_file_system_1 = require("./real-file-system");
|
|
7
|
-
/**
|
|
8
|
-
* It's an implementation of FileSystem interface which reads and writes to the in-memory file system.
|
|
9
|
-
*/
|
|
10
|
-
exports.memFileSystem = {
|
|
11
|
-
...real_file_system_1.realFileSystem,
|
|
12
|
-
exists(path) {
|
|
13
|
-
return exists(real_file_system_1.realFileSystem.realPath(path));
|
|
14
|
-
},
|
|
15
|
-
readFile(path, encoding) {
|
|
16
|
-
return readFile(real_file_system_1.realFileSystem.realPath(path), encoding);
|
|
17
|
-
},
|
|
18
|
-
readDir(path) {
|
|
19
|
-
return readDir(real_file_system_1.realFileSystem.realPath(path));
|
|
20
|
-
},
|
|
21
|
-
readStats(path) {
|
|
22
|
-
return readStats(real_file_system_1.realFileSystem.realPath(path));
|
|
23
|
-
},
|
|
24
|
-
writeFile(path, data) {
|
|
25
|
-
writeFile(real_file_system_1.realFileSystem.realPath(path), data);
|
|
26
|
-
},
|
|
27
|
-
deleteFile(path) {
|
|
28
|
-
deleteFile(real_file_system_1.realFileSystem.realPath(path));
|
|
29
|
-
},
|
|
30
|
-
createDir(path) {
|
|
31
|
-
createDir(real_file_system_1.realFileSystem.realPath(path));
|
|
32
|
-
},
|
|
33
|
-
updateTimes(path, atime, mtime) {
|
|
34
|
-
updateTimes(real_file_system_1.realFileSystem.realPath(path), atime, mtime);
|
|
35
|
-
},
|
|
36
|
-
clearCache() {
|
|
37
|
-
real_file_system_1.realFileSystem.clearCache();
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
function exists(path) {
|
|
41
|
-
return memfs_1.fs.existsSync(real_file_system_1.realFileSystem.normalizePath(path));
|
|
42
|
-
}
|
|
43
|
-
function readStats(path) {
|
|
44
|
-
return exists(path) ? memfs_1.fs.statSync(real_file_system_1.realFileSystem.normalizePath(path)) : undefined;
|
|
45
|
-
}
|
|
46
|
-
function readFile(path, encoding) {
|
|
47
|
-
const stats = readStats(path);
|
|
48
|
-
if (stats && stats.isFile()) {
|
|
49
|
-
return memfs_1.fs
|
|
50
|
-
.readFileSync(real_file_system_1.realFileSystem.normalizePath(path), { encoding: encoding })
|
|
51
|
-
.toString();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function readDir(path) {
|
|
55
|
-
const stats = readStats(path);
|
|
56
|
-
if (stats && stats.isDirectory()) {
|
|
57
|
-
return memfs_1.fs.readdirSync(real_file_system_1.realFileSystem.normalizePath(path), {
|
|
58
|
-
withFileTypes: true,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return [];
|
|
62
|
-
}
|
|
63
|
-
function createDir(path) {
|
|
64
|
-
memfs_1.fs.mkdirSync(real_file_system_1.realFileSystem.normalizePath(path), { recursive: true });
|
|
65
|
-
}
|
|
66
|
-
function writeFile(path, data) {
|
|
67
|
-
if (!exists((0, path_1.dirname)(path))) {
|
|
68
|
-
createDir((0, path_1.dirname)(path));
|
|
69
|
-
}
|
|
70
|
-
memfs_1.fs.writeFileSync(real_file_system_1.realFileSystem.normalizePath(path), data);
|
|
71
|
-
}
|
|
72
|
-
function deleteFile(path) {
|
|
73
|
-
if (exists(path)) {
|
|
74
|
-
memfs_1.fs.unlinkSync(real_file_system_1.realFileSystem.normalizePath(path));
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
function updateTimes(path, atime, mtime) {
|
|
78
|
-
if (exists(path)) {
|
|
79
|
-
memfs_1.fs.utimesSync(real_file_system_1.realFileSystem.normalizePath(path), atime, mtime);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.passiveFileSystem = void 0;
|
|
4
|
-
const mem_file_system_1 = require("./mem-file-system");
|
|
5
|
-
const real_file_system_1 = require("./real-file-system");
|
|
6
|
-
/**
|
|
7
|
-
* It's an implementation of FileSystem interface which reads from the real file system, but write to the in-memory file system.
|
|
8
|
-
*/
|
|
9
|
-
exports.passiveFileSystem = {
|
|
10
|
-
...mem_file_system_1.memFileSystem,
|
|
11
|
-
exists(path) {
|
|
12
|
-
return exists(real_file_system_1.realFileSystem.realPath(path));
|
|
13
|
-
},
|
|
14
|
-
readFile(path, encoding) {
|
|
15
|
-
return readFile(real_file_system_1.realFileSystem.realPath(path), encoding);
|
|
16
|
-
},
|
|
17
|
-
readDir(path) {
|
|
18
|
-
return readDir(real_file_system_1.realFileSystem.realPath(path));
|
|
19
|
-
},
|
|
20
|
-
readStats(path) {
|
|
21
|
-
return readStats(real_file_system_1.realFileSystem.realPath(path));
|
|
22
|
-
},
|
|
23
|
-
realPath(path) {
|
|
24
|
-
return real_file_system_1.realFileSystem.realPath(path);
|
|
25
|
-
},
|
|
26
|
-
clearCache() {
|
|
27
|
-
real_file_system_1.realFileSystem.clearCache();
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
function exists(path) {
|
|
31
|
-
return real_file_system_1.realFileSystem.exists(path) || mem_file_system_1.memFileSystem.exists(path);
|
|
32
|
-
}
|
|
33
|
-
function readFile(path, encoding) {
|
|
34
|
-
const fsStats = real_file_system_1.realFileSystem.readStats(path);
|
|
35
|
-
const memStats = mem_file_system_1.memFileSystem.readStats(path);
|
|
36
|
-
if (fsStats && memStats) {
|
|
37
|
-
return fsStats.mtimeMs > memStats.mtimeMs
|
|
38
|
-
? real_file_system_1.realFileSystem.readFile(path, encoding)
|
|
39
|
-
: mem_file_system_1.memFileSystem.readFile(path, encoding);
|
|
40
|
-
}
|
|
41
|
-
else if (fsStats) {
|
|
42
|
-
return real_file_system_1.realFileSystem.readFile(path, encoding);
|
|
43
|
-
}
|
|
44
|
-
else if (memStats) {
|
|
45
|
-
return mem_file_system_1.memFileSystem.readFile(path, encoding);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function readDir(path) {
|
|
49
|
-
const fsDirents = real_file_system_1.realFileSystem.readDir(path);
|
|
50
|
-
const memDirents = mem_file_system_1.memFileSystem.readDir(path);
|
|
51
|
-
// merge list of dirents from fs and mem
|
|
52
|
-
return fsDirents
|
|
53
|
-
.filter((fsDirent) => !memDirents.some((memDirent) => memDirent.name === fsDirent.name))
|
|
54
|
-
.concat(memDirents);
|
|
55
|
-
}
|
|
56
|
-
function readStats(path) {
|
|
57
|
-
const fsStats = real_file_system_1.realFileSystem.readStats(path);
|
|
58
|
-
const memStats = mem_file_system_1.memFileSystem.readStats(path);
|
|
59
|
-
if (fsStats && memStats) {
|
|
60
|
-
return fsStats.mtimeMs > memStats.mtimeMs ? fsStats : memStats;
|
|
61
|
-
}
|
|
62
|
-
else if (fsStats) {
|
|
63
|
-
return fsStats;
|
|
64
|
-
}
|
|
65
|
-
else if (memStats) {
|
|
66
|
-
return memStats;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
@@ -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;
|