fork-ts-checker-webpack-plugin 7.2.4 → 7.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -359,6 +359,10 @@ setting "generateTrace" compiler option. This is an instruction from [microsoft/
359
359
  6. Open `types.json` in an editor
360
360
  7. When you see a type ID in the tracing output, go-to-line {id} to find data about that type
361
361
 
362
+ ## Enabling incremental mode
363
+
364
+ You must both set "incremental": true in your `tsconfig.json` (under `compilerOptions`) and also specify mode: 'write-references' in `ForkTsCheckerWebpackPlugin` settings.
365
+
362
366
 
363
367
  ## Related projects
364
368
 
@@ -1,9 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.aggregateFilesChanges = exports.clearFilesChange = exports.updateFilesChange = exports.consumeFilesChange = exports.getFilesChange = void 0;
4
+ // we ignore package.json file because of https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/674
5
+ const IGNORED_FILES = ['package.json'];
6
+ const isIgnoredFile = (file) => IGNORED_FILES.some((ignoredFile) => file.endsWith(`/${ignoredFile}`) || file.endsWith(`\\${ignoredFile}`));
4
7
  const compilerFilesChangeMap = new WeakMap();
5
8
  function getFilesChange(compiler) {
6
- return compilerFilesChangeMap.get(compiler) || { changedFiles: [], deletedFiles: [] };
9
+ const { changedFiles = [], deletedFiles = [] } = compilerFilesChangeMap.get(compiler) || {
10
+ changedFiles: [],
11
+ deletedFiles: [],
12
+ };
13
+ return {
14
+ changedFiles: changedFiles.filter((changedFile) => !isIgnoredFile(changedFile)),
15
+ deletedFiles: deletedFiles.filter((deletedFile) => !isIgnoredFile(deletedFile)),
16
+ };
7
17
  }
8
18
  exports.getFilesChange = getFilesChange;
9
19
  function consumeFilesChange(compiler) {
package/lib/plugin.js CHANGED
@@ -70,7 +70,7 @@ exports.ForkTsCheckerWebpackPlugin = ForkTsCheckerWebpackPlugin;
70
70
  /**
71
71
  * Current version of the plugin
72
72
  */
73
- ForkTsCheckerWebpackPlugin.version = '7.2.4'; // will be replaced by the @semantic-release/exec
73
+ ForkTsCheckerWebpackPlugin.version = '7.2.7'; // will be replaced by the @semantic-release/exec
74
74
  /**
75
75
  * Default pools for the plugin concurrency limit
76
76
  */
@@ -1,23 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -29,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
29
10
  };
30
11
  Object.defineProperty(exports, "__esModule", { value: true });
31
12
  exports.wrapRpc = void 0;
32
- const process = __importStar(require("process"));
13
+ const controlled_promise_1 = require("../utils/async/controlled-promise");
33
14
  const rpc_error_1 = require("./rpc-error");
34
15
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
16
  function wrapRpc(childProcess) {
@@ -41,50 +22,52 @@ function wrapRpc(childProcess) {
41
22
  throw new Error(`Process ${childProcess.pid} doesn't have open IPC channels`);
42
23
  }
43
24
  const id = uuid();
44
- const resultPromise = new Promise((resolve, reject) => {
45
- const handleMessage = (message) => {
46
- if (message.id === id) {
47
- if (message.type === 'resolve') {
48
- resolve(message.value);
49
- unsubscribe();
50
- }
51
- else if (message.type === 'reject') {
52
- reject(message.error);
53
- unsubscribe();
54
- }
55
- }
56
- };
57
- const handleClose = (code, signal) => {
58
- reject(new rpc_error_1.RpcExitError(code
59
- ? `Process ${process.pid} exited with code "${code}" [${signal}]`
60
- : `Process ${process.pid} exited [${signal}].`, code, signal));
61
- unsubscribe();
62
- };
63
- const subscribe = () => {
64
- childProcess.on('message', handleMessage);
65
- childProcess.on('close', handleClose);
66
- };
67
- const unsubscribe = () => {
68
- childProcess.off('message', handleMessage);
69
- childProcess.off('exit', handleClose);
70
- };
71
- subscribe();
72
- });
73
- yield new Promise((resolve, reject) => {
74
- childProcess.send({
75
- type: 'call',
76
- id,
77
- args,
78
- }, (error) => {
79
- if (error) {
80
- reject(error);
25
+ // create promises
26
+ const { promise: resultPromise, resolve: resolveResult, reject: rejectResult, } = (0, controlled_promise_1.createControlledPromise)();
27
+ const { promise: sendPromise, resolve: resolveSend, reject: rejectSend, } = (0, controlled_promise_1.createControlledPromise)();
28
+ const handleMessage = (message) => {
29
+ if ((message === null || message === void 0 ? void 0 : message.id) === id) {
30
+ if (message.type === 'resolve') {
31
+ // assume the contract is respected
32
+ resolveResult(message.value);
33
+ removeHandlers();
81
34
  }
82
- else {
83
- resolve(undefined);
35
+ else if (message.type === 'reject') {
36
+ rejectResult(message.error);
37
+ removeHandlers();
84
38
  }
85
- });
39
+ }
40
+ };
41
+ const handleClose = (code, signal) => {
42
+ rejectResult(new rpc_error_1.RpcExitError(code
43
+ ? `Process ${childProcess.pid} exited with code ${code}` +
44
+ (signal ? ` [${signal}]` : '')
45
+ : `Process ${childProcess.pid} exited` + (signal ? ` [${signal}]` : ''), code, signal));
46
+ removeHandlers();
47
+ };
48
+ // to prevent event handler leaks
49
+ const removeHandlers = () => {
50
+ childProcess.off('message', handleMessage);
51
+ childProcess.off('close', handleClose);
52
+ };
53
+ // add event listeners
54
+ childProcess.on('message', handleMessage);
55
+ childProcess.on('close', handleClose);
56
+ // send call message
57
+ childProcess.send({
58
+ type: 'call',
59
+ id,
60
+ args,
61
+ }, (error) => {
62
+ if (error) {
63
+ rejectSend(error);
64
+ removeHandlers();
65
+ }
66
+ else {
67
+ resolveSend(undefined);
68
+ }
86
69
  });
87
- return resultPromise;
70
+ return sendPromise.then(() => resultPromise);
88
71
  }));
89
72
  }
90
73
  exports.wrapRpc = wrapRpc;
@@ -0,0 +1,6 @@
1
+ declare function createControlledPromise<T = unknown>(): {
2
+ promise: Promise<T>;
3
+ resolve: (value: T) => void;
4
+ reject: (error: unknown) => void;
5
+ };
6
+ export { createControlledPromise };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createControlledPromise = void 0;
4
+ function createControlledPromise() {
5
+ let resolve = () => undefined;
6
+ let reject = () => undefined;
7
+ const promise = new Promise((aResolve, aReject) => {
8
+ resolve = aResolve;
9
+ reject = aReject;
10
+ });
11
+ return {
12
+ promise,
13
+ resolve,
14
+ reject,
15
+ };
16
+ }
17
+ exports.createControlledPromise = createControlledPromise;
@@ -10,8 +10,6 @@ const minimatch_1 = __importDefault(require("minimatch"));
10
10
  const files_change_1 = require("../files-change");
11
11
  const infrastructure_logger_1 = require("../infrastructure-logger");
12
12
  const BUILTIN_IGNORED_DIRS = ['node_modules', '.git', '.yarn', '.pnp'];
13
- // we ignore package.json file because of https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/674
14
- const BUILTIN_IGNORED_FILES = ['package.json'];
15
13
  function createIsIgnored(ignored, excluded) {
16
14
  const ignoredPatterns = ignored ? (Array.isArray(ignored) ? ignored : [ignored]) : [];
17
15
  const ignoredFunctions = ignoredPatterns.map((pattern) => {
@@ -28,8 +26,7 @@ function createIsIgnored(ignored, excluded) {
28
26
  }
29
27
  });
30
28
  ignoredFunctions.push((path) => excluded.some((excludedPath) => path.startsWith(excludedPath)));
31
- ignoredFunctions.push((path) => BUILTIN_IGNORED_DIRS.some((ignoredDir) => path.includes(`/${ignoredDir}/`)));
32
- ignoredFunctions.push((path) => BUILTIN_IGNORED_FILES.some((ignoredFile) => path.endsWith(`/${ignoredFile}`)));
29
+ ignoredFunctions.push((path) => BUILTIN_IGNORED_DIRS.some((ignoredDir) => path.includes(`/${ignoredDir}/`) || path.includes(`\\${ignoredDir}\\`)));
33
30
  return function isIgnored(path) {
34
31
  return ignoredFunctions.some((ignoredFunction) => ignoredFunction(path));
35
32
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fork-ts-checker-webpack-plugin",
3
- "version": "7.2.4",
3
+ "version": "7.2.7",
4
4
  "description": "Runs typescript type checker and linter on separate process.",
5
5
  "keywords": [
6
6
  "webpack",