ts-checker-rspack-plugin 1.0.0 → 1.0.2

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
@@ -10,7 +10,6 @@ Rspack plugin that runs TypeScript type checker on a separate process.
10
10
  <a href="https://npmcharts.com/compare/ts-checker-rspack-plugin?minimal=true"><img src="https://img.shields.io/npm/dm/ts-checker-rspack-plugin.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="downloads" /></a>
11
11
  </p>
12
12
 
13
-
14
13
  ## Credits
15
14
 
16
15
  This plugin is forked from [TypeStrong/fork-ts-checker-webpack-plugin](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin), which is created by [Piotr Oleś](https://github.com/piotr-oles). See the original project's [LICENSE](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/blob/main/LICENSE).
@@ -23,6 +22,8 @@ Big thanks to `fork-ts-checker-webpack-plugin` creators and contributors for the
23
22
  - Supports modern TypeScript features like [project references](https://www.typescriptlang.org/docs/handbook/project-references.html) and [incremental mode](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#faster-subsequent-builds-with-the---incremental-flag) ✨
24
23
  - Displays nice error messages with the [code frame](https://babeljs.io/docs/en/next/babel-code-frame.html) formatter 🌈
25
24
 
25
+ 💡 For Rsbuild projects, use [@rsbuild/plugin-type-check](https://github.com/rspack-contrib/rsbuild-plugin-type-check) to get out-of-the-box experience.
26
+
26
27
  ## Installation
27
28
 
28
29
  This plugin requires **Node.js >=16.0.0+**, **Rspack ^1.0.0**, **TypeScript ^3.8.0**
@@ -191,7 +192,7 @@ module.exports = MyRspackPlugin;
191
192
 
192
193
  // rspack.config.js
193
194
  const { TsCheckerRspackPlugin } = require('ts-checker-rspack-plugin');
194
- const MyRspackPlugin = require('./src/webpack/MyRspackPlugin');
195
+ const MyRspackPlugin = require('./src/rspack/MyRspackPlugin');
195
196
 
196
197
  module.exports = {
197
198
  /* ... */
@@ -14,7 +14,10 @@ function createCodeFrameFormatter(options) {
14
14
  const source = issue.file && node_fs_1.default.existsSync(issue.file) && node_fs_1.default.readFileSync(issue.file, 'utf-8');
15
15
  let frame = '';
16
16
  if (source && issue.location) {
17
- frame = (0, code_frame_1.codeFrameColumns)(source, issue.location, Object.assign({ highlightCode: true }, (options || {})))
17
+ frame = (0, code_frame_1.codeFrameColumns)(source, issue.location, {
18
+ highlightCode: true,
19
+ ...(options || {}),
20
+ })
18
21
  .split('\n')
19
22
  .map((line) => ' ' + line)
20
23
  .join(os_1.default.EOL);
@@ -1,24 +1,15 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.tapAfterCompileToAddDependencies = void 0;
13
4
  const infrastructure_logger_1 = require("../infrastructure-logger");
14
5
  function tapAfterCompileToAddDependencies(compiler, config, state) {
15
6
  const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
16
- compiler.hooks.afterCompile.tapPromise('TsCheckerRspackPlugin', (compilation) => __awaiter(this, void 0, void 0, function* () {
7
+ compiler.hooks.afterCompile.tapPromise('TsCheckerRspackPlugin', async (compilation) => {
17
8
  if (compilation.compiler !== compiler) {
18
9
  // run only for the compiler that the plugin was registered for
19
10
  return;
20
11
  }
21
- const dependencies = yield state.dependenciesPromise;
12
+ const dependencies = await state.dependenciesPromise;
22
13
  debug(`Got dependencies from the getDependenciesWorker.`, dependencies);
23
14
  if (dependencies) {
24
15
  state.lastDependencies = dependencies;
@@ -26,6 +17,6 @@ function tapAfterCompileToAddDependencies(compiler, config, state) {
26
17
  compilation.fileDependencies.add(file);
27
18
  });
28
19
  }
29
- }));
20
+ });
30
21
  }
31
22
  exports.tapAfterCompileToAddDependencies = tapAfterCompileToAddDependencies;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.tapAfterCompileToGetIssues = void 0;
13
4
  const infrastructure_logger_1 = require("../infrastructure-logger");
@@ -16,20 +7,20 @@ const plugin_hooks_1 = require("../plugin-hooks");
16
7
  function tapAfterCompileToGetIssues(compiler, config, state) {
17
8
  const hooks = (0, plugin_hooks_1.getPluginHooks)(compiler);
18
9
  const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
19
- compiler.hooks.afterCompile.tapPromise('TsCheckerRspackPlugin', (compilation) => __awaiter(this, void 0, void 0, function* () {
10
+ compiler.hooks.afterCompile.tapPromise('TsCheckerRspackPlugin', async (compilation) => {
20
11
  if (compilation.compiler !== compiler) {
21
12
  // run only for the compiler that the plugin was registered for
22
13
  return;
23
14
  }
24
15
  let issues = [];
25
16
  try {
26
- issues = yield state.issuesPromise;
17
+ issues = await state.issuesPromise;
27
18
  }
28
19
  catch (error) {
29
20
  hooks.error.call(error, compilation);
30
21
  return;
31
22
  }
32
- debug('Got issues from getIssuesWorker.', issues === null || issues === void 0 ? void 0 : issues.length);
23
+ debug('Got issues from getIssuesWorker.', issues?.length);
33
24
  if (!issues) {
34
25
  // some error has been thrown or it was canceled
35
26
  return;
@@ -47,6 +38,6 @@ function tapAfterCompileToGetIssues(compiler, config, state) {
47
38
  compilation.errors.push(error);
48
39
  }
49
40
  });
50
- }));
41
+ });
51
42
  }
52
43
  exports.tapAfterCompileToGetIssues = tapAfterCompileToGetIssues;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -25,7 +16,7 @@ const wait_1 = require("../utils/async/wait");
25
16
  function tapDoneToAsyncGetIssues(compiler, config, state) {
26
17
  const hooks = (0, plugin_hooks_1.getPluginHooks)(compiler);
27
18
  const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
28
- compiler.hooks.done.tap('TsCheckerRspackPlugin', (stats) => __awaiter(this, void 0, void 0, function* () {
19
+ compiler.hooks.done.tap('TsCheckerRspackPlugin', async (stats) => {
29
20
  if (stats.compilation.compiler !== compiler) {
30
21
  // run only for the compiler that the plugin was registered for
31
22
  return;
@@ -33,15 +24,15 @@ function tapDoneToAsyncGetIssues(compiler, config, state) {
33
24
  const issuesPromise = state.issuesPromise;
34
25
  let issues;
35
26
  try {
36
- if (yield (0, is_pending_1.isPending)(issuesPromise)) {
27
+ if (await (0, is_pending_1.isPending)(issuesPromise)) {
37
28
  hooks.waiting.call(stats.compilation);
38
29
  config.logger.log(picocolors_1.default.cyan('Type-checking in progress...'));
39
30
  }
40
31
  else {
41
32
  // wait 10ms to log issues after webpack stats
42
- yield (0, wait_1.wait)(10);
33
+ await (0, wait_1.wait)(10);
43
34
  }
44
- issues = yield issuesPromise;
35
+ issues = await issuesPromise;
45
36
  }
46
37
  catch (error) {
47
38
  hooks.error.call(error, stats.compilation);
@@ -52,7 +43,7 @@ function tapDoneToAsyncGetIssues(compiler, config, state) {
52
43
  ) {
53
44
  return;
54
45
  }
55
- debug(`Got ${(issues === null || issues === void 0 ? void 0 : issues.length) || 0} issues from getIssuesWorker.`);
46
+ debug(`Got ${issues?.length || 0} issues from getIssuesWorker.`);
56
47
  // filter list of issues by provided issue predicate
57
48
  issues = issues.filter(config.issue.predicate);
58
49
  // modify list of issues in the plugin hooks
@@ -82,6 +73,6 @@ function tapDoneToAsyncGetIssues(compiler, config, state) {
82
73
  debug('Sending issues to the webpack-dev-server.');
83
74
  state.webpackDevServerDoneTap.fn(stats);
84
75
  }
85
- }));
76
+ });
86
77
  }
87
78
  exports.tapDoneToAsyncGetIssues = tapDoneToAsyncGetIssues;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.tapStartToRunWorkers = void 0;
13
4
  const files_change_1 = require("../files-change");
@@ -28,7 +19,7 @@ function tapStartToRunWorkers(compiler, getIssuesWorker, getDependenciesWorker,
28
19
  (0, tap_after_compile_to_get_issues_1.tapAfterCompileToGetIssues)(compiler, config, state);
29
20
  }
30
21
  });
31
- compiler.hooks.watchRun.tap('TsCheckerRspackPlugin', () => __awaiter(this, void 0, void 0, function* () {
22
+ compiler.hooks.watchRun.tap('TsCheckerRspackPlugin', async () => {
32
23
  if (!state.initialized) {
33
24
  state.initialized = true;
34
25
  state.watching = true;
@@ -42,8 +33,8 @@ function tapStartToRunWorkers(compiler, getIssuesWorker, getDependenciesWorker,
42
33
  (0, tap_after_compile_to_get_issues_1.tapAfterCompileToGetIssues)(compiler, config, state);
43
34
  }
44
35
  }
45
- }));
46
- compiler.hooks.compilation.tap('TsCheckerRspackPlugin', (compilation) => __awaiter(this, void 0, void 0, function* () {
36
+ });
37
+ compiler.hooks.compilation.tap('TsCheckerRspackPlugin', async (compilation) => {
47
38
  if (compilation.compiler !== compiler) {
48
39
  // run only for the compiler that the plugin was registered for
49
40
  return;
@@ -70,7 +61,7 @@ function tapStartToRunWorkers(compiler, getIssuesWorker, getDependenciesWorker,
70
61
  else {
71
62
  log('Calling reporter service for single check.');
72
63
  }
73
- filesChange = yield hooks.start.promise(filesChange, compilation);
64
+ filesChange = await hooks.start.promise(filesChange, compilation);
74
65
  let aggregatedFilesChange = filesChange;
75
66
  if (state.aggregatedFilesChange) {
76
67
  aggregatedFilesChange = (0, files_change_1.aggregateFilesChanges)([aggregatedFilesChange, filesChange]);
@@ -91,10 +82,10 @@ function tapStartToRunWorkers(compiler, getIssuesWorker, getDependenciesWorker,
91
82
  return undefined;
92
83
  }
93
84
  debug(`Submitting the getIssuesWorker to the pool, iteration ${iteration}.`);
94
- return plugin_pools_1.issuesPool.submit(() => __awaiter(this, void 0, void 0, function* () {
85
+ return plugin_pools_1.issuesPool.submit(async () => {
95
86
  try {
96
87
  debug(`Running the getIssuesWorker, iteration ${iteration}.`);
97
- const issues = yield getIssuesWorker(aggregatedFilesChange, state.watching);
88
+ const issues = await getIssuesWorker(aggregatedFilesChange, state.watching);
98
89
  if (state.aggregatedFilesChange === aggregatedFilesChange) {
99
90
  state.aggregatedFilesChange = undefined;
100
91
  }
@@ -110,13 +101,13 @@ function tapStartToRunWorkers(compiler, getIssuesWorker, getDependenciesWorker,
110
101
  finally {
111
102
  debug(`The getIssuesWorker finished its job, iteration ${iteration}.`);
112
103
  }
113
- }), abortController.signal);
104
+ }, abortController.signal);
114
105
  });
115
106
  debug(`Submitting the getDependenciesWorker to the pool, iteration ${iteration}.`);
116
- state.dependenciesPromise = plugin_pools_1.dependenciesPool.submit(() => __awaiter(this, void 0, void 0, function* () {
107
+ state.dependenciesPromise = plugin_pools_1.dependenciesPool.submit(async () => {
117
108
  try {
118
109
  debug(`Running the getDependenciesWorker, iteration ${iteration}.`);
119
- return yield getDependenciesWorker(filesChange);
110
+ return await getDependenciesWorker(filesChange);
120
111
  }
121
112
  catch (error) {
122
113
  hooks.error.call(error, compilation);
@@ -125,7 +116,7 @@ function tapStartToRunWorkers(compiler, getIssuesWorker, getDependenciesWorker,
125
116
  finally {
126
117
  debug(`The getDependenciesWorker finished its job, iteration ${iteration}.`);
127
118
  }
128
- })); // don't pass abortController.signal because getDependencies() is blocking
129
- }));
119
+ }); // don't pass abortController.signal because getDependencies() is blocking
120
+ });
130
121
  }
131
122
  exports.tapStartToRunWorkers = tapStartToRunWorkers;
@@ -1,7 +1,6 @@
1
- import * as rspack from '@rspack/core';
2
1
  import type { FormatterPathType } from '../formatter';
3
2
  import type { Issue } from './issue';
4
- declare class IssueWebpackError extends rspack.WebpackError {
3
+ declare class IssueWebpackError extends Error {
5
4
  readonly issue: Issue;
6
5
  readonly hideStack = true;
7
6
  file?: string;
@@ -1,38 +1,14 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
4
  };
28
5
  Object.defineProperty(exports, "__esModule", { value: true });
29
6
  exports.IssueWebpackError = void 0;
30
7
  const path_1 = __importDefault(require("path"));
31
- const rspack = __importStar(require("@rspack/core"));
32
8
  const forward_slash_1 = require("../utils/path/forward-slash");
33
9
  const relative_to_context_1 = require("../utils/path/relative-to-context");
34
10
  const issue_location_1 = require("./issue-location");
35
- class IssueWebpackError extends rspack.WebpackError {
11
+ class IssueWebpackError extends Error {
36
12
  constructor(message, pathType, issue) {
37
13
  super(message);
38
14
  this.issue = issue;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -34,7 +25,7 @@ function exposeRpc(fn) {
34
25
  });
35
26
  }
36
27
  });
37
- const handleMessage = (message) => __awaiter(this, void 0, void 0, function* () {
28
+ const handleMessage = async (message) => {
38
29
  if (message.type === 'call') {
39
30
  if (!process_1.default.send) {
40
31
  // process disconnected - skip
@@ -43,21 +34,21 @@ function exposeRpc(fn) {
43
34
  let value;
44
35
  let error;
45
36
  try {
46
- value = yield fn(...message.args);
37
+ value = await fn(...message.args);
47
38
  }
48
39
  catch (fnError) {
49
40
  error = fnError;
50
41
  }
51
42
  try {
52
43
  if (error) {
53
- yield sendMessage({
44
+ await sendMessage({
54
45
  type: 'reject',
55
46
  id: message.id,
56
47
  error,
57
48
  });
58
49
  }
59
50
  else {
60
- yield sendMessage({
51
+ await sendMessage({
61
52
  type: 'resolve',
62
53
  id: message.id,
63
54
  value,
@@ -72,7 +63,7 @@ function exposeRpc(fn) {
72
63
  console.error(sendError);
73
64
  }
74
65
  }
75
- });
66
+ };
76
67
  process_1.default.on('message', handleMessage);
77
68
  }
78
69
  exports.exposeRpc = exposeRpc;
@@ -30,7 +30,10 @@ const wrap_rpc_1 = require("./wrap-rpc");
30
30
  const WORKER_DATA_ENV_KEY = 'WORKER_DATA';
31
31
  function createRpcWorker(modulePath, data, memoryLimit) {
32
32
  const options = {
33
- env: Object.assign(Object.assign({}, process.env), { [WORKER_DATA_ENV_KEY]: JSON.stringify(data || {}) }),
33
+ env: {
34
+ ...process.env,
35
+ [WORKER_DATA_ENV_KEY]: JSON.stringify(data || {}),
36
+ },
34
37
  stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
35
38
  serialization: 'advanced',
36
39
  };
@@ -46,7 +49,7 @@ function createRpcWorker(modulePath, data, memoryLimit) {
46
49
  childProcess = undefined;
47
50
  remoteMethod = undefined;
48
51
  }
49
- if (!(childProcess === null || childProcess === void 0 ? void 0 : childProcess.connected)) {
52
+ if (!childProcess?.connected) {
50
53
  childProcess = child_process.fork(modulePath, options);
51
54
  remoteMethod = (0, wrap_rpc_1.wrapRpc)(childProcess);
52
55
  }
@@ -59,7 +62,7 @@ function createRpcWorker(modulePath, data, memoryLimit) {
59
62
  }
60
63
  },
61
64
  get connected() {
62
- return Boolean(childProcess === null || childProcess === void 0 ? void 0 : childProcess.connected);
65
+ return Boolean(childProcess?.connected);
63
66
  },
64
67
  get process() {
65
68
  return childProcess;
@@ -1,20 +1,11 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.wrapRpc = void 0;
13
4
  const controlled_promise_1 = require("../utils/async/controlled-promise");
14
5
  const rpc_error_1 = require("./rpc-error");
15
6
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
7
  function wrapRpc(childProcess) {
17
- return ((...args) => __awaiter(this, void 0, void 0, function* () {
8
+ return (async (...args) => {
18
9
  if (!childProcess.send) {
19
10
  throw new Error(`Process ${childProcess.pid} doesn't have IPC channels`);
20
11
  }
@@ -26,7 +17,7 @@ function wrapRpc(childProcess) {
26
17
  const { promise: resultPromise, resolve: resolveResult, reject: rejectResult, } = (0, controlled_promise_1.createControlledPromise)();
27
18
  const { promise: sendPromise, resolve: resolveSend, reject: rejectSend, } = (0, controlled_promise_1.createControlledPromise)();
28
19
  const handleMessage = (message) => {
29
- if ((message === null || message === void 0 ? void 0 : message.id) === id) {
20
+ if (message?.id === id) {
30
21
  if (message.type === 'resolve') {
31
22
  // assume the contract is respected
32
23
  resolveResult(message.value);
@@ -68,7 +59,7 @@ function wrapRpc(childProcess) {
68
59
  }
69
60
  });
70
61
  return sendPromise.then(() => resultPromise);
71
- }));
62
+ });
72
63
  }
73
64
  exports.wrapRpc = wrapRpc;
74
65
  function uuid() {
@@ -13,6 +13,24 @@ function createTypeScriptWorkerConfig(compiler, options) {
13
13
  : path_1.default.resolve(compiler.options.context || process.cwd(), configFile));
14
14
  const optionsAsObject = typeof options === 'object' ? options : {};
15
15
  const typescriptPath = optionsAsObject.typescriptPath || require.resolve('typescript');
16
- return Object.assign(Object.assign({ enabled: Boolean(options) || options === undefined, memoryLimit: 8192, build: false, mode: optionsAsObject.build ? 'write-tsbuildinfo' : 'readonly', profile: false }, optionsAsObject), { configFile: configFile, configOverwrite: optionsAsObject.configOverwrite || {}, context: optionsAsObject.context || path_1.default.dirname(configFile), diagnosticOptions: Object.assign({ syntactic: false, semantic: true, declaration: false, global: false }, (optionsAsObject.diagnosticOptions || {})), typescriptPath: typescriptPath });
16
+ return {
17
+ enabled: Boolean(options) || options === undefined,
18
+ memoryLimit: 8192,
19
+ build: false,
20
+ mode: optionsAsObject.build ? 'write-tsbuildinfo' : 'readonly',
21
+ profile: false,
22
+ ...optionsAsObject,
23
+ configFile: configFile,
24
+ configOverwrite: optionsAsObject.configOverwrite || {},
25
+ context: optionsAsObject.context || path_1.default.dirname(configFile),
26
+ diagnosticOptions: {
27
+ syntactic: false,
28
+ semantic: true,
29
+ declaration: false,
30
+ global: false,
31
+ ...(optionsAsObject.diagnosticOptions || {}),
32
+ },
33
+ typescriptPath: typescriptPath,
34
+ };
17
35
  }
18
36
  exports.createTypeScriptWorkerConfig = createTypeScriptWorkerConfig;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  const rpc_1 = require("../../rpc");
13
4
  const artifacts_1 = require("./lib/artifacts");
@@ -22,8 +13,7 @@ const system_1 = require("./lib/system");
22
13
  const tracing_1 = require("./lib/tracing");
23
14
  const tsbuildinfo_1 = require("./lib/tsbuildinfo");
24
15
  const worker_config_1 = require("./lib/worker-config");
25
- const getIssuesWorker = (change, watching) => __awaiter(void 0, void 0, void 0, function* () {
26
- var _a, _b;
16
+ const getIssuesWorker = async (change, watching) => {
27
17
  system_1.system.invalidateCache();
28
18
  if ((0, config_1.didConfigFileChanged)(change)) {
29
19
  (0, config_1.invalidateConfig)();
@@ -62,19 +52,19 @@ const getIssuesWorker = (change, watching) => __awaiter(void 0, void 0, void 0,
62
52
  (0, program_1.useProgram)();
63
53
  }
64
54
  // simulate file system events
65
- (_a = change.changedFiles) === null || _a === void 0 ? void 0 : _a.forEach((changedFile) => {
66
- system_1.system === null || system_1.system === void 0 ? void 0 : system_1.system.invokeFileChanged(changedFile);
55
+ change.changedFiles?.forEach((changedFile) => {
56
+ system_1.system?.invokeFileChanged(changedFile);
67
57
  });
68
- (_b = change.deletedFiles) === null || _b === void 0 ? void 0 : _b.forEach((deletedFile) => {
69
- system_1.system === null || system_1.system === void 0 ? void 0 : system_1.system.invokeFileDeleted(deletedFile);
58
+ change.deletedFiles?.forEach((deletedFile) => {
59
+ system_1.system?.invokeFileDeleted(deletedFile);
70
60
  });
71
61
  // wait for all queued events to be processed
72
- yield system_1.system.waitForQueued();
62
+ await system_1.system.waitForQueued();
73
63
  // retrieve all collected diagnostics as normalized issues
74
64
  const issues = (0, diagnostics_1.getIssues)();
75
65
  (0, tracing_1.dumpTracingLegendIfNeeded)();
76
66
  (0, performance_1.printPerformanceMeasuresIfNeeded)();
77
67
  (0, performance_1.disablePerformanceIfNeeded)();
78
68
  return issues;
79
- });
69
+ };
80
70
  (0, rpc_1.exposeRpc)(getIssuesWorker);
@@ -33,9 +33,12 @@ const worker_config_1 = require("./worker-config");
33
33
  let parsedConfig;
34
34
  let parseConfigDiagnostics = [];
35
35
  // initialize ParseConfigFileHost
36
- const parseConfigFileHost = Object.assign(Object.assign({}, system_1.system), { onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
36
+ const parseConfigFileHost = {
37
+ ...system_1.system,
38
+ onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
37
39
  parseConfigDiagnostics.push(diagnostic);
38
- } });
40
+ },
41
+ };
39
42
  function getUserProvidedConfigOverwrite() {
40
43
  return worker_config_1.config.configOverwrite || {};
41
44
  }
@@ -48,12 +51,22 @@ function getImplicitConfigOverwrite() {
48
51
  switch (worker_config_1.config.mode) {
49
52
  case 'write-dts':
50
53
  return {
51
- compilerOptions: Object.assign(Object.assign({}, baseCompilerOptionsOverwrite), { declaration: true, emitDeclarationOnly: true, noEmit: false }),
54
+ compilerOptions: {
55
+ ...baseCompilerOptionsOverwrite,
56
+ declaration: true,
57
+ emitDeclarationOnly: true,
58
+ noEmit: false,
59
+ },
52
60
  };
53
61
  case 'write-tsbuildinfo':
54
62
  case 'write-references':
55
63
  return {
56
- compilerOptions: Object.assign(Object.assign({}, baseCompilerOptionsOverwrite), { declaration: true, emitDeclarationOnly: false, noEmit: false }),
64
+ compilerOptions: {
65
+ ...baseCompilerOptionsOverwrite,
66
+ declaration: true,
67
+ emitDeclarationOnly: false,
68
+ noEmit: false,
69
+ },
57
70
  };
58
71
  }
59
72
  return {
@@ -63,7 +76,14 @@ function getImplicitConfigOverwrite() {
63
76
  function applyConfigOverwrite(baseConfig, ...overwriteConfigs) {
64
77
  let config = baseConfig;
65
78
  for (const overwriteConfig of overwriteConfigs) {
66
- config = Object.assign(Object.assign(Object.assign({}, (config || {})), (overwriteConfig || {})), { compilerOptions: Object.assign(Object.assign({}, ((config === null || config === void 0 ? void 0 : config.compilerOptions) || {})), ((overwriteConfig === null || overwriteConfig === void 0 ? void 0 : overwriteConfig.compilerOptions) || {})) });
79
+ config = {
80
+ ...(config || {}),
81
+ ...(overwriteConfig || {}),
82
+ compilerOptions: {
83
+ ...(config?.compilerOptions || {}),
84
+ ...(overwriteConfig?.compilerOptions || {}),
85
+ },
86
+ };
67
87
  }
68
88
  return config;
69
89
  }
@@ -72,7 +92,14 @@ function parseConfig(configFileName, configFileContext) {
72
92
  const { config: baseConfig, error: readConfigError } = typescript_1.typescript.readConfigFile(configFilePath, parseConfigFileHost.readFile);
73
93
  const overwrittenConfig = applyConfigOverwrite(baseConfig || {}, getImplicitConfigOverwrite(), getUserProvidedConfigOverwrite());
74
94
  const parsedConfigFile = typescript_1.typescript.parseJsonConfigFileContent(overwrittenConfig, parseConfigFileHost, configFileContext);
75
- return Object.assign(Object.assign({}, parsedConfigFile), { options: Object.assign(Object.assign({}, parsedConfigFile.options), { configFilePath: configFilePath }), errors: readConfigError ? [readConfigError] : parsedConfigFile.errors });
95
+ return {
96
+ ...parsedConfigFile,
97
+ options: {
98
+ ...parsedConfigFile.options,
99
+ configFilePath: configFilePath,
100
+ },
101
+ errors: readConfigError ? [readConfigError] : parsedConfigFile.errors,
102
+ };
76
103
  }
77
104
  exports.parseConfig = parseConfig;
78
105
  function getParseConfigIssues() {
@@ -42,14 +42,13 @@ function invalidateDependencies() {
42
42
  }
43
43
  exports.invalidateDependencies = invalidateDependencies;
44
44
  function getDependenciesWorker(parsedConfig, configFileContext, processedConfigFiles = []) {
45
- var _a;
46
45
  const files = new Set(parsedConfig.fileNames);
47
46
  const configFilePath = parsedConfig.options.configFilePath;
48
47
  if (typeof configFilePath === 'string') {
49
48
  files.add(configFilePath);
50
49
  }
51
50
  const dirs = new Set(Object.keys(parsedConfig.wildcardDirectories || {}));
52
- const excluded = new Set((((_a = parsedConfig.raw) === null || _a === void 0 ? void 0 : _a.exclude) || []).map((filePath) => path.resolve(configFileContext, filePath)));
51
+ const excluded = new Set((parsedConfig.raw?.exclude || []).map((filePath) => path.resolve(configFileContext, filePath)));
53
52
  for (const projectReference of parsedConfig.projectReferences || []) {
54
53
  const childConfigFilePath = typescript_1.typescript.resolveProjectReferencePath(projectReference);
55
54
  const childConfigContext = path.dirname(childConfigFilePath);
@@ -7,7 +7,9 @@ const real_file_system_1 = require("./real-file-system");
7
7
  /**
8
8
  * It's an implementation of FileSystem interface which reads and writes to the in-memory file system.
9
9
  */
10
- exports.memFileSystem = Object.assign(Object.assign({}, real_file_system_1.realFileSystem), { exists(path) {
10
+ exports.memFileSystem = {
11
+ ...real_file_system_1.realFileSystem,
12
+ exists(path) {
11
13
  return exists(real_file_system_1.realFileSystem.realPath(path));
12
14
  },
13
15
  readFile(path, encoding) {
@@ -33,7 +35,8 @@ exports.memFileSystem = Object.assign(Object.assign({}, real_file_system_1.realF
33
35
  },
34
36
  clearCache() {
35
37
  real_file_system_1.realFileSystem.clearCache();
36
- } });
38
+ },
39
+ };
37
40
  function exists(path) {
38
41
  return memfs_1.fs.existsSync(real_file_system_1.realFileSystem.normalizePath(path));
39
42
  }
@@ -6,7 +6,9 @@ const real_file_system_1 = require("./real-file-system");
6
6
  /**
7
7
  * It's an implementation of FileSystem interface which reads from the real file system, but write to the in-memory file system.
8
8
  */
9
- exports.passiveFileSystem = Object.assign(Object.assign({}, mem_file_system_1.memFileSystem), { exists(path) {
9
+ exports.passiveFileSystem = {
10
+ ...mem_file_system_1.memFileSystem,
11
+ exists(path) {
10
12
  return exists(real_file_system_1.realFileSystem.realPath(path));
11
13
  },
12
14
  readFile(path, encoding) {
@@ -23,7 +25,8 @@ exports.passiveFileSystem = Object.assign(Object.assign({}, mem_file_system_1.me
23
25
  },
24
26
  clearCache() {
25
27
  real_file_system_1.realFileSystem.clearCache();
26
- } });
28
+ },
29
+ };
27
30
  function exists(path) {
28
31
  return real_file_system_1.realFileSystem.exists(path) || mem_file_system_1.memFileSystem.exists(path);
29
32
  }
@@ -5,6 +5,13 @@ const system_1 = require("../system");
5
5
  const typescript_1 = require("../typescript");
6
6
  function createCompilerHost(parsedConfig) {
7
7
  const baseCompilerHost = typescript_1.typescript.createCompilerHost(parsedConfig.options);
8
- return Object.assign(Object.assign({}, baseCompilerHost), { fileExists: system_1.system.fileExists, readFile: system_1.system.readFile, directoryExists: system_1.system.directoryExists, getDirectories: system_1.system.getDirectories, realpath: system_1.system.realpath });
8
+ return {
9
+ ...baseCompilerHost,
10
+ fileExists: system_1.system.fileExists,
11
+ readFile: system_1.system.readFile,
12
+ directoryExists: system_1.system.directoryExists,
13
+ getDirectories: system_1.system.getDirectories,
14
+ realpath: system_1.system.realpath,
15
+ };
9
16
  }
10
17
  exports.createCompilerHost = createCompilerHost;
@@ -5,7 +5,9 @@ const system_1 = require("../system");
5
5
  const typescript_1 = require("../typescript");
6
6
  function createWatchCompilerHost(parsedConfig, createProgram, reportDiagnostic, reportWatchStatus, afterProgramCreate) {
7
7
  const baseWatchCompilerHost = typescript_1.typescript.createWatchCompilerHost(parsedConfig.fileNames, parsedConfig.options, system_1.system, createProgram, reportDiagnostic, reportWatchStatus, parsedConfig.projectReferences);
8
- return Object.assign(Object.assign({}, baseWatchCompilerHost), { createProgram(rootNames, options, compilerHost, oldProgram, configFileParsingDiagnostics, projectReferences) {
8
+ return {
9
+ ...baseWatchCompilerHost,
10
+ createProgram(rootNames, options, compilerHost, oldProgram, configFileParsingDiagnostics, projectReferences) {
9
11
  return baseWatchCompilerHost.createProgram(rootNames, options, compilerHost, oldProgram, configFileParsingDiagnostics, projectReferences);
10
12
  },
11
13
  afterProgramCreate(program) {
@@ -15,6 +17,16 @@ function createWatchCompilerHost(parsedConfig, createProgram, reportDiagnostic,
15
17
  },
16
18
  onWatchStatusChange() {
17
19
  // do nothing
18
- }, watchFile: system_1.system.watchFile, watchDirectory: system_1.system.watchDirectory, setTimeout: system_1.system.setTimeout, clearTimeout: system_1.system.clearTimeout, fileExists: system_1.system.fileExists, readFile: system_1.system.readFile, directoryExists: system_1.system.directoryExists, getDirectories: system_1.system.getDirectories, realpath: system_1.system.realpath });
20
+ },
21
+ watchFile: system_1.system.watchFile,
22
+ watchDirectory: system_1.system.watchDirectory,
23
+ setTimeout: system_1.system.setTimeout,
24
+ clearTimeout: system_1.system.clearTimeout,
25
+ fileExists: system_1.system.fileExists,
26
+ readFile: system_1.system.readFile,
27
+ directoryExists: system_1.system.directoryExists,
28
+ getDirectories: system_1.system.getDirectories,
29
+ realpath: system_1.system.realpath,
30
+ };
19
31
  }
20
32
  exports.createWatchCompilerHost = createWatchCompilerHost;
@@ -6,7 +6,9 @@ const typescript_1 = require("../typescript");
6
6
  const watch_compiler_host_1 = require("./watch-compiler-host");
7
7
  function createWatchSolutionBuilderHost(parsedConfig, createProgram, reportDiagnostic, reportWatchStatus, reportSolutionBuilderStatus, afterProgramCreate, afterProgramEmitAndDiagnostics) {
8
8
  const controlledWatchCompilerHost = (0, watch_compiler_host_1.createWatchCompilerHost)(parsedConfig, createProgram, reportDiagnostic, reportWatchStatus, afterProgramCreate);
9
- return Object.assign(Object.assign({}, controlledWatchCompilerHost), { reportDiagnostic(diagnostic) {
9
+ return {
10
+ ...controlledWatchCompilerHost,
11
+ reportDiagnostic(diagnostic) {
10
12
  if (reportDiagnostic) {
11
13
  reportDiagnostic(diagnostic);
12
14
  }
@@ -37,11 +39,15 @@ function createWatchSolutionBuilderHost(parsedConfig, createProgram, reportDiagn
37
39
  system_1.system.deleteFile(fileName);
38
40
  },
39
41
  getParsedCommandLine(fileName) {
40
- return typescript_1.typescript.getParsedCommandLineOfConfigFile(fileName, { skipLibCheck: true }, Object.assign(Object.assign({}, system_1.system), { onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
42
+ return typescript_1.typescript.getParsedCommandLineOfConfigFile(fileName, { skipLibCheck: true }, {
43
+ ...system_1.system,
44
+ onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
41
45
  if (reportDiagnostic) {
42
46
  reportDiagnostic(diagnostic);
43
47
  }
44
- } }));
45
- } });
48
+ },
49
+ });
50
+ },
51
+ };
46
52
  }
47
53
  exports.createWatchSolutionBuilderHost = createWatchSolutionBuilderHost;
@@ -6,24 +6,21 @@ const worker_config_1 = require("./worker-config");
6
6
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
7
  const performance = typescript_1.typescript.performance;
8
8
  function enablePerformanceIfNeeded() {
9
- var _a;
10
9
  if (worker_config_1.config.profile) {
11
- (_a = performance === null || performance === void 0 ? void 0 : performance.enable) === null || _a === void 0 ? void 0 : _a.call(performance);
10
+ performance?.enable?.();
12
11
  }
13
12
  }
14
13
  exports.enablePerformanceIfNeeded = enablePerformanceIfNeeded;
15
14
  function disablePerformanceIfNeeded() {
16
- var _a;
17
15
  if (worker_config_1.config.profile) {
18
- (_a = performance === null || performance === void 0 ? void 0 : performance.disable) === null || _a === void 0 ? void 0 : _a.call(performance);
16
+ performance?.disable?.();
19
17
  }
20
18
  }
21
19
  exports.disablePerformanceIfNeeded = disablePerformanceIfNeeded;
22
20
  function printPerformanceMeasuresIfNeeded() {
23
- var _a;
24
21
  if (worker_config_1.config.profile) {
25
22
  const measures = {};
26
- (_a = performance === null || performance === void 0 ? void 0 : performance.forEachMeasure) === null || _a === void 0 ? void 0 : _a.call(performance, (measureName, duration) => {
23
+ performance?.forEachMeasure?.((measureName, duration) => {
27
24
  measures[measureName] = duration;
28
25
  });
29
26
  console.table(measures);
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.system = void 0;
13
4
  const path_1 = require("path");
@@ -34,7 +25,10 @@ const deletedFiles = new Map();
34
25
  const timeoutCallbacks = new Set();
35
26
  // based on the ts.ignorePaths
36
27
  const ignoredPaths = ['/node_modules/.', '/.git', '/.#'];
37
- exports.system = Object.assign(Object.assign({}, typescript_1.typescript.sys), { useCaseSensitiveFileNames: true, realpath(path) {
28
+ exports.system = {
29
+ ...typescript_1.typescript.sys,
30
+ useCaseSensitiveFileNames: true,
31
+ realpath(path) {
38
32
  return getReadFileSystem(path).realPath(path);
39
33
  },
40
34
  fileExists(path) {
@@ -57,8 +51,7 @@ exports.system = Object.assign(Object.assign({}, typescript_1.typescript.sys), {
57
51
  exports.system.invokeFileDeleted(path);
58
52
  },
59
53
  directoryExists(path) {
60
- var _a;
61
- return Boolean((_a = getReadFileSystem(path).readStats(path)) === null || _a === void 0 ? void 0 : _a.isDirectory());
54
+ return Boolean(getReadFileSystem(path).readStats(path)?.isDirectory());
62
55
  },
63
56
  createDirectory(path) {
64
57
  getWriteFileSystem(path).createDir(path);
@@ -87,7 +80,7 @@ exports.system = Object.assign(Object.assign({}, typescript_1.typescript.sys), {
87
80
  },
88
81
  watchDirectory(path, callback, recursive = false) {
89
82
  return createWatcher(recursive ? recursiveDirectoryWatcherCallbacksMap : directoryWatcherCallbacksMap, path, callback);
90
- },
83
+ },
91
84
  // use immediate instead of timeout to avoid waiting 250ms for batching files changes
92
85
  setTimeout: (callback, timeout, ...args) => {
93
86
  const timeoutId = setImmediate(() => {
@@ -96,16 +89,16 @@ exports.system = Object.assign(Object.assign({}, typescript_1.typescript.sys), {
96
89
  });
97
90
  timeoutCallbacks.add(timeoutId);
98
91
  return timeoutId;
99
- }, clearTimeout: (timeoutId) => {
92
+ },
93
+ clearTimeout: (timeoutId) => {
100
94
  clearImmediate(timeoutId);
101
95
  timeoutCallbacks.delete(timeoutId);
102
- }, waitForQueued() {
103
- return __awaiter(this, void 0, void 0, function* () {
104
- while (timeoutCallbacks.size > 0) {
105
- yield new Promise((resolve) => setImmediate(resolve));
106
- }
107
- isInitialRun = false;
108
- });
96
+ },
97
+ async waitForQueued() {
98
+ while (timeoutCallbacks.size > 0) {
99
+ await new Promise((resolve) => setImmediate(resolve));
100
+ }
101
+ isInitialRun = false;
109
102
  },
110
103
  invokeFileCreated(path) {
111
104
  const normalizedPath = normalizeAndResolvePath(path);
@@ -139,7 +132,8 @@ exports.system = Object.assign(Object.assign({}, typescript_1.typescript.sys), {
139
132
  },
140
133
  setArtifacts(nextArtifacts) {
141
134
  artifacts = nextArtifacts;
142
- } });
135
+ },
136
+ };
143
137
  function createWatcher(watchersMap, path, callback) {
144
138
  const normalizedPath = normalizeAndResolvePath(path);
145
139
  const watchers = watchersMap.get(normalizedPath) || [];
@@ -209,7 +203,7 @@ function getReadFileSystem(path) {
209
203
  if (isInitialRun && !mem_file_system_1.memFileSystem.exists(path) && passive_file_system_1.passiveFileSystem.exists(path)) {
210
204
  // copy file to memory on initial run
211
205
  const stats = passive_file_system_1.passiveFileSystem.readStats(path);
212
- if (stats === null || stats === void 0 ? void 0 : stats.isFile()) {
206
+ if (stats?.isFile()) {
213
207
  const content = passive_file_system_1.passiveFileSystem.readFile(path);
214
208
  if (content) {
215
209
  mem_file_system_1.memFileSystem.writeFile(path, content);
@@ -14,16 +14,14 @@ function startTracingIfNeeded(compilerOptions) {
14
14
  }
15
15
  exports.startTracingIfNeeded = startTracingIfNeeded;
16
16
  function stopTracingIfNeeded(program) {
17
- var _a;
18
17
  const compilerOptions = program.getCompilerOptions();
19
18
  if (typeof compilerOptions.generateTrace === 'string' &&
20
- typeof ((_a = traceableTypescript.tracing) === null || _a === void 0 ? void 0 : _a.stopTracing) === 'function') {
19
+ typeof traceableTypescript.tracing?.stopTracing === 'function') {
21
20
  traceableTypescript.tracing.stopTracing();
22
21
  }
23
22
  }
24
23
  exports.stopTracingIfNeeded = stopTracingIfNeeded;
25
24
  function dumpTracingLegendIfNeeded() {
26
- var _a;
27
- (_a = traceableTypescript.tracing) === null || _a === void 0 ? void 0 : _a.dumpLegend();
25
+ traceableTypescript.tracing?.dumpLegend();
28
26
  }
29
27
  exports.dumpTracingLegendIfNeeded = dumpTracingLegendIfNeeded;
@@ -7,7 +7,7 @@ class AbortError extends Error {
7
7
  this.name = 'AbortError';
8
8
  }
9
9
  static throwIfAborted(signal) {
10
- if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
10
+ if (signal?.aborted) {
11
11
  throw new AbortError();
12
12
  }
13
13
  }
@@ -1,32 +1,21 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.createPool = void 0;
13
4
  const abort_error_1 = require("./abort-error");
14
5
  function createPool(size) {
15
6
  let pendingPromises = [];
16
7
  const pool = {
17
- submit(task, signal) {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- while (pendingPromises.length >= pool.size) {
20
- abort_error_1.AbortError.throwIfAborted(signal);
21
- yield Promise.race(pendingPromises).catch(() => undefined);
22
- }
8
+ async submit(task, signal) {
9
+ while (pendingPromises.length >= pool.size) {
23
10
  abort_error_1.AbortError.throwIfAborted(signal);
24
- const taskPromise = task(signal).finally(() => {
25
- pendingPromises = pendingPromises.filter((pendingPromise) => pendingPromise !== taskPromise);
26
- });
27
- pendingPromises.push(taskPromise);
28
- return taskPromise;
11
+ await Promise.race(pendingPromises).catch(() => undefined);
12
+ }
13
+ abort_error_1.AbortError.throwIfAborted(signal);
14
+ const taskPromise = task(signal).finally(() => {
15
+ pendingPromises = pendingPromises.filter((pendingPromise) => pendingPromise !== taskPromise);
29
16
  });
17
+ pendingPromises.push(taskPromise);
18
+ return taskPromise;
30
19
  },
31
20
  size,
32
21
  get pending() {
@@ -34,12 +23,12 @@ function createPool(size) {
34
23
  },
35
24
  get drained() {
36
25
  // eslint-disable-next-line no-async-promise-executor
37
- return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
26
+ return new Promise(async (resolve) => {
38
27
  while (pendingPromises.length > 0) {
39
- yield Promise.race(pendingPromises).catch(() => undefined);
28
+ await Promise.race(pendingPromises).catch(() => undefined);
40
29
  }
41
30
  resolve(undefined);
42
- }));
31
+ });
43
32
  },
44
33
  };
45
34
  return pool;
@@ -34,8 +34,7 @@ function createIsIgnored(ignored, excluded) {
34
34
  }
35
35
  class InclusiveNodeWatchFileSystem {
36
36
  get watcher() {
37
- var _a;
38
- return this.watchFileSystem.watcher || ((_a = this.watchFileSystem.wfs) === null || _a === void 0 ? void 0 : _a.watcher);
37
+ return this.watchFileSystem.watcher || this.watchFileSystem.wfs?.watcher;
39
38
  }
40
39
  constructor(watchFileSystem, compiler, pluginState) {
41
40
  this.watchFileSystem = watchFileSystem;
@@ -43,13 +42,12 @@ class InclusiveNodeWatchFileSystem {
43
42
  this.pluginState = pluginState;
44
43
  this.paused = true;
45
44
  this.watch = (files, dirs, missing, startTime, options, callback, callbackUndelayed) => {
46
- var _a, _b, _c, _d;
47
45
  const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(this.compiler);
48
46
  (0, files_change_1.clearFilesChange)(this.compiler);
49
- const isIgnored = createIsIgnored(options === null || options === void 0 ? void 0 : options.ignored, ((_a = this.pluginState.lastDependencies) === null || _a === void 0 ? void 0 : _a.excluded) || []);
47
+ const isIgnored = createIsIgnored(options?.ignored, this.pluginState.lastDependencies?.excluded || []);
50
48
  // use standard watch file system for files and missing
51
49
  const standardWatcher = this.watchFileSystem.watch(files, dirs, missing, startTime, options, callback, callbackUndelayed);
52
- (_b = this.watcher) === null || _b === void 0 ? void 0 : _b.on('change', (file) => {
50
+ this.watcher?.on('change', (file) => {
53
51
  if (typeof file !== 'string') {
54
52
  return;
55
53
  }
@@ -62,7 +60,7 @@ class InclusiveNodeWatchFileSystem {
62
60
  debug("Detected file change but it's ignored", file);
63
61
  }
64
62
  });
65
- (_c = this.watcher) === null || _c === void 0 ? void 0 : _c.on('remove', (file) => {
63
+ this.watcher?.on('remove', (file) => {
66
64
  if (typeof file !== 'string') {
67
65
  return;
68
66
  }
@@ -81,22 +79,21 @@ class InclusiveNodeWatchFileSystem {
81
79
  });
82
80
  // calculate what to change
83
81
  const prevDirs = Array.from(this.dirsWatchers.keys());
84
- const nextDirs = Array.from(((_d = this.pluginState.lastDependencies) === null || _d === void 0 ? void 0 : _d.dirs) || []);
82
+ const nextDirs = Array.from(this.pluginState.lastDependencies?.dirs || []);
85
83
  const dirsToUnwatch = prevDirs.filter((prevDir) => !nextDirs.includes(prevDir));
86
84
  const dirsToWatch = nextDirs.filter((nextDir) => !prevDirs.includes(nextDir) && !isIgnored(nextDir));
87
85
  // update dirs watcher
88
86
  dirsToUnwatch.forEach((dirToUnwatch) => {
89
- var _a;
90
- (_a = this.dirsWatchers.get(dirToUnwatch)) === null || _a === void 0 ? void 0 : _a.close();
87
+ this.dirsWatchers.get(dirToUnwatch)?.close();
91
88
  this.dirsWatchers.delete(dirToUnwatch);
92
89
  });
93
90
  dirsToWatch.forEach((dirToWatch) => {
94
- const interval = typeof (options === null || options === void 0 ? void 0 : options.poll) === 'number' ? options.poll : undefined;
91
+ const interval = typeof options?.poll === 'number' ? options.poll : undefined;
95
92
  const dirWatcher = chokidar_1.default.watch(dirToWatch, {
96
93
  ignoreInitial: true,
97
94
  ignorePermissionErrors: true,
98
95
  ignored: (path) => isIgnored(path),
99
- usePolling: (options === null || options === void 0 ? void 0 : options.poll) ? true : undefined,
96
+ usePolling: options?.poll ? true : undefined,
100
97
  interval: interval,
101
98
  binaryInterval: interval,
102
99
  alwaysStat: true,
@@ -104,12 +101,11 @@ class InclusiveNodeWatchFileSystem {
104
101
  awaitWriteFinish: true,
105
102
  });
106
103
  dirWatcher.on('add', (file, stats) => {
107
- var _a, _b;
108
104
  if (this.paused) {
109
105
  return;
110
106
  }
111
107
  const extension = (0, path_1.extname)(file);
112
- const supportedExtensions = ((_a = this.pluginState.lastDependencies) === null || _a === void 0 ? void 0 : _a.extensions) || [];
108
+ const supportedExtensions = this.pluginState.lastDependencies?.extensions || [];
113
109
  if (!supportedExtensions.includes(extension)) {
114
110
  debug('Detected new file add but extension is not supported', file);
115
111
  return;
@@ -117,15 +113,14 @@ class InclusiveNodeWatchFileSystem {
117
113
  debug('Detected new file add', file);
118
114
  this.deletedFiles.delete(file);
119
115
  (0, files_change_1.updateFilesChange)(this.compiler, { changedFiles: [file] });
120
- (_b = this.watcher) === null || _b === void 0 ? void 0 : _b._onChange(dirToWatch, (stats === null || stats === void 0 ? void 0 : stats.mtimeMs) || (stats === null || stats === void 0 ? void 0 : stats.ctimeMs) || 1, file, 'rename');
116
+ this.watcher?._onChange(dirToWatch, stats?.mtimeMs || stats?.ctimeMs || 1, file, 'rename');
121
117
  });
122
118
  dirWatcher.on('unlink', (file) => {
123
- var _a, _b;
124
119
  if (this.paused) {
125
120
  return;
126
121
  }
127
122
  const extension = (0, path_1.extname)(file);
128
- const supportedExtensions = ((_a = this.pluginState.lastDependencies) === null || _a === void 0 ? void 0 : _a.extensions) || [];
123
+ const supportedExtensions = this.pluginState.lastDependencies?.extensions || [];
129
124
  if (!supportedExtensions.includes(extension)) {
130
125
  debug('Detected new file remove but extension is not supported', file);
131
126
  return;
@@ -137,27 +132,31 @@ class InclusiveNodeWatchFileSystem {
137
132
  debug('Detected new file remove', file);
138
133
  this.deletedFiles.add(file);
139
134
  (0, files_change_1.updateFilesChange)(this.compiler, { deletedFiles: [file] });
140
- (_b = this.watcher) === null || _b === void 0 ? void 0 : _b._onRemove(dirToWatch, file, 'rename');
135
+ this.watcher?._onRemove(dirToWatch, file, 'rename');
141
136
  });
142
137
  this.dirsWatchers.set(dirToWatch, dirWatcher);
143
138
  });
144
139
  this.paused = false;
145
- return Object.assign(Object.assign({}, standardWatcher), { close: () => {
140
+ return {
141
+ ...standardWatcher,
142
+ close: () => {
146
143
  (0, files_change_1.clearFilesChange)(this.compiler);
147
144
  if (standardWatcher) {
148
145
  standardWatcher.close();
149
146
  }
150
147
  this.dirsWatchers.forEach((dirWatcher) => {
151
- dirWatcher === null || dirWatcher === void 0 ? void 0 : dirWatcher.close();
148
+ dirWatcher?.close();
152
149
  });
153
150
  this.dirsWatchers.clear();
154
151
  this.paused = true;
155
- }, pause: () => {
152
+ },
153
+ pause: () => {
156
154
  if (standardWatcher) {
157
155
  standardWatcher.pause();
158
156
  }
159
157
  this.paused = true;
160
- } });
158
+ },
159
+ };
161
160
  };
162
161
  this.dirsWatchers = new Map();
163
162
  this.deletedFiles = new Set();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-checker-rspack-plugin",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Runs typescript type checker and linter on separate process.",
5
5
  "keywords": [
6
6
  "rspack",
@@ -69,6 +69,7 @@
69
69
  },
70
70
  "publishConfig": {
71
71
  "access": "public",
72
+ "provenance": true,
72
73
  "registry": "https://registry.npmjs.org/"
73
74
  },
74
75
  "packageManager": "pnpm@9.14.2"