ts-checker-rspack-plugin 1.0.0-beta.0 → 1.0.0

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 (46) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +25 -19
  3. package/lib/formatter/basic-formatter.js +2 -2
  4. package/lib/formatter/code-frame-formatter.js +2 -2
  5. package/lib/formatter/formatter-config.d.ts +1 -1
  6. package/lib/formatter/formatter-options.d.ts +4 -4
  7. package/lib/formatter/formatter.d.ts +2 -2
  8. package/lib/formatter/index.js +5 -1
  9. package/lib/formatter/stats-formatter.js +3 -3
  10. package/lib/formatter/webpack-formatter.js +6 -6
  11. package/lib/hooks/tap-done-to-async-get-issues.js +4 -3
  12. package/lib/hooks/tap-error-to-log-message.js +3 -3
  13. package/lib/hooks/tap-start-to-run-workers.js +1 -2
  14. package/lib/issue/index.js +5 -1
  15. package/lib/issue/issue-match.d.ts +1 -1
  16. package/lib/issue/issue-match.js +2 -2
  17. package/lib/issue/issue-options.d.ts +1 -1
  18. package/lib/issue/issue-predicate.d.ts +1 -1
  19. package/lib/issue/issue-severity.d.ts +1 -1
  20. package/lib/issue/issue-webpack-error.js +5 -1
  21. package/lib/plugin-hooks.d.ts +26 -10
  22. package/lib/plugin-hooks.js +6 -6
  23. package/lib/plugin-pools.js +5 -1
  24. package/lib/plugin-state.d.ts +2 -3
  25. package/lib/plugin.d.ts +13 -6
  26. package/lib/plugin.js +8 -13
  27. package/lib/rpc/rpc-worker.d.ts +1 -1
  28. package/lib/rpc/rpc-worker.js +5 -1
  29. package/lib/rpc/types.d.ts +3 -3
  30. package/lib/typescript/type-script-support.js +2 -34
  31. package/lib/typescript/type-script-worker-config.js +1 -1
  32. package/lib/typescript/type-script-worker-options.d.ts +1 -1
  33. package/lib/typescript/worker/get-dependencies-worker.d.ts +1 -1
  34. package/lib/typescript/worker/get-issues-worker.d.ts +1 -1
  35. package/lib/typescript/worker/lib/artifacts.js +5 -1
  36. package/lib/typescript/worker/lib/config.js +5 -1
  37. package/lib/typescript/worker/lib/dependencies.js +5 -1
  38. package/lib/typescript/worker/lib/diagnostics.js +5 -1
  39. package/lib/typescript/worker/lib/file-system/real-file-system.js +12 -28
  40. package/lib/typescript/worker/lib/tsbuildinfo.js +5 -1
  41. package/lib/utils/async/abort-error.d.ts +1 -1
  42. package/lib/utils/async/pool.d.ts +2 -2
  43. package/lib/watch/inclusive-node-watch-file-system.js +6 -6
  44. package/lib/watch/watch-file-system.d.ts +1 -1
  45. package/package.json +14 -27
  46. package/lib/plugin-options.json +0 -197
package/LICENSE CHANGED
@@ -1,5 +1,6 @@
1
1
  MIT License
2
2
 
3
+ Copyright (c) 2024-present Rspack Contrib
3
4
  Copyright (c) 2020 TypeStrong
4
5
 
5
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
package/README.md CHANGED
@@ -1,9 +1,15 @@
1
- # TS Checker Rspack Plugin
1
+ # ts-checker-rspack-plugin
2
2
 
3
3
  Rspack plugin that runs TypeScript type checker on a separate process.
4
4
 
5
- [![npm version](https://img.shields.io/npm/v/ts-checker-rspack-plugin.svg)](https://www.npmjs.com/package/ts-checker-rspack-plugin)
6
- [![downloads](http://img.shields.io/npm/dm/ts-checker-rspack-plugin.svg)](https://npmjs.org/package/ts-checker-rspack-plugin)
5
+ <p>
6
+ <a href="https://npmjs.com/package/ts-checker-rspack-plugin">
7
+ <img src="https://img.shields.io/npm/v/ts-checker-rspack-plugin?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" />
8
+ </a>
9
+ <img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="license" />
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
+ </p>
12
+
7
13
 
8
14
  ## Credits
9
15
 
@@ -19,7 +25,7 @@ Big thanks to `fork-ts-checker-webpack-plugin` creators and contributors for the
19
25
 
20
26
  ## Installation
21
27
 
22
- This plugin requires **Node.js >=14.0.0+**, **Rspack ^1.0.0**, **TypeScript ^3.6.0**
28
+ This plugin requires **Node.js >=16.0.0+**, **Rspack ^1.0.0**, **TypeScript ^3.8.0**
23
29
 
24
30
  ```sh
25
31
  # with npm
@@ -32,7 +38,7 @@ yarn add -D ts-checker-rspack-plugin
32
38
  pnpm add -D ts-checker-rspack-plugin
33
39
  ```
34
40
 
35
- The minimal webpack config (with [ts-loader](https://github.com/TypeStrong/ts-loader))
41
+ The minimal Rspack config with [builtin:swc-loader](https://rspack.dev/guide/features/builtin-swc-loader).
36
42
 
37
43
  ```js
38
44
  // rspack.config.js
@@ -48,11 +54,14 @@ module.exports = {
48
54
  rules: [
49
55
  {
50
56
  test: /\.tsx?$/,
51
- loader: 'ts-loader',
52
- // add transpileOnly option if you use ts-loader < 9.3.0
53
- // options: {
54
- // transpileOnly: true
55
- // }
57
+ loader: 'builtin:swc-loader',
58
+ options: {
59
+ jsc: {
60
+ parser: {
61
+ syntax: 'typescript',
62
+ },
63
+ },
64
+ },
56
65
  },
57
66
  ],
58
67
  },
@@ -66,9 +75,6 @@ module.exports = {
66
75
  };
67
76
  ```
68
77
 
69
- > Examples how to configure it with [babel-loader](https://github.com/babel/babel-loader), [ts-loader](https://github.com/TypeStrong/ts-loader)
70
- > and [Visual Studio Code](https://code.visualstudio.com/) are in the [**examples**](./examples) directory.
71
-
72
78
  ## Modules resolution
73
79
 
74
80
  It's very important to be aware that **this plugin uses [TypeScript](https://github.com/Microsoft/TypeScript)'s, not
@@ -95,7 +101,7 @@ Options for the TypeScript checker (`typescript` option object).
95
101
 
96
102
  | Name | Type | Default value | Description |
97
103
  | ------------------- | ------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
98
- | `memoryLimit` | `number` | `2048` | Memory limit for the checker process in MB. If the process exits with the allocation failed error, try to increase this number. |
104
+ | `memoryLimit` | `number` | `8192` | Memory limit for the checker process in MB. If the process exits with the allocation failed error, try to increase this number. |
99
105
  | `configFile` | `string` | `'tsconfig.json'` | Path to the `tsconfig.json` file (path relative to the `compiler.options.context` or absolute path) |
100
106
  | `configOverwrite` | `object` | `{ compilerOptions: { skipLibCheck: true, sourceMap: false, inlineSourceMap: false, declarationMap: false } }` | This configuration will overwrite configuration from the `tsconfig.json` file. Supported fields are: `extends`, `compilerOptions`, `include`, `exclude`, `files`, and `references`. |
101
107
  | `context` | `string` | `dirname(configuration.configFile)` | The base path for finding files specified in the `tsconfig.json`. Same as the `context` option from the [ts-loader](https://github.com/TypeStrong/ts-loader#context). Useful if you want to keep your `tsconfig.json` in an external package. Keep in mind that **not** having a `tsconfig.json` in your project root can cause different behaviour between `ts-checker-rspack-plugin` and `tsc`. When using editors like `VS Code` it is advised to add a `tsconfig.json` file to the root of the project and extend the config file referenced in option `configFile`. |
@@ -165,10 +171,10 @@ When we call this method with a [Rspack compiler instance](https://rspack.dev/ap
165
171
  [tapable](https://github.com/webpack/tapable) hooks where you can pass in your callbacks.
166
172
 
167
173
  ```js
168
- // ./src/webpack/MyWebpackPlugin.js
174
+ // ./src/rspack/MyRspackPlugin.js
169
175
  const { TsCheckerRspackPlugin } = require('ts-checker-rspack-plugin');
170
176
 
171
- class MyWebpackPlugin {
177
+ class MyRspackPlugin {
172
178
  apply(compiler) {
173
179
  const hooks = TsCheckerRspackPlugin.getCompilerHooks(compiler);
174
180
 
@@ -181,15 +187,15 @@ class MyWebpackPlugin {
181
187
  }
182
188
  }
183
189
 
184
- module.exports = MyWebpackPlugin;
190
+ module.exports = MyRspackPlugin;
185
191
 
186
192
  // rspack.config.js
187
193
  const { TsCheckerRspackPlugin } = require('ts-checker-rspack-plugin');
188
- const MyWebpackPlugin = require('./src/webpack/MyWebpackPlugin');
194
+ const MyRspackPlugin = require('./src/webpack/MyRspackPlugin');
189
195
 
190
196
  module.exports = {
191
197
  /* ... */
192
- plugins: [new TsCheckerRspackPlugin(), new MyWebpackPlugin()],
198
+ plugins: [new TsCheckerRspackPlugin(), new MyRspackPlugin()],
193
199
  };
194
200
  ```
195
201
 
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createBasicFormatter = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
7
+ const picocolors_1 = __importDefault(require("picocolors"));
8
8
  function createBasicFormatter() {
9
9
  return function basicFormatter(issue) {
10
- return chalk_1.default.grey(issue.code + ': ') + issue.message;
10
+ return picocolors_1.default.gray(issue.code + ': ') + issue.message;
11
11
  };
12
12
  }
13
13
  exports.createBasicFormatter = createBasicFormatter;
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createCodeFrameFormatter = void 0;
7
7
  const os_1 = __importDefault(require("os"));
8
8
  const code_frame_1 = require("@babel/code-frame");
9
- const fs_extra_1 = __importDefault(require("fs-extra"));
9
+ const node_fs_1 = __importDefault(require("node:fs"));
10
10
  const basic_formatter_1 = require("./basic-formatter");
11
11
  function createCodeFrameFormatter(options) {
12
12
  const basicFormatter = (0, basic_formatter_1.createBasicFormatter)();
13
13
  return function codeFrameFormatter(issue) {
14
- const source = issue.file && fs_extra_1.default.existsSync(issue.file) && fs_extra_1.default.readFileSync(issue.file, 'utf-8');
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
17
  frame = (0, code_frame_1.codeFrameColumns)(source, issue.location, Object.assign({ highlightCode: true }, (options || {})))
@@ -1,6 +1,6 @@
1
1
  import type { Formatter, FormatterPathType } from './formatter';
2
2
  import type { FormatterOptions } from './formatter-options';
3
- declare type FormatterConfig = {
3
+ type FormatterConfig = {
4
4
  format: Formatter;
5
5
  pathType: FormatterPathType;
6
6
  };
@@ -1,14 +1,14 @@
1
1
  import type { Formatter, FormatterPathType } from './formatter';
2
2
  import type { BabelCodeFrameOptions } from './types/babel__code-frame';
3
- declare type FormatterType = 'basic' | 'codeframe';
4
- declare type BasicFormatterOptions = {
3
+ type FormatterType = 'basic' | 'codeframe';
4
+ type BasicFormatterOptions = {
5
5
  type: 'basic';
6
6
  pathType?: FormatterPathType;
7
7
  };
8
- declare type CodeframeFormatterOptions = {
8
+ type CodeframeFormatterOptions = {
9
9
  type: 'codeframe';
10
10
  pathType?: FormatterPathType;
11
11
  options?: BabelCodeFrameOptions;
12
12
  };
13
- declare type FormatterOptions = undefined | FormatterType | BasicFormatterOptions | CodeframeFormatterOptions | Formatter;
13
+ type FormatterOptions = undefined | FormatterType | BasicFormatterOptions | CodeframeFormatterOptions | Formatter;
14
14
  export { FormatterOptions, FormatterType, BasicFormatterOptions, CodeframeFormatterOptions };
@@ -1,4 +1,4 @@
1
1
  import type { Issue } from '../issue';
2
- declare type Formatter = (issue: Issue) => string;
3
- declare type FormatterPathType = 'relative' | 'absolute';
2
+ type Formatter = (issue: Issue) => string;
3
+ type FormatterPathType = 'relative' | 'absolute';
4
4
  export { Formatter, FormatterPathType };
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -4,16 +4,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.statsFormatter = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
7
+ const picocolors_1 = __importDefault(require("picocolors"));
8
8
  // mimics webpack's stats summary formatter
9
9
  function statsFormatter(issues, stats) {
10
10
  const errorsNumber = issues.filter((issue) => issue.severity === 'error').length;
11
11
  const warningsNumber = issues.filter((issue) => issue.severity === 'warning').length;
12
12
  const errorsFormatted = errorsNumber
13
- ? chalk_1.default.red.bold(`${errorsNumber} ${errorsNumber === 1 ? 'error' : 'errors'}`)
13
+ ? picocolors_1.default.bold(picocolors_1.default.red(`${errorsNumber} ${errorsNumber === 1 ? 'error' : 'errors'}`))
14
14
  : '';
15
15
  const warningsFormatted = warningsNumber
16
- ? chalk_1.default.yellow.bold(`${warningsNumber} ${warningsNumber === 1 ? 'warning' : 'warnings'}`)
16
+ ? picocolors_1.default.bold(picocolors_1.default.yellow(`${warningsNumber} ${warningsNumber === 1 ? 'warning' : 'warnings'}`))
17
17
  : '';
18
18
  const timeFormatted = stats.startTime ? Math.round(Date.now() - stats.startTime) : 0;
19
19
  return [
@@ -6,26 +6,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createWebpackFormatter = void 0;
7
7
  const os_1 = __importDefault(require("os"));
8
8
  const path_1 = __importDefault(require("path"));
9
- const chalk_1 = __importDefault(require("chalk"));
9
+ const picocolors_1 = __importDefault(require("picocolors"));
10
10
  const issue_1 = require("../issue");
11
11
  const forward_slash_1 = require("../utils/path/forward-slash");
12
12
  const relative_to_context_1 = require("../utils/path/relative-to-context");
13
13
  function createWebpackFormatter(formatter, pathType) {
14
14
  // mimics webpack error formatter
15
15
  return function webpackFormatter(issue) {
16
- const color = issue.severity === 'warning' ? chalk_1.default.yellow.bold : chalk_1.default.red.bold;
16
+ const color = issue.severity === 'warning' ? picocolors_1.default.yellow : picocolors_1.default.red;
17
17
  const severity = issue.severity.toUpperCase();
18
18
  if (issue.file) {
19
- let location = chalk_1.default.bold(pathType === 'absolute'
19
+ let location = picocolors_1.default.bold(pathType === 'absolute'
20
20
  ? (0, forward_slash_1.forwardSlash)(path_1.default.resolve(issue.file))
21
21
  : (0, relative_to_context_1.relativeToContext)(issue.file, process.cwd()));
22
22
  if (issue.location) {
23
- location += `:${chalk_1.default.green.bold((0, issue_1.formatIssueLocation)(issue.location))}`;
23
+ location += `:${picocolors_1.default.bold(picocolors_1.default.green((0, issue_1.formatIssueLocation)(issue.location)))}`;
24
24
  }
25
- return [`${color(severity)} in ${location}`, formatter(issue), ''].join(os_1.default.EOL);
25
+ return [`${picocolors_1.default.bold(color(severity))} in ${location}`, formatter(issue), ''].join(os_1.default.EOL);
26
26
  }
27
27
  else {
28
- return [`${color(severity)} in ` + formatter(issue), ''].join(os_1.default.EOL);
28
+ return [`${picocolors_1.default.bold(color(severity))} in ` + formatter(issue), ''].join(os_1.default.EOL);
29
29
  }
30
30
  };
31
31
  }
@@ -13,7 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.tapDoneToAsyncGetIssues = void 0;
16
- const chalk_1 = __importDefault(require("chalk"));
16
+ const picocolors_1 = __importDefault(require("picocolors"));
17
+ ;
17
18
  const stats_formatter_1 = require("../formatter/stats-formatter");
18
19
  const webpack_formatter_1 = require("../formatter/webpack-formatter");
19
20
  const infrastructure_logger_1 = require("../infrastructure-logger");
@@ -34,7 +35,7 @@ function tapDoneToAsyncGetIssues(compiler, config, state) {
34
35
  try {
35
36
  if (yield (0, is_pending_1.isPending)(issuesPromise)) {
36
37
  hooks.waiting.call(stats.compilation);
37
- config.logger.log(chalk_1.default.cyan('Type-checking in progress...'));
38
+ config.logger.log(picocolors_1.default.cyan('Type-checking in progress...'));
38
39
  }
39
40
  else {
40
41
  // wait 10ms to log issues after webpack stats
@@ -64,7 +65,7 @@ function tapDoneToAsyncGetIssues(compiler, config, state) {
64
65
  config.logger.log((0, stats_formatter_1.statsFormatter)(issues, stats));
65
66
  }
66
67
  else {
67
- config.logger.log(chalk_1.default.green('No errors found.'));
68
+ config.logger.log(picocolors_1.default.green('No errors found.'));
68
69
  }
69
70
  // report issues to webpack-dev-server, if it's listening
70
71
  // skip reporting if there are no issues, to avoid an extra hot reload
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.tapErrorToLogMessage = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
7
+ const picocolors_1 = __importDefault(require("picocolors"));
8
8
  const plugin_hooks_1 = require("../plugin-hooks");
9
9
  const rpc_1 = require("../rpc");
10
10
  const abort_error_1 = require("../utils/async/abort-error");
@@ -17,12 +17,12 @@ function tapErrorToLogMessage(compiler, config) {
17
17
  config.logger.error(String(error));
18
18
  if (error instanceof rpc_1.RpcExitError) {
19
19
  if (error.signal === 'SIGINT') {
20
- config.logger.error(chalk_1.default.red('Issues checking service interrupted - If running in a docker container, this may be caused ' +
20
+ config.logger.error(picocolors_1.default.red('Issues checking service interrupted - If running in a docker container, this may be caused ' +
21
21
  "by the container running out of memory. If so, try increasing the container's memory limit " +
22
22
  'or lowering the `memoryLimit` value in the TsCheckerRspackPlugin configuration.'));
23
23
  }
24
24
  else {
25
- config.logger.error(chalk_1.default.red('Issues checking service aborted - probably out of memory. ' +
25
+ config.logger.error(picocolors_1.default.red('Issues checking service aborted - probably out of memory. ' +
26
26
  'Check the `memoryLimit` option in the TsCheckerRspackPlugin configuration.\n' +
27
27
  "If increasing the memory doesn't solve the issue, it's most probably a bug in the TypeScript."));
28
28
  }
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.tapStartToRunWorkers = void 0;
13
- const node_abort_controller_1 = require("node-abort-controller");
14
13
  const files_change_1 = require("../files-change");
15
14
  const infrastructure_logger_1 = require("../infrastructure-logger");
16
15
  const plugin_hooks_1 = require("../plugin-hooks");
@@ -57,7 +56,7 @@ function tapStartToRunWorkers(compiler, getIssuesWorker, getDependenciesWorker,
57
56
  state.abortController.abort();
58
57
  }
59
58
  // create new abort controller for the new iteration
60
- const abortController = new node_abort_controller_1.AbortController();
59
+ const abortController = new AbortController();
61
60
  state.abortController = abortController;
62
61
  let filesChange = {};
63
62
  if (state.watching) {
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,5 +1,5 @@
1
1
  import type { IssuePredicate } from './issue-predicate';
2
2
  import type { Issue } from './index';
3
- declare type IssueMatch = Partial<Pick<Issue, 'severity' | 'code' | 'file'>>;
3
+ type IssueMatch = Partial<Pick<Issue, 'severity' | 'code' | 'file'>>;
4
4
  declare function createIssuePredicateFromIssueMatch(context: string, match: IssueMatch): IssuePredicate;
5
5
  export { IssueMatch, createIssuePredicateFromIssueMatch };
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createIssuePredicateFromIssueMatch = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
- const minimatch_1 = __importDefault(require("minimatch"));
8
+ const minimatch_1 = require("minimatch");
9
9
  const forward_slash_1 = require("../utils/path/forward-slash");
10
10
  function createIssuePredicateFromIssueMatch(context, match) {
11
11
  return (issue) => {
@@ -13,7 +13,7 @@ function createIssuePredicateFromIssueMatch(context, match) {
13
13
  const matchesCode = !match.code || match.code === issue.code;
14
14
  const matchesFile = !issue.file ||
15
15
  (!!issue.file &&
16
- (!match.file || (0, minimatch_1.default)((0, forward_slash_1.forwardSlash)(path_1.default.relative(context, issue.file)), match.file)));
16
+ (!match.file || (0, minimatch_1.minimatch)((0, forward_slash_1.forwardSlash)(path_1.default.relative(context, issue.file)), match.file)));
17
17
  return matchesSeverity && matchesCode && matchesFile;
18
18
  };
19
19
  }
@@ -1,6 +1,6 @@
1
1
  import type { IssueMatch } from './issue-match';
2
2
  import type { IssuePredicate } from './issue-predicate';
3
- declare type IssuePredicateOption = IssuePredicate | IssueMatch | (IssuePredicate | IssueMatch)[];
3
+ type IssuePredicateOption = IssuePredicate | IssueMatch | (IssuePredicate | IssueMatch)[];
4
4
  interface IssueOptions {
5
5
  include?: IssuePredicateOption;
6
6
  exclude?: IssuePredicateOption;
@@ -1,5 +1,5 @@
1
1
  import type { Issue } from './index';
2
- declare type IssuePredicate = (issue: Issue) => boolean;
2
+ type IssuePredicate = (issue: Issue) => boolean;
3
3
  declare function createTrivialIssuePredicate(result: boolean): IssuePredicate;
4
4
  declare function composeIssuePredicates(predicates: IssuePredicate[]): IssuePredicate;
5
5
  export { IssuePredicate, createTrivialIssuePredicate, composeIssuePredicates };
@@ -1,4 +1,4 @@
1
- declare type IssueSeverity = 'error' | 'warning';
1
+ type IssueSeverity = 'error' | 'warning';
2
2
  declare function isIssueSeverity(value: unknown): value is IssueSeverity;
3
3
  declare function compareIssueSeverities(severityA: IssueSeverity, severityB: IssueSeverity): number;
4
4
  export { IssueSeverity, isIssueSeverity, compareIssueSeverities };
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,20 +1,36 @@
1
- import { SyncHook, SyncWaterfallHook, AsyncSeriesWaterfallHook } from 'tapable';
1
+ import { SyncHook, SyncWaterfallHook, AsyncSeriesWaterfallHook } from '@rspack/lite-tapable';
2
2
  import type * as rspack from '@rspack/core';
3
3
  import type { FilesChange } from './files-change';
4
4
  import type { Issue } from './issue';
5
5
  declare function createPluginHooks(): {
6
- start: AsyncSeriesWaterfallHook<[FilesChange, rspack.Compilation], import("tapable").UnsetAdditionalOptions>;
7
- waiting: SyncHook<[rspack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
8
- canceled: SyncHook<[rspack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
9
- error: SyncHook<[unknown, rspack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
6
+ start: AsyncSeriesWaterfallHook<[FilesChange, rspack.Compilation], {
7
+ _UnsetAdditionalOptions: true;
8
+ }>;
9
+ waiting: SyncHook<[rspack.Compilation], void, {
10
+ _UnsetAdditionalOptions: true;
11
+ }>;
12
+ canceled: SyncHook<[rspack.Compilation], void, {
13
+ _UnsetAdditionalOptions: true;
14
+ }>;
15
+ error: SyncHook<[unknown, rspack.Compilation], void, {
16
+ _UnsetAdditionalOptions: true;
17
+ }>;
10
18
  issues: SyncWaterfallHook<[Issue[], rspack.Compilation | undefined], void>;
11
19
  };
12
- declare type TsCheckerRspackPluginHooks = ReturnType<typeof createPluginHooks>;
20
+ type TsCheckerRspackPluginHooks = ReturnType<typeof createPluginHooks>;
13
21
  declare function getPluginHooks(compiler: rspack.Compiler | rspack.MultiCompiler): {
14
- start: AsyncSeriesWaterfallHook<[FilesChange, rspack.Compilation], import("tapable").UnsetAdditionalOptions>;
15
- waiting: SyncHook<[rspack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
16
- canceled: SyncHook<[rspack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
17
- error: SyncHook<[unknown, rspack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
22
+ start: AsyncSeriesWaterfallHook<[FilesChange, rspack.Compilation], {
23
+ _UnsetAdditionalOptions: true;
24
+ }>;
25
+ waiting: SyncHook<[rspack.Compilation], void, {
26
+ _UnsetAdditionalOptions: true;
27
+ }>;
28
+ canceled: SyncHook<[rspack.Compilation], void, {
29
+ _UnsetAdditionalOptions: true;
30
+ }>;
31
+ error: SyncHook<[unknown, rspack.Compilation], void, {
32
+ _UnsetAdditionalOptions: true;
33
+ }>;
18
34
  issues: SyncWaterfallHook<[Issue[], rspack.Compilation | undefined], void>;
19
35
  };
20
36
  export { getPluginHooks, TsCheckerRspackPluginHooks };
@@ -1,18 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPluginHooks = void 0;
4
- const tapable_1 = require("tapable");
4
+ const lite_tapable_1 = require("@rspack/lite-tapable");
5
5
  const compilerHookMap = new WeakMap();
6
6
  function createPluginHooks() {
7
7
  return {
8
- start: new tapable_1.AsyncSeriesWaterfallHook([
8
+ start: new lite_tapable_1.AsyncSeriesWaterfallHook([
9
9
  'change',
10
10
  'compilation',
11
11
  ]),
12
- waiting: new tapable_1.SyncHook(['compilation']),
13
- canceled: new tapable_1.SyncHook(['compilation']),
14
- error: new tapable_1.SyncHook(['error', 'compilation']),
15
- issues: new tapable_1.SyncWaterfallHook([
12
+ waiting: new lite_tapable_1.SyncHook(['compilation']),
13
+ canceled: new lite_tapable_1.SyncHook(['compilation']),
14
+ error: new lite_tapable_1.SyncHook(['error', 'compilation']),
15
+ issues: new lite_tapable_1.SyncWaterfallHook([
16
16
  'issues',
17
17
  'compilation',
18
18
  ]),
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,5 +1,4 @@
1
- import type { AbortController } from 'node-abort-controller';
2
- import type { FullTap } from 'tapable';
1
+ /// <reference types="node" />
3
2
  import type { FilesChange } from './files-change';
4
3
  import type { FilesMatch } from './files-match';
5
4
  import type { Issue } from './issue';
@@ -12,7 +11,7 @@ interface TsCheckerRspackPluginState {
12
11
  watching: boolean;
13
12
  initialized: boolean;
14
13
  iteration: number;
15
- webpackDevServerDoneTap: FullTap | undefined;
14
+ webpackDevServerDoneTap: any | undefined;
16
15
  }
17
16
  declare function createPluginState(): TsCheckerRspackPluginState;
18
17
  export { TsCheckerRspackPluginState, createPluginState };
package/lib/plugin.d.ts CHANGED
@@ -3,7 +3,6 @@ import type { TsCheckerRspackPluginOptions } from './plugin-options';
3
3
  declare class TsCheckerRspackPlugin {
4
4
  /**
5
5
  * Current version of the plugin
6
- * TODO: use `define` to replace it
7
6
  */
8
7
  static readonly version: string;
9
8
  /**
@@ -18,11 +17,19 @@ declare class TsCheckerRspackPlugin {
18
17
  private readonly options;
19
18
  constructor(options?: TsCheckerRspackPluginOptions);
20
19
  static getCompilerHooks(compiler: rspack.Compiler): {
21
- start: import("tapable").AsyncSeriesWaterfallHook<[import("./files-change").FilesChange, rspack.Compilation], import("tapable").UnsetAdditionalOptions>;
22
- waiting: import("tapable").SyncHook<[rspack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
23
- canceled: import("tapable").SyncHook<[rspack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
24
- error: import("tapable").SyncHook<[unknown, rspack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
25
- issues: import("tapable").SyncWaterfallHook<[import("./issue/issue").Issue[], rspack.Compilation | undefined], void>;
20
+ start: import("@rspack/lite-tapable").AsyncSeriesWaterfallHook<[import("./files-change").FilesChange, rspack.Compilation], {
21
+ _UnsetAdditionalOptions: true;
22
+ }>;
23
+ waiting: import("@rspack/lite-tapable").SyncHook<[rspack.Compilation], void, {
24
+ _UnsetAdditionalOptions: true;
25
+ }>;
26
+ canceled: import("@rspack/lite-tapable").SyncHook<[rspack.Compilation], void, {
27
+ _UnsetAdditionalOptions: true;
28
+ }>;
29
+ error: import("@rspack/lite-tapable").SyncHook<[unknown, rspack.Compilation], void, {
30
+ _UnsetAdditionalOptions: true;
31
+ }>;
32
+ issues: import("@rspack/lite-tapable").SyncWaterfallHook<[import("./issue/issue").Issue[], rspack.Compilation | undefined], void>;
26
33
  };
27
34
  apply(compiler: rspack.Compiler): void;
28
35
  }
package/lib/plugin.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -18,13 +22,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
18
22
  __setModuleDefault(result, mod);
19
23
  return result;
20
24
  };
21
- var __importDefault = (this && this.__importDefault) || function (mod) {
22
- return (mod && mod.__esModule) ? mod : { "default": mod };
23
- };
24
25
  Object.defineProperty(exports, "__esModule", { value: true });
25
26
  exports.TsCheckerRspackPlugin = void 0;
26
27
  const path = __importStar(require("path"));
27
- const schema_utils_1 = require("schema-utils");
28
28
  const tap_after_compile_to_add_dependencies_1 = require("./hooks/tap-after-compile-to-add-dependencies");
29
29
  const tap_after_environment_to_patch_watching_1 = require("./hooks/tap-after-environment-to-patch-watching");
30
30
  const tap_error_to_log_message_1 = require("./hooks/tap-error-to-log-message");
@@ -32,19 +32,15 @@ const tap_start_to_run_workers_1 = require("./hooks/tap-start-to-run-workers");
32
32
  const tap_stop_to_terminate_workers_1 = require("./hooks/tap-stop-to-terminate-workers");
33
33
  const plugin_config_1 = require("./plugin-config");
34
34
  const plugin_hooks_1 = require("./plugin-hooks");
35
- const plugin_options_json_1 = __importDefault(require("./plugin-options.json"));
36
35
  const plugin_pools_1 = require("./plugin-pools");
37
36
  const plugin_state_1 = require("./plugin-state");
38
37
  const rpc_1 = require("./rpc");
39
38
  const type_script_support_1 = require("./typescript/type-script-support");
39
+ const node_fs_1 = require("node:fs");
40
+ const pkgJson = JSON.parse((0, node_fs_1.readFileSync)(path.join(__dirname, '../package.json'), 'utf-8'));
40
41
  class TsCheckerRspackPlugin {
41
42
  constructor(options = {}) {
42
- // first validate options directly passed to the constructor
43
- const config = { name: 'TsCheckerRspackPlugin' };
44
- (0, schema_utils_1.validate)(plugin_options_json_1.default, options, config);
45
43
  this.options = options;
46
- // then validate merged options
47
- (0, schema_utils_1.validate)(plugin_options_json_1.default, this.options, config);
48
44
  }
49
45
  static getCompilerHooks(compiler) {
50
46
  return (0, plugin_hooks_1.getPluginHooks)(compiler);
@@ -65,9 +61,8 @@ class TsCheckerRspackPlugin {
65
61
  exports.TsCheckerRspackPlugin = TsCheckerRspackPlugin;
66
62
  /**
67
63
  * Current version of the plugin
68
- * TODO: use `define` to replace it
69
64
  */
70
- TsCheckerRspackPlugin.version = '1.0.0-beta.0';
65
+ TsCheckerRspackPlugin.version = pkgJson.version;
71
66
  /**
72
67
  * Default pools for the plugin concurrency limit
73
68
  */
@@ -7,7 +7,7 @@ interface RpcWorkerBase {
7
7
  readonly connected: boolean;
8
8
  readonly process: ChildProcess | undefined;
9
9
  }
10
- declare type RpcWorker<T extends RpcMethod = RpcMethod> = RpcWorkerBase & RpcRemoteMethod<T>;
10
+ type RpcWorker<T extends RpcMethod = RpcMethod> = RpcWorkerBase & RpcRemoteMethod<T>;
11
11
  declare function createRpcWorker<T extends RpcMethod>(modulePath: string, data: unknown, memoryLimit?: number): RpcWorker<T>;
12
12
  declare function getRpcWorkerData(): unknown;
13
13
  export { createRpcWorker, getRpcWorkerData, RpcWorker };