fork-ts-checker-webpack-plugin 6.2.9 → 6.2.10
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/ForkTsCheckerWebpackPlugin.js +1 -1
- package/lib/ForkTsCheckerWebpackPluginState.d.ts +3 -3
- package/lib/reporter/{Dependencies.d.ts → FilesMatch.d.ts} +2 -2
- package/lib/reporter/{Dependencies.js → FilesMatch.js} +0 -0
- package/lib/reporter/Report.d.ts +2 -2
- package/lib/reporter/index.d.ts +1 -1
- package/lib/reporter/reporter-rpc/ReporterRpcProcedure.d.ts +2 -2
- package/lib/typescript-reporter/extension/TypeScriptExtension.d.ts +2 -2
- package/lib/typescript-reporter/file-system/MemFileSystem.d.ts +8 -0
- package/lib/typescript-reporter/file-system/MemFileSystem.js +81 -0
- package/lib/typescript-reporter/file-system/PassiveFileSystem.d.ts +2 -2
- package/lib/typescript-reporter/file-system/PassiveFileSystem.js +10 -72
- package/lib/typescript-reporter/reporter/ControlledTypeScriptSystem.d.ts +2 -0
- package/lib/typescript-reporter/reporter/ControlledTypeScriptSystem.js +37 -12
- package/lib/typescript-reporter/reporter/TypeScriptConfigurationParser.d.ts +5 -3
- package/lib/typescript-reporter/reporter/TypeScriptConfigurationParser.js +107 -16
- package/lib/typescript-reporter/reporter/TypeScriptReporter.js +18 -4
- package/package.json +1 -1
|
@@ -65,7 +65,7 @@ exports.ForkTsCheckerWebpackPlugin = ForkTsCheckerWebpackPlugin;
|
|
|
65
65
|
/**
|
|
66
66
|
* Current version of the plugin
|
|
67
67
|
*/
|
|
68
|
-
ForkTsCheckerWebpackPlugin.version = '6.2.
|
|
68
|
+
ForkTsCheckerWebpackPlugin.version = '6.2.10'; // will be replaced by the @semantic-release/exec
|
|
69
69
|
/**
|
|
70
70
|
* Default pool for the plugin concurrency limit
|
|
71
71
|
*/
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Tap } from 'tapable';
|
|
2
|
-
import {
|
|
2
|
+
import { FilesMatch, Report } from './reporter';
|
|
3
3
|
import { Issue } from './issue';
|
|
4
4
|
interface ForkTsCheckerWebpackPluginState {
|
|
5
5
|
reportPromise: Promise<Report | undefined>;
|
|
6
6
|
issuesPromise: Promise<Issue[] | undefined>;
|
|
7
|
-
dependenciesPromise: Promise<
|
|
8
|
-
lastDependencies:
|
|
7
|
+
dependenciesPromise: Promise<FilesMatch | undefined>;
|
|
8
|
+
lastDependencies: FilesMatch | undefined;
|
|
9
9
|
watching: boolean;
|
|
10
10
|
initialized: boolean;
|
|
11
11
|
webpackDevServerDoneTap: Tap | undefined;
|
|
File without changes
|
package/lib/reporter/Report.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FilesMatch } from './FilesMatch';
|
|
2
2
|
import { Issue } from '../issue';
|
|
3
3
|
interface Report {
|
|
4
|
-
getDependencies(): Promise<
|
|
4
|
+
getDependencies(): Promise<FilesMatch>;
|
|
5
5
|
getIssues(): Promise<Issue[]>;
|
|
6
6
|
close(): Promise<void>;
|
|
7
7
|
}
|
package/lib/reporter/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ export * from './Report';
|
|
|
2
2
|
export * from './Reporter';
|
|
3
3
|
export * from './AggregatedReporter';
|
|
4
4
|
export * from './FilesChange';
|
|
5
|
-
export * from './
|
|
5
|
+
export * from './FilesMatch';
|
|
6
6
|
export * from './reporter-rpc/ReporterRpcClient';
|
|
7
7
|
export * from './reporter-rpc/ReporterRpcService';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { RpcProcedure } from '../../rpc';
|
|
2
2
|
import { FilesChange } from '../FilesChange';
|
|
3
3
|
import { Issue } from '../../issue';
|
|
4
|
-
import {
|
|
4
|
+
import { FilesMatch } from '../FilesMatch';
|
|
5
5
|
declare const configure: RpcProcedure<object, void>;
|
|
6
6
|
declare const getReport: RpcProcedure<FilesChange, void>;
|
|
7
|
-
declare const getDependencies: RpcProcedure<void,
|
|
7
|
+
declare const getDependencies: RpcProcedure<void, FilesMatch>;
|
|
8
8
|
declare const getIssues: RpcProcedure<void, Issue[]>;
|
|
9
9
|
declare const closeReport: RpcProcedure<void, void>;
|
|
10
10
|
export { configure, getReport, getDependencies, getIssues, closeReport };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
2
|
import { Issue } from '../../issue';
|
|
3
|
-
import {
|
|
3
|
+
import { FilesMatch } from '../../reporter';
|
|
4
4
|
interface TypeScriptHostExtension {
|
|
5
5
|
extendWatchSolutionBuilderHost?<TProgram extends ts.BuilderProgram, THost extends ts.SolutionBuilderWithWatchHost<TProgram>>(host: THost, parsedCommandLine?: ts.ParsedCommandLine): THost;
|
|
6
6
|
extendWatchCompilerHost?<TProgram extends ts.BuilderProgram, THost extends ts.WatchCompilerHost<TProgram>>(host: THost, parsedCommandLine?: ts.ParsedCommandLine): THost;
|
|
@@ -9,7 +9,7 @@ interface TypeScriptHostExtension {
|
|
|
9
9
|
}
|
|
10
10
|
interface TypeScriptReporterExtension {
|
|
11
11
|
extendIssues?(issues: Issue[]): Issue[];
|
|
12
|
-
extendDependencies?(dependencies:
|
|
12
|
+
extendDependencies?(dependencies: FilesMatch): FilesMatch;
|
|
13
13
|
}
|
|
14
14
|
interface TypeScriptExtension extends TypeScriptHostExtension, TypeScriptReporterExtension {
|
|
15
15
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FileSystem } from './FileSystem';
|
|
2
|
+
/**
|
|
3
|
+
* It's an implementation of FileSystem interface which reads and writes to the in-memory file system.
|
|
4
|
+
*
|
|
5
|
+
* @param realFileSystem
|
|
6
|
+
*/
|
|
7
|
+
declare function createMemFileSystem(realFileSystem: FileSystem): FileSystem;
|
|
8
|
+
export { createMemFileSystem };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const path_1 = require("path");
|
|
4
|
+
const memfs_1 = require("memfs");
|
|
5
|
+
/**
|
|
6
|
+
* It's an implementation of FileSystem interface which reads and writes to the in-memory file system.
|
|
7
|
+
*
|
|
8
|
+
* @param realFileSystem
|
|
9
|
+
*/
|
|
10
|
+
function createMemFileSystem(realFileSystem) {
|
|
11
|
+
function exists(path) {
|
|
12
|
+
return memfs_1.fs.existsSync(realFileSystem.normalizePath(path));
|
|
13
|
+
}
|
|
14
|
+
function readStats(path) {
|
|
15
|
+
return exists(path) ? memfs_1.fs.statSync(realFileSystem.normalizePath(path)) : undefined;
|
|
16
|
+
}
|
|
17
|
+
function readFile(path, encoding) {
|
|
18
|
+
const stats = readStats(path);
|
|
19
|
+
if (stats && stats.isFile()) {
|
|
20
|
+
return memfs_1.fs
|
|
21
|
+
.readFileSync(realFileSystem.normalizePath(path), { encoding: encoding })
|
|
22
|
+
.toString();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function readDir(path) {
|
|
26
|
+
const stats = readStats(path);
|
|
27
|
+
if (stats && stats.isDirectory()) {
|
|
28
|
+
return memfs_1.fs.readdirSync(realFileSystem.normalizePath(path), {
|
|
29
|
+
withFileTypes: true,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
function createDir(path) {
|
|
35
|
+
memfs_1.fs.mkdirSync(realFileSystem.normalizePath(path), { recursive: true });
|
|
36
|
+
}
|
|
37
|
+
function writeFile(path, data) {
|
|
38
|
+
if (!exists(path_1.dirname(path))) {
|
|
39
|
+
createDir(path_1.dirname(path));
|
|
40
|
+
}
|
|
41
|
+
memfs_1.fs.writeFileSync(realFileSystem.normalizePath(path), data);
|
|
42
|
+
}
|
|
43
|
+
function deleteFile(path) {
|
|
44
|
+
if (exists(path)) {
|
|
45
|
+
memfs_1.fs.unlinkSync(realFileSystem.normalizePath(path));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function updateTimes(path, atime, mtime) {
|
|
49
|
+
if (exists(path)) {
|
|
50
|
+
memfs_1.fs.utimesSync(realFileSystem.normalizePath(path), atime, mtime);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return Object.assign(Object.assign({}, realFileSystem), { exists(path) {
|
|
54
|
+
return exists(realFileSystem.realPath(path));
|
|
55
|
+
},
|
|
56
|
+
readFile(path, encoding) {
|
|
57
|
+
return readFile(realFileSystem.realPath(path), encoding);
|
|
58
|
+
},
|
|
59
|
+
readDir(path) {
|
|
60
|
+
return readDir(realFileSystem.realPath(path));
|
|
61
|
+
},
|
|
62
|
+
readStats(path) {
|
|
63
|
+
return readStats(realFileSystem.realPath(path));
|
|
64
|
+
},
|
|
65
|
+
writeFile(path, data) {
|
|
66
|
+
writeFile(realFileSystem.realPath(path), data);
|
|
67
|
+
},
|
|
68
|
+
deleteFile(path) {
|
|
69
|
+
deleteFile(realFileSystem.realPath(path));
|
|
70
|
+
},
|
|
71
|
+
createDir(path) {
|
|
72
|
+
createDir(realFileSystem.realPath(path));
|
|
73
|
+
},
|
|
74
|
+
updateTimes(path, atime, mtime) {
|
|
75
|
+
updateTimes(realFileSystem.realPath(path), atime, mtime);
|
|
76
|
+
},
|
|
77
|
+
clearCache() {
|
|
78
|
+
realFileSystem.clearCache();
|
|
79
|
+
} });
|
|
80
|
+
}
|
|
81
|
+
exports.createMemFileSystem = createMemFileSystem;
|
|
@@ -2,8 +2,8 @@ import { FileSystem } from './FileSystem';
|
|
|
2
2
|
/**
|
|
3
3
|
* It's an implementation of FileSystem interface which reads from the real file system, but write to the in-memory file system.
|
|
4
4
|
*
|
|
5
|
-
* @param
|
|
5
|
+
* @param memFileSystem
|
|
6
6
|
* @param realFileSystem
|
|
7
7
|
*/
|
|
8
|
-
declare function createPassiveFileSystem(
|
|
8
|
+
declare function createPassiveFileSystem(memFileSystem: FileSystem, realFileSystem: FileSystem): FileSystem;
|
|
9
9
|
export { createPassiveFileSystem };
|
|
@@ -1,59 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const path_1 = require("path");
|
|
4
|
-
const memfs_1 = require("memfs");
|
|
5
3
|
/**
|
|
6
4
|
* It's an implementation of FileSystem interface which reads from the real file system, but write to the in-memory file system.
|
|
7
5
|
*
|
|
8
|
-
* @param
|
|
6
|
+
* @param memFileSystem
|
|
9
7
|
* @param realFileSystem
|
|
10
8
|
*/
|
|
11
|
-
function createPassiveFileSystem(
|
|
12
|
-
function normalizePath(path) {
|
|
13
|
-
return caseSensitive ? path_1.normalize(path) : path_1.normalize(path).toLowerCase();
|
|
14
|
-
}
|
|
15
|
-
function memExists(path) {
|
|
16
|
-
return memfs_1.fs.existsSync(normalizePath(path));
|
|
17
|
-
}
|
|
18
|
-
function memReadStats(path) {
|
|
19
|
-
return memExists(path) ? memfs_1.fs.statSync(normalizePath(path)) : undefined;
|
|
20
|
-
}
|
|
21
|
-
function memReadFile(path, encoding) {
|
|
22
|
-
const stats = memReadStats(path);
|
|
23
|
-
if (stats && stats.isFile()) {
|
|
24
|
-
return memfs_1.fs
|
|
25
|
-
.readFileSync(normalizePath(path), { encoding: encoding })
|
|
26
|
-
.toString();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function memReadDir(path) {
|
|
30
|
-
const stats = memReadStats(path);
|
|
31
|
-
if (stats && stats.isDirectory()) {
|
|
32
|
-
return memfs_1.fs.readdirSync(normalizePath(path), { withFileTypes: true });
|
|
33
|
-
}
|
|
34
|
-
return [];
|
|
35
|
-
}
|
|
9
|
+
function createPassiveFileSystem(memFileSystem, realFileSystem) {
|
|
36
10
|
function exists(path) {
|
|
37
|
-
return realFileSystem.exists(path) ||
|
|
11
|
+
return realFileSystem.exists(path) || memFileSystem.exists(path);
|
|
38
12
|
}
|
|
39
13
|
function readFile(path, encoding) {
|
|
40
14
|
const fsStats = realFileSystem.readStats(path);
|
|
41
|
-
const memStats =
|
|
15
|
+
const memStats = memFileSystem.readStats(path);
|
|
42
16
|
if (fsStats && memStats) {
|
|
43
17
|
return fsStats.mtimeMs > memStats.mtimeMs
|
|
44
18
|
? realFileSystem.readFile(path, encoding)
|
|
45
|
-
:
|
|
19
|
+
: memFileSystem.readFile(path, encoding);
|
|
46
20
|
}
|
|
47
21
|
else if (fsStats) {
|
|
48
22
|
return realFileSystem.readFile(path, encoding);
|
|
49
23
|
}
|
|
50
24
|
else if (memStats) {
|
|
51
|
-
return
|
|
25
|
+
return memFileSystem.readFile(path, encoding);
|
|
52
26
|
}
|
|
53
27
|
}
|
|
54
28
|
function readDir(path) {
|
|
55
29
|
const fsDirents = realFileSystem.readDir(path);
|
|
56
|
-
const memDirents =
|
|
30
|
+
const memDirents = memFileSystem.readDir(path);
|
|
57
31
|
// merge list of dirents from fs and mem
|
|
58
32
|
return fsDirents
|
|
59
33
|
.filter((fsDirent) => !memDirents.some((memDirent) => memDirent.name === fsDirent.name))
|
|
@@ -61,7 +35,7 @@ function createPassiveFileSystem(caseSensitive = false, realFileSystem) {
|
|
|
61
35
|
}
|
|
62
36
|
function readStats(path) {
|
|
63
37
|
const fsStats = realFileSystem.readStats(path);
|
|
64
|
-
const memStats =
|
|
38
|
+
const memStats = memFileSystem.readStats(path);
|
|
65
39
|
if (fsStats && memStats) {
|
|
66
40
|
return fsStats.mtimeMs > memStats.mtimeMs ? fsStats : memStats;
|
|
67
41
|
}
|
|
@@ -72,27 +46,7 @@ function createPassiveFileSystem(caseSensitive = false, realFileSystem) {
|
|
|
72
46
|
return memStats;
|
|
73
47
|
}
|
|
74
48
|
}
|
|
75
|
-
|
|
76
|
-
memfs_1.fs.mkdirSync(normalizePath(path), { recursive: true });
|
|
77
|
-
}
|
|
78
|
-
function writeFile(path, data) {
|
|
79
|
-
if (!memExists(path_1.dirname(path))) {
|
|
80
|
-
createDir(path_1.dirname(path));
|
|
81
|
-
}
|
|
82
|
-
memfs_1.fs.writeFileSync(normalizePath(path), data);
|
|
83
|
-
}
|
|
84
|
-
function deleteFile(path) {
|
|
85
|
-
if (memExists(path)) {
|
|
86
|
-
memfs_1.fs.unlinkSync(normalizePath(path));
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
function updateTimes(path, atime, mtime) {
|
|
90
|
-
if (memExists(path)) {
|
|
91
|
-
memfs_1.fs.utimesSync(normalizePath(path), atime, mtime);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
exists(path) {
|
|
49
|
+
return Object.assign(Object.assign({}, memFileSystem), { exists(path) {
|
|
96
50
|
return exists(realFileSystem.realPath(path));
|
|
97
51
|
},
|
|
98
52
|
readFile(path, encoding) {
|
|
@@ -107,24 +61,8 @@ function createPassiveFileSystem(caseSensitive = false, realFileSystem) {
|
|
|
107
61
|
realPath(path) {
|
|
108
62
|
return realFileSystem.realPath(path);
|
|
109
63
|
},
|
|
110
|
-
normalizePath(path) {
|
|
111
|
-
return normalizePath(path);
|
|
112
|
-
},
|
|
113
|
-
writeFile(path, data) {
|
|
114
|
-
writeFile(realFileSystem.realPath(path), data);
|
|
115
|
-
},
|
|
116
|
-
deleteFile(path) {
|
|
117
|
-
deleteFile(realFileSystem.realPath(path));
|
|
118
|
-
},
|
|
119
|
-
createDir(path) {
|
|
120
|
-
createDir(realFileSystem.realPath(path));
|
|
121
|
-
},
|
|
122
|
-
updateTimes(path, atime, mtime) {
|
|
123
|
-
updateTimes(realFileSystem.realPath(path), atime, mtime);
|
|
124
|
-
},
|
|
125
64
|
clearCache() {
|
|
126
65
|
realFileSystem.clearCache();
|
|
127
|
-
}
|
|
128
|
-
};
|
|
66
|
+
} });
|
|
129
67
|
}
|
|
130
68
|
exports.createPassiveFileSystem = createPassiveFileSystem;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
|
+
import { FilesMatch } from '../../reporter';
|
|
2
3
|
interface ControlledTypeScriptSystem extends ts.System {
|
|
3
4
|
invokeFileCreated(path: string): void;
|
|
4
5
|
invokeFileChanged(path: string): void;
|
|
@@ -13,6 +14,7 @@ interface ControlledTypeScriptSystem extends ts.System {
|
|
|
13
14
|
setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): any;
|
|
14
15
|
clearTimeout(timeoutId: any): void;
|
|
15
16
|
waitForQueued(): Promise<void>;
|
|
17
|
+
setArtifacts(artifacts: FilesMatch): void;
|
|
16
18
|
}
|
|
17
19
|
declare type FileSystemMode = 'readonly' | 'write-tsbuildinfo' | 'write-references';
|
|
18
20
|
declare function createControlledTypeScriptSystem(typescript: typeof ts, mode?: FileSystemMode): ControlledTypeScriptSystem;
|
|
@@ -16,7 +16,14 @@ const path_1 = require("path");
|
|
|
16
16
|
const PassiveFileSystem_1 = require("../file-system/PassiveFileSystem");
|
|
17
17
|
const forwardSlash_1 = __importDefault(require("../../utils/path/forwardSlash"));
|
|
18
18
|
const RealFileSystem_1 = require("../file-system/RealFileSystem");
|
|
19
|
+
const MemFileSystem_1 = require("../file-system/MemFileSystem");
|
|
19
20
|
function createControlledTypeScriptSystem(typescript, mode = 'readonly') {
|
|
21
|
+
let artifacts = {
|
|
22
|
+
files: [],
|
|
23
|
+
dirs: [],
|
|
24
|
+
extensions: [],
|
|
25
|
+
};
|
|
26
|
+
let isInitialRun = true;
|
|
20
27
|
// watchers
|
|
21
28
|
const fileWatcherCallbacksMap = new Map();
|
|
22
29
|
const directoryWatcherCallbacksMap = new Map();
|
|
@@ -28,7 +35,8 @@ function createControlledTypeScriptSystem(typescript, mode = 'readonly') {
|
|
|
28
35
|
// third-party libraries, like fsevents
|
|
29
36
|
const caseSensitive = true;
|
|
30
37
|
const realFileSystem = RealFileSystem_1.createRealFileSystem(caseSensitive);
|
|
31
|
-
const
|
|
38
|
+
const memFileSystem = MemFileSystem_1.createMemFileSystem(realFileSystem);
|
|
39
|
+
const passiveFileSystem = PassiveFileSystem_1.createPassiveFileSystem(memFileSystem, realFileSystem);
|
|
32
40
|
// based on the ts.ignorePaths
|
|
33
41
|
const ignoredPaths = ['/node_modules/.', '/.git', '/.#'];
|
|
34
42
|
function createWatcher(watchersMap, path, callback) {
|
|
@@ -80,23 +88,35 @@ function createControlledTypeScriptSystem(typescript, mode = 'readonly') {
|
|
|
80
88
|
}
|
|
81
89
|
});
|
|
82
90
|
}
|
|
83
|
-
function
|
|
84
|
-
|
|
85
|
-
|
|
91
|
+
function isArtifact(path) {
|
|
92
|
+
return ((artifacts.dirs.some((dir) => path.includes(dir)) ||
|
|
93
|
+
artifacts.files.some((file) => path === file)) &&
|
|
94
|
+
artifacts.extensions.some((extension) => path.endsWith(extension)));
|
|
95
|
+
}
|
|
96
|
+
function getReadFileSystem(path) {
|
|
97
|
+
if (!isInitialRun &&
|
|
98
|
+
(mode === 'readonly' || mode === 'write-tsbuildinfo') &&
|
|
99
|
+
isArtifact(path)) {
|
|
100
|
+
return memFileSystem;
|
|
86
101
|
}
|
|
87
|
-
|
|
102
|
+
return passiveFileSystem;
|
|
103
|
+
}
|
|
104
|
+
function getWriteFileSystem(path) {
|
|
105
|
+
if (mode === 'write-references' ||
|
|
106
|
+
(mode === 'write-tsbuildinfo' && path.endsWith('.tsbuildinfo'))) {
|
|
88
107
|
return realFileSystem;
|
|
89
108
|
}
|
|
109
|
+
return passiveFileSystem;
|
|
90
110
|
}
|
|
91
111
|
const controlledSystem = Object.assign(Object.assign({}, typescript.sys), { useCaseSensitiveFileNames: caseSensitive, fileExists(path) {
|
|
92
|
-
const stats =
|
|
112
|
+
const stats = getReadFileSystem(path).readStats(path);
|
|
93
113
|
return !!stats && stats.isFile();
|
|
94
114
|
},
|
|
95
115
|
readFile(path, encoding) {
|
|
96
|
-
return
|
|
116
|
+
return getReadFileSystem(path).readFile(path, encoding);
|
|
97
117
|
},
|
|
98
118
|
getFileSize(path) {
|
|
99
|
-
const stats =
|
|
119
|
+
const stats = getReadFileSystem(path).readStats(path);
|
|
100
120
|
return stats ? stats.size : 0;
|
|
101
121
|
},
|
|
102
122
|
writeFile(path, data) {
|
|
@@ -108,7 +128,7 @@ function createControlledTypeScriptSystem(typescript, mode = 'readonly') {
|
|
|
108
128
|
controlledSystem.invokeFileDeleted(path);
|
|
109
129
|
},
|
|
110
130
|
directoryExists(path) {
|
|
111
|
-
const stats =
|
|
131
|
+
const stats = getReadFileSystem(path).readStats(path);
|
|
112
132
|
return !!stats && stats.isDirectory();
|
|
113
133
|
},
|
|
114
134
|
createDirectory(path) {
|
|
@@ -116,11 +136,11 @@ function createControlledTypeScriptSystem(typescript, mode = 'readonly') {
|
|
|
116
136
|
invokeDirectoryWatchers(path);
|
|
117
137
|
},
|
|
118
138
|
getDirectories(path) {
|
|
119
|
-
const dirents =
|
|
139
|
+
const dirents = getReadFileSystem(path).readDir(path);
|
|
120
140
|
return dirents.filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
|
|
121
141
|
},
|
|
122
142
|
getModifiedTime(path) {
|
|
123
|
-
const stats =
|
|
143
|
+
const stats = getReadFileSystem(path).readStats(path);
|
|
124
144
|
if (stats) {
|
|
125
145
|
return stats.mtime;
|
|
126
146
|
}
|
|
@@ -152,6 +172,7 @@ function createControlledTypeScriptSystem(typescript, mode = 'readonly') {
|
|
|
152
172
|
while (timeoutCallbacks.size > 0) {
|
|
153
173
|
yield new Promise((resolve) => setImmediate(resolve));
|
|
154
174
|
}
|
|
175
|
+
isInitialRun = false;
|
|
155
176
|
});
|
|
156
177
|
},
|
|
157
178
|
invokeFileCreated(path) {
|
|
@@ -180,8 +201,12 @@ function createControlledTypeScriptSystem(typescript, mode = 'readonly') {
|
|
|
180
201
|
}
|
|
181
202
|
},
|
|
182
203
|
clearCache() {
|
|
183
|
-
passiveFileSystem.clearCache();
|
|
184
204
|
realFileSystem.clearCache();
|
|
205
|
+
memFileSystem.clearCache();
|
|
206
|
+
passiveFileSystem.clearCache();
|
|
207
|
+
},
|
|
208
|
+
setArtifacts(nextArtifacts) {
|
|
209
|
+
artifacts = nextArtifacts;
|
|
185
210
|
} });
|
|
186
211
|
return controlledSystem;
|
|
187
212
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
2
|
import { TypeScriptConfigurationOverwrite } from '../TypeScriptConfigurationOverwrite';
|
|
3
|
-
import {
|
|
3
|
+
import { FilesMatch } from '../../reporter';
|
|
4
4
|
declare function parseTypeScriptConfiguration(typescript: typeof ts, configFileName: string, configFileContext: string, configOverwriteJSON: TypeScriptConfigurationOverwrite, parseConfigFileHost: ts.ParseConfigFileHost): ts.ParsedCommandLine;
|
|
5
|
-
declare function getDependenciesFromTypeScriptConfiguration(typescript: typeof ts, parsedConfiguration: ts.ParsedCommandLine,
|
|
6
|
-
export
|
|
5
|
+
declare function getDependenciesFromTypeScriptConfiguration(typescript: typeof ts, parsedConfiguration: ts.ParsedCommandLine, parseConfigFileHost: ts.ParseConfigFileHost, processedConfigFiles?: string[]): FilesMatch;
|
|
6
|
+
export declare function isIncrementalCompilation(options: ts.CompilerOptions): boolean;
|
|
7
|
+
declare function getArtifactsFromTypeScriptConfiguration(typescript: typeof ts, parsedConfiguration: ts.ParsedCommandLine, configFileContext: string, parseConfigFileHost: ts.ParseConfigFileHost, processedConfigFiles?: string[]): FilesMatch;
|
|
8
|
+
export { parseTypeScriptConfiguration, getDependenciesFromTypeScriptConfiguration, getArtifactsFromTypeScriptConfiguration, };
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
3
|
+
if (mod && mod.__esModule) return mod;
|
|
4
|
+
var result = {};
|
|
5
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
6
|
+
result["default"] = mod;
|
|
7
|
+
return result;
|
|
8
|
+
};
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
const ts = __importStar(require("typescript"));
|
|
3
11
|
const path_1 = require("path");
|
|
4
12
|
function parseTypeScriptConfiguration(typescript, configFileName, configFileContext, configOverwriteJSON, parseConfigFileHost) {
|
|
5
13
|
const parsedConfigFileJSON = typescript.readConfigFile(configFileName, parseConfigFileHost.readFile);
|
|
@@ -8,27 +16,25 @@ function parseTypeScriptConfiguration(typescript, configFileName, configFileCont
|
|
|
8
16
|
return Object.assign(Object.assign({}, parsedConfigFile), { options: Object.assign(Object.assign({}, parsedConfigFile.options), { configFilePath: configFileName }), errors: parsedConfigFileJSON.error ? [parsedConfigFileJSON.error] : parsedConfigFile.errors });
|
|
9
17
|
}
|
|
10
18
|
exports.parseTypeScriptConfiguration = parseTypeScriptConfiguration;
|
|
11
|
-
function getDependenciesFromTypeScriptConfiguration(typescript, parsedConfiguration,
|
|
19
|
+
function getDependenciesFromTypeScriptConfiguration(typescript, parsedConfiguration, parseConfigFileHost, processedConfigFiles = []) {
|
|
12
20
|
const files = new Set(parsedConfiguration.fileNames);
|
|
13
21
|
if (typeof parsedConfiguration.options.configFilePath === 'string') {
|
|
14
22
|
files.add(parsedConfiguration.options.configFilePath);
|
|
15
23
|
}
|
|
16
24
|
const dirs = new Set(Object.keys(parsedConfiguration.wildcardDirectories || {}));
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
dirs.add(dir);
|
|
31
|
-
});
|
|
25
|
+
for (const projectReference of parsedConfiguration.projectReferences || []) {
|
|
26
|
+
const configFile = typescript.resolveProjectReferencePath(projectReference);
|
|
27
|
+
if (processedConfigFiles.includes(configFile)) {
|
|
28
|
+
// handle circular dependencies
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const parsedConfiguration = parseTypeScriptConfiguration(typescript, configFile, path_1.dirname(configFile), {}, parseConfigFileHost);
|
|
32
|
+
const childDependencies = getDependenciesFromTypeScriptConfiguration(typescript, parsedConfiguration, parseConfigFileHost, [...processedConfigFiles, configFile]);
|
|
33
|
+
childDependencies.files.forEach((file) => {
|
|
34
|
+
files.add(file);
|
|
35
|
+
});
|
|
36
|
+
childDependencies.dirs.forEach((dir) => {
|
|
37
|
+
dirs.add(dir);
|
|
32
38
|
});
|
|
33
39
|
}
|
|
34
40
|
const extensions = [
|
|
@@ -45,3 +51,88 @@ function getDependenciesFromTypeScriptConfiguration(typescript, parsedConfigurat
|
|
|
45
51
|
};
|
|
46
52
|
}
|
|
47
53
|
exports.getDependenciesFromTypeScriptConfiguration = getDependenciesFromTypeScriptConfiguration;
|
|
54
|
+
function isIncrementalCompilation(options) {
|
|
55
|
+
return Boolean((options.incremental || options.composite) && !options.outFile);
|
|
56
|
+
}
|
|
57
|
+
exports.isIncrementalCompilation = isIncrementalCompilation;
|
|
58
|
+
function removeJsonExtension(path) {
|
|
59
|
+
if (path.endsWith('.json')) {
|
|
60
|
+
return path.slice(0, -'.json'.length);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
return path;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function getTsBuildInfoEmitOutputFilePath(options) {
|
|
67
|
+
if (typeof ts.getTsBuildInfoEmitOutputFilePath === 'function') {
|
|
68
|
+
// old TypeScript version doesn't provides this method
|
|
69
|
+
return ts.getTsBuildInfoEmitOutputFilePath(options);
|
|
70
|
+
}
|
|
71
|
+
// based on the implementation from typescript
|
|
72
|
+
const configFile = options.configFilePath;
|
|
73
|
+
if (!isIncrementalCompilation(options)) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
if (options.tsBuildInfoFile) {
|
|
77
|
+
return options.tsBuildInfoFile;
|
|
78
|
+
}
|
|
79
|
+
const outPath = options.outFile || options.out;
|
|
80
|
+
let buildInfoExtensionLess;
|
|
81
|
+
if (outPath) {
|
|
82
|
+
buildInfoExtensionLess = removeJsonExtension(outPath);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
if (!configFile) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
const configFileExtensionLess = removeJsonExtension(configFile);
|
|
89
|
+
buildInfoExtensionLess = options.outDir
|
|
90
|
+
? options.rootDir
|
|
91
|
+
? path_1.resolve(options.outDir, path_1.relative(options.rootDir, configFileExtensionLess))
|
|
92
|
+
: path_1.resolve(options.outDir, path_1.basename(configFileExtensionLess))
|
|
93
|
+
: configFileExtensionLess;
|
|
94
|
+
}
|
|
95
|
+
return buildInfoExtensionLess + '.tsbuildinfo';
|
|
96
|
+
}
|
|
97
|
+
function getArtifactsFromTypeScriptConfiguration(typescript, parsedConfiguration, configFileContext, parseConfigFileHost, processedConfigFiles = []) {
|
|
98
|
+
const files = new Set();
|
|
99
|
+
const dirs = new Set();
|
|
100
|
+
if (parsedConfiguration.fileNames.length > 0) {
|
|
101
|
+
if (parsedConfiguration.options.outFile) {
|
|
102
|
+
files.add(path_1.resolve(configFileContext, parsedConfiguration.options.outFile));
|
|
103
|
+
}
|
|
104
|
+
const tsBuildInfoPath = getTsBuildInfoEmitOutputFilePath(parsedConfiguration.options);
|
|
105
|
+
if (tsBuildInfoPath) {
|
|
106
|
+
files.add(path_1.resolve(configFileContext, tsBuildInfoPath));
|
|
107
|
+
}
|
|
108
|
+
if (parsedConfiguration.options.outDir) {
|
|
109
|
+
dirs.add(path_1.resolve(configFileContext, parsedConfiguration.options.outDir));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
for (const projectReference of parsedConfiguration.projectReferences || []) {
|
|
113
|
+
const configFile = typescript.resolveProjectReferencePath(projectReference);
|
|
114
|
+
if (processedConfigFiles.includes(configFile)) {
|
|
115
|
+
// handle circular dependencies
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const parsedConfiguration = parseTypeScriptConfiguration(typescript, configFile, path_1.dirname(configFile), {}, parseConfigFileHost);
|
|
119
|
+
const childArtifacts = getArtifactsFromTypeScriptConfiguration(typescript, parsedConfiguration, configFileContext, parseConfigFileHost, [...processedConfigFiles, configFile]);
|
|
120
|
+
childArtifacts.files.forEach((file) => {
|
|
121
|
+
files.add(file);
|
|
122
|
+
});
|
|
123
|
+
childArtifacts.dirs.forEach((dir) => {
|
|
124
|
+
dirs.add(dir);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
const extensions = [
|
|
128
|
+
typescript.Extension.Dts,
|
|
129
|
+
typescript.Extension.Js,
|
|
130
|
+
typescript.Extension.TsBuildInfo,
|
|
131
|
+
];
|
|
132
|
+
return {
|
|
133
|
+
files: Array.from(files).map((file) => path_1.normalize(file)),
|
|
134
|
+
dirs: Array.from(dirs).map((dir) => path_1.normalize(dir)),
|
|
135
|
+
extensions,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
exports.getArtifactsFromTypeScriptConfiguration = getArtifactsFromTypeScriptConfiguration;
|
|
@@ -25,6 +25,7 @@ function createTypeScriptReporter(configuration) {
|
|
|
25
25
|
let parsedConfiguration;
|
|
26
26
|
let parseConfigurationDiagnostics = [];
|
|
27
27
|
let dependencies;
|
|
28
|
+
let artifacts;
|
|
28
29
|
let configurationChanged = false;
|
|
29
30
|
let watchCompilerHost;
|
|
30
31
|
let watchSolutionBuilderHost;
|
|
@@ -77,8 +78,7 @@ function createTypeScriptReporter(configuration) {
|
|
|
77
78
|
function emitTsBuildInfoFileForBuilderProgram(builderProgram) {
|
|
78
79
|
if (configuration.mode !== 'readonly' &&
|
|
79
80
|
parsedConfiguration &&
|
|
80
|
-
parsedConfiguration.options
|
|
81
|
-
!parsedConfiguration.options.outFile) {
|
|
81
|
+
TypeScriptConfigurationParser_1.isIncrementalCompilation(parsedConfiguration.options)) {
|
|
82
82
|
const program = builderProgram.getProgram();
|
|
83
83
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
84
|
if (typeof program.emitBuildInfo === 'function') {
|
|
@@ -116,7 +116,7 @@ function createTypeScriptReporter(configuration) {
|
|
|
116
116
|
function getDependencies() {
|
|
117
117
|
parsedConfiguration = parseConfigurationIfNeeded();
|
|
118
118
|
const [parseConfigFileHost] = getParseConfigFileHost();
|
|
119
|
-
let dependencies = TypeScriptConfigurationParser_1.getDependenciesFromTypeScriptConfiguration(typescript, parsedConfiguration,
|
|
119
|
+
let dependencies = TypeScriptConfigurationParser_1.getDependenciesFromTypeScriptConfiguration(typescript, parsedConfiguration, parseConfigFileHost);
|
|
120
120
|
for (const extension of extensions) {
|
|
121
121
|
if (extension.extendDependencies) {
|
|
122
122
|
dependencies = extension.extendDependencies(dependencies);
|
|
@@ -124,6 +124,17 @@ function createTypeScriptReporter(configuration) {
|
|
|
124
124
|
}
|
|
125
125
|
return dependencies;
|
|
126
126
|
}
|
|
127
|
+
function getArtifacts() {
|
|
128
|
+
parsedConfiguration = parseConfigurationIfNeeded();
|
|
129
|
+
const [parseConfigFileHost] = getParseConfigFileHost();
|
|
130
|
+
return TypeScriptConfigurationParser_1.getArtifactsFromTypeScriptConfiguration(typescript, parsedConfiguration, configuration.context, parseConfigFileHost);
|
|
131
|
+
}
|
|
132
|
+
function getArtifactsIfNeeded() {
|
|
133
|
+
if (!artifacts) {
|
|
134
|
+
artifacts = getArtifacts();
|
|
135
|
+
}
|
|
136
|
+
return artifacts;
|
|
137
|
+
}
|
|
127
138
|
function startProfilingIfNeeded() {
|
|
128
139
|
if (configuration.profile) {
|
|
129
140
|
performance.enable();
|
|
@@ -165,6 +176,7 @@ function createTypeScriptReporter(configuration) {
|
|
|
165
176
|
// we need to re-create programs
|
|
166
177
|
parsedConfiguration = undefined;
|
|
167
178
|
dependencies = undefined;
|
|
179
|
+
artifacts = undefined;
|
|
168
180
|
watchCompilerHost = undefined;
|
|
169
181
|
watchSolutionBuilderHost = undefined;
|
|
170
182
|
watchProgram = undefined;
|
|
@@ -178,12 +190,14 @@ function createTypeScriptReporter(configuration) {
|
|
|
178
190
|
if (previousParsedConfiguration &&
|
|
179
191
|
JSON.stringify(previousParsedConfiguration.fileNames) !==
|
|
180
192
|
JSON.stringify(parsedConfiguration.fileNames)) {
|
|
181
|
-
// root files changed - we need to recompute dependencies
|
|
193
|
+
// root files changed - we need to recompute dependencies and artifacts
|
|
182
194
|
dependencies = getDependencies();
|
|
195
|
+
artifacts = getArtifacts();
|
|
183
196
|
shouldUpdateRootFiles = true;
|
|
184
197
|
}
|
|
185
198
|
}
|
|
186
199
|
parsedConfiguration = parseConfigurationIfNeeded();
|
|
200
|
+
system.setArtifacts(getArtifactsIfNeeded());
|
|
187
201
|
if (configurationChanged) {
|
|
188
202
|
configurationChanged = false;
|
|
189
203
|
// try to remove outdated .tsbuildinfo file for incremental mode
|