fork-ts-checker-webpack-plugin 6.2.11 → 6.3.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 (26) hide show
  1. package/README.md +26 -13
  2. package/lib/ForkTsCheckerWebpackPlugin.d.ts +7 -2
  3. package/lib/ForkTsCheckerWebpackPlugin.js +22 -10
  4. package/lib/ForkTsCheckerWebpackPluginState.d.ts +2 -1
  5. package/lib/ForkTsCheckerWebpackPluginState.js +2 -1
  6. package/lib/eslint-reporter/reporter/EsLintReporter.js +1 -0
  7. package/lib/hooks/tapDoneToAsyncGetIssues.js +2 -2
  8. package/lib/hooks/tapStartToConnectAndRunReporter.d.ts +1 -1
  9. package/lib/hooks/tapStartToConnectAndRunReporter.js +35 -15
  10. package/lib/hooks/tapStopToDisconnectReporter.d.ts +1 -1
  11. package/lib/hooks/tapStopToDisconnectReporter.js +6 -4
  12. package/lib/reporter/FilesMatch.d.ts +1 -0
  13. package/lib/reporter/reporter-rpc/ReporterRpcClient.js +13 -3
  14. package/lib/typescript-reporter/extension/TypeScriptExtension.d.ts +1 -1
  15. package/lib/typescript-reporter/issue/TypeScriptIssueFactory.d.ts +1 -1
  16. package/lib/typescript-reporter/profile/TypeScriptPerformance.d.ts +1 -1
  17. package/lib/typescript-reporter/reporter/ControlledTypeScriptSystem.d.ts +1 -1
  18. package/lib/typescript-reporter/reporter/ControlledTypeScriptSystem.js +1 -0
  19. package/lib/typescript-reporter/reporter/ControlledWatchCompilerHost.d.ts +1 -1
  20. package/lib/typescript-reporter/reporter/ControlledWatchSolutionBuilderHost.d.ts +1 -1
  21. package/lib/typescript-reporter/reporter/ControlledWatchSolutionBuilderHost.js +1 -9
  22. package/lib/typescript-reporter/reporter/TypeScriptConfigurationParser.d.ts +2 -2
  23. package/lib/typescript-reporter/reporter/TypeScriptConfigurationParser.js +17 -19
  24. package/lib/typescript-reporter/reporter/TypeScriptReporter.js +1 -1
  25. package/lib/watch/InclusiveNodeWatchFileSystem.js +7 -6
  26. package/package.json +1 -1
package/README.md CHANGED
@@ -362,24 +362,37 @@ When we call this method with a [webpack compiler instance](https://webpack.js.o
362
362
  [tapable](https://github.com/webpack/tapable) hooks where you can pass in your callbacks.
363
363
 
364
364
  ```js
365
- const webpack = require('webpack');
365
+ // ./src/webpack/MyWebpackPlugin.js
366
366
  const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
367
367
 
368
- const compiler = webpack({
369
- // ... webpack config
370
- });
368
+ class MyWebpackPlugin {
369
+ apply(compiler) {
370
+ const hooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(compiler);
371
+
372
+ // log some message on waiting
373
+ hooks.waiting.tap('MyPlugin', () => {
374
+ console.log('waiting for issues');
375
+ });
376
+ // don't show warnings
377
+ hooks.issues.tap('MyPlugin', (issues) =>
378
+ issues.filter((issue) => issue.severity === 'error')
379
+ );
380
+ }
381
+ }
371
382
 
372
- // optionally add the plugin to the compiler
373
- // **don't do this if already added through configuration**
374
- new ForkTsCheckerWebpackPlugin().apply(compiler);
383
+ module.exports = MyWebpackPlugin;
375
384
 
376
- // now get the plugin hooks from compiler
377
- const hooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(compiler);
385
+ // webpack.config.js
386
+ const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
387
+ const MyWebpackPlugin = require('./src/webpack/MyWebpackPlugin');
378
388
 
379
- // say we want to show some message when plugin is waiting for issues results
380
- hooks.waiting.tap('yourListenerName', () => {
381
- console.log('waiting for issues');
382
- });
389
+ module.exports = {
390
+ /* ... */
391
+ plugins: [
392
+ new ForkTsCheckerWebpackPlugin(),
393
+ new MyWebpackPlugin()
394
+ ]
395
+ };
383
396
  ```
384
397
 
385
398
  ## Typings
@@ -7,9 +7,14 @@ declare class ForkTsCheckerWebpackPlugin implements webpack.Plugin {
7
7
  */
8
8
  static readonly version: string;
9
9
  /**
10
- * Default pool for the plugin concurrency limit
10
+ * Default pools for the plugin concurrency limit
11
11
  */
12
- static readonly pool: Pool;
12
+ static readonly issuesPool: Pool;
13
+ static readonly dependenciesPool: Pool;
14
+ /**
15
+ * @deprecated Use ForkTsCheckerWebpackPlugin.issuesPool instead
16
+ */
17
+ static get pool(): Pool;
13
18
  private readonly options;
14
19
  constructor(options?: ForkTsCheckerWebpackPluginOptions);
15
20
  static getCompilerHooks(compiler: webpack.Compiler): {
@@ -33,27 +33,38 @@ class ForkTsCheckerWebpackPlugin {
33
33
  // then validate merged options
34
34
  schema_utils_1.default(ForkTsCheckerWebpackPluginOptions_json_1.default, this.options, configuration);
35
35
  }
36
+ /**
37
+ * @deprecated Use ForkTsCheckerWebpackPlugin.issuesPool instead
38
+ */
39
+ static get pool() {
40
+ // for backward compatibility
41
+ return ForkTsCheckerWebpackPlugin.issuesPool;
42
+ }
36
43
  static getCompilerHooks(compiler) {
37
44
  return pluginHooks_1.getForkTsCheckerWebpackPluginHooks(compiler);
38
45
  }
39
46
  apply(compiler) {
40
47
  const configuration = ForkTsCheckerWebpackPluginConfiguration_1.createForkTsCheckerWebpackPluginConfiguration(compiler, this.options);
41
48
  const state = ForkTsCheckerWebpackPluginState_1.createForkTsCheckerWebpackPluginState();
42
- const reporters = [];
49
+ const issuesReporters = [];
50
+ const dependenciesReporters = [];
43
51
  if (configuration.typescript.enabled) {
44
52
  TypeScriptSupport_1.assertTypeScriptSupport(configuration.typescript);
45
- reporters.push(TypeScriptReporterRpcClient_1.createTypeScriptReporterRpcClient(configuration.typescript));
53
+ issuesReporters.push(TypeScriptReporterRpcClient_1.createTypeScriptReporterRpcClient(configuration.typescript));
54
+ dependenciesReporters.push(TypeScriptReporterRpcClient_1.createTypeScriptReporterRpcClient(configuration.typescript));
46
55
  }
47
56
  if (configuration.eslint.enabled) {
48
57
  assertEsLintSupport_1.assertEsLintSupport(configuration.eslint);
49
- reporters.push(EsLintReporterRpcClient_1.createEsLintReporterRpcClient(configuration.eslint));
58
+ issuesReporters.push(EsLintReporterRpcClient_1.createEsLintReporterRpcClient(configuration.eslint));
59
+ dependenciesReporters.push(EsLintReporterRpcClient_1.createEsLintReporterRpcClient(configuration.eslint));
50
60
  }
51
- if (reporters.length) {
52
- const reporter = reporter_1.createAggregatedReporter(reporter_1.composeReporterRpcClients(reporters));
61
+ if (issuesReporters.length) {
62
+ const issuesReporter = reporter_1.createAggregatedReporter(reporter_1.composeReporterRpcClients(issuesReporters));
63
+ const dependenciesReporter = reporter_1.createAggregatedReporter(reporter_1.composeReporterRpcClients(dependenciesReporters));
53
64
  tapAfterEnvironmentToPatchWatching_1.tapAfterEnvironmentToPatchWatching(compiler, state);
54
- tapStartToConnectAndRunReporter_1.tapStartToConnectAndRunReporter(compiler, reporter, configuration, state);
65
+ tapStartToConnectAndRunReporter_1.tapStartToConnectAndRunReporter(compiler, issuesReporter, dependenciesReporter, configuration, state);
55
66
  tapAfterCompileToAddDependencies_1.tapAfterCompileToAddDependencies(compiler, configuration, state);
56
- tapStopToDisconnectReporter_1.tapStopToDisconnectReporter(compiler, reporter, state);
67
+ tapStopToDisconnectReporter_1.tapStopToDisconnectReporter(compiler, issuesReporter, dependenciesReporter, state);
57
68
  tapErrorToLogMessage_1.tapErrorToLogMessage(compiler, configuration);
58
69
  }
59
70
  else {
@@ -65,8 +76,9 @@ exports.ForkTsCheckerWebpackPlugin = ForkTsCheckerWebpackPlugin;
65
76
  /**
66
77
  * Current version of the plugin
67
78
  */
68
- ForkTsCheckerWebpackPlugin.version = '6.2.11'; // will be replaced by the @semantic-release/exec
79
+ ForkTsCheckerWebpackPlugin.version = '6.3.1'; // will be replaced by the @semantic-release/exec
69
80
  /**
70
- * Default pool for the plugin concurrency limit
81
+ * Default pools for the plugin concurrency limit
71
82
  */
72
- ForkTsCheckerWebpackPlugin.pool = pool_1.createPool(Math.max(1, os_1.default.cpus().length));
83
+ ForkTsCheckerWebpackPlugin.issuesPool = pool_1.createPool(Math.max(1, os_1.default.cpus().length));
84
+ ForkTsCheckerWebpackPlugin.dependenciesPool = pool_1.createPool(Math.max(1, os_1.default.cpus().length));
@@ -2,7 +2,8 @@ import { Tap } from 'tapable';
2
2
  import { FilesMatch, Report } from './reporter';
3
3
  import { Issue } from './issue';
4
4
  interface ForkTsCheckerWebpackPluginState {
5
- reportPromise: Promise<Report | undefined>;
5
+ issuesReportPromise: Promise<Report | undefined>;
6
+ dependenciesReportPromise: Promise<Report | undefined>;
6
7
  issuesPromise: Promise<Issue[] | undefined>;
7
8
  dependenciesPromise: Promise<FilesMatch | undefined>;
8
9
  lastDependencies: FilesMatch | undefined;
@@ -2,7 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  function createForkTsCheckerWebpackPluginState() {
4
4
  return {
5
- reportPromise: Promise.resolve(undefined),
5
+ issuesReportPromise: Promise.resolve(undefined),
6
+ dependenciesReportPromise: Promise.resolve(undefined),
6
7
  issuesPromise: Promise.resolve(undefined),
7
8
  dependenciesPromise: Promise.resolve(undefined),
8
9
  lastDependencies: 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
  });
@@ -25,7 +25,7 @@ function tapDoneToAsyncGetIssues(compiler, configuration, state) {
25
25
  // run only for the compiler that the plugin was registered for
26
26
  return;
27
27
  }
28
- const reportPromise = state.reportPromise;
28
+ const reportPromise = state.issuesReportPromise;
29
29
  const issuesPromise = state.issuesPromise;
30
30
  let issues;
31
31
  try {
@@ -47,7 +47,7 @@ function tapDoneToAsyncGetIssues(compiler, configuration, state) {
47
47
  // some error has been thrown or it was canceled
48
48
  return;
49
49
  }
50
- if (reportPromise !== state.reportPromise) {
50
+ if (reportPromise !== state.issuesReportPromise) {
51
51
  // there is a newer report - ignore this one
52
52
  return;
53
53
  }
@@ -2,5 +2,5 @@ import webpack from 'webpack';
2
2
  import { ForkTsCheckerWebpackPluginConfiguration } from '../ForkTsCheckerWebpackPluginConfiguration';
3
3
  import { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
4
4
  import { ReporterRpcClient } from '../reporter';
5
- declare function tapStartToConnectAndRunReporter(compiler: webpack.Compiler, reporter: ReporterRpcClient, configuration: ForkTsCheckerWebpackPluginConfiguration, state: ForkTsCheckerWebpackPluginState): void;
5
+ declare function tapStartToConnectAndRunReporter(compiler: webpack.Compiler, issuesReporter: ReporterRpcClient, dependenciesReporter: ReporterRpcClient, configuration: ForkTsCheckerWebpackPluginConfiguration, state: ForkTsCheckerWebpackPluginState): void;
6
6
  export { tapStartToConnectAndRunReporter };
@@ -16,7 +16,7 @@ const tapDoneToAsyncGetIssues_1 = require("./tapDoneToAsyncGetIssues");
16
16
  const tapAfterCompileToGetIssues_1 = require("./tapAfterCompileToGetIssues");
17
17
  const interceptDoneToGetWebpackDevServerTap_1 = require("./interceptDoneToGetWebpackDevServerTap");
18
18
  const ForkTsCheckerWebpackPlugin_1 = require("../ForkTsCheckerWebpackPlugin");
19
- function tapStartToConnectAndRunReporter(compiler, reporter, configuration, state) {
19
+ function tapStartToConnectAndRunReporter(compiler, issuesReporter, dependenciesReporter, configuration, state) {
20
20
  const hooks = pluginHooks_1.getForkTsCheckerWebpackPluginHooks(compiler);
21
21
  compiler.hooks.run.tap('ForkTsCheckerWebpackPlugin', () => {
22
22
  if (!state.initialized) {
@@ -56,36 +56,57 @@ function tapStartToConnectAndRunReporter(compiler, reporter, configuration, stat
56
56
  configuration.logger.infrastructure.info('Calling reporter service for single check.');
57
57
  }
58
58
  let resolveDependencies;
59
- let rejectedDependencies;
59
+ let rejectDependencies;
60
60
  let resolveIssues;
61
61
  let rejectIssues;
62
62
  state.dependenciesPromise = new Promise((resolve, reject) => {
63
63
  resolveDependencies = resolve;
64
- rejectedDependencies = reject;
64
+ rejectDependencies = reject;
65
65
  });
66
66
  state.issuesPromise = new Promise((resolve, reject) => {
67
67
  resolveIssues = resolve;
68
68
  rejectIssues = reject;
69
69
  });
70
- const previousReportPromise = state.reportPromise;
71
- state.reportPromise = ForkTsCheckerWebpackPlugin_1.ForkTsCheckerWebpackPlugin.pool.submit((done) => new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
72
- change = yield hooks.start.promise(change, compilation);
70
+ const previousIssuesReportPromise = state.issuesReportPromise;
71
+ const previousDependenciesReportPromise = state.dependenciesReportPromise;
72
+ change = yield hooks.start.promise(change, compilation);
73
+ state.issuesReportPromise = ForkTsCheckerWebpackPlugin_1.ForkTsCheckerWebpackPlugin.issuesPool.submit((done) => new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
73
74
  try {
74
- yield reporter.connect();
75
- const previousReport = yield previousReportPromise;
75
+ yield issuesReporter.connect();
76
+ const previousReport = yield previousIssuesReportPromise;
76
77
  if (previousReport) {
77
78
  yield previousReport.close();
78
79
  }
79
- const report = yield reporter.getReport(change);
80
+ const report = yield issuesReporter.getReport(change);
81
+ resolve(report);
82
+ report.getIssues().then(resolveIssues).catch(rejectIssues).finally(done);
83
+ }
84
+ catch (error) {
85
+ if (error instanceof OperationCanceledError_1.OperationCanceledError) {
86
+ hooks.canceled.call(compilation);
87
+ }
88
+ else {
89
+ hooks.error.call(error, compilation);
90
+ }
91
+ resolve(undefined);
92
+ resolveIssues(undefined);
93
+ done();
94
+ }
95
+ })));
96
+ state.dependenciesReportPromise = ForkTsCheckerWebpackPlugin_1.ForkTsCheckerWebpackPlugin.dependenciesPool.submit((done) => new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
97
+ try {
98
+ yield dependenciesReporter.connect();
99
+ const previousReport = yield previousDependenciesReportPromise;
100
+ if (previousReport) {
101
+ yield previousReport.close();
102
+ }
103
+ const report = yield dependenciesReporter.getReport(change);
80
104
  resolve(report);
81
105
  report
82
106
  .getDependencies()
83
107
  .then(resolveDependencies)
84
- .catch(rejectedDependencies)
85
- .finally(() => {
86
- // get issues after dependencies are resolved as it can be blocking
87
- report.getIssues().then(resolveIssues).catch(rejectIssues).finally(done);
88
- });
108
+ .catch(rejectDependencies)
109
+ .finally(done);
89
110
  }
90
111
  catch (error) {
91
112
  if (error instanceof OperationCanceledError_1.OperationCanceledError) {
@@ -96,7 +117,6 @@ function tapStartToConnectAndRunReporter(compiler, reporter, configuration, stat
96
117
  }
97
118
  resolve(undefined);
98
119
  resolveDependencies(undefined);
99
- resolveIssues(undefined);
100
120
  done();
101
121
  }
102
122
  })));
@@ -1,5 +1,5 @@
1
1
  import webpack from 'webpack';
2
2
  import { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
3
3
  import { ReporterRpcClient } from '../reporter';
4
- declare function tapStopToDisconnectReporter(compiler: webpack.Compiler, reporter: ReporterRpcClient, state: ForkTsCheckerWebpackPluginState): void;
4
+ declare function tapStopToDisconnectReporter(compiler: webpack.Compiler, issuesReporter: ReporterRpcClient, dependenciesReporter: ReporterRpcClient, state: ForkTsCheckerWebpackPluginState): void;
5
5
  export { tapStopToDisconnectReporter };
@@ -9,18 +9,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- function tapStopToDisconnectReporter(compiler, reporter, state) {
12
+ function tapStopToDisconnectReporter(compiler, issuesReporter, dependenciesReporter, state) {
13
13
  compiler.hooks.watchClose.tap('ForkTsCheckerWebpackPlugin', () => {
14
- reporter.disconnect();
14
+ issuesReporter.disconnect();
15
+ dependenciesReporter.disconnect();
15
16
  });
16
17
  compiler.hooks.done.tap('ForkTsCheckerWebpackPlugin', () => __awaiter(this, void 0, void 0, function* () {
17
18
  if (!state.watching) {
18
- yield reporter.disconnect();
19
+ yield Promise.all([issuesReporter.disconnect(), dependenciesReporter.disconnect()]);
19
20
  }
20
21
  }));
21
22
  compiler.hooks.failed.tap('ForkTsCheckerWebpackPlugin', () => {
22
23
  if (!state.watching) {
23
- reporter.disconnect();
24
+ issuesReporter.disconnect();
25
+ dependenciesReporter.disconnect();
24
26
  }
25
27
  });
26
28
  }
@@ -1,6 +1,7 @@
1
1
  interface FilesMatch {
2
2
  files: string[];
3
3
  dirs: string[];
4
+ excluded: string[];
4
5
  extensions: string[];
5
6
  }
6
7
  export { FilesMatch };
@@ -24,8 +24,17 @@ function createReporterRpcClient(channel, configuration) {
24
24
  yield channel.open();
25
25
  }
26
26
  if (!rpcClient.isConnected()) {
27
- yield rpcClient.connect();
28
- yield rpcClient.dispatchCall(ReporterRpcProcedure_1.configure, configuration);
27
+ try {
28
+ yield rpcClient.connect();
29
+ yield rpcClient.dispatchCall(ReporterRpcProcedure_1.configure, configuration);
30
+ }
31
+ catch (error) {
32
+ // connect or configure was not successful -
33
+ // close the reporter and re-throw an error
34
+ yield rpcClient.disconnect();
35
+ yield channel.close();
36
+ throw error;
37
+ }
29
38
  }
30
39
  }),
31
40
  disconnect: () => __awaiter(this, void 0, void 0, function* () {
@@ -62,8 +71,9 @@ function composeReporterRpcClients(clients) {
62
71
  getDependencies: () => Promise.all(reports.map((report) => report.getDependencies())).then((dependencies) => dependencies.reduce((mergedDependencies, singleDependencies) => ({
63
72
  files: Array.from(new Set([...mergedDependencies.files, ...singleDependencies.files])),
64
73
  dirs: Array.from(new Set([...mergedDependencies.dirs, ...singleDependencies.dirs])),
74
+ excluded: Array.from(new Set([...mergedDependencies.excluded, ...singleDependencies.excluded])),
65
75
  extensions: Array.from(new Set([...mergedDependencies.extensions, ...singleDependencies.extensions])),
66
- }), { files: [], dirs: [], extensions: [] })),
76
+ }), { files: [], dirs: [], excluded: [], extensions: [] })),
67
77
  getIssues: () => Promise.all(reports.map((report) => report.getIssues())).then((issues) => flatten_1.default(issues)),
68
78
  close: () => Promise.all(reports.map((report) => report.close())).then(() => undefined),
69
79
  })),
@@ -1,4 +1,4 @@
1
- import * as ts from 'typescript';
1
+ import type * as ts from 'typescript';
2
2
  import { Issue } from '../../issue';
3
3
  import { FilesMatch } from '../../reporter';
4
4
  interface TypeScriptHostExtension {
@@ -1,4 +1,4 @@
1
- import * as ts from 'typescript';
1
+ import type * as ts from 'typescript';
2
2
  import { Issue } from '../../issue';
3
3
  declare function createIssuesFromTsDiagnostics(typescript: typeof ts, diagnostics: ts.Diagnostic[]): Issue[];
4
4
  export { createIssuesFromTsDiagnostics };
@@ -1,4 +1,4 @@
1
- import * as ts from 'typescript';
1
+ import type * as ts from 'typescript';
2
2
  import { Performance } from '../../profile/Performance';
3
3
  interface TypeScriptPerformance {
4
4
  enable(): void;
@@ -1,4 +1,4 @@
1
- import * as ts from 'typescript';
1
+ import type * as ts from 'typescript';
2
2
  import { FilesMatch } from '../../reporter';
3
3
  interface ControlledTypeScriptSystem extends ts.System {
4
4
  invokeFileCreated(path: string): void;
@@ -21,6 +21,7 @@ function createControlledTypeScriptSystem(typescript, mode = 'readonly') {
21
21
  let artifacts = {
22
22
  files: [],
23
23
  dirs: [],
24
+ excluded: [],
24
25
  extensions: [],
25
26
  };
26
27
  let isInitialRun = true;
@@ -1,4 +1,4 @@
1
- import * as ts from 'typescript';
1
+ import type * as ts from 'typescript';
2
2
  import { TypeScriptHostExtension } from '../extension/TypeScriptExtension';
3
3
  import { ControlledTypeScriptSystem } from './ControlledTypeScriptSystem';
4
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>;
@@ -1,4 +1,4 @@
1
- import * as ts from 'typescript';
1
+ import type * as ts from 'typescript';
2
2
  import { TypeScriptHostExtension } from '../extension/TypeScriptExtension';
3
3
  import { ControlledTypeScriptSystem } from './ControlledTypeScriptSystem';
4
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>;
@@ -1,13 +1,5 @@
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
3
  const ControlledWatchCompilerHost_1 = require("./ControlledWatchCompilerHost");
12
4
  function createControlledWatchSolutionBuilderHost(typescript, parsedCommandLine, system, createProgram, reportDiagnostic, reportWatchStatus, reportSolutionBuilderStatus, afterProgramCreate, afterProgramEmitAndDiagnostics, hostExtensions = []) {
13
5
  const controlledWatchCompilerHost = ControlledWatchCompilerHost_1.createControlledWatchCompilerHost(typescript, parsedCommandLine, system, createProgram, reportDiagnostic, reportWatchStatus, afterProgramCreate, hostExtensions);
@@ -42,7 +34,7 @@ function createControlledWatchSolutionBuilderHost(typescript, parsedCommandLine,
42
34
  system.deleteFile(fileName);
43
35
  },
44
36
  getParsedCommandLine(fileName) {
45
- return ts.getParsedCommandLineOfConfigFile(fileName, { skipLibCheck: true }, Object.assign(Object.assign({}, system), { onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
37
+ return typescript.getParsedCommandLineOfConfigFile(fileName, { skipLibCheck: true }, Object.assign(Object.assign({}, system), { onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
46
38
  if (reportDiagnostic) {
47
39
  reportDiagnostic(diagnostic);
48
40
  }
@@ -1,8 +1,8 @@
1
- import * as ts from 'typescript';
1
+ import type * as ts from 'typescript';
2
2
  import { TypeScriptConfigurationOverwrite } from '../TypeScriptConfigurationOverwrite';
3
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, parseConfigFileHost: ts.ParseConfigFileHost, processedConfigFiles?: string[]): FilesMatch;
5
+ declare function getDependenciesFromTypeScriptConfiguration(typescript: typeof ts, parsedConfiguration: ts.ParsedCommandLine, configFileContext: string, parseConfigFileHost: ts.ParseConfigFileHost, processedConfigFiles?: string[]): FilesMatch;
6
6
  export declare function isIncrementalCompilation(options: ts.CompilerOptions): boolean;
7
7
  declare function getArtifactsFromTypeScriptConfiguration(typescript: typeof ts, parsedConfiguration: ts.ParsedCommandLine, configFileContext: string, parseConfigFileHost: ts.ParseConfigFileHost, processedConfigFiles?: string[]): FilesMatch;
8
8
  export { parseTypeScriptConfiguration, getDependenciesFromTypeScriptConfiguration, getArtifactsFromTypeScriptConfiguration, };
@@ -1,13 +1,5 @@
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
3
  const path_1 = require("path");
12
4
  function parseTypeScriptConfiguration(typescript, configFileName, configFileContext, configOverwriteJSON, parseConfigFileHost) {
13
5
  const parsedConfigFileJSON = typescript.readConfigFile(configFileName, parseConfigFileHost.readFile);
@@ -16,20 +8,24 @@ function parseTypeScriptConfiguration(typescript, configFileName, configFileCont
16
8
  return Object.assign(Object.assign({}, parsedConfigFile), { options: Object.assign(Object.assign({}, parsedConfigFile.options), { configFilePath: configFileName }), errors: parsedConfigFileJSON.error ? [parsedConfigFileJSON.error] : parsedConfigFile.errors });
17
9
  }
18
10
  exports.parseTypeScriptConfiguration = parseTypeScriptConfiguration;
19
- function getDependenciesFromTypeScriptConfiguration(typescript, parsedConfiguration, parseConfigFileHost, processedConfigFiles = []) {
11
+ function getDependenciesFromTypeScriptConfiguration(typescript, parsedConfiguration, configFileContext, parseConfigFileHost, processedConfigFiles = []) {
12
+ var _a;
20
13
  const files = new Set(parsedConfiguration.fileNames);
21
- if (typeof parsedConfiguration.options.configFilePath === 'string') {
22
- files.add(parsedConfiguration.options.configFilePath);
14
+ const configFilePath = parsedConfiguration.options.configFilePath;
15
+ if (typeof configFilePath === 'string') {
16
+ files.add(configFilePath);
23
17
  }
24
18
  const dirs = new Set(Object.keys(parsedConfiguration.wildcardDirectories || {}));
19
+ const excluded = new Set((((_a = parsedConfiguration.raw) === null || _a === void 0 ? void 0 : _a.exclude) || []).map((path) => path_1.resolve(configFileContext, path)));
25
20
  for (const projectReference of parsedConfiguration.projectReferences || []) {
26
- const configFile = typescript.resolveProjectReferencePath(projectReference);
27
- if (processedConfigFiles.includes(configFile)) {
21
+ const childConfigFilePath = typescript.resolveProjectReferencePath(projectReference);
22
+ const childConfigContext = path_1.dirname(childConfigFilePath);
23
+ if (processedConfigFiles.includes(childConfigFilePath)) {
28
24
  // handle circular dependencies
29
25
  continue;
30
26
  }
31
- const parsedConfiguration = parseTypeScriptConfiguration(typescript, configFile, path_1.dirname(configFile), {}, parseConfigFileHost);
32
- const childDependencies = getDependenciesFromTypeScriptConfiguration(typescript, parsedConfiguration, parseConfigFileHost, [...processedConfigFiles, configFile]);
27
+ const childParsedConfiguration = parseTypeScriptConfiguration(typescript, childConfigFilePath, childConfigContext, {}, parseConfigFileHost);
28
+ const childDependencies = getDependenciesFromTypeScriptConfiguration(typescript, childParsedConfiguration, childConfigContext, parseConfigFileHost, [...processedConfigFiles, childConfigFilePath]);
33
29
  childDependencies.files.forEach((file) => {
34
30
  files.add(file);
35
31
  });
@@ -47,6 +43,7 @@ function getDependenciesFromTypeScriptConfiguration(typescript, parsedConfigurat
47
43
  return {
48
44
  files: Array.from(files).map((file) => path_1.normalize(file)),
49
45
  dirs: Array.from(dirs).map((dir) => path_1.normalize(dir)),
46
+ excluded: Array.from(excluded).map((path) => path_1.normalize(path)),
50
47
  extensions: extensions,
51
48
  };
52
49
  }
@@ -63,10 +60,10 @@ function removeJsonExtension(path) {
63
60
  return path;
64
61
  }
65
62
  }
66
- function getTsBuildInfoEmitOutputFilePath(options) {
67
- if (typeof ts.getTsBuildInfoEmitOutputFilePath === 'function') {
63
+ function getTsBuildInfoEmitOutputFilePath(typescript, options) {
64
+ if (typeof typescript.getTsBuildInfoEmitOutputFilePath === 'function') {
68
65
  // old TypeScript version doesn't provides this method
69
- return ts.getTsBuildInfoEmitOutputFilePath(options);
66
+ return typescript.getTsBuildInfoEmitOutputFilePath(options);
70
67
  }
71
68
  // based on the implementation from typescript
72
69
  const configFile = options.configFilePath;
@@ -101,7 +98,7 @@ function getArtifactsFromTypeScriptConfiguration(typescript, parsedConfiguration
101
98
  if (parsedConfiguration.options.outFile) {
102
99
  files.add(path_1.resolve(configFileContext, parsedConfiguration.options.outFile));
103
100
  }
104
- const tsBuildInfoPath = getTsBuildInfoEmitOutputFilePath(parsedConfiguration.options);
101
+ const tsBuildInfoPath = getTsBuildInfoEmitOutputFilePath(typescript, parsedConfiguration.options);
105
102
  if (tsBuildInfoPath) {
106
103
  files.add(path_1.resolve(configFileContext, tsBuildInfoPath));
107
104
  }
@@ -132,6 +129,7 @@ function getArtifactsFromTypeScriptConfiguration(typescript, parsedConfiguration
132
129
  return {
133
130
  files: Array.from(files).map((file) => path_1.normalize(file)),
134
131
  dirs: Array.from(dirs).map((dir) => path_1.normalize(dir)),
132
+ excluded: [],
135
133
  extensions,
136
134
  };
137
135
  }
@@ -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, parseConfigFileHost);
119
+ let dependencies = TypeScriptConfigurationParser_1.getDependenciesFromTypeScriptConfiguration(typescript, parsedConfiguration, configuration.context, parseConfigFileHost);
120
120
  for (const extension of extensions) {
121
121
  if (extension.extendDependencies) {
122
122
  dependencies = extension.extendDependencies(dependencies);
@@ -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.11",
3
+ "version": "6.3.1",
4
4
  "description": "Runs typescript type checker and linter on separate process.",
5
5
  "keywords": [
6
6
  "fast",