fork-ts-checker-webpack-plugin 6.0.4 → 6.0.5

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.
@@ -60,4 +60,4 @@ class ForkTsCheckerWebpackPlugin {
60
60
  }
61
61
  }
62
62
  exports.ForkTsCheckerWebpackPlugin = ForkTsCheckerWebpackPlugin;
63
- ForkTsCheckerWebpackPlugin.version = '6.0.4'; // will be replaced by the @semantic-release/exec
63
+ ForkTsCheckerWebpackPlugin.version = '6.0.5'; // will be replaced by the @semantic-release/exec
@@ -6,7 +6,7 @@ function tapAfterEnvironmentToPatchWatching(compiler, state) {
6
6
  const watchFileSystem = compiler.watchFileSystem;
7
7
  if (watchFileSystem) {
8
8
  // wrap original watch file system
9
- compiler.watchFileSystem = new InclusiveNodeWatchFileSystem_1.InclusiveNodeWatchFileSystem(watchFileSystem, state);
9
+ compiler.watchFileSystem = new InclusiveNodeWatchFileSystem_1.InclusiveNodeWatchFileSystem(watchFileSystem, compiler, state);
10
10
  }
11
11
  });
12
12
  }
@@ -10,8 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const pluginHooks_1 = require("./pluginHooks");
13
- const getDeletedFiles_1 = require("./getDeletedFiles");
14
- const getChangedFiles_1 = require("./getChangedFiles");
13
+ const reporter_1 = require("../reporter");
15
14
  const OperationCanceledError_1 = require("../error/OperationCanceledError");
16
15
  const tapDoneToAsyncGetIssues_1 = require("./tapDoneToAsyncGetIssues");
17
16
  const tapAfterCompileToGetIssues_1 = require("./tapAfterCompileToGetIssues");
@@ -45,10 +44,7 @@ function tapStartToConnectAndRunReporter(compiler, reporter, configuration, stat
45
44
  }
46
45
  let change = {};
47
46
  if (state.watching) {
48
- change = {
49
- changedFiles: getChangedFiles_1.getChangedFiles(compilation.compiler),
50
- deletedFiles: getDeletedFiles_1.getDeletedFiles(compilation.compiler),
51
- };
47
+ change = reporter_1.getFilesChange(compiler);
52
48
  configuration.logger.infrastructure.info([
53
49
  'Calling reporter service for incremental check.',
54
50
  ` Changed files: ${JSON.stringify(change.changedFiles)}`,
@@ -1,7 +1,11 @@
1
+ import { Compiler } from 'webpack';
1
2
  interface FilesChange {
2
3
  changedFiles?: string[];
3
4
  deletedFiles?: string[];
4
5
  }
6
+ declare function getFilesChange(compiler: Compiler): FilesChange;
7
+ declare function updateFilesChange(compiler: Compiler, change: FilesChange): void;
8
+ declare function clearFilesChange(compiler: Compiler): void;
5
9
  /**
6
10
  * Computes aggregated files change based on the subsequent files changes.
7
11
  *
@@ -9,4 +13,4 @@ interface FilesChange {
9
13
  * @returns Files change that represents all subsequent changes as a one event
10
14
  */
11
15
  declare function aggregateFilesChanges(changes: FilesChange[]): FilesChange;
12
- export { FilesChange, aggregateFilesChanges };
16
+ export { FilesChange, getFilesChange, updateFilesChange, clearFilesChange, aggregateFilesChanges };
@@ -5,6 +5,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const substract_1 = __importDefault(require("../utils/array/substract"));
7
7
  const unique_1 = __importDefault(require("../utils/array/unique"));
8
+ const compilerFilesChangeMap = new WeakMap();
9
+ function getFilesChange(compiler) {
10
+ return compilerFilesChangeMap.get(compiler) || {};
11
+ }
12
+ exports.getFilesChange = getFilesChange;
13
+ function updateFilesChange(compiler, change) {
14
+ compilerFilesChangeMap.set(compiler, aggregateFilesChanges([getFilesChange(compiler), change]));
15
+ }
16
+ exports.updateFilesChange = updateFilesChange;
17
+ function clearFilesChange(compiler) {
18
+ compilerFilesChangeMap.delete(compiler);
19
+ }
20
+ exports.clearFilesChange = clearFilesChange;
8
21
  /**
9
22
  * Computes aggregated files change based on the subsequent files changes.
10
23
  *
@@ -1,14 +1,14 @@
1
1
  import { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
2
2
  import { FSWatcher } from 'chokidar';
3
3
  import { Watcher, WatchFileSystem, WatchFileSystemOptions } from './WatchFileSystem';
4
+ import { Compiler } from 'webpack';
4
5
  declare class InclusiveNodeWatchFileSystem implements WatchFileSystem {
5
6
  private watchFileSystem;
7
+ private compiler;
6
8
  private pluginState;
7
9
  get watcher(): import("./WatchFileSystem").Watchpack;
8
- readonly changedFiles: Set<string>;
9
- readonly removedFiles: Set<string>;
10
10
  readonly dirsWatchers: Map<string, FSWatcher | undefined>;
11
- constructor(watchFileSystem: WatchFileSystem, pluginState: ForkTsCheckerWebpackPluginState);
11
+ constructor(watchFileSystem: WatchFileSystem, compiler: Compiler, pluginState: ForkTsCheckerWebpackPluginState);
12
12
  private paused;
13
13
  watch(files: Iterable<string>, dirs: Iterable<string>, missing: Iterable<string>, startTime?: number, options?: Partial<WatchFileSystemOptions>, callback?: Function, callbackUndelayed?: Function): Watcher;
14
14
  }
@@ -5,17 +5,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const chokidar_1 = __importDefault(require("chokidar"));
7
7
  const path_1 = require("path");
8
+ const reporter_1 = require("../reporter");
8
9
  const IGNORED_DIRS = ['node_modules', '.git', '.yarn', '.pnp'];
9
10
  function isIgnored(path) {
10
11
  return IGNORED_DIRS.some((ignoredDir) => path.includes(`/${ignoredDir}/`));
11
12
  }
12
13
  class InclusiveNodeWatchFileSystem {
13
- constructor(watchFileSystem, pluginState) {
14
+ constructor(watchFileSystem, compiler, pluginState) {
14
15
  this.watchFileSystem = watchFileSystem;
16
+ this.compiler = compiler;
15
17
  this.pluginState = pluginState;
16
18
  this.paused = true;
17
- this.changedFiles = new Set();
18
- this.removedFiles = new Set();
19
19
  this.dirsWatchers = new Map();
20
20
  }
21
21
  get watcher() {
@@ -24,20 +24,17 @@ class InclusiveNodeWatchFileSystem {
24
24
  }
25
25
  watch(files, dirs, missing, startTime, options, callback, callbackUndelayed) {
26
26
  var _a, _b, _c;
27
- this.changedFiles.clear();
28
- this.removedFiles.clear();
27
+ reporter_1.clearFilesChange(this.compiler);
29
28
  // use standard watch file system for files and missing
30
29
  const standardWatcher = this.watchFileSystem.watch(files, dirs, missing, startTime, options, callback, callbackUndelayed);
31
30
  (_a = this.watcher) === null || _a === void 0 ? void 0 : _a.on('change', (file) => {
32
31
  if (typeof file === 'string' && !isIgnored(file)) {
33
- this.changedFiles.add(file);
34
- this.removedFiles.delete(file);
32
+ reporter_1.updateFilesChange(this.compiler, { changedFiles: [file] });
35
33
  }
36
34
  });
37
35
  (_b = this.watcher) === null || _b === void 0 ? void 0 : _b.on('remove', (file) => {
38
36
  if (typeof file === 'string' && !isIgnored(file)) {
39
- this.removedFiles.add(file);
40
- this.changedFiles.delete(file);
37
+ reporter_1.updateFilesChange(this.compiler, { deletedFiles: [file] });
41
38
  }
42
39
  });
43
40
  // calculate what to change
@@ -74,8 +71,7 @@ class InclusiveNodeWatchFileSystem {
74
71
  if (!supportedExtensions.includes(extension)) {
75
72
  return;
76
73
  }
77
- this.changedFiles.add(file);
78
- this.removedFiles.delete(file);
74
+ reporter_1.updateFilesChange(this.compiler, { changedFiles: [file] });
79
75
  const mtime = (stats === null || stats === void 0 ? void 0 : stats.mtimeMs) || (stats === null || stats === void 0 ? void 0 : stats.ctimeMs) || 1;
80
76
  (_b = this.watcher) === null || _b === void 0 ? void 0 : _b._onChange(dirToWatch, mtime, file, 'rename');
81
77
  });
@@ -89,16 +85,14 @@ class InclusiveNodeWatchFileSystem {
89
85
  if (!supportedExtensions.includes(extension)) {
90
86
  return;
91
87
  }
92
- this.removedFiles.add(file);
93
- this.changedFiles.delete(file);
88
+ reporter_1.updateFilesChange(this.compiler, { deletedFiles: [file] });
94
89
  (_b = this.watcher) === null || _b === void 0 ? void 0 : _b._onRemove(dirToWatch, file, 'rename');
95
90
  });
96
91
  this.dirsWatchers.set(dirToWatch, dirWatcher);
97
92
  });
98
93
  this.paused = false;
99
94
  return Object.assign(Object.assign({}, standardWatcher), { close: () => {
100
- this.changedFiles.clear();
101
- this.removedFiles.clear();
95
+ reporter_1.clearFilesChange(this.compiler);
102
96
  if (standardWatcher) {
103
97
  standardWatcher.close();
104
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fork-ts-checker-webpack-plugin",
3
- "version": "6.0.4",
3
+ "version": "6.0.5",
4
4
  "description": "Runs typescript type checker and linter on separate process.",
5
5
  "keywords": [
6
6
  "fast",
@@ -1,3 +0,0 @@
1
- import webpack from 'webpack';
2
- declare function getChangedFiles(compiler: webpack.Compiler): string[];
3
- export { getChangedFiles };
@@ -1,14 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const path_1 = __importDefault(require("path"));
7
- function getChangedFiles(compiler) {
8
- const watchFileSystem = compiler
9
- .watchFileSystem;
10
- return watchFileSystem
11
- ? Array.from(watchFileSystem.changedFiles).map((changedFile) => path_1.default.normalize(changedFile))
12
- : [];
13
- }
14
- exports.getChangedFiles = getChangedFiles;
@@ -1,3 +0,0 @@
1
- import webpack from 'webpack';
2
- declare function getDeletedFiles(compiler: webpack.Compiler): string[];
3
- export { getDeletedFiles };
@@ -1,14 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const path_1 = __importDefault(require("path"));
7
- function getDeletedFiles(compiler) {
8
- const watchFileSystem = compiler
9
- .watchFileSystem;
10
- return watchFileSystem
11
- ? Array.from(watchFileSystem.removedFiles).map((removeFile) => path_1.default.normalize(removeFile))
12
- : [];
13
- }
14
- exports.getDeletedFiles = getDeletedFiles;
@@ -1,8 +0,0 @@
1
- /// <reference types="node" />
2
- import webpack from 'webpack';
3
- import { EventEmitter } from 'events';
4
- interface Watcher extends EventEmitter {
5
- mtimes: Record<string, number>;
6
- }
7
- declare function getWatcher(compiler: webpack.Compiler): Watcher | undefined;
8
- export { getWatcher, Watcher };
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function getWatcher(compiler) {
4
- // webpack 4
5
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
- const { watchFileSystem } = compiler;
7
- if (watchFileSystem) {
8
- return watchFileSystem.watcher || (watchFileSystem.wfs && watchFileSystem.wfs.watcher);
9
- }
10
- }
11
- exports.getWatcher = getWatcher;