fork-ts-checker-webpack-plugin 5.0.13 → 5.2.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.
Files changed (29) hide show
  1. package/README.md +9 -8
  2. package/lib/ForkTsCheckerWebpackPlugin.js +1 -1
  3. package/lib/ForkTsCheckerWebpackPluginOptions.json +8 -0
  4. package/lib/formatter/WebpackFormatter.d.ts +1 -1
  5. package/lib/formatter/WebpackFormatter.js +2 -2
  6. package/lib/hooks/interceptDoneToGetWebpackDevServerTap.js +3 -1
  7. package/lib/hooks/tapDoneToAsyncGetIssues.js +1 -1
  8. package/lib/logger/LoggerConfiguration.d.ts +1 -0
  9. package/lib/logger/LoggerConfiguration.js +1 -0
  10. package/lib/logger/LoggerOptions.d.ts +1 -0
  11. package/lib/typescript-reporter/TypeScriptReporterConfiguration.d.ts +1 -0
  12. package/lib/typescript-reporter/TypeScriptReporterConfiguration.js +3 -10
  13. package/lib/typescript-reporter/TypeScriptReporterOptions.d.ts +1 -0
  14. package/lib/typescript-reporter/TypeScriptSupport.js +1 -1
  15. package/lib/typescript-reporter/file-system/RealFileSystem.js +1 -1
  16. package/lib/typescript-reporter/issue/TypeScriptIssueFactory.d.ts +1 -1
  17. package/lib/typescript-reporter/issue/TypeScriptIssueFactory.js +4 -5
  18. package/lib/typescript-reporter/profile/TypeScriptPerformance.d.ts +2 -1
  19. package/lib/typescript-reporter/profile/TypeScriptPerformance.js +4 -12
  20. package/lib/typescript-reporter/reporter/ControlledTypeScriptSystem.d.ts +1 -1
  21. package/lib/typescript-reporter/reporter/ControlledTypeScriptSystem.js +8 -16
  22. package/lib/typescript-reporter/reporter/ControlledWatchCompilerHost.d.ts +1 -1
  23. package/lib/typescript-reporter/reporter/ControlledWatchCompilerHost.js +3 -11
  24. package/lib/typescript-reporter/reporter/ControlledWatchSolutionBuilderHost.d.ts +1 -1
  25. package/lib/typescript-reporter/reporter/ControlledWatchSolutionBuilderHost.js +17 -2
  26. package/lib/typescript-reporter/reporter/TypeScriptConfigurationParser.d.ts +1 -1
  27. package/lib/typescript-reporter/reporter/TypeScriptConfigurationParser.js +3 -11
  28. package/lib/typescript-reporter/reporter/TypeScriptReporter.js +13 -19
  29. package/package.json +28 -26
package/README.md CHANGED
@@ -143,14 +143,14 @@ you can place your configuration in the:
143
143
 
144
144
  Options passed to the plugin constructor will overwrite options from the cosmiconfig (using [deepmerge](https://github.com/TehShrike/deepmerge)).
145
145
 
146
- | Name | Type | Default value | Description |
147
- | ----------------- | --------------------- | ------------------------------------------------ | ----------- |
148
- | `async` | `boolean` | `compiler.options.mode === 'development'` | If `true`, reports issues **after** webpack's compilation is done. Thanks to that it doesn't block the compilation. Used only in the `watch` mode. |
149
- | `typescript` | `object` or `boolean` | `true` | If a `boolean`, it enables/disables TypeScript checker. If an `object`, see [TypeScript options](#typescript-options). |
150
- | `eslint` | `object` | `undefined` | If `undefined`, it disables ESLint linter. If an `object`, see [ESLint options](#eslint-options). |
151
- | `issue` | `object` | `{}` | See [Issues options](#issues-options). |
152
- | `formatter` | `string` or `object` | `codeframe` | Available formatters are `basic` and `codeframe`. To [configure](https://babeljs.io/docs/en/babel-code-frame#options) `codeframe` formatter, pass object: `{ type: 'codeframe', options: { <coderame options> } }`. |
153
- | `logger` | `object` | `{ infrastructure: 'silent', issues: 'console' }` | Available loggers are `silent`, `console`, and `webpack-infrastructure`. Infrastructure logger prints additional information, issue logger prints `issues` in the `async` mode. |
146
+ | Name | Type | Default value | Description |
147
+ | ----------------- | --------------------- | ------------------------------------------------------------------ | ----------- |
148
+ | `async` | `boolean` | `compiler.options.mode === 'development'` | If `true`, reports issues **after** webpack's compilation is done. Thanks to that it doesn't block the compilation. Used only in the `watch` mode. |
149
+ | `typescript` | `object` or `boolean` | `true` | If a `boolean`, it enables/disables TypeScript checker. If an `object`, see [TypeScript options](#typescript-options). |
150
+ | `eslint` | `object` | `undefined` | If `undefined`, it disables ESLint linter. If an `object`, see [ESLint options](#eslint-options). |
151
+ | `issue` | `object` | `{}` | See [Issues options](#issues-options). |
152
+ | `formatter` | `string` or `object` | `codeframe` | Available formatters are `basic` and `codeframe`. To [configure](https://babeljs.io/docs/en/babel-code-frame#options) `codeframe` formatter, pass object: `{ type: 'codeframe', options: { <coderame options> } }`. |
153
+ | `logger` | `object` | `{ infrastructure: 'silent', issues: 'console', devServer: true }` | Available loggers are `silent`, `console`, and `webpack-infrastructure`. Infrastructure logger prints additional information, issue logger prints `issues` in the `async` mode. If `devServer` is set to `false`, errors will not be reported to Webpack Dev Server. |
154
154
 
155
155
  ### TypeScript options
156
156
 
@@ -168,6 +168,7 @@ Options for the TypeScript checker (`typescript` option object).
168
168
  | `diagnosticOptions` | `object` | `{ syntactic: false, semantic: true, declaration: false, global: false }` | Settings to select which diagnostics do we want to perform. |
169
169
  | `extensions` | `object` | `{}` | See [TypeScript extensions options](#typescript-extensions-options). |
170
170
  | `profile` | `boolean` | `false` | Measures and prints timings related to the TypeScript performance. |
171
+ | `typescriptPath` | `string` | `require.resolve('typescript')` | If supplied this is a custom path where TypeScript can be found. |
171
172
 
172
173
  #### TypeScript extensions options
173
174
 
@@ -60,4 +60,4 @@ class ForkTsCheckerWebpackPlugin {
60
60
  }
61
61
  }
62
62
  exports.ForkTsCheckerWebpackPlugin = ForkTsCheckerWebpackPlugin;
63
- ForkTsCheckerWebpackPlugin.version = '5.0.13'; // will be replaced by the @semantic-release/exec
63
+ ForkTsCheckerWebpackPlugin.version = '5.2.1'; // will be replaced by the @semantic-release/exec
@@ -175,6 +175,10 @@
175
175
  "profile": {
176
176
  "type": "boolean",
177
177
  "description": "Measures and prints timings related to the TypeScript performance."
178
+ },
179
+ "typescriptPath": {
180
+ "type": "string",
181
+ "description": "If supplied this is a custom path where TypeScript can be found."
178
182
  }
179
183
  }
180
184
  }
@@ -287,6 +291,10 @@
287
291
  "$ref": "#/definitions/Logger"
288
292
  }
289
293
  ]
294
+ },
295
+ "devServer": {
296
+ "type": "boolean",
297
+ "description": "Enable reporting to Webpack Dev Server."
290
298
  }
291
299
  }
292
300
  }
@@ -1,3 +1,3 @@
1
1
  import { Formatter } from './Formatter';
2
- declare function createWebpackFormatter(formatter: Formatter, context: string): Formatter;
2
+ declare function createWebpackFormatter(formatter: Formatter): Formatter;
3
3
  export { createWebpackFormatter };
@@ -8,13 +8,13 @@ const chalk_1 = __importDefault(require("chalk"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const issue_1 = require("../issue");
10
10
  const forwardSlash_1 = __importDefault(require("../utils/path/forwardSlash"));
11
- function createWebpackFormatter(formatter, context) {
11
+ function createWebpackFormatter(formatter) {
12
12
  // mimics webpack error formatter
13
13
  return function webpackFormatter(issue) {
14
14
  const color = issue.severity === 'warning' ? chalk_1.default.yellow.bold : chalk_1.default.red.bold;
15
15
  const severity = issue.severity.toUpperCase();
16
16
  if (issue.file) {
17
- let location = forwardSlash_1.default(path_1.default.relative(context, issue.file));
17
+ let location = forwardSlash_1.default(path_1.default.relative(process.cwd(), issue.file));
18
18
  if (issue.location) {
19
19
  location += `:${issue_1.formatIssueLocation(issue.location)}`;
20
20
  }
@@ -4,7 +4,9 @@ function interceptDoneToGetWebpackDevServerTap(compiler, configuration, state) {
4
4
  // inspired by https://github.com/ypresto/fork-ts-checker-async-overlay-webpack-plugin
5
5
  compiler.hooks.done.intercept({
6
6
  register: (tap) => {
7
- if (tap.name === 'webpack-dev-server' && tap.type === 'sync') {
7
+ if (tap.name === 'webpack-dev-server' &&
8
+ tap.type === 'sync' &&
9
+ configuration.logger.devServer) {
8
10
  state.webpackDevServerDoneTap = tap;
9
11
  }
10
12
  return tap;
@@ -59,7 +59,7 @@ function tapDoneToAsyncGetIssues(compiler, configuration, state) {
59
59
  issues = issues.filter(configuration.issue.predicate);
60
60
  // modify list of issues in the plugin hooks
61
61
  issues = hooks.issues.call(issues, stats.compilation);
62
- const formatter = WebpackFormatter_1.createWebpackFormatter(configuration.formatter, compiler.context);
62
+ const formatter = WebpackFormatter_1.createWebpackFormatter(configuration.formatter);
63
63
  if (issues.length) {
64
64
  // follow webpack's approach - one process.write to stderr with all errors and warnings
65
65
  configuration.logger.issues.error(issues.map((issue) => formatter(issue)).join('\n'));
@@ -4,6 +4,7 @@ import webpack from 'webpack';
4
4
  interface LoggerConfiguration {
5
5
  infrastructure: Logger;
6
6
  issues: Logger;
7
+ devServer: boolean;
7
8
  }
8
9
  declare function createLoggerConfiguration(compiler: webpack.Compiler, options: LoggerOptions | undefined): LoggerConfiguration;
9
10
  export { LoggerConfiguration, createLoggerConfiguration };
@@ -5,6 +5,7 @@ function createLoggerConfiguration(compiler, options) {
5
5
  return {
6
6
  infrastructure: LoggerFactory_1.createLogger((options && options.infrastructure) || 'silent', compiler),
7
7
  issues: LoggerFactory_1.createLogger((options && options.issues) || 'console', compiler),
8
+ devServer: (options === null || options === void 0 ? void 0 : options.devServer) !== false,
8
9
  };
9
10
  }
10
11
  exports.createLoggerConfiguration = createLoggerConfiguration;
@@ -3,5 +3,6 @@ import Logger from './Logger';
3
3
  declare type LoggerOptions = {
4
4
  infrastructure?: LoggerType | Logger;
5
5
  issues?: LoggerType | Logger;
6
+ devServer?: boolean;
6
7
  };
7
8
  export default LoggerOptions;
@@ -16,6 +16,7 @@ interface TypeScriptReporterConfiguration {
16
16
  vue: TypeScriptVueExtensionConfiguration;
17
17
  };
18
18
  profile: boolean;
19
+ typescriptPath: string;
19
20
  }
20
21
  declare function createTypeScriptReporterConfiguration(compiler: webpack.Compiler, options: TypeScriptReporterOptions | undefined): TypeScriptReporterConfiguration;
21
22
  export { createTypeScriptReporterConfiguration, TypeScriptReporterConfiguration };
@@ -2,16 +2,8 @@
2
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
- var __importStar = (this && this.__importStar) || function (mod) {
6
- if (mod && mod.__esModule) return mod;
7
- var result = {};
8
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
9
- result["default"] = mod;
10
- return result;
11
- };
12
5
  Object.defineProperty(exports, "__esModule", { value: true });
13
6
  const path_1 = __importDefault(require("path"));
14
- const ts = __importStar(require("typescript"));
15
7
  const semver_1 = __importDefault(require("semver"));
16
8
  const TypeScriptVueExtensionConfiguration_1 = require("./extension/vue/TypeScriptVueExtensionConfiguration");
17
9
  function createTypeScriptReporterConfiguration(compiler, options) {
@@ -21,16 +13,17 @@ function createTypeScriptReporterConfiguration(compiler, options) {
21
13
  ? configFile
22
14
  : path_1.default.resolve(compiler.options.context || process.cwd(), configFile));
23
15
  const optionsAsObject = typeof options === 'object' ? options : {};
16
+ const typescriptPath = optionsAsObject.typescriptPath || require.resolve('typescript');
24
17
  const defaultCompilerOptions = {
25
18
  skipLibCheck: true,
26
19
  sourceMap: false,
27
20
  inlineSourceMap: false,
28
21
  };
29
- if (semver_1.default.gte(ts.version, '2.9.0')) {
22
+ if (semver_1.default.gte(require(typescriptPath).version, '2.9.0')) {
30
23
  defaultCompilerOptions.declarationMap = false;
31
24
  }
32
25
  return Object.assign(Object.assign({ enabled: options !== false, memoryLimit: 2048, build: false, mode: 'write-tsbuildinfo', profile: false }, optionsAsObject), { configFile: configFile, configOverwrite: Object.assign(Object.assign({}, (optionsAsObject.configOverwrite || {})), { compilerOptions: Object.assign(Object.assign({}, defaultCompilerOptions), ((optionsAsObject.configOverwrite || {}).compilerOptions || {})) }), context: optionsAsObject.context || path_1.default.dirname(configFile), extensions: {
33
26
  vue: TypeScriptVueExtensionConfiguration_1.createTypeScriptVueExtensionConfiguration(optionsAsObject.extensions ? optionsAsObject.extensions.vue : undefined),
34
- }, diagnosticOptions: Object.assign({ syntactic: false, semantic: true, declaration: false, global: false }, (optionsAsObject.diagnosticOptions || {})) });
27
+ }, diagnosticOptions: Object.assign({ syntactic: false, semantic: true, declaration: false, global: false }, (optionsAsObject.diagnosticOptions || {})), typescriptPath: typescriptPath });
35
28
  }
36
29
  exports.createTypeScriptReporterConfiguration = createTypeScriptReporterConfiguration;
@@ -14,5 +14,6 @@ declare type TypeScriptReporterOptions = boolean | {
14
14
  vue?: TypeScriptVueExtensionOptions;
15
15
  };
16
16
  profile?: boolean;
17
+ typescriptPath?: string;
17
18
  };
18
19
  export { TypeScriptReporterOptions };
@@ -17,7 +17,7 @@ const TypeScriptVueExtensionSupport_1 = require("./extension/vue/TypeScriptVueEx
17
17
  function assertTypeScriptSupport(configuration) {
18
18
  let typescriptVersion;
19
19
  try {
20
- typescriptVersion = require('typescript').version;
20
+ typescriptVersion = require(configuration.typescriptPath).version;
21
21
  }
22
22
  catch (error) { }
23
23
  if (!typescriptVersion) {
@@ -42,7 +42,7 @@ function createRealFileSystem(caseSensitive = false) {
42
42
  if (!readFileCache.has(normalizedPath)) {
43
43
  const stats = readStats(normalizedPath);
44
44
  if (stats && stats.isFile()) {
45
- readFileCache.set(normalizedPath, fs_extra_1.default.readFileSync(normalizedPath, { encoding }).toString());
45
+ readFileCache.set(normalizedPath, fs_extra_1.default.readFileSync(normalizedPath, { encoding: encoding }).toString());
46
46
  }
47
47
  else {
48
48
  readFileCache.set(normalizedPath, undefined);
@@ -1,4 +1,4 @@
1
1
  import * as ts from 'typescript';
2
2
  import { Issue } from '../../issue';
3
- declare function createIssuesFromTsDiagnostics(diagnostics: ts.Diagnostic[]): Issue[];
3
+ declare function createIssuesFromTsDiagnostics(typescript: typeof ts, diagnostics: ts.Diagnostic[]): Issue[];
4
4
  export { createIssuesFromTsDiagnostics };
@@ -7,10 +7,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
7
7
  return result;
8
8
  };
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- const ts = __importStar(require("typescript"));
11
10
  const os = __importStar(require("os"));
12
11
  const issue_1 = require("../../issue");
13
- function createIssueFromTsDiagnostic(diagnostic) {
12
+ function createIssueFromTsDiagnostic(typescript, diagnostic) {
14
13
  let file;
15
14
  let location;
16
15
  if (diagnostic.file) {
@@ -35,12 +34,12 @@ function createIssueFromTsDiagnostic(diagnostic) {
35
34
  code: 'TS' + String(diagnostic.code),
36
35
  // we don't handle Suggestion and Message diagnostics
37
36
  severity: diagnostic.category === 0 ? 'warning' : 'error',
38
- message: ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL),
37
+ message: typescript.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL),
39
38
  file,
40
39
  location,
41
40
  };
42
41
  }
43
- function createIssuesFromTsDiagnostics(diagnostics) {
44
- return issue_1.deduplicateAndSortIssues(diagnostics.map((diagnostic) => createIssueFromTsDiagnostic(diagnostic)));
42
+ function createIssuesFromTsDiagnostics(typescript, diagnostics) {
43
+ return issue_1.deduplicateAndSortIssues(diagnostics.map((diagnostic) => createIssueFromTsDiagnostic(typescript, diagnostic)));
45
44
  }
46
45
  exports.createIssuesFromTsDiagnostics = createIssuesFromTsDiagnostics;
@@ -1,3 +1,4 @@
1
+ import * as ts from 'typescript';
1
2
  import { Performance } from '../../profile/Performance';
2
3
  interface TypeScriptPerformance {
3
4
  enable(): void;
@@ -5,5 +6,5 @@ interface TypeScriptPerformance {
5
6
  mark(name: string): void;
6
7
  measure(name: string, startMark?: string, endMark?: string): void;
7
8
  }
8
- declare function connectTypeScriptPerformance(performance: Performance): Performance;
9
+ declare function connectTypeScriptPerformance(typescript: typeof ts, performance: Performance): Performance;
9
10
  export { TypeScriptPerformance, connectTypeScriptPerformance };
@@ -1,19 +1,11 @@
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
- };
9
2
  Object.defineProperty(exports, "__esModule", { value: true });
10
- const ts = __importStar(require("typescript"));
11
- function getTypeScriptPerformance() {
3
+ function getTypeScriptPerformance(typescript) {
12
4
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
- return ts.performance;
5
+ return typescript.performance;
14
6
  }
15
- function connectTypeScriptPerformance(performance) {
16
- const typeScriptPerformance = getTypeScriptPerformance();
7
+ function connectTypeScriptPerformance(typescript, performance) {
8
+ const typeScriptPerformance = getTypeScriptPerformance(typescript);
17
9
  if (typeScriptPerformance) {
18
10
  const { mark, measure } = typeScriptPerformance;
19
11
  const { enable, disable } = performance;
@@ -16,5 +16,5 @@ interface ControlledTypeScriptSystem extends ts.System {
16
16
  waitForQueued(): Promise<void>;
17
17
  }
18
18
  declare type FileSystemMode = 'readonly' | 'write-tsbuildinfo' | 'write-references';
19
- declare function createControlledTypeScriptSystem(mode?: FileSystemMode): ControlledTypeScriptSystem;
19
+ declare function createControlledTypeScriptSystem(typescript: typeof ts, mode?: FileSystemMode): ControlledTypeScriptSystem;
20
20
  export { createControlledTypeScriptSystem, ControlledTypeScriptSystem };
@@ -8,23 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importStar = (this && this.__importStar) || function (mod) {
12
- if (mod && mod.__esModule) return mod;
13
- var result = {};
14
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
15
- result["default"] = mod;
16
- return result;
17
- };
18
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
19
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
20
13
  };
21
14
  Object.defineProperty(exports, "__esModule", { value: true });
22
- const ts = __importStar(require("typescript"));
23
15
  const path_1 = require("path");
24
16
  const PassiveFileSystem_1 = require("../file-system/PassiveFileSystem");
25
17
  const forwardSlash_1 = __importDefault(require("../../utils/path/forwardSlash"));
26
18
  const RealFileSystem_1 = require("../file-system/RealFileSystem");
27
- function createControlledTypeScriptSystem(mode = 'readonly') {
19
+ function createControlledTypeScriptSystem(typescript, mode = 'readonly') {
28
20
  // watchers
29
21
  const fileWatcherCallbacksMap = new Map();
30
22
  const directoryWatcherCallbacksMap = new Map();
@@ -33,7 +25,7 @@ function createControlledTypeScriptSystem(mode = 'readonly') {
33
25
  const deletedFiles = new Map();
34
26
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
27
  const timeoutCallbacks = new Set();
36
- const caseSensitive = ts.sys.useCaseSensitiveFileNames;
28
+ const caseSensitive = typescript.sys.useCaseSensitiveFileNames;
37
29
  const realFileSystem = RealFileSystem_1.createRealFileSystem(caseSensitive);
38
30
  const passiveFileSystem = PassiveFileSystem_1.createPassiveFileSystem(caseSensitive, realFileSystem);
39
31
  // based on the ts.ignorePaths
@@ -101,7 +93,7 @@ function createControlledTypeScriptSystem(mode = 'readonly') {
101
93
  return realFileSystem;
102
94
  }
103
95
  }
104
- const controlledSystem = Object.assign(Object.assign({}, ts.sys), { useCaseSensitiveFileNames: caseSensitive, fileExists(path) {
96
+ const controlledSystem = Object.assign(Object.assign({}, typescript.sys), { useCaseSensitiveFileNames: caseSensitive, fileExists(path) {
105
97
  const stats = passiveFileSystem.readStats(path);
106
98
  return !!stats && stats.isFile();
107
99
  },
@@ -141,7 +133,7 @@ function createControlledTypeScriptSystem(mode = 'readonly') {
141
133
  setModifiedTime(path, date) {
142
134
  getWriteFileSystem(path).updateTimes(path, date, date);
143
135
  invokeDirectoryWatchers(path);
144
- invokeFileWatchers(path, ts.FileWatcherEventKind.Changed);
136
+ invokeFileWatchers(path, typescript.FileWatcherEventKind.Changed);
145
137
  },
146
138
  watchFile(path, callback) {
147
139
  return createWatcher(fileWatcherCallbacksMap, path, callback);
@@ -170,25 +162,25 @@ function createControlledTypeScriptSystem(mode = 'readonly') {
170
162
  },
171
163
  invokeFileCreated(path) {
172
164
  const normalizedPath = realFileSystem.normalizePath(path);
173
- invokeFileWatchers(path, ts.FileWatcherEventKind.Created);
165
+ invokeFileWatchers(path, typescript.FileWatcherEventKind.Created);
174
166
  invokeDirectoryWatchers(normalizedPath);
175
167
  deletedFiles.set(normalizedPath, false);
176
168
  },
177
169
  invokeFileChanged(path) {
178
170
  const normalizedPath = realFileSystem.normalizePath(path);
179
171
  if (deletedFiles.get(normalizedPath) || !fileWatcherCallbacksMap.has(normalizedPath)) {
180
- invokeFileWatchers(path, ts.FileWatcherEventKind.Created);
172
+ invokeFileWatchers(path, typescript.FileWatcherEventKind.Created);
181
173
  invokeDirectoryWatchers(normalizedPath);
182
174
  deletedFiles.set(normalizedPath, false);
183
175
  }
184
176
  else {
185
- invokeFileWatchers(path, ts.FileWatcherEventKind.Changed);
177
+ invokeFileWatchers(path, typescript.FileWatcherEventKind.Changed);
186
178
  }
187
179
  },
188
180
  invokeFileDeleted(path) {
189
181
  const normalizedPath = realFileSystem.normalizePath(path);
190
182
  if (!deletedFiles.get(normalizedPath)) {
191
- invokeFileWatchers(path, ts.FileWatcherEventKind.Deleted);
183
+ invokeFileWatchers(path, typescript.FileWatcherEventKind.Deleted);
192
184
  invokeDirectoryWatchers(path);
193
185
  deletedFiles.set(normalizedPath, true);
194
186
  }
@@ -1,5 +1,5 @@
1
1
  import * as ts from 'typescript';
2
2
  import { TypeScriptHostExtension } from '../extension/TypeScriptExtension';
3
3
  import { ControlledTypeScriptSystem } from './ControlledTypeScriptSystem';
4
- declare function createControlledWatchCompilerHost<TProgram extends ts.BuilderProgram>(parsedCommandLine: ts.ParsedCommandLine, system: ControlledTypeScriptSystem, createProgram?: ts.CreateProgram<TProgram>, reportDiagnostic?: ts.DiagnosticReporter, reportWatchStatus?: ts.WatchStatusReporter, afterProgramCreate?: (program: TProgram) => void, hostExtensions?: TypeScriptHostExtension[]): ts.WatchCompilerHostOfFilesAndCompilerOptions<TProgram>;
4
+ declare function createControlledWatchCompilerHost<TProgram extends ts.BuilderProgram>(typescript: typeof ts, parsedCommandLine: ts.ParsedCommandLine, system: ControlledTypeScriptSystem, createProgram?: ts.CreateProgram<TProgram>, reportDiagnostic?: ts.DiagnosticReporter, reportWatchStatus?: ts.WatchStatusReporter, afterProgramCreate?: (program: TProgram) => void, hostExtensions?: TypeScriptHostExtension[]): ts.WatchCompilerHostOfFilesAndCompilerOptions<TProgram>;
5
5
  export { createControlledWatchCompilerHost };
@@ -1,19 +1,11 @@
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
- };
9
2
  Object.defineProperty(exports, "__esModule", { value: true });
10
- const ts = __importStar(require("typescript"));
11
- function createControlledWatchCompilerHost(parsedCommandLine, system, createProgram, reportDiagnostic, reportWatchStatus, afterProgramCreate, hostExtensions = []) {
12
- const baseWatchCompilerHost = ts.createWatchCompilerHost(parsedCommandLine.fileNames, parsedCommandLine.options, system, createProgram, reportDiagnostic, reportWatchStatus, parsedCommandLine.projectReferences);
3
+ function createControlledWatchCompilerHost(typescript, parsedCommandLine, system, createProgram, reportDiagnostic, reportWatchStatus, afterProgramCreate, hostExtensions = []) {
4
+ const baseWatchCompilerHost = typescript.createWatchCompilerHost(parsedCommandLine.fileNames, parsedCommandLine.options, system, createProgram, reportDiagnostic, reportWatchStatus, parsedCommandLine.projectReferences);
13
5
  let controlledWatchCompilerHost = Object.assign(Object.assign({}, baseWatchCompilerHost), { createProgram(rootNames, options, compilerHost, oldProgram, configFileParsingDiagnostics, projectReferences) {
14
6
  // as compilerHost is optional, ensure that we have it
15
7
  if (!compilerHost) {
16
- compilerHost = ts.createCompilerHost(options || parsedCommandLine.options);
8
+ compilerHost = typescript.createCompilerHost(options || parsedCommandLine.options);
17
9
  }
18
10
  hostExtensions.forEach((hostExtension) => {
19
11
  if (compilerHost && hostExtension.extendCompilerHost) {
@@ -1,5 +1,5 @@
1
1
  import * as ts from 'typescript';
2
2
  import { TypeScriptHostExtension } from '../extension/TypeScriptExtension';
3
3
  import { ControlledTypeScriptSystem } from './ControlledTypeScriptSystem';
4
- declare function createControlledWatchSolutionBuilderHost<TProgram extends ts.BuilderProgram>(parsedCommandLine: ts.ParsedCommandLine, system: ControlledTypeScriptSystem, createProgram?: ts.CreateProgram<TProgram>, reportDiagnostic?: ts.DiagnosticReporter, reportWatchStatus?: ts.WatchStatusReporter, reportSolutionBuilderStatus?: (diagnostic: ts.Diagnostic) => void, afterProgramCreate?: (program: TProgram) => void, afterProgramEmitAndDiagnostics?: (program: TProgram) => void, hostExtensions?: TypeScriptHostExtension[]): ts.SolutionBuilderWithWatchHost<TProgram>;
4
+ declare function createControlledWatchSolutionBuilderHost<TProgram extends ts.BuilderProgram>(typescript: typeof ts, parsedCommandLine: ts.ParsedCommandLine, system: ControlledTypeScriptSystem, createProgram?: ts.CreateProgram<TProgram>, reportDiagnostic?: ts.DiagnosticReporter, reportWatchStatus?: ts.WatchStatusReporter, reportSolutionBuilderStatus?: (diagnostic: ts.Diagnostic) => void, afterProgramCreate?: (program: TProgram) => void, afterProgramEmitAndDiagnostics?: (program: TProgram) => void, hostExtensions?: TypeScriptHostExtension[]): ts.SolutionBuilderWithWatchHost<TProgram>;
5
5
  export { createControlledWatchSolutionBuilderHost };
@@ -1,8 +1,16 @@
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 ControlledWatchCompilerHost_1 = require("./ControlledWatchCompilerHost");
4
- function createControlledWatchSolutionBuilderHost(parsedCommandLine, system, createProgram, reportDiagnostic, reportWatchStatus, reportSolutionBuilderStatus, afterProgramCreate, afterProgramEmitAndDiagnostics, hostExtensions = []) {
5
- const controlledWatchCompilerHost = ControlledWatchCompilerHost_1.createControlledWatchCompilerHost(parsedCommandLine, system, createProgram, reportDiagnostic, reportWatchStatus, afterProgramCreate, hostExtensions);
12
+ function createControlledWatchSolutionBuilderHost(typescript, parsedCommandLine, system, createProgram, reportDiagnostic, reportWatchStatus, reportSolutionBuilderStatus, afterProgramCreate, afterProgramEmitAndDiagnostics, hostExtensions = []) {
13
+ const controlledWatchCompilerHost = ControlledWatchCompilerHost_1.createControlledWatchCompilerHost(typescript, parsedCommandLine, system, createProgram, reportDiagnostic, reportWatchStatus, afterProgramCreate, hostExtensions);
6
14
  let controlledWatchSolutionBuilderHost = Object.assign(Object.assign({}, controlledWatchCompilerHost), { reportDiagnostic(diagnostic) {
7
15
  if (reportDiagnostic) {
8
16
  reportDiagnostic(diagnostic);
@@ -32,6 +40,13 @@ function createControlledWatchSolutionBuilderHost(parsedCommandLine, system, cre
32
40
  },
33
41
  deleteFile(fileName) {
34
42
  system.deleteFile(fileName);
43
+ },
44
+ getParsedCommandLine(fileName) {
45
+ return ts.getParsedCommandLineOfConfigFile(fileName, { skipLibCheck: true }, Object.assign(Object.assign({}, system), { onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
46
+ if (reportDiagnostic) {
47
+ reportDiagnostic(diagnostic);
48
+ }
49
+ } }));
35
50
  } });
36
51
  hostExtensions.forEach((hostExtension) => {
37
52
  if (hostExtension.extendWatchSolutionBuilderHost) {
@@ -1,4 +1,4 @@
1
1
  import * as ts from 'typescript';
2
2
  import { TypeScriptConfigurationOverwrite } from '../TypeScriptConfigurationOverwrite';
3
- declare function parseTypeScriptConfiguration(configFileName: string, configFileContext: string, configOverwriteJSON: TypeScriptConfigurationOverwrite, parseConfigFileHost: ts.ParseConfigFileHost): ts.ParsedCommandLine;
3
+ declare function parseTypeScriptConfiguration(typescript: typeof ts, configFileName: string, configFileContext: string, configOverwriteJSON: TypeScriptConfigurationOverwrite, parseConfigFileHost: ts.ParseConfigFileHost): ts.ParsedCommandLine;
4
4
  export { parseTypeScriptConfiguration };
@@ -1,17 +1,9 @@
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
- };
9
2
  Object.defineProperty(exports, "__esModule", { value: true });
10
- const ts = __importStar(require("typescript"));
11
- function parseTypeScriptConfiguration(configFileName, configFileContext, configOverwriteJSON, parseConfigFileHost) {
12
- const parsedConfigFileJSON = ts.readConfigFile(configFileName, parseConfigFileHost.readFile);
3
+ function parseTypeScriptConfiguration(typescript, configFileName, configFileContext, configOverwriteJSON, parseConfigFileHost) {
4
+ const parsedConfigFileJSON = typescript.readConfigFile(configFileName, parseConfigFileHost.readFile);
13
5
  const overwrittenConfigFileJSON = Object.assign(Object.assign(Object.assign({}, (parsedConfigFileJSON.config || {})), configOverwriteJSON), { compilerOptions: Object.assign(Object.assign({}, ((parsedConfigFileJSON.config || {}).compilerOptions || {})), (configOverwriteJSON.compilerOptions || {})) });
14
- const parsedConfigFile = ts.parseJsonConfigFileContent(overwrittenConfigFileJSON, parseConfigFileHost, configFileContext);
6
+ const parsedConfigFile = typescript.parseJsonConfigFileContent(overwrittenConfigFileJSON, parseConfigFileHost, configFileContext);
15
7
  return Object.assign(Object.assign({}, parsedConfigFile), { options: Object.assign(Object.assign({}, parsedConfigFile.options), { configFilePath: configFileName }), errors: parsedConfigFileJSON.error ? [parsedConfigFileJSON.error] : parsedConfigFile.errors });
16
8
  }
17
9
  exports.parseTypeScriptConfiguration = parseTypeScriptConfiguration;
@@ -8,18 +8,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importStar = (this && this.__importStar) || function (mod) {
12
- if (mod && mod.__esModule) return mod;
13
- var result = {};
14
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
15
- result["default"] = mod;
16
- return result;
17
- };
18
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
19
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
20
13
  };
21
14
  Object.defineProperty(exports, "__esModule", { value: true });
22
- const ts = __importStar(require("typescript"));
23
15
  const path_1 = __importDefault(require("path"));
24
16
  const TypeScriptIssueFactory_1 = require("../issue/TypeScriptIssueFactory");
25
17
  const ControlledWatchCompilerHost_1 = require("./ControlledWatchCompilerHost");
@@ -39,7 +31,9 @@ function createTypeScriptReporter(configuration) {
39
31
  let watchProgram;
40
32
  let solutionBuilder;
41
33
  const diagnosticsPerProject = new Map();
42
- const performance = TypeScriptPerformance_1.connectTypeScriptPerformance(Performance_1.createPerformance());
34
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
35
+ const typescript = require(configuration.typescriptPath);
36
+ const performance = TypeScriptPerformance_1.connectTypeScriptPerformance(typescript, Performance_1.createPerformance());
43
37
  if (configuration.extensions.vue.enabled) {
44
38
  extensions.push(TypeScriptVueExtension_1.createTypeScriptVueExtension(configuration.extensions.vue));
45
39
  }
@@ -88,7 +82,7 @@ function createTypeScriptReporter(configuration) {
88
82
  performance.enable();
89
83
  }
90
84
  if (!system) {
91
- system = ControlledTypeScriptSystem_1.createControlledTypeScriptSystem(configuration.mode);
85
+ system = ControlledTypeScriptSystem_1.createControlledTypeScriptSystem(typescript, configuration.mode);
92
86
  }
93
87
  // clear cache to be ready for next iteration and to free memory
94
88
  system.clearCache();
@@ -115,7 +109,7 @@ function createTypeScriptReporter(configuration) {
115
109
  }
116
110
  });
117
111
  performance.markStart('Parse Configuration');
118
- parsedConfiguration = TypeScriptConfigurationParser_1.parseTypeScriptConfiguration(configuration.configFile, configuration.context, configuration.configOverwrite, parseConfigFileHost);
112
+ parsedConfiguration = TypeScriptConfigurationParser_1.parseTypeScriptConfiguration(typescript, configuration.configFile, configuration.context, configuration.configOverwrite, parseConfigFileHost);
119
113
  performance.markEnd('Parse Configuration');
120
114
  if (parsedConfiguration.errors) {
121
115
  parseConfigurationDiagnostics.push(...parsedConfiguration.errors);
@@ -123,7 +117,7 @@ function createTypeScriptReporter(configuration) {
123
117
  // report configuration diagnostics and exit
124
118
  if (parseConfigurationDiagnostics.length) {
125
119
  parsedConfiguration = undefined;
126
- let issues = TypeScriptIssueFactory_1.createIssuesFromTsDiagnostics(parseConfigurationDiagnostics);
120
+ let issues = TypeScriptIssueFactory_1.createIssuesFromTsDiagnostics(typescript, parseConfigurationDiagnostics);
127
121
  issues.forEach((issue) => {
128
122
  if (!issue.file) {
129
123
  issue.file = configuration.configFile;
@@ -139,10 +133,10 @@ function createTypeScriptReporter(configuration) {
139
133
  if (configurationChanged) {
140
134
  configurationChanged = false;
141
135
  // try to remove outdated .tsbuildinfo file for incremental mode
142
- if (typeof ts.getTsBuildInfoEmitOutputFilePath === 'function' &&
136
+ if (typeof typescript.getTsBuildInfoEmitOutputFilePath === 'function' &&
143
137
  configuration.mode !== 'readonly' &&
144
138
  parsedConfiguration.options.incremental) {
145
- const tsBuildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(parsedConfiguration.options);
139
+ const tsBuildInfoPath = typescript.getTsBuildInfoEmitOutputFilePath(parsedConfiguration.options);
146
140
  if (tsBuildInfoPath) {
147
141
  try {
148
142
  system.deleteFile(tsBuildInfoPath);
@@ -159,7 +153,7 @@ function createTypeScriptReporter(configuration) {
159
153
  // ensure watch solution builder host exists
160
154
  if (!watchSolutionBuilderHost) {
161
155
  performance.markStart('Create Solution Builder Host');
162
- watchSolutionBuilderHost = ControlledWatchSolutionBuilderHost_1.createControlledWatchSolutionBuilderHost(parsedConfiguration, system, ts.createSemanticDiagnosticsBuilderProgram, undefined, undefined, undefined, undefined, (builderProgram) => {
156
+ watchSolutionBuilderHost = ControlledWatchSolutionBuilderHost_1.createControlledWatchSolutionBuilderHost(typescript, parsedConfiguration, system, typescript.createSemanticDiagnosticsBuilderProgram, undefined, undefined, undefined, undefined, (builderProgram) => {
163
157
  const projectName = getProjectNameOfBuilderProgram(builderProgram);
164
158
  const diagnostics = getDiagnosticsOfBuilderProgram(builderProgram);
165
159
  // update diagnostics
@@ -173,7 +167,7 @@ function createTypeScriptReporter(configuration) {
173
167
  // ensure solution builder exists
174
168
  if (!solutionBuilder) {
175
169
  performance.markStart('Create Solution Builder');
176
- solutionBuilder = ts.createSolutionBuilderWithWatch(watchSolutionBuilderHost, [configuration.configFile], {});
170
+ solutionBuilder = typescript.createSolutionBuilderWithWatch(watchSolutionBuilderHost, [configuration.configFile], {});
177
171
  performance.markEnd('Create Solution Builder');
178
172
  performance.markStart('Build Solutions');
179
173
  solutionBuilder.build();
@@ -185,7 +179,7 @@ function createTypeScriptReporter(configuration) {
185
179
  // ensure watch compiler host exists
186
180
  if (!watchCompilerHost) {
187
181
  performance.markStart('Create Watch Compiler Host');
188
- watchCompilerHost = ControlledWatchCompilerHost_1.createControlledWatchCompilerHost(parsedConfiguration, system, ts.createSemanticDiagnosticsBuilderProgram, undefined, undefined, (builderProgram) => {
182
+ watchCompilerHost = ControlledWatchCompilerHost_1.createControlledWatchCompilerHost(typescript, parsedConfiguration, system, typescript.createSemanticDiagnosticsBuilderProgram, undefined, undefined, (builderProgram) => {
189
183
  const projectName = getProjectNameOfBuilderProgram(builderProgram);
190
184
  const diagnostics = getDiagnosticsOfBuilderProgram(builderProgram);
191
185
  // update diagnostics
@@ -199,7 +193,7 @@ function createTypeScriptReporter(configuration) {
199
193
  // ensure watch program exists
200
194
  if (!watchProgram) {
201
195
  performance.markStart('Create Watch Program');
202
- watchProgram = ts.createWatchProgram(watchCompilerHost);
196
+ watchProgram = typescript.createWatchProgram(watchCompilerHost);
203
197
  performance.markEnd('Create Watch Program');
204
198
  }
205
199
  }
@@ -225,7 +219,7 @@ function createTypeScriptReporter(configuration) {
225
219
  diagnosticsPerProject.forEach((projectDiagnostics) => {
226
220
  diagnostics.push(...projectDiagnostics);
227
221
  });
228
- let issues = TypeScriptIssueFactory_1.createIssuesFromTsDiagnostics(diagnostics);
222
+ let issues = TypeScriptIssueFactory_1.createIssuesFromTsDiagnostics(typescript, diagnostics);
229
223
  extensions.forEach((extension) => {
230
224
  if (extension.extendIssues) {
231
225
  issues = extension.extendIssues(issues);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fork-ts-checker-webpack-plugin",
3
- "version": "5.0.13",
3
+ "version": "5.2.1",
4
4
  "description": "Runs typescript type checker and linter on separate process.",
5
5
  "keywords": [
6
6
  "fast",
@@ -34,8 +34,8 @@
34
34
  "build": "cross-env rimraf lib && cross-env tsc --version && cross-env tsc",
35
35
  "lint": "cross-env eslint ./src ./test --ext .ts",
36
36
  "test": "yarn build && yarn test:unit && yarn test:e2e",
37
- "test:unit": "cross-env jest unit",
38
- "test:e2e": "npm pack && cross-env jest e2e --ci --runInBand --bail --verbose",
37
+ "test:unit": "cross-env jest --config=test/unit/jest.config.js",
38
+ "test:e2e": "npm pack && cross-env jest --config=test/e2e/jest.config.js --ci -i -b",
39
39
  "precommit": "cross-env lint-staged && yarn build && yarn test:unit",
40
40
  "commit": "cross-env git-cz",
41
41
  "semantic-release": "semantic-release"
@@ -73,43 +73,45 @@
73
73
  "tapable": "^1.0.0"
74
74
  },
75
75
  "devDependencies": {
76
- "@commitlint/config-conventional": "^8.3.4",
76
+ "@commitlint/config-conventional": "^11.0.0",
77
77
  "@semantic-release/commit-analyzer": "^8.0.1",
78
78
  "@semantic-release/exec": "^5.0.0",
79
- "@semantic-release/github": "^7.0.7",
80
- "@semantic-release/npm": "^7.0.5",
79
+ "@semantic-release/github": "^7.1.1",
80
+ "@semantic-release/npm": "^7.0.6",
81
81
  "@semantic-release/release-notes-generator": "^9.0.1",
82
- "@types/babel__code-frame": "^7.0.1",
82
+ "@types/babel__code-frame": "^7.0.2",
83
83
  "@types/cross-spawn": "^6.0.2",
84
- "@types/eslint": "^6.8.0",
85
- "@types/fs-extra": "^8.1.0",
86
- "@types/jest": "^25.2.1",
84
+ "@types/eslint": "^7.2.4",
85
+ "@types/fs-extra": "^9.0.2",
86
+ "@types/jest": "^26.0.14",
87
87
  "@types/minimatch": "^3.0.1",
88
- "@types/mock-fs": "^4.10.0",
89
- "@types/node": "^13.11.1",
88
+ "@types/mock-fs": "^4.13.0",
89
+ "@types/node": "^14.11.10",
90
90
  "@types/rimraf": "^3.0.0",
91
- "@types/semver": "^7.1.0",
92
- "@types/webpack": "^4.41.11",
91
+ "@types/semver": "^7.3.4",
92
+ "@types/webpack": "^4.41.22",
93
93
  "@typescript-eslint/eslint-plugin": "^2.27.0",
94
94
  "@typescript-eslint/parser": "^2.27.0",
95
- "commitlint": "^8.3.5",
95
+ "commitlint": "^11.0.0",
96
96
  "cross-env": "^7.0.2",
97
- "cross-spawn": "^7.0.2",
97
+ "cross-spawn": "^7.0.3",
98
98
  "eslint": "^6.8.0",
99
- "eslint-config-prettier": "^6.10.1",
99
+ "eslint-config-prettier": "^6.13.0",
100
100
  "eslint-plugin-node": "^11.1.0",
101
- "eslint-plugin-prettier": "^3.1.3",
102
- "git-cz": "^4.3.1",
103
- "husky": "^4.2.5",
104
- "jest": "^25.3.0",
105
- "lint-staged": "^10.1.3",
106
- "mock-fs": "^4.11.0",
107
- "prettier": "^2.0.4",
101
+ "eslint-plugin-prettier": "^3.1.4",
102
+ "git-cz": "^4.7.1",
103
+ "husky": "^4.3.0",
104
+ "jest": "^26.5.3",
105
+ "jest-circus": "^26.5.3",
106
+ "jest-environment-node": "^26.5.2",
107
+ "lint-staged": "^10.4.2",
108
+ "mock-fs": "^4.13.0",
109
+ "prettier": "^2.1.2",
108
110
  "rimraf": "^3.0.2",
109
- "semantic-release": "^17.0.0",
111
+ "semantic-release": "^17.2.1",
110
112
  "strip-ansi": "^6.0.0",
111
113
  "tree-kill": "^1.2.2",
112
- "ts-jest": "^25.3.1",
114
+ "ts-jest": "^26.4.1",
113
115
  "typescript": "^3.8.3",
114
116
  "webpack": "^4.42.1"
115
117
  },