fork-ts-checker-webpack-plugin 9.1.1 → 10.0.0-alpha.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 +23 -13
- package/lib/files-change.js +5 -6
- package/lib/formatter/basic-formatter.js +3 -4
- package/lib/formatter/code-frame-formatter.d.ts +3 -2
- package/lib/formatter/code-frame-formatter.js +14 -5
- package/lib/formatter/formatter-config.js +3 -3
- package/lib/formatter/formatter-options.d.ts +1 -1
- package/lib/formatter/stats-formatter.js +4 -5
- package/lib/formatter/webpack-formatter.js +6 -11
- package/lib/hooks/intercept-done-to-get-dev-server-tap.js +1 -2
- package/lib/hooks/report-issues.d.ts +8 -0
- package/lib/hooks/report-issues.js +22 -0
- package/lib/hooks/tap-after-compile-to-add-dependencies.js +4 -14
- package/lib/hooks/tap-after-compile-to-get-issues.js +7 -29
- package/lib/hooks/tap-after-environment-to-patch-watching.js +1 -2
- package/lib/hooks/tap-done-to-async-get-issues.js +13 -34
- package/lib/hooks/tap-error-to-log-message.js +6 -9
- package/lib/hooks/tap-start-to-run-workers.js +13 -24
- package/lib/hooks/tap-stop-to-terminate-workers.js +1 -2
- package/lib/infrastructure-logger.js +1 -2
- package/lib/issue/issue-config.js +1 -2
- package/lib/issue/issue-location.js +2 -3
- package/lib/issue/issue-match.js +3 -4
- package/lib/issue/issue-position.js +1 -2
- package/lib/issue/issue-predicate.js +2 -3
- package/lib/issue/issue-severity.js +2 -3
- package/lib/issue/issue-webpack-error.js +21 -18
- package/lib/issue/issue.js +2 -3
- package/lib/plugin-config.js +1 -2
- package/lib/plugin-hooks.d.ts +4 -4
- package/lib/plugin-hooks.js +1 -2
- package/lib/plugin-options.json +4 -8
- package/lib/plugin-pools.js +17 -7
- package/lib/plugin-state.d.ts +0 -1
- package/lib/plugin-state.js +1 -2
- package/lib/plugin.d.ts +2 -2
- package/lib/plugin.js +39 -24
- package/lib/rpc/expose-rpc.js +6 -16
- package/lib/rpc/rpc-error.js +2 -0
- package/lib/rpc/rpc-worker.d.ts +1 -2
- package/lib/rpc/rpc-worker.js +26 -17
- package/lib/rpc/wrap-rpc.d.ts +0 -1
- package/lib/rpc/wrap-rpc.js +4 -14
- package/lib/typescript/type-script-package.d.ts +4 -0
- package/lib/typescript/type-script-package.js +88 -0
- package/lib/typescript/type-script-support.js +26 -27
- package/lib/typescript/type-script-worker-config.d.ts +2 -3
- package/lib/typescript/type-script-worker-config.js +24 -4
- package/lib/typescript/type-script-worker-options.d.ts +4 -3
- package/lib/typescript/type-script-worker-options.js +4 -0
- package/lib/typescript/worker/get-dependencies-worker.js +15 -4
- package/lib/typescript/worker/get-issues-worker.d.ts +1 -1
- package/lib/typescript/worker/get-issues-worker.js +52 -64
- package/lib/typescript/worker/lib/api.d.ts +13 -0
- package/lib/typescript/worker/lib/api.js +62 -0
- package/lib/typescript/worker/lib/config.d.ts +13 -9
- package/lib/typescript/worker/lib/config.js +93 -65
- package/lib/typescript/worker/lib/dependencies.d.ts +6 -1
- package/lib/typescript/worker/lib/dependencies.js +187 -53
- package/lib/typescript/worker/lib/diagnostics.d.ts +5 -4
- package/lib/typescript/worker/lib/diagnostics.js +67 -51
- package/lib/typescript/worker/lib/in-memory-file-system.d.ts +14 -0
- package/lib/typescript/worker/lib/in-memory-file-system.js +140 -0
- package/lib/typescript/worker/lib/performance.d.ts +1 -2
- package/lib/typescript/worker/lib/performance.js +13 -21
- package/lib/typescript/worker/lib/program/program.d.ts +6 -2
- package/lib/typescript/worker/lib/program/program.js +136 -26
- package/lib/typescript/worker/lib/program/solution-builder.d.ts +3 -1
- package/lib/typescript/worker/lib/program/solution-builder.js +43 -27
- package/lib/typescript/worker/lib/typescript.d.ts +4 -2
- package/lib/typescript/worker/lib/typescript.js +69 -3
- package/lib/utils/async/abort-error.d.ts +0 -1
- package/lib/utils/async/abort-error.js +1 -1
- package/lib/utils/async/controlled-promise.js +1 -2
- package/lib/utils/async/is-pending.js +1 -2
- package/lib/utils/async/pool.d.ts +0 -1
- package/lib/utils/async/pool.js +13 -25
- package/lib/utils/async/wait.js +1 -2
- package/lib/utils/deep-merge.d.ts +5 -0
- package/lib/utils/deep-merge.js +56 -0
- package/lib/utils/path/format-file-path.d.ts +3 -0
- package/lib/utils/path/format-file-path.js +15 -0
- package/lib/utils/path/forward-slash.js +1 -2
- package/lib/utils/path/is-inside-another-path.js +1 -2
- package/lib/utils/path/relative-to-context.js +1 -2
- package/lib/watch/inclusive-node-watch-file-system.d.ts +3 -0
- package/lib/watch/inclusive-node-watch-file-system.js +121 -113
- package/lib/watch/watch-file-system.d.ts +0 -1
- package/package.json +43 -53
- package/lib/formatter/types/babel__code-frame.d.ts +0 -21
- package/lib/formatter/types/babel__code-frame.js +0 -7
- package/lib/typescript/worker/lib/artifacts.d.ts +0 -4
- package/lib/typescript/worker/lib/artifacts.js +0 -94
- package/lib/typescript/worker/lib/emit.d.ts +0 -2
- package/lib/typescript/worker/lib/emit.js +0 -13
- package/lib/typescript/worker/lib/file-system/file-system.d.ts +0 -18
- package/lib/typescript/worker/lib/file-system/file-system.js +0 -2
- package/lib/typescript/worker/lib/file-system/mem-file-system.d.ts +0 -5
- package/lib/typescript/worker/lib/file-system/mem-file-system.js +0 -78
- package/lib/typescript/worker/lib/file-system/passive-file-system.d.ts +0 -5
- package/lib/typescript/worker/lib/file-system/passive-file-system.js +0 -65
- package/lib/typescript/worker/lib/file-system/real-file-system.d.ts +0 -5
- package/lib/typescript/worker/lib/file-system/real-file-system.js +0 -191
- package/lib/typescript/worker/lib/host/compiler-host.d.ts +0 -2
- package/lib/typescript/worker/lib/host/compiler-host.js +0 -10
- package/lib/typescript/worker/lib/host/watch-compiler-host.d.ts +0 -2
- package/lib/typescript/worker/lib/host/watch-compiler-host.js +0 -20
- package/lib/typescript/worker/lib/host/watch-solution-builder-host.d.ts +0 -2
- package/lib/typescript/worker/lib/host/watch-solution-builder-host.js +0 -47
- package/lib/typescript/worker/lib/program/watch-program.d.ts +0 -3
- package/lib/typescript/worker/lib/program/watch-program.js +0 -51
- package/lib/typescript/worker/lib/system.d.ts +0 -19
- package/lib/typescript/worker/lib/system.js +0 -232
- package/lib/typescript/worker/lib/tracing.d.ts +0 -4
- package/lib/typescript/worker/lib/tracing.js +0 -29
- package/lib/typescript/worker/lib/tsbuildinfo.d.ts +0 -4
- package/lib/typescript/worker/lib/tsbuildinfo.js +0 -96
|
@@ -15,24 +15,40 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
36
|
+
exports.updateDiagnostics = updateDiagnostics;
|
|
37
|
+
exports.getIssues = getIssues;
|
|
38
|
+
exports.invalidateDiagnostics = invalidateDiagnostics;
|
|
39
|
+
exports.createCrashDiagnostic = createCrashDiagnostic;
|
|
40
|
+
exports.getDiagnosticsOfProgram = getDiagnosticsOfProgram;
|
|
41
|
+
exports.createIssuesFromDiagnostics = createIssuesFromDiagnostics;
|
|
27
42
|
const os = __importStar(require("os"));
|
|
43
|
+
const path = __importStar(require("path"));
|
|
28
44
|
const issue_1 = require("../../../issue");
|
|
29
|
-
const typescript_1 = require("./typescript");
|
|
30
45
|
const worker_config_1 = require("./worker-config");
|
|
46
|
+
// matches TypeScript's DiagnosticCategory
|
|
47
|
+
const DIAGNOSTIC_CATEGORY_WARNING = 0;
|
|
31
48
|
const diagnosticsPerConfigFile = new Map();
|
|
32
49
|
function updateDiagnostics(configFile, diagnostics) {
|
|
33
50
|
diagnosticsPerConfigFile.set(configFile, diagnostics);
|
|
34
51
|
}
|
|
35
|
-
exports.updateDiagnostics = updateDiagnostics;
|
|
36
52
|
function getIssues() {
|
|
37
53
|
const allDiagnostics = [];
|
|
38
54
|
diagnosticsPerConfigFile.forEach((diagnostics) => {
|
|
@@ -40,73 +56,73 @@ function getIssues() {
|
|
|
40
56
|
});
|
|
41
57
|
return createIssuesFromDiagnostics(allDiagnostics);
|
|
42
58
|
}
|
|
43
|
-
exports.getIssues = getIssues;
|
|
44
59
|
function invalidateDiagnostics() {
|
|
45
60
|
diagnosticsPerConfigFile.clear();
|
|
46
61
|
}
|
|
47
|
-
|
|
62
|
+
function createCrashDiagnostic(error) {
|
|
63
|
+
return {
|
|
64
|
+
pos: -1,
|
|
65
|
+
end: -1,
|
|
66
|
+
code: 1,
|
|
67
|
+
category: 1,
|
|
68
|
+
text: `TSC compiler crashed: ${error instanceof Error ? `${error.message}\n${error.stack}` : String(error)}`,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
48
71
|
function getDiagnosticsOfProgram(program) {
|
|
72
|
+
// errors aren't caught here: the worker reports them and resets the compiler
|
|
49
73
|
const programDiagnostics = [];
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
}
|
|
74
|
+
// compiler options diagnostics (e.g. a removed `target`)
|
|
75
|
+
programDiagnostics.push(...program.getProgramDiagnostics());
|
|
76
|
+
if (worker_config_1.config.diagnosticOptions.syntactic) {
|
|
77
|
+
programDiagnostics.push(...program.getSyntacticDiagnostics());
|
|
63
78
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
start: undefined,
|
|
73
|
-
length: undefined,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
79
|
+
if (worker_config_1.config.diagnosticOptions.global) {
|
|
80
|
+
programDiagnostics.push(...program.getGlobalDiagnostics());
|
|
81
|
+
}
|
|
82
|
+
if (worker_config_1.config.diagnosticOptions.semantic) {
|
|
83
|
+
programDiagnostics.push(...program.getSemanticDiagnostics());
|
|
84
|
+
}
|
|
85
|
+
if (worker_config_1.config.diagnosticOptions.declaration) {
|
|
86
|
+
programDiagnostics.push(...program.getDeclarationDiagnostics());
|
|
76
87
|
}
|
|
77
88
|
return programDiagnostics;
|
|
78
89
|
}
|
|
79
|
-
exports.getDiagnosticsOfProgram = getDiagnosticsOfProgram;
|
|
80
90
|
function createIssueFromDiagnostic(diagnostic) {
|
|
81
91
|
let file;
|
|
82
92
|
let location;
|
|
83
|
-
if (diagnostic.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const { line: endLine, character: endCharacter } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start + diagnostic.length);
|
|
93
|
+
if (diagnostic.fileName) {
|
|
94
|
+
// the API always returns forward-slashed paths
|
|
95
|
+
file = path.normalize(diagnostic.fileName);
|
|
96
|
+
if (diagnostic.startPosition && diagnostic.endPosition) {
|
|
88
97
|
location = {
|
|
89
98
|
start: {
|
|
90
|
-
line:
|
|
91
|
-
column:
|
|
99
|
+
line: diagnostic.startPosition.line + 1,
|
|
100
|
+
column: diagnostic.startPosition.character + 1,
|
|
92
101
|
},
|
|
93
102
|
end: {
|
|
94
|
-
line:
|
|
95
|
-
column:
|
|
103
|
+
line: diagnostic.endPosition.line + 1,
|
|
104
|
+
column: diagnostic.endPosition.character + 1,
|
|
96
105
|
},
|
|
97
106
|
};
|
|
98
107
|
}
|
|
99
108
|
}
|
|
100
109
|
return {
|
|
101
|
-
code: 'TS' + String(diagnostic.code),
|
|
110
|
+
code: (diagnostic.source || 'TS') + String(diagnostic.code),
|
|
102
111
|
// we don't handle Suggestion and Message diagnostics
|
|
103
|
-
severity: diagnostic.category ===
|
|
104
|
-
message:
|
|
112
|
+
severity: diagnostic.category === DIAGNOSTIC_CATEGORY_WARNING ? 'warning' : 'error',
|
|
113
|
+
message: flattenDiagnosticMessageText(diagnostic),
|
|
105
114
|
file,
|
|
106
115
|
location,
|
|
107
116
|
};
|
|
108
117
|
}
|
|
118
|
+
// same output as TypeScript's classic `flattenDiagnosticMessageText`
|
|
119
|
+
function flattenDiagnosticMessageText(diagnostic, indent = 0) {
|
|
120
|
+
let result = indent ? os.EOL + ' '.repeat(indent) + diagnostic.text : diagnostic.text;
|
|
121
|
+
for (const chained of diagnostic.messageChain ?? []) {
|
|
122
|
+
result += flattenDiagnosticMessageText(chained, indent + 1);
|
|
123
|
+
}
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
109
126
|
function createIssuesFromDiagnostics(diagnostics) {
|
|
110
127
|
return (0, issue_1.deduplicateAndSortIssues)(diagnostics.map((diagnostic) => createIssueFromDiagnostic(diagnostic)));
|
|
111
128
|
}
|
|
112
|
-
exports.createIssuesFromDiagnostics = createIssuesFromDiagnostics;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FileSystemCallbacks } from 'typescript/fs';
|
|
2
|
+
export interface InMemoryFileSystem {
|
|
3
|
+
callbacks: FileSystemCallbacks;
|
|
4
|
+
/** Forgets the resolved symlinks, in case packages were relinked between builds. */
|
|
5
|
+
invalidateRealDirectories(): void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* File system callbacks that keep everything the build orchestrator writes in
|
|
9
|
+
* memory, for `build: true` in the `in-memory` mode. Later projects read what
|
|
10
|
+
* earlier ones "wrote", and nothing reaches the user's disk. The callbacks are
|
|
11
|
+
* round trips from the native compiler, so reads of anything not written here
|
|
12
|
+
* are left to the compiler's own file system.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createInMemoryFileSystem(): InMemoryFileSystem;
|
|
@@ -0,0 +1,140 @@
|
|
|
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.createInMemoryFileSystem = createInMemoryFileSystem;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const forward_slash_1 = require("../../../utils/path/forward-slash");
|
|
40
|
+
const typescript_1 = require("./typescript");
|
|
41
|
+
/**
|
|
42
|
+
* File system callbacks that keep everything the build orchestrator writes in
|
|
43
|
+
* memory, for `build: true` in the `in-memory` mode. Later projects read what
|
|
44
|
+
* earlier ones "wrote", and nothing reaches the user's disk. The callbacks are
|
|
45
|
+
* round trips from the native compiler, so reads of anything not written here
|
|
46
|
+
* are left to the compiler's own file system.
|
|
47
|
+
*/
|
|
48
|
+
function createInMemoryFileSystem() {
|
|
49
|
+
const { serverFS } = typescript_1.typescriptFs;
|
|
50
|
+
// The compiler always gives the callbacks forward-slashed paths, on Windows too
|
|
51
|
+
// (`C:/project/lib/index.d.ts`), so paths are handled with `path.posix`.
|
|
52
|
+
// file content, by path
|
|
53
|
+
const outputs = new Map();
|
|
54
|
+
// file mtime, by path: the up-to-date check compares inputs with the .tsbuildinfo
|
|
55
|
+
// mtime, so reporting "now" would make every input look older
|
|
56
|
+
const outputTimes = new Map();
|
|
57
|
+
// the directories that contain the files
|
|
58
|
+
const outputDirectories = new Set();
|
|
59
|
+
// A cache of resolved symlinks (symlinked directory -> real directory), cleared
|
|
60
|
+
// before each build in case of relinks.
|
|
61
|
+
const realDirectories = new Map();
|
|
62
|
+
// The up-to-date check only compares inputs with .tsbuildinfo, never with the
|
|
63
|
+
// other outputs. A .tsbuildinfo left on disk by an earlier run in the `write` mode
|
|
64
|
+
// (or by `tsc --build`) could mark projects as built while their .d.ts files are
|
|
65
|
+
// missing from memory - so hide any .tsbuildinfo that wasn't written here.
|
|
66
|
+
const isHidden = (fileName) => fileName.endsWith('.tsbuildinfo') && !outputs.has(fileName);
|
|
67
|
+
// Outputs are keyed by their real path, but the compiler can also look them up
|
|
68
|
+
// through a symlink - typically a workspace package in node_modules whose
|
|
69
|
+
// `types` point at another project's in-memory .d.ts files.
|
|
70
|
+
const toOutputPath = (fileName) => {
|
|
71
|
+
if (outputs.has(fileName) || outputDirectories.has(fileName)) {
|
|
72
|
+
return fileName;
|
|
73
|
+
}
|
|
74
|
+
if (outputs.size === 0 || !fileName.includes('/node_modules/')) {
|
|
75
|
+
return fileName;
|
|
76
|
+
}
|
|
77
|
+
let directory = path.posix.dirname(fileName);
|
|
78
|
+
const rest = [path.posix.basename(fileName)];
|
|
79
|
+
while (!realDirectories.has(directory) && !fs.existsSync(directory)) {
|
|
80
|
+
const parent = path.posix.dirname(directory);
|
|
81
|
+
if (parent === directory) {
|
|
82
|
+
return fileName;
|
|
83
|
+
}
|
|
84
|
+
rest.unshift(path.posix.basename(directory));
|
|
85
|
+
directory = parent;
|
|
86
|
+
}
|
|
87
|
+
let realDirectory = realDirectories.get(directory);
|
|
88
|
+
if (realDirectory === undefined) {
|
|
89
|
+
realDirectory = (0, forward_slash_1.forwardSlash)(fs.realpathSync(directory));
|
|
90
|
+
realDirectories.set(directory, realDirectory);
|
|
91
|
+
}
|
|
92
|
+
return path.posix.join(realDirectory, ...rest);
|
|
93
|
+
};
|
|
94
|
+
// The API throws unless every callback is a function or a `serverFS` sentinel.
|
|
95
|
+
const callbacks = {
|
|
96
|
+
writeFile(fileName, content) {
|
|
97
|
+
outputs.set(fileName, content);
|
|
98
|
+
outputTimes.set(fileName, new Date());
|
|
99
|
+
for (let dir = path.posix.dirname(fileName); !outputDirectories.has(dir);) {
|
|
100
|
+
outputDirectories.add(dir);
|
|
101
|
+
const parent = path.posix.dirname(dir);
|
|
102
|
+
if (parent === dir)
|
|
103
|
+
break;
|
|
104
|
+
dir = parent;
|
|
105
|
+
}
|
|
106
|
+
return serverFS.noop;
|
|
107
|
+
},
|
|
108
|
+
readFile: (fileName) => isHidden(fileName) ? undefined : (outputs.get(toOutputPath(fileName)) ?? serverFS.useOS),
|
|
109
|
+
fileExists: (fileName) => isHidden(fileName) ? false : outputs.has(toOutputPath(fileName)) || serverFS.useOS,
|
|
110
|
+
directoryExists: (directoryName) => outputDirectories.has(toOutputPath(directoryName)) || serverFS.useOS,
|
|
111
|
+
stat: (fileName) => {
|
|
112
|
+
if (isHidden(fileName)) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
const outputPath = toOutputPath(fileName);
|
|
116
|
+
const content = outputs.get(outputPath);
|
|
117
|
+
return content === undefined
|
|
118
|
+
? serverFS.useOS
|
|
119
|
+
: {
|
|
120
|
+
mode: 0o100644,
|
|
121
|
+
size: Buffer.byteLength(content),
|
|
122
|
+
mtime: outputTimes.get(outputPath) ?? new Date(),
|
|
123
|
+
};
|
|
124
|
+
},
|
|
125
|
+
// never delete from the disk, where the user's real build output may be
|
|
126
|
+
removeFile: (fileName) => {
|
|
127
|
+
outputs.delete(fileName);
|
|
128
|
+
outputTimes.delete(fileName);
|
|
129
|
+
return serverFS.noop;
|
|
130
|
+
},
|
|
131
|
+
getAccessibleEntries: serverFS.useOS,
|
|
132
|
+
realpath: (fileName) => {
|
|
133
|
+
const outputPath = toOutputPath(fileName);
|
|
134
|
+
return outputs.has(outputPath) || outputDirectories.has(outputPath)
|
|
135
|
+
? outputPath
|
|
136
|
+
: serverFS.useOS;
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
return { callbacks, invalidateRealDirectories: () => realDirectories.clear() };
|
|
140
|
+
}
|
|
@@ -1,32 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
3
|
+
exports.resetPerformanceIfNeeded = resetPerformanceIfNeeded;
|
|
4
|
+
exports.printPerformanceMeasuresIfNeeded = printPerformanceMeasuresIfNeeded;
|
|
5
|
+
const api_1 = require("./api");
|
|
5
6
|
const worker_config_1 = require("./worker-config");
|
|
6
|
-
|
|
7
|
-
const performance = typescript_1.typescript.performance;
|
|
8
|
-
function enablePerformanceIfNeeded() {
|
|
9
|
-
var _a;
|
|
7
|
+
function resetPerformanceIfNeeded() {
|
|
10
8
|
if (worker_config_1.config.profile) {
|
|
11
|
-
(
|
|
9
|
+
(0, api_1.getApi)().resetTimingInfo();
|
|
12
10
|
}
|
|
13
11
|
}
|
|
14
|
-
exports.enablePerformanceIfNeeded = enablePerformanceIfNeeded;
|
|
15
|
-
function disablePerformanceIfNeeded() {
|
|
16
|
-
var _a;
|
|
17
|
-
if (worker_config_1.config.profile) {
|
|
18
|
-
(_a = performance === null || performance === void 0 ? void 0 : performance.disable) === null || _a === void 0 ? void 0 : _a.call(performance);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.disablePerformanceIfNeeded = disablePerformanceIfNeeded;
|
|
22
12
|
function printPerformanceMeasuresIfNeeded() {
|
|
23
|
-
var _a;
|
|
24
13
|
if (worker_config_1.config.profile) {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
const { totals } = (0, api_1.getApi)().getTimingInfo();
|
|
15
|
+
console.table({
|
|
16
|
+
Requests: totals.requestCount,
|
|
17
|
+
'Round trip (ms)': Math.round(totals.roundTripMs),
|
|
18
|
+
'Compiler (ms)': Math.round(totals.serverTimeMs),
|
|
19
|
+
'Transport (ms)': Math.round(totals.roundTripMs - totals.serverTimeMs),
|
|
20
|
+
'Sent (bytes)': totals.bytesSent,
|
|
21
|
+
'Received (bytes)': totals.bytesReceived,
|
|
28
22
|
});
|
|
29
|
-
console.table(measures);
|
|
30
23
|
}
|
|
31
24
|
}
|
|
32
|
-
exports.printPerformanceMeasuresIfNeeded = printPerformanceMeasuresIfNeeded;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function
|
|
1
|
+
import type { FilesChange } from '../../../../files-change';
|
|
2
|
+
export declare function useProgram(change: FilesChange): void;
|
|
3
|
+
export declare function invalidateProgramConfig(): void;
|
|
4
|
+
export declare function invalidateProgramRootFileNames(): void;
|
|
5
|
+
/** Forgets the program without talking to the compiler, which may be gone. */
|
|
6
|
+
export declare function resetProgram(): void;
|
|
@@ -1,37 +1,147 @@
|
|
|
1
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
36
|
+
exports.useProgram = useProgram;
|
|
37
|
+
exports.invalidateProgramConfig = invalidateProgramConfig;
|
|
38
|
+
exports.invalidateProgramRootFileNames = invalidateProgramRootFileNames;
|
|
39
|
+
exports.resetProgram = resetProgram;
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
const api_1 = require("../api");
|
|
4
43
|
const config_1 = require("../config");
|
|
5
44
|
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
45
|
const typescript_1 = require("../typescript");
|
|
10
|
-
|
|
11
|
-
let
|
|
12
|
-
|
|
46
|
+
const worker_config_1 = require("../worker-config");
|
|
47
|
+
let snapshot;
|
|
48
|
+
let programId;
|
|
49
|
+
let didRootFileNamesChange = false;
|
|
50
|
+
let didConfigChange = false;
|
|
51
|
+
function getProgramParams() {
|
|
13
52
|
const parsedConfig = (0, config_1.getParsedConfig)();
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
(0, tracing_1.startTracingIfNeeded)(parsedConfig.options);
|
|
19
|
-
program = typescript_1.typescript.createProgram({
|
|
20
|
-
rootNames: parsedConfig.fileNames,
|
|
21
|
-
options: parsedConfig.options,
|
|
53
|
+
return {
|
|
54
|
+
rootFiles: parsedConfig.fileNames,
|
|
55
|
+
compilerOptions: parsedConfig.options,
|
|
56
|
+
options: {
|
|
22
57
|
projectReferences: parsedConfig.projectReferences,
|
|
23
|
-
|
|
24
|
-
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function getFileNotifications({ changedFiles = [], deletedFiles = [], }) {
|
|
62
|
+
if (changedFiles.length === 0 && deletedFiles.length === 0) {
|
|
63
|
+
return undefined;
|
|
25
64
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
65
|
+
// webpack's watcher doesn't distinguish created from changed files
|
|
66
|
+
return {
|
|
67
|
+
changed: changedFiles.map((file) => path.resolve(file)),
|
|
68
|
+
deleted: deletedFiles.map((file) => path.resolve(file)),
|
|
69
|
+
};
|
|
29
70
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
71
|
+
function updateSnapshot(params) {
|
|
72
|
+
const previousSnapshot = snapshot;
|
|
73
|
+
// each snapshot must be derived from the previous one to keep the API's cache
|
|
74
|
+
const nextSnapshot = previousSnapshot
|
|
75
|
+
? previousSnapshot.update(params)
|
|
76
|
+
: (0, api_1.getApi)().createSnapshot(params);
|
|
77
|
+
previousSnapshot?.dispose();
|
|
78
|
+
snapshot = nextSnapshot;
|
|
79
|
+
return nextSnapshot;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Writes the program's .d.ts files, skipping unchanged ones: the program re-emits
|
|
83
|
+
* every file each time, and rewriting them all would trigger more watch events.
|
|
84
|
+
*/
|
|
85
|
+
function emitDeclarations(program) {
|
|
86
|
+
// `configOverwrite` can turn `emitDeclarationOnly` off, so don't rely on it
|
|
87
|
+
const { diagnostics, outputFiles } = program.emitToString(typescript_1.typescriptSync.EmitOnly.OnlyDts);
|
|
88
|
+
for (const [fileName, { text }] of outputFiles) {
|
|
89
|
+
let previousText;
|
|
90
|
+
try {
|
|
91
|
+
previousText = fs.readFileSync(fileName, 'utf8');
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
// not written yet
|
|
95
|
+
}
|
|
96
|
+
if (previousText !== text) {
|
|
97
|
+
fs.mkdirSync(path.dirname(fileName), { recursive: true });
|
|
98
|
+
fs.writeFileSync(fileName, text);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return diagnostics;
|
|
102
|
+
}
|
|
103
|
+
function useProgram(change) {
|
|
104
|
+
const fileNotifications = getFileNotifications(change);
|
|
105
|
+
if (programId === undefined) {
|
|
106
|
+
const nextSnapshot = updateSnapshot({ createPrograms: [getProgramParams()] });
|
|
107
|
+
programId = nextSnapshot.operation.createdPrograms[0].id;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
updateSnapshot({
|
|
111
|
+
// a config change can affect how any file is read, so start afresh
|
|
112
|
+
fileNotifications: didConfigChange ? { invalidateAll: true } : fileNotifications,
|
|
113
|
+
// reconfigure in place: `removePrograms` + `createPrograms` in a single
|
|
114
|
+
// update crashes the 7.1 beta compiler process
|
|
115
|
+
reconfigurePrograms: didRootFileNamesChange || didConfigChange
|
|
116
|
+
? [{ id: programId, ...getProgramParams() }]
|
|
117
|
+
: undefined,
|
|
118
|
+
// without it, a synthetic program keeps the old contents of changed files
|
|
119
|
+
ensurePrograms: true,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
didRootFileNamesChange = false;
|
|
123
|
+
didConfigChange = false;
|
|
124
|
+
const program = snapshot?.getProgram(programId);
|
|
125
|
+
if (!program) {
|
|
126
|
+
throw new Error('TypeScript program is missing from the snapshot.');
|
|
34
127
|
}
|
|
35
|
-
|
|
128
|
+
const diagnostics = (0, diagnostics_1.getDiagnosticsOfProgram)(program);
|
|
129
|
+
// `configOverwrite` can turn `declaration` off, as with `tsc`
|
|
130
|
+
if (worker_config_1.config.mode === 'write' && (0, config_1.getParsedConfig)().options.declaration) {
|
|
131
|
+
diagnostics.push(...emitDeclarations(program));
|
|
132
|
+
}
|
|
133
|
+
(0, diagnostics_1.updateDiagnostics)(worker_config_1.config.configFile, diagnostics);
|
|
134
|
+
}
|
|
135
|
+
function invalidateProgramConfig() {
|
|
136
|
+
didConfigChange = true;
|
|
137
|
+
}
|
|
138
|
+
function invalidateProgramRootFileNames() {
|
|
139
|
+
didRootFileNamesChange = true;
|
|
140
|
+
}
|
|
141
|
+
/** Forgets the program without talking to the compiler, which may be gone. */
|
|
142
|
+
function resetProgram() {
|
|
143
|
+
snapshot = undefined;
|
|
144
|
+
programId = undefined;
|
|
145
|
+
didRootFileNamesChange = false;
|
|
146
|
+
didConfigChange = false;
|
|
36
147
|
}
|
|
37
|
-
exports.invalidateProgram = invalidateProgram;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export declare function useSolutionBuilder(): void;
|
|
2
|
-
export declare function invalidateSolutionBuilder(
|
|
2
|
+
export declare function invalidateSolutionBuilder(): void;
|
|
3
|
+
/** Forgets the orchestrator without talking to the compiler, which may be gone. */
|
|
4
|
+
export declare function resetSolutionBuilder(): void;
|
|
@@ -1,39 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.useSolutionBuilder = useSolutionBuilder;
|
|
4
|
+
exports.invalidateSolutionBuilder = invalidateSolutionBuilder;
|
|
5
|
+
exports.resetSolutionBuilder = resetSolutionBuilder;
|
|
6
|
+
const api_1 = require("../api");
|
|
4
7
|
const config_1 = require("../config");
|
|
5
8
|
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
9
|
const worker_config_1 = require("../worker-config");
|
|
11
|
-
|
|
10
|
+
const OVERRIDABLE_COMPILER_OPTIONS = [
|
|
11
|
+
'incremental',
|
|
12
|
+
'assumeChangesOnlyAffectDirectDependencies',
|
|
13
|
+
'declaration',
|
|
14
|
+
'declarationMap',
|
|
15
|
+
'emitDeclarationOnly',
|
|
16
|
+
'sourceMap',
|
|
17
|
+
'inlineSourceMap',
|
|
18
|
+
'traceResolution',
|
|
19
|
+
];
|
|
20
|
+
/**
|
|
21
|
+
* The build orchestrator reads each project's tsconfig.json from disk and only
|
|
22
|
+
* accepts this small set of overrides, so the rest of `configOverwrite` can't apply.
|
|
23
|
+
*/
|
|
24
|
+
function getOverrideCompilerOptions() {
|
|
25
|
+
const userCompilerOptions = worker_config_1.config.configOverwrite?.compilerOptions || {};
|
|
26
|
+
const overrides = (0, config_1.getSharedImplicitCompilerOptions)();
|
|
27
|
+
for (const option of OVERRIDABLE_COMPILER_OPTIONS) {
|
|
28
|
+
if (option in userCompilerOptions) {
|
|
29
|
+
overrides[option] = userCompilerOptions[option];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return overrides;
|
|
33
|
+
}
|
|
12
34
|
let solutionBuilder;
|
|
13
35
|
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
36
|
if (!solutionBuilder) {
|
|
28
|
-
solutionBuilder =
|
|
29
|
-
|
|
37
|
+
solutionBuilder = (0, api_1.createBuildOrchestrator)([worker_config_1.config.configFile], {
|
|
38
|
+
cwd: worker_config_1.config.context,
|
|
39
|
+
overrideCompilerOptions: getOverrideCompilerOptions(),
|
|
40
|
+
});
|
|
30
41
|
}
|
|
42
|
+
// the orchestrator checks the file system for changes itself, but a
|
|
43
|
+
// `yarn install` can relink workspace packages between builds
|
|
44
|
+
(0, api_1.invalidateRealDirectories)();
|
|
45
|
+
const result = solutionBuilder.build();
|
|
46
|
+
(0, diagnostics_1.updateDiagnostics)(worker_config_1.config.configFile, result.diagnostics || []);
|
|
31
47
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
48
|
+
function invalidateSolutionBuilder() {
|
|
49
|
+
solutionBuilder?.dispose();
|
|
50
|
+
solutionBuilder = undefined;
|
|
51
|
+
}
|
|
52
|
+
/** Forgets the orchestrator without talking to the compiler, which may be gone. */
|
|
53
|
+
function resetSolutionBuilder() {
|
|
37
54
|
solutionBuilder = undefined;
|
|
38
55
|
}
|
|
39
|
-
exports.invalidateSolutionBuilder = invalidateSolutionBuilder;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import type * as
|
|
2
|
-
|
|
1
|
+
import type * as TypeScriptFs from 'typescript/fs';
|
|
2
|
+
import type * as TypeScriptSync from 'typescript/sync';
|
|
3
|
+
export declare const typescriptSync: typeof TypeScriptSync;
|
|
4
|
+
export declare const typescriptFs: typeof TypeScriptFs;
|