fork-ts-checker-webpack-plugin 9.2.0 → 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/formatter/basic-formatter.js +2 -2
- package/lib/formatter/code-frame-formatter.d.ts +3 -2
- package/lib/formatter/code-frame-formatter.js +13 -3
- package/lib/formatter/formatter-config.js +2 -1
- package/lib/formatter/formatter-options.d.ts +1 -1
- package/lib/formatter/stats-formatter.js +3 -3
- package/lib/formatter/webpack-formatter.js +5 -9
- 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 +3 -12
- package/lib/hooks/tap-after-compile-to-get-issues.js +6 -27
- package/lib/hooks/tap-done-to-async-get-issues.js +12 -32
- package/lib/hooks/tap-error-to-log-message.js +5 -7
- package/lib/hooks/tap-start-to-run-workers.js +12 -22
- package/lib/issue/issue-webpack-error.js +4 -11
- package/lib/plugin-options.json +4 -8
- package/lib/plugin-state.d.ts +0 -1
- package/lib/plugin.js +23 -23
- package/lib/rpc/expose-rpc.js +5 -14
- package/lib/rpc/rpc-error.js +2 -0
- package/lib/rpc/rpc-worker.d.ts +1 -1
- package/lib/rpc/rpc-worker.js +7 -7
- package/lib/rpc/wrap-rpc.js +3 -12
- 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 +8 -18
- package/lib/typescript/type-script-worker-config.d.ts +2 -3
- package/lib/typescript/type-script-worker-config.js +23 -2
- 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 +63 -63
- package/lib/typescript/worker/lib/dependencies.d.ts +6 -1
- package/lib/typescript/worker/lib/dependencies.js +168 -43
- package/lib/typescript/worker/lib/diagnostics.d.ts +5 -4
- package/lib/typescript/worker/lib/diagnostics.js +44 -50
- 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 +12 -19
- package/lib/typescript/worker/lib/program/program.d.ts +6 -2
- package/lib/typescript/worker/lib/program/program.js +135 -24
- package/lib/typescript/worker/lib/program/solution-builder.d.ts +3 -1
- package/lib/typescript/worker/lib/program/solution-builder.js +41 -24
- 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/pool.d.ts +0 -1
- package/lib/utils/async/pool.js +12 -23
- 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/watch/inclusive-node-watch-file-system.d.ts +3 -0
- package/lib/watch/inclusive-node-watch-file-system.js +119 -111
- package/package.json +30 -38
- 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 -103
- package/lib/typescript/worker/lib/emit.d.ts +0 -2
- package/lib/typescript/worker/lib/emit.js +0 -12
- package/lib/typescript/worker/lib/file-system/file-system.d.ts +0 -17
- 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 -79
- 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 -201
- package/lib/typescript/worker/lib/host/compiler-host.d.ts +0 -2
- package/lib/typescript/worker/lib/host/compiler-host.js +0 -9
- package/lib/typescript/worker/lib/host/watch-compiler-host.d.ts +0 -2
- package/lib/typescript/worker/lib/host/watch-compiler-host.js +0 -19
- 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 -46
- package/lib/typescript/worker/lib/program/watch-program.d.ts +0 -3
- package/lib/typescript/worker/lib/program/watch-program.js +0 -50
- 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 -28
- package/lib/typescript/worker/lib/tsbuildinfo.d.ts +0 -4
- package/lib/typescript/worker/lib/tsbuildinfo.js +0 -105
|
@@ -1,80 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
const rpc_1 = require("../../rpc");
|
|
13
|
-
const
|
|
4
|
+
const api_1 = require("./lib/api");
|
|
14
5
|
const config_1 = require("./lib/config");
|
|
15
6
|
const dependencies_1 = require("./lib/dependencies");
|
|
16
7
|
const diagnostics_1 = require("./lib/diagnostics");
|
|
17
8
|
const performance_1 = require("./lib/performance");
|
|
18
9
|
const program_1 = require("./lib/program/program");
|
|
19
10
|
const solution_builder_1 = require("./lib/program/solution-builder");
|
|
20
|
-
const watch_program_1 = require("./lib/program/watch-program");
|
|
21
|
-
const system_1 = require("./lib/system");
|
|
22
|
-
const tracing_1 = require("./lib/tracing");
|
|
23
|
-
const tsbuildinfo_1 = require("./lib/tsbuildinfo");
|
|
24
11
|
const worker_config_1 = require("./lib/worker-config");
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
(0,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
(0, config_1.invalidateConfig)();
|
|
40
|
-
(0, dependencies_1.invalidateDependencies)();
|
|
41
|
-
(0, artifacts_1.invalidateArtifacts)();
|
|
42
|
-
if ((0, config_1.didRootFilesChanged)()) {
|
|
43
|
-
(0, watch_program_1.invalidateWatchProgramRootFileNames)();
|
|
12
|
+
// The native compiler runs in its own process, which must not outlive the worker.
|
|
13
|
+
// Signals are deliberately left alone: the compiler exits by itself once the
|
|
14
|
+
// worker's end of the pipe closes, and a signal handler couldn't run while the
|
|
15
|
+
// worker is blocked in a synchronous compiler call, so the plugin's SIGTERM
|
|
16
|
+
// wouldn't stop a busy worker.
|
|
17
|
+
process.on('exit', api_1.closeApi);
|
|
18
|
+
(0, api_1.interceptBuildOutputs)();
|
|
19
|
+
const getIssuesWorker = async (change) => {
|
|
20
|
+
try {
|
|
21
|
+
if ((0, config_1.didConfigFileChanged)((0, dependencies_1.getConfigFiles)(), change)) {
|
|
22
|
+
(0, config_1.invalidateConfig)();
|
|
23
|
+
(0, dependencies_1.invalidateDependencies)();
|
|
24
|
+
(0, diagnostics_1.invalidateDiagnostics)();
|
|
25
|
+
(0, program_1.invalidateProgramConfig)();
|
|
44
26
|
(0, solution_builder_1.invalidateSolutionBuilder)();
|
|
45
27
|
}
|
|
28
|
+
else if ((0, config_1.didDependenciesProbablyChanged)((0, dependencies_1.getDependencies)(), change)) {
|
|
29
|
+
const previousRootFiles = (0, config_1.getParsedConfig)().fileNames;
|
|
30
|
+
(0, config_1.invalidateConfig)();
|
|
31
|
+
(0, dependencies_1.invalidateDependencies)();
|
|
32
|
+
if ((0, config_1.didRootFilesChanged)(previousRootFiles)) {
|
|
33
|
+
(0, program_1.invalidateProgramRootFileNames)();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
(0, performance_1.resetPerformanceIfNeeded)();
|
|
37
|
+
const parseConfigIssues = (0, config_1.getParseConfigIssues)();
|
|
38
|
+
if (parseConfigIssues.length) {
|
|
39
|
+
// the program never sees this run's file changes, so it has to start afresh
|
|
40
|
+
// once the config can be parsed again
|
|
41
|
+
(0, program_1.invalidateProgramConfig)();
|
|
42
|
+
// report config parse issues and exit
|
|
43
|
+
return parseConfigIssues;
|
|
44
|
+
}
|
|
45
|
+
// use proper implementation based on the config
|
|
46
|
+
if (worker_config_1.config.build) {
|
|
47
|
+
(0, solution_builder_1.useSolutionBuilder)();
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
(0, program_1.useProgram)(change);
|
|
51
|
+
}
|
|
52
|
+
// the timings come from the compiler process too
|
|
53
|
+
(0, performance_1.printPerformanceMeasuresIfNeeded)();
|
|
46
54
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
(0, solution_builder_1.useSolutionBuilder)();
|
|
57
|
-
}
|
|
58
|
-
else if (watching) {
|
|
59
|
-
(0, watch_program_1.useWatchProgram)();
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
(0, program_1.useProgram)();
|
|
55
|
+
catch (error) {
|
|
56
|
+
// the compiler process may have died - start from scratch on the next run
|
|
57
|
+
(0, program_1.resetProgram)();
|
|
58
|
+
(0, solution_builder_1.resetSolutionBuilder)();
|
|
59
|
+
(0, api_1.closeApi)();
|
|
60
|
+
(0, config_1.invalidateConfig)();
|
|
61
|
+
(0, dependencies_1.invalidateDependencies)();
|
|
62
|
+
(0, diagnostics_1.invalidateDiagnostics)();
|
|
63
|
+
return (0, diagnostics_1.createIssuesFromDiagnostics)([(0, diagnostics_1.createCrashDiagnostic)(error)]);
|
|
63
64
|
}
|
|
64
|
-
// simulate file system events
|
|
65
|
-
(_a = change.changedFiles) === null || _a === void 0 ? void 0 : _a.forEach((changedFile) => {
|
|
66
|
-
system_1.system === null || system_1.system === void 0 ? void 0 : system_1.system.invokeFileChanged(changedFile);
|
|
67
|
-
});
|
|
68
|
-
(_b = change.deletedFiles) === null || _b === void 0 ? void 0 : _b.forEach((deletedFile) => {
|
|
69
|
-
system_1.system === null || system_1.system === void 0 ? void 0 : system_1.system.invokeFileDeleted(deletedFile);
|
|
70
|
-
});
|
|
71
|
-
// wait for all queued events to be processed
|
|
72
|
-
yield system_1.system.waitForQueued();
|
|
73
65
|
// retrieve all collected diagnostics as normalized issues
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
(0, performance_1.printPerformanceMeasuresIfNeeded)();
|
|
77
|
-
(0, performance_1.disablePerformanceIfNeeded)();
|
|
78
|
-
return issues;
|
|
79
|
-
});
|
|
66
|
+
return (0, diagnostics_1.getIssues)();
|
|
67
|
+
};
|
|
80
68
|
(0, rpc_1.exposeRpc)(getIssuesWorker);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { API, BuildOrchestrator, BuildOrchestratorOptions } from 'typescript/sync';
|
|
2
|
+
/**
|
|
3
|
+
* Makes the API keep build-mode outputs in memory in the `in-memory` mode. Only
|
|
4
|
+
* the worker that builds needs it: the callbacks are round trips from the native
|
|
5
|
+
* compiler, which a worker that only parses tsconfig files would pay for nothing.
|
|
6
|
+
* Call it before the first `getApi()`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function interceptBuildOutputs(): void;
|
|
9
|
+
/** Forgets the resolved symlinks, in case packages were relinked between builds. */
|
|
10
|
+
export declare function invalidateRealDirectories(): void;
|
|
11
|
+
export declare function getApi(): API;
|
|
12
|
+
export declare function createBuildOrchestrator(rootNames: readonly string[], options: BuildOrchestratorOptions): BuildOrchestrator;
|
|
13
|
+
export declare function closeApi(): void;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.interceptBuildOutputs = interceptBuildOutputs;
|
|
4
|
+
exports.invalidateRealDirectories = invalidateRealDirectories;
|
|
5
|
+
exports.getApi = getApi;
|
|
6
|
+
exports.createBuildOrchestrator = createBuildOrchestrator;
|
|
7
|
+
exports.closeApi = closeApi;
|
|
8
|
+
const in_memory_file_system_1 = require("./in-memory-file-system");
|
|
9
|
+
const typescript_1 = require("./typescript");
|
|
10
|
+
const worker_config_1 = require("./worker-config");
|
|
11
|
+
let api;
|
|
12
|
+
let invalidateRealDirectoriesOfApi;
|
|
13
|
+
let interceptsBuildOutputs = false;
|
|
14
|
+
/**
|
|
15
|
+
* Makes the API keep build-mode outputs in memory in the `in-memory` mode. Only
|
|
16
|
+
* the worker that builds needs it: the callbacks are round trips from the native
|
|
17
|
+
* compiler, which a worker that only parses tsconfig files would pay for nothing.
|
|
18
|
+
* Call it before the first `getApi()`.
|
|
19
|
+
*/
|
|
20
|
+
function interceptBuildOutputs() {
|
|
21
|
+
interceptsBuildOutputs = true;
|
|
22
|
+
}
|
|
23
|
+
/** Forgets the resolved symlinks, in case packages were relinked between builds. */
|
|
24
|
+
function invalidateRealDirectories() {
|
|
25
|
+
invalidateRealDirectoriesOfApi?.();
|
|
26
|
+
}
|
|
27
|
+
function getApi() {
|
|
28
|
+
if (!api) {
|
|
29
|
+
// only `build` lets TypeScript decide what to write, and the `write` mode lets it;
|
|
30
|
+
// the outputs live in the callbacks' closure, so they go with the API
|
|
31
|
+
const fileSystem = interceptsBuildOutputs && worker_config_1.config.build && worker_config_1.config.mode === 'in-memory'
|
|
32
|
+
? (0, in_memory_file_system_1.createInMemoryFileSystem)()
|
|
33
|
+
: undefined;
|
|
34
|
+
invalidateRealDirectoriesOfApi = fileSystem?.invalidateRealDirectories;
|
|
35
|
+
api = new typescript_1.typescriptSync.API({
|
|
36
|
+
cwd: worker_config_1.config.context,
|
|
37
|
+
fs: fileSystem?.callbacks,
|
|
38
|
+
collectTiming: worker_config_1.config.profile,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return api;
|
|
42
|
+
}
|
|
43
|
+
function createBuildOrchestrator(rootNames, options) {
|
|
44
|
+
const create = getApi()
|
|
45
|
+
.createBuildOrchestrator;
|
|
46
|
+
if (typeof create !== 'function') {
|
|
47
|
+
throw new Error('The installed TypeScript version does not support the `build` option (missing API#createBuildOrchestrator).');
|
|
48
|
+
}
|
|
49
|
+
return create.call(api, rootNames, options);
|
|
50
|
+
}
|
|
51
|
+
function closeApi() {
|
|
52
|
+
invalidateRealDirectoriesOfApi = undefined;
|
|
53
|
+
if (api) {
|
|
54
|
+
try {
|
|
55
|
+
api.close();
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
// the compiler process may already be gone
|
|
59
|
+
}
|
|
60
|
+
api = undefined;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { ParsedCommandLine } from 'typescript/sync';
|
|
2
2
|
import type { FilesChange } from '../../../files-change';
|
|
3
3
|
import type { FilesMatch } from '../../../files-match';
|
|
4
4
|
import type { Issue } from '../../../issue';
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* The implicit overrides that apply both to a program and to the build
|
|
7
|
+
* orchestrator, which only accepts a small set of options.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getSharedImplicitCompilerOptions(): {
|
|
10
|
+
sourceMap: boolean;
|
|
11
|
+
inlineSourceMap: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare function parseConfig(configFileName: string, configFileContext: string): ParsedCommandLine;
|
|
6
14
|
export declare function getParseConfigIssues(): Issue[];
|
|
7
|
-
export declare function getParsedConfig(
|
|
8
|
-
export declare function parseNextConfig(): readonly [ts.ParsedCommandLine | undefined, ts.ParsedCommandLine];
|
|
15
|
+
export declare function getParsedConfig(): ParsedCommandLine;
|
|
9
16
|
export declare function invalidateConfig(): void;
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function getConfigFilePathFromProgram(program: ts.Program): string;
|
|
12
|
-
export declare function getConfigFilePathFromBuilderProgram(builderProgram: ts.BuilderProgram): string;
|
|
13
|
-
export declare function didConfigFileChanged({ changedFiles, deletedFiles }: FilesChange): boolean;
|
|
17
|
+
export declare function didConfigFileChanged(configFiles: readonly string[], { changedFiles, deletedFiles }: FilesChange): boolean;
|
|
14
18
|
export declare function didDependenciesProbablyChanged(dependencies: FilesMatch, { changedFiles, deletedFiles }: FilesChange): boolean;
|
|
15
|
-
export declare function didRootFilesChanged(): boolean
|
|
19
|
+
export declare function didRootFilesChanged(previousRootFiles: readonly string[]): boolean;
|
|
@@ -32,69 +32,70 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
36
|
-
var t = {};
|
|
37
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
38
|
-
t[p] = s[p];
|
|
39
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
40
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
41
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
42
|
-
t[p[i]] = s[p[i]];
|
|
43
|
-
}
|
|
44
|
-
return t;
|
|
45
|
-
};
|
|
46
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getSharedImplicitCompilerOptions = getSharedImplicitCompilerOptions;
|
|
47
37
|
exports.parseConfig = parseConfig;
|
|
48
38
|
exports.getParseConfigIssues = getParseConfigIssues;
|
|
49
39
|
exports.getParsedConfig = getParsedConfig;
|
|
50
|
-
exports.parseNextConfig = parseNextConfig;
|
|
51
40
|
exports.invalidateConfig = invalidateConfig;
|
|
52
|
-
exports.getConfigFilePathFromCompilerOptions = getConfigFilePathFromCompilerOptions;
|
|
53
|
-
exports.getConfigFilePathFromProgram = getConfigFilePathFromProgram;
|
|
54
|
-
exports.getConfigFilePathFromBuilderProgram = getConfigFilePathFromBuilderProgram;
|
|
55
41
|
exports.didConfigFileChanged = didConfigFileChanged;
|
|
56
42
|
exports.didDependenciesProbablyChanged = didDependenciesProbablyChanged;
|
|
57
43
|
exports.didRootFilesChanged = didRootFilesChanged;
|
|
58
44
|
const path = __importStar(require("path"));
|
|
59
|
-
const
|
|
45
|
+
const api_1 = require("./api");
|
|
60
46
|
const diagnostics_1 = require("./diagnostics");
|
|
61
|
-
const system_1 = require("./system");
|
|
62
|
-
const typescript_1 = require("./typescript");
|
|
63
47
|
const worker_config_1 = require("./worker-config");
|
|
64
48
|
let parsedConfig;
|
|
65
49
|
let parseConfigDiagnostics = [];
|
|
66
|
-
// initialize ParseConfigFileHost
|
|
67
|
-
const parseConfigFileHost = Object.assign(Object.assign({}, system_1.system), { onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
|
|
68
|
-
parseConfigDiagnostics.push(diagnostic);
|
|
69
|
-
} });
|
|
70
50
|
function getUserProvidedConfigOverwrite() {
|
|
71
51
|
return worker_config_1.config.configOverwrite || {};
|
|
72
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* The implicit overrides that apply both to a program and to the build
|
|
55
|
+
* orchestrator, which only accepts a small set of options.
|
|
56
|
+
*/
|
|
57
|
+
function getSharedImplicitCompilerOptions() {
|
|
58
|
+
return {
|
|
59
|
+
sourceMap: false,
|
|
60
|
+
inlineSourceMap: false,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
73
63
|
function getImplicitConfigOverwrite() {
|
|
74
64
|
const baseCompilerOptionsOverwrite = {
|
|
75
65
|
skipLibCheck: true,
|
|
76
|
-
|
|
77
|
-
inlineSourceMap: false,
|
|
66
|
+
...getSharedImplicitCompilerOptions(),
|
|
78
67
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
68
|
+
if (worker_config_1.config.mode === 'write') {
|
|
69
|
+
return {
|
|
70
|
+
compilerOptions: {
|
|
71
|
+
...baseCompilerOptionsOverwrite,
|
|
72
|
+
declaration: true,
|
|
73
|
+
// `build` writes everything, like `tsc --build` - a program only the declarations
|
|
74
|
+
emitDeclarationOnly: !worker_config_1.config.build,
|
|
75
|
+
noEmit: false,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
89
78
|
}
|
|
90
79
|
return {
|
|
91
|
-
compilerOptions:
|
|
80
|
+
compilerOptions: {
|
|
81
|
+
...baseCompilerOptionsOverwrite,
|
|
82
|
+
// nothing is emitted, and without it emit-only option diagnostics
|
|
83
|
+
// (like TS5011 for a missing `rootDir`) are reported, unlike `tsc --noEmit`
|
|
84
|
+
noEmit: true,
|
|
85
|
+
},
|
|
92
86
|
};
|
|
93
87
|
}
|
|
94
88
|
function applyConfigOverwrite(baseConfig, ...overwriteConfigs) {
|
|
95
89
|
let config = baseConfig;
|
|
96
90
|
for (const overwriteConfig of overwriteConfigs) {
|
|
97
|
-
config =
|
|
91
|
+
config = {
|
|
92
|
+
...(config || {}),
|
|
93
|
+
...(overwriteConfig || {}),
|
|
94
|
+
compilerOptions: {
|
|
95
|
+
...(config?.compilerOptions || {}),
|
|
96
|
+
...(overwriteConfig?.compilerOptions || {}),
|
|
97
|
+
},
|
|
98
|
+
};
|
|
98
99
|
}
|
|
99
100
|
return config;
|
|
100
101
|
}
|
|
@@ -103,15 +104,27 @@ function applyConfigOverwrite(baseConfig, ...overwriteConfigs) {
|
|
|
103
104
|
* them would become invalid, so we remove them as well.
|
|
104
105
|
*/
|
|
105
106
|
function removeOrphanedSourceMapOptions(options) {
|
|
106
|
-
const { inlineSources, sourceRoot, mapRoot
|
|
107
|
-
return
|
|
107
|
+
const { inlineSources, sourceRoot, mapRoot, ...otherOptions } = options;
|
|
108
|
+
return {
|
|
109
|
+
...otherOptions,
|
|
110
|
+
...(options.sourceMap || options.inlineSourceMap ? { inlineSources, sourceRoot } : {}),
|
|
111
|
+
...(options.sourceMap || options.declarationMap ? { mapRoot } : {}),
|
|
112
|
+
};
|
|
108
113
|
}
|
|
109
114
|
function parseConfig(configFileName, configFileContext) {
|
|
110
|
-
const
|
|
111
|
-
const { config: baseConfig, error: readConfigError } =
|
|
115
|
+
const api = (0, api_1.getApi)();
|
|
116
|
+
const { config: baseConfig, error: readConfigError } = api.readConfigFile(configFileName);
|
|
112
117
|
const overwrittenConfig = applyConfigOverwrite(baseConfig || {}, getImplicitConfigOverwrite(), getUserProvidedConfigOverwrite());
|
|
113
|
-
|
|
114
|
-
|
|
118
|
+
// the API resolves relative paths against the config file's directory unless
|
|
119
|
+
// we give it an explicit base directory - that's what the `context` option is for
|
|
120
|
+
const parsedConfigFile = api.parseJsonConfigFileContent(overwrittenConfig, path.normalize(configFileContext) === path.normalize(path.dirname(configFileName))
|
|
121
|
+
? { configFileName }
|
|
122
|
+
: { configDirectory: configFileContext });
|
|
123
|
+
return {
|
|
124
|
+
...parsedConfigFile,
|
|
125
|
+
options: removeOrphanedSourceMapOptions(parsedConfigFile.options),
|
|
126
|
+
errors: readConfigError ? [readConfigError] : parsedConfigFile.errors,
|
|
127
|
+
};
|
|
115
128
|
}
|
|
116
129
|
function getParseConfigIssues() {
|
|
117
130
|
const issues = (0, diagnostics_1.createIssuesFromDiagnostics)(parseConfigDiagnostics);
|
|
@@ -122,42 +135,29 @@ function getParseConfigIssues() {
|
|
|
122
135
|
});
|
|
123
136
|
return issues;
|
|
124
137
|
}
|
|
125
|
-
function getParsedConfig(
|
|
126
|
-
if (!parsedConfig
|
|
138
|
+
function getParsedConfig() {
|
|
139
|
+
if (!parsedConfig) {
|
|
127
140
|
parsedConfig = parseConfig(worker_config_1.config.configFile, worker_config_1.config.context);
|
|
128
141
|
parseConfigDiagnostics = parsedConfig.errors || [];
|
|
129
142
|
}
|
|
130
143
|
return parsedConfig;
|
|
131
144
|
}
|
|
132
|
-
function parseNextConfig() {
|
|
133
|
-
const prevParsedConfig = parsedConfig;
|
|
134
|
-
const nextParsedConfig = getParsedConfig(true);
|
|
135
|
-
return [prevParsedConfig, nextParsedConfig];
|
|
136
|
-
}
|
|
137
145
|
function invalidateConfig() {
|
|
138
146
|
parsedConfig = undefined;
|
|
139
147
|
parseConfigDiagnostics = [];
|
|
140
148
|
}
|
|
141
|
-
function
|
|
142
|
-
return compilerOptions.configFilePath;
|
|
143
|
-
}
|
|
144
|
-
function getConfigFilePathFromProgram(program) {
|
|
145
|
-
return getConfigFilePathFromCompilerOptions(program.getCompilerOptions());
|
|
146
|
-
}
|
|
147
|
-
function getConfigFilePathFromBuilderProgram(builderProgram) {
|
|
148
|
-
return getConfigFilePathFromCompilerOptions(builderProgram.getProgram().getCompilerOptions());
|
|
149
|
-
}
|
|
150
|
-
function didConfigFileChanged({ changedFiles = [], deletedFiles = [] }) {
|
|
149
|
+
function didConfigFileChanged(configFiles, { changedFiles = [], deletedFiles = [] }) {
|
|
151
150
|
return [...changedFiles, ...deletedFiles]
|
|
152
151
|
.map((file) => path.normalize(file))
|
|
153
|
-
.
|
|
152
|
+
.some((file) => configFiles.includes(file));
|
|
154
153
|
}
|
|
155
154
|
function didDependenciesProbablyChanged(dependencies, { changedFiles = [], deletedFiles = [] }) {
|
|
156
155
|
const didSomeDependencyHasBeenAdded = changedFiles.some((changeFile) => !dependencies.files.includes(changeFile));
|
|
157
156
|
const didSomeDependencyHasBeenDeleted = deletedFiles.some((deletedFile) => dependencies.files.includes(deletedFile));
|
|
158
157
|
return didSomeDependencyHasBeenAdded || didSomeDependencyHasBeenDeleted;
|
|
159
158
|
}
|
|
160
|
-
function didRootFilesChanged() {
|
|
161
|
-
const
|
|
162
|
-
|
|
159
|
+
function didRootFilesChanged(previousRootFiles) {
|
|
160
|
+
const previous = new Set(previousRootFiles);
|
|
161
|
+
const next = new Set(getParsedConfig().fileNames);
|
|
162
|
+
return previous.size !== next.size || [...next].some((fileName) => !previous.has(fileName));
|
|
163
163
|
}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { FilesMatch } from '../../../files-match';
|
|
2
|
-
export declare function getDependencies(
|
|
2
|
+
export declare function getDependencies(): FilesMatch;
|
|
3
|
+
/**
|
|
4
|
+
* The root config file, the config file of every referenced project, and every
|
|
5
|
+
* local config file they extend.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getConfigFiles(): string[];
|
|
3
8
|
export declare function invalidateDependencies(): void;
|