fork-ts-checker-webpack-plugin 6.2.8 → 6.2.12

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.
@@ -65,7 +65,7 @@ exports.ForkTsCheckerWebpackPlugin = ForkTsCheckerWebpackPlugin;
65
65
  /**
66
66
  * Current version of the plugin
67
67
  */
68
- ForkTsCheckerWebpackPlugin.version = '6.2.8'; // will be replaced by the @semantic-release/exec
68
+ ForkTsCheckerWebpackPlugin.version = '6.2.12'; // 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 { Dependencies, Report } from './reporter';
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<Dependencies | undefined>;
8
- lastDependencies: Dependencies | undefined;
7
+ dependenciesPromise: Promise<FilesMatch | undefined>;
8
+ lastDependencies: FilesMatch | undefined;
9
9
  watching: boolean;
10
10
  initialized: boolean;
11
11
  webpackDevServerDoneTap: Tap | undefined;
@@ -78,6 +78,7 @@ function createEsLintReporter(configuration) {
78
78
  return {
79
79
  files: (yield getFiles()).map((file) => path_1.normalize(file)),
80
80
  dirs: getDirs().map((dir) => path_1.normalize(dir)),
81
+ excluded: [],
81
82
  extensions: getExtensions(),
82
83
  };
83
84
  });
@@ -0,0 +1,7 @@
1
+ interface FilesMatch {
2
+ files: string[];
3
+ dirs: string[];
4
+ excluded: string[];
5
+ extensions: string[];
6
+ }
7
+ export { FilesMatch };
File without changes
@@ -1,7 +1,7 @@
1
- import { Dependencies } from './Dependencies';
1
+ import { FilesMatch } from './FilesMatch';
2
2
  import { Issue } from '../issue';
3
3
  interface Report {
4
- getDependencies(): Promise<Dependencies>;
4
+ getDependencies(): Promise<FilesMatch>;
5
5
  getIssues(): Promise<Issue[]>;
6
6
  close(): Promise<void>;
7
7
  }
@@ -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 './Dependencies';
5
+ export * from './FilesMatch';
6
6
  export * from './reporter-rpc/ReporterRpcClient';
7
7
  export * from './reporter-rpc/ReporterRpcService';
@@ -62,8 +62,9 @@ function composeReporterRpcClients(clients) {
62
62
  getDependencies: () => Promise.all(reports.map((report) => report.getDependencies())).then((dependencies) => dependencies.reduce((mergedDependencies, singleDependencies) => ({
63
63
  files: Array.from(new Set([...mergedDependencies.files, ...singleDependencies.files])),
64
64
  dirs: Array.from(new Set([...mergedDependencies.dirs, ...singleDependencies.dirs])),
65
+ excluded: Array.from(new Set([...mergedDependencies.excluded, ...singleDependencies.excluded])),
65
66
  extensions: Array.from(new Set([...mergedDependencies.extensions, ...singleDependencies.extensions])),
66
- }), { files: [], dirs: [], extensions: [] })),
67
+ }), { files: [], dirs: [], excluded: [], extensions: [] })),
67
68
  getIssues: () => Promise.all(reports.map((report) => report.getIssues())).then((issues) => flatten_1.default(issues)),
68
69
  close: () => Promise.all(reports.map((report) => report.close())).then(() => undefined),
69
70
  })),
@@ -1,10 +1,10 @@
1
1
  import { RpcProcedure } from '../../rpc';
2
2
  import { FilesChange } from '../FilesChange';
3
3
  import { Issue } from '../../issue';
4
- import { Dependencies } from '../Dependencies';
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, Dependencies>;
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 { Dependencies } from '../../reporter';
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: Dependencies): 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 caseSensitive
5
+ * @param memFileSystem
6
6
  * @param realFileSystem
7
7
  */
8
- declare function createPassiveFileSystem(caseSensitive: boolean | undefined, realFileSystem: FileSystem): FileSystem;
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 caseSensitive
6
+ * @param memFileSystem
9
7
  * @param realFileSystem
10
8
  */
11
- function createPassiveFileSystem(caseSensitive = false, realFileSystem) {
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) || memExists(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 = memReadStats(path);
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
- : memReadFile(path, encoding);
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 memReadFile(path, encoding);
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 = memReadDir(path);
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 = memReadStats(path);
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
- function createDir(path) {
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,15 @@ 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
+ excluded: [],
25
+ extensions: [],
26
+ };
27
+ let isInitialRun = true;
20
28
  // watchers
21
29
  const fileWatcherCallbacksMap = new Map();
22
30
  const directoryWatcherCallbacksMap = new Map();
@@ -28,7 +36,8 @@ function createControlledTypeScriptSystem(typescript, mode = 'readonly') {
28
36
  // third-party libraries, like fsevents
29
37
  const caseSensitive = true;
30
38
  const realFileSystem = RealFileSystem_1.createRealFileSystem(caseSensitive);
31
- const passiveFileSystem = PassiveFileSystem_1.createPassiveFileSystem(caseSensitive, realFileSystem);
39
+ const memFileSystem = MemFileSystem_1.createMemFileSystem(realFileSystem);
40
+ const passiveFileSystem = PassiveFileSystem_1.createPassiveFileSystem(memFileSystem, realFileSystem);
32
41
  // based on the ts.ignorePaths
33
42
  const ignoredPaths = ['/node_modules/.', '/.git', '/.#'];
34
43
  function createWatcher(watchersMap, path, callback) {
@@ -80,23 +89,35 @@ function createControlledTypeScriptSystem(typescript, mode = 'readonly') {
80
89
  }
81
90
  });
82
91
  }
83
- function getWriteFileSystem(path) {
84
- if (mode === 'readonly' || (mode === 'write-tsbuildinfo' && !path.endsWith('.tsbuildinfo'))) {
85
- return passiveFileSystem;
92
+ function isArtifact(path) {
93
+ return ((artifacts.dirs.some((dir) => path.includes(dir)) ||
94
+ artifacts.files.some((file) => path === file)) &&
95
+ artifacts.extensions.some((extension) => path.endsWith(extension)));
96
+ }
97
+ function getReadFileSystem(path) {
98
+ if (!isInitialRun &&
99
+ (mode === 'readonly' || mode === 'write-tsbuildinfo') &&
100
+ isArtifact(path)) {
101
+ return memFileSystem;
86
102
  }
87
- else {
103
+ return passiveFileSystem;
104
+ }
105
+ function getWriteFileSystem(path) {
106
+ if (mode === 'write-references' ||
107
+ (mode === 'write-tsbuildinfo' && path.endsWith('.tsbuildinfo'))) {
88
108
  return realFileSystem;
89
109
  }
110
+ return passiveFileSystem;
90
111
  }
91
112
  const controlledSystem = Object.assign(Object.assign({}, typescript.sys), { useCaseSensitiveFileNames: caseSensitive, fileExists(path) {
92
- const stats = passiveFileSystem.readStats(path);
113
+ const stats = getReadFileSystem(path).readStats(path);
93
114
  return !!stats && stats.isFile();
94
115
  },
95
116
  readFile(path, encoding) {
96
- return passiveFileSystem.readFile(path, encoding);
117
+ return getReadFileSystem(path).readFile(path, encoding);
97
118
  },
98
119
  getFileSize(path) {
99
- const stats = passiveFileSystem.readStats(path);
120
+ const stats = getReadFileSystem(path).readStats(path);
100
121
  return stats ? stats.size : 0;
101
122
  },
102
123
  writeFile(path, data) {
@@ -108,19 +129,22 @@ function createControlledTypeScriptSystem(typescript, mode = 'readonly') {
108
129
  controlledSystem.invokeFileDeleted(path);
109
130
  },
110
131
  directoryExists(path) {
111
- const stats = passiveFileSystem.readStats(path);
112
- return !!stats && stats.isDirectory();
132
+ var _a;
133
+ return Boolean((_a = getReadFileSystem(path).readStats(path)) === null || _a === void 0 ? void 0 : _a.isDirectory());
113
134
  },
114
135
  createDirectory(path) {
115
136
  getWriteFileSystem(path).createDir(path);
116
137
  invokeDirectoryWatchers(path);
117
138
  },
118
139
  getDirectories(path) {
119
- const dirents = passiveFileSystem.readDir(path);
120
- return dirents.filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
140
+ const dirents = getReadFileSystem(path).readDir(path);
141
+ return dirents
142
+ .filter((dirent) => dirent.isDirectory() ||
143
+ (dirent.isSymbolicLink() && controlledSystem.directoryExists(path_1.join(path, dirent.name))))
144
+ .map((dirent) => dirent.name);
121
145
  },
122
146
  getModifiedTime(path) {
123
- const stats = passiveFileSystem.readStats(path);
147
+ const stats = getReadFileSystem(path).readStats(path);
124
148
  if (stats) {
125
149
  return stats.mtime;
126
150
  }
@@ -152,6 +176,7 @@ function createControlledTypeScriptSystem(typescript, mode = 'readonly') {
152
176
  while (timeoutCallbacks.size > 0) {
153
177
  yield new Promise((resolve) => setImmediate(resolve));
154
178
  }
179
+ isInitialRun = false;
155
180
  });
156
181
  },
157
182
  invokeFileCreated(path) {
@@ -180,8 +205,12 @@ function createControlledTypeScriptSystem(typescript, mode = 'readonly') {
180
205
  }
181
206
  },
182
207
  clearCache() {
183
- passiveFileSystem.clearCache();
184
208
  realFileSystem.clearCache();
209
+ memFileSystem.clearCache();
210
+ passiveFileSystem.clearCache();
211
+ },
212
+ setArtifacts(nextArtifacts) {
213
+ artifacts = nextArtifacts;
185
214
  } });
186
215
  return controlledSystem;
187
216
  }
@@ -1,6 +1,8 @@
1
1
  import * as ts from 'typescript';
2
2
  import { TypeScriptConfigurationOverwrite } from '../TypeScriptConfigurationOverwrite';
3
- import { Dependencies } from '../../reporter';
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, configFileContext: string, parseConfigFileHost: ts.ParseConfigFileHost, processedConfigFiles?: string[]): Dependencies;
6
- export { parseTypeScriptConfiguration, getDependenciesFromTypeScriptConfiguration };
5
+ declare function getDependenciesFromTypeScriptConfiguration(typescript: typeof ts, parsedConfiguration: ts.ParsedCommandLine, configFileContext: string, 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);
@@ -9,26 +17,28 @@ function parseTypeScriptConfiguration(typescript, configFileName, configFileCont
9
17
  }
10
18
  exports.parseTypeScriptConfiguration = parseTypeScriptConfiguration;
11
19
  function getDependenciesFromTypeScriptConfiguration(typescript, parsedConfiguration, configFileContext, parseConfigFileHost, processedConfigFiles = []) {
20
+ var _a;
12
21
  const files = new Set(parsedConfiguration.fileNames);
13
- if (typeof parsedConfiguration.options.configFilePath === 'string') {
14
- files.add(parsedConfiguration.options.configFilePath);
22
+ const configFilePath = parsedConfiguration.options.configFilePath;
23
+ if (typeof configFilePath === 'string') {
24
+ files.add(configFilePath);
15
25
  }
16
26
  const dirs = new Set(Object.keys(parsedConfiguration.wildcardDirectories || {}));
17
- if (parsedConfiguration.projectReferences) {
18
- parsedConfiguration.projectReferences.forEach((projectReference) => {
19
- const configFile = typescript.resolveProjectReferencePath(projectReference);
20
- if (processedConfigFiles.includes(configFile)) {
21
- // handle circular dependencies
22
- return;
23
- }
24
- const parsedConfiguration = parseTypeScriptConfiguration(typescript, configFile, configFileContext, {}, parseConfigFileHost);
25
- const childDependencies = getDependenciesFromTypeScriptConfiguration(typescript, parsedConfiguration, configFileContext, parseConfigFileHost, [...processedConfigFiles, configFile]);
26
- childDependencies.files.forEach((file) => {
27
- files.add(file);
28
- });
29
- childDependencies.dirs.forEach((dir) => {
30
- dirs.add(dir);
31
- });
27
+ const excluded = new Set((((_a = parsedConfiguration.raw) === null || _a === void 0 ? void 0 : _a.exclude) || []).map((path) => path_1.resolve(configFileContext, path)));
28
+ for (const projectReference of parsedConfiguration.projectReferences || []) {
29
+ const childConfigFilePath = typescript.resolveProjectReferencePath(projectReference);
30
+ const childConfigContext = path_1.dirname(childConfigFilePath);
31
+ if (processedConfigFiles.includes(childConfigFilePath)) {
32
+ // handle circular dependencies
33
+ continue;
34
+ }
35
+ const childParsedConfiguration = parseTypeScriptConfiguration(typescript, childConfigFilePath, childConfigContext, {}, parseConfigFileHost);
36
+ const childDependencies = getDependenciesFromTypeScriptConfiguration(typescript, childParsedConfiguration, childConfigContext, parseConfigFileHost, [...processedConfigFiles, childConfigFilePath]);
37
+ childDependencies.files.forEach((file) => {
38
+ files.add(file);
39
+ });
40
+ childDependencies.dirs.forEach((dir) => {
41
+ dirs.add(dir);
32
42
  });
33
43
  }
34
44
  const extensions = [
@@ -41,7 +51,94 @@ function getDependenciesFromTypeScriptConfiguration(typescript, parsedConfigurat
41
51
  return {
42
52
  files: Array.from(files).map((file) => path_1.normalize(file)),
43
53
  dirs: Array.from(dirs).map((dir) => path_1.normalize(dir)),
54
+ excluded: Array.from(excluded).map((path) => path_1.normalize(path)),
44
55
  extensions: extensions,
45
56
  };
46
57
  }
47
58
  exports.getDependenciesFromTypeScriptConfiguration = getDependenciesFromTypeScriptConfiguration;
59
+ function isIncrementalCompilation(options) {
60
+ return Boolean((options.incremental || options.composite) && !options.outFile);
61
+ }
62
+ exports.isIncrementalCompilation = isIncrementalCompilation;
63
+ function removeJsonExtension(path) {
64
+ if (path.endsWith('.json')) {
65
+ return path.slice(0, -'.json'.length);
66
+ }
67
+ else {
68
+ return path;
69
+ }
70
+ }
71
+ function getTsBuildInfoEmitOutputFilePath(options) {
72
+ if (typeof ts.getTsBuildInfoEmitOutputFilePath === 'function') {
73
+ // old TypeScript version doesn't provides this method
74
+ return ts.getTsBuildInfoEmitOutputFilePath(options);
75
+ }
76
+ // based on the implementation from typescript
77
+ const configFile = options.configFilePath;
78
+ if (!isIncrementalCompilation(options)) {
79
+ return undefined;
80
+ }
81
+ if (options.tsBuildInfoFile) {
82
+ return options.tsBuildInfoFile;
83
+ }
84
+ const outPath = options.outFile || options.out;
85
+ let buildInfoExtensionLess;
86
+ if (outPath) {
87
+ buildInfoExtensionLess = removeJsonExtension(outPath);
88
+ }
89
+ else {
90
+ if (!configFile) {
91
+ return undefined;
92
+ }
93
+ const configFileExtensionLess = removeJsonExtension(configFile);
94
+ buildInfoExtensionLess = options.outDir
95
+ ? options.rootDir
96
+ ? path_1.resolve(options.outDir, path_1.relative(options.rootDir, configFileExtensionLess))
97
+ : path_1.resolve(options.outDir, path_1.basename(configFileExtensionLess))
98
+ : configFileExtensionLess;
99
+ }
100
+ return buildInfoExtensionLess + '.tsbuildinfo';
101
+ }
102
+ function getArtifactsFromTypeScriptConfiguration(typescript, parsedConfiguration, configFileContext, parseConfigFileHost, processedConfigFiles = []) {
103
+ const files = new Set();
104
+ const dirs = new Set();
105
+ if (parsedConfiguration.fileNames.length > 0) {
106
+ if (parsedConfiguration.options.outFile) {
107
+ files.add(path_1.resolve(configFileContext, parsedConfiguration.options.outFile));
108
+ }
109
+ const tsBuildInfoPath = getTsBuildInfoEmitOutputFilePath(parsedConfiguration.options);
110
+ if (tsBuildInfoPath) {
111
+ files.add(path_1.resolve(configFileContext, tsBuildInfoPath));
112
+ }
113
+ if (parsedConfiguration.options.outDir) {
114
+ dirs.add(path_1.resolve(configFileContext, parsedConfiguration.options.outDir));
115
+ }
116
+ }
117
+ for (const projectReference of parsedConfiguration.projectReferences || []) {
118
+ const configFile = typescript.resolveProjectReferencePath(projectReference);
119
+ if (processedConfigFiles.includes(configFile)) {
120
+ // handle circular dependencies
121
+ continue;
122
+ }
123
+ const parsedConfiguration = parseTypeScriptConfiguration(typescript, configFile, path_1.dirname(configFile), {}, parseConfigFileHost);
124
+ const childArtifacts = getArtifactsFromTypeScriptConfiguration(typescript, parsedConfiguration, configFileContext, parseConfigFileHost, [...processedConfigFiles, configFile]);
125
+ childArtifacts.files.forEach((file) => {
126
+ files.add(file);
127
+ });
128
+ childArtifacts.dirs.forEach((dir) => {
129
+ dirs.add(dir);
130
+ });
131
+ }
132
+ const extensions = [
133
+ typescript.Extension.Dts,
134
+ typescript.Extension.Js,
135
+ typescript.Extension.TsBuildInfo,
136
+ ];
137
+ return {
138
+ files: Array.from(files).map((file) => path_1.normalize(file)),
139
+ dirs: Array.from(dirs).map((dir) => path_1.normalize(dir)),
140
+ excluded: [],
141
+ extensions,
142
+ };
143
+ }
144
+ 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.incremental &&
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') {
@@ -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
@@ -8,7 +8,7 @@ const path_1 = require("path");
8
8
  const reporter_1 = require("../reporter");
9
9
  const minimatch_1 = __importDefault(require("minimatch"));
10
10
  const BUILTIN_IGNORED_DIRS = ['node_modules', '.git', '.yarn', '.pnp'];
11
- function createIsIgnored(ignored) {
11
+ function createIsIgnored(ignored, excluded) {
12
12
  const ignoredPatterns = ignored ? (Array.isArray(ignored) ? ignored : [ignored]) : [];
13
13
  const ignoredFunctions = ignoredPatterns.map((pattern) => {
14
14
  // ensure patterns are valid - see https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/594
@@ -26,6 +26,7 @@ function createIsIgnored(ignored) {
26
26
  return () => false;
27
27
  }
28
28
  });
29
+ ignoredFunctions.push((path) => excluded.some((excludedPath) => path.startsWith(excludedPath)));
29
30
  ignoredFunctions.push((path) => BUILTIN_IGNORED_DIRS.some((ignoredDir) => path.includes(`/${ignoredDir}/`)));
30
31
  return function isIgnored(path) {
31
32
  return ignoredFunctions.some((ignoredFunction) => ignoredFunction(path));
@@ -44,24 +45,24 @@ class InclusiveNodeWatchFileSystem {
44
45
  return this.watchFileSystem.watcher || ((_a = this.watchFileSystem.wfs) === null || _a === void 0 ? void 0 : _a.watcher);
45
46
  }
46
47
  watch(files, dirs, missing, startTime, options, callback, callbackUndelayed) {
47
- var _a, _b, _c;
48
+ var _a, _b, _c, _d;
48
49
  reporter_1.clearFilesChange(this.compiler);
49
- const isIgnored = createIsIgnored(options === null || options === void 0 ? void 0 : options.ignored);
50
+ const isIgnored = createIsIgnored(options === null || options === void 0 ? void 0 : options.ignored, ((_a = this.pluginState.lastDependencies) === null || _a === void 0 ? void 0 : _a.excluded) || []);
50
51
  // use standard watch file system for files and missing
51
52
  const standardWatcher = this.watchFileSystem.watch(files, dirs, missing, startTime, options, callback, callbackUndelayed);
52
- (_a = this.watcher) === null || _a === void 0 ? void 0 : _a.on('change', (file) => {
53
+ (_b = this.watcher) === null || _b === void 0 ? void 0 : _b.on('change', (file) => {
53
54
  if (typeof file === 'string' && !isIgnored(file)) {
54
55
  reporter_1.updateFilesChange(this.compiler, { changedFiles: [file] });
55
56
  }
56
57
  });
57
- (_b = this.watcher) === null || _b === void 0 ? void 0 : _b.on('remove', (file) => {
58
+ (_c = this.watcher) === null || _c === void 0 ? void 0 : _c.on('remove', (file) => {
58
59
  if (typeof file === 'string' && !isIgnored(file)) {
59
60
  reporter_1.updateFilesChange(this.compiler, { deletedFiles: [file] });
60
61
  }
61
62
  });
62
63
  // calculate what to change
63
64
  const prevDirs = Array.from(this.dirsWatchers.keys());
64
- const nextDirs = Array.from(((_c = this.pluginState.lastDependencies) === null || _c === void 0 ? void 0 : _c.dirs) || []);
65
+ const nextDirs = Array.from(((_d = this.pluginState.lastDependencies) === null || _d === void 0 ? void 0 : _d.dirs) || []);
65
66
  const dirsToUnwatch = prevDirs.filter((prevDir) => !nextDirs.includes(prevDir));
66
67
  const dirsToWatch = nextDirs.filter((nextDir) => !prevDirs.includes(nextDir) && !isIgnored(nextDir));
67
68
  // update dirs watcher
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fork-ts-checker-webpack-plugin",
3
- "version": "6.2.8",
3
+ "version": "6.2.12",
4
4
  "description": "Runs typescript type checker and linter on separate process.",
5
5
  "keywords": [
6
6
  "fast",
@@ -1,6 +0,0 @@
1
- interface Dependencies {
2
- files: string[];
3
- dirs: string[];
4
- extensions: string[];
5
- }
6
- export { Dependencies };