ts-checker-rspack-plugin 1.1.7 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/README.md +69 -22
  2. package/lib/getDependenciesWorker.js +652 -0
  3. package/lib/getIssuesWorker.js +1095 -0
  4. package/lib/index.js +972 -4
  5. package/lib/issue/issue-config.d.ts +2 -0
  6. package/lib/issue/issue-options.d.ts +2 -0
  7. package/lib/issue/issue-severity.d.ts +4 -4
  8. package/lib/plugin-state.d.ts +0 -1
  9. package/lib/plugin.d.ts +1 -1
  10. package/lib/rpc/rpc-worker.d.ts +0 -1
  11. package/lib/rpc/wrap-rpc.d.ts +0 -1
  12. package/lib/typescript/worker/get-issues-worker.d.ts +2 -2
  13. package/lib/typescript/worker/lib/config.d.ts +2 -2
  14. package/lib/typescript/worker/lib/diagnostics.d.ts +3 -3
  15. package/lib/typescript/worker/lib/file-system/file-system.d.ts +0 -1
  16. package/lib/utils/async/abort-error.d.ts +0 -1
  17. package/lib/utils/async/pool.d.ts +0 -1
  18. package/lib/watch/watch-file-system.d.ts +0 -1
  19. package/package.json +12 -11
  20. package/lib/files-change.js +0 -57
  21. package/lib/files-match.js +0 -2
  22. package/lib/formatter/basic-formatter.js +0 -13
  23. package/lib/formatter/code-frame-formatter.js +0 -32
  24. package/lib/formatter/formatter-config.js +0 -36
  25. package/lib/formatter/formatter-options.js +0 -2
  26. package/lib/formatter/formatter.js +0 -2
  27. package/lib/formatter/index.js +0 -22
  28. package/lib/formatter/stats-formatter.js +0 -30
  29. package/lib/formatter/types/babel__code-frame.js +0 -7
  30. package/lib/formatter/webpack-formatter.js +0 -32
  31. package/lib/hooks/intercept-done-to-get-dev-server-tap.js +0 -18
  32. package/lib/hooks/tap-after-compile-to-add-dependencies.js +0 -59
  33. package/lib/hooks/tap-after-compile-to-get-issues.js +0 -43
  34. package/lib/hooks/tap-after-environment-to-patch-watching.js +0 -22
  35. package/lib/hooks/tap-done-to-async-get-issues.js +0 -74
  36. package/lib/hooks/tap-error-to-log-message.js +0 -32
  37. package/lib/hooks/tap-start-to-run-workers.js +0 -122
  38. package/lib/hooks/tap-stop-to-terminate-workers.js +0 -26
  39. package/lib/infrastructure-logger.js +0 -14
  40. package/lib/issue/index.js +0 -19
  41. package/lib/issue/issue-config.js +0 -29
  42. package/lib/issue/issue-location.js +0 -22
  43. package/lib/issue/issue-match.js +0 -20
  44. package/lib/issue/issue-options.js +0 -2
  45. package/lib/issue/issue-position.js +0 -16
  46. package/lib/issue/issue-predicate.js +0 -11
  47. package/lib/issue/issue-severity.js +0 -12
  48. package/lib/issue/issue-webpack-error.js +0 -31
  49. package/lib/issue/issue.js +0 -41
  50. package/lib/logger.js +0 -2
  51. package/lib/plugin-config.js +0 -26
  52. package/lib/plugin-hooks.js +0 -45
  53. package/lib/plugin-options.js +0 -2
  54. package/lib/plugin-pools.js +0 -32
  55. package/lib/plugin-state.js +0 -17
  56. package/lib/plugin.js +0 -74
  57. package/lib/rpc/expose-rpc.js +0 -69
  58. package/lib/rpc/index.js +0 -12
  59. package/lib/rpc/rpc-error.js +0 -12
  60. package/lib/rpc/rpc-worker.js +0 -86
  61. package/lib/rpc/types.js +0 -2
  62. package/lib/rpc/wrap-rpc.js +0 -70
  63. package/lib/typescript/type-script-config-overwrite.js +0 -2
  64. package/lib/typescript/type-script-diagnostics-options.js +0 -2
  65. package/lib/typescript/type-script-support.js +0 -31
  66. package/lib/typescript/type-script-worker-config.js +0 -36
  67. package/lib/typescript/type-script-worker-options.js +0 -2
  68. package/lib/typescript/worker/get-dependencies-worker.js +0 -15
  69. package/lib/typescript/worker/get-issues-worker.js +0 -70
  70. package/lib/typescript/worker/lib/artifacts.js +0 -94
  71. package/lib/typescript/worker/lib/config.js +0 -162
  72. package/lib/typescript/worker/lib/dependencies.js +0 -84
  73. package/lib/typescript/worker/lib/diagnostics.js +0 -112
  74. package/lib/typescript/worker/lib/emit.js +0 -13
  75. package/lib/typescript/worker/lib/file-system/file-system.js +0 -2
  76. package/lib/typescript/worker/lib/file-system/mem-file-system.js +0 -81
  77. package/lib/typescript/worker/lib/file-system/passive-file-system.js +0 -68
  78. package/lib/typescript/worker/lib/file-system/real-file-system.js +0 -171
  79. package/lib/typescript/worker/lib/host/compiler-host.js +0 -17
  80. package/lib/typescript/worker/lib/host/watch-compiler-host.js +0 -32
  81. package/lib/typescript/worker/lib/host/watch-solution-builder-host.js +0 -53
  82. package/lib/typescript/worker/lib/performance.js +0 -29
  83. package/lib/typescript/worker/lib/program/program.js +0 -37
  84. package/lib/typescript/worker/lib/program/solution-builder.js +0 -39
  85. package/lib/typescript/worker/lib/program/watch-program.js +0 -51
  86. package/lib/typescript/worker/lib/system.js +0 -229
  87. package/lib/typescript/worker/lib/tracing.js +0 -27
  88. package/lib/typescript/worker/lib/tsbuildinfo.js +0 -96
  89. package/lib/typescript/worker/lib/typescript.js +0 -6
  90. package/lib/typescript/worker/lib/worker-config.js +0 -5
  91. package/lib/utils/async/abort-error.js +0 -15
  92. package/lib/utils/async/controlled-promise.js +0 -17
  93. package/lib/utils/async/is-pending.js +0 -10
  94. package/lib/utils/async/pool.js +0 -36
  95. package/lib/utils/async/wait.js +0 -7
  96. package/lib/utils/path/forward-slash.js +0 -15
  97. package/lib/utils/path/is-inside-another-path.js +0 -22
  98. package/lib/utils/path/relative-to-context.js +0 -16
  99. package/lib/watch/inclusive-node-watch-file-system.js +0 -183
  100. package/lib/watch/watch-file-system.js +0 -2
@@ -1,8 +1,10 @@
1
1
  import type * as rspack from '@rspack/core';
2
2
  import type { IssueOptions } from './issue-options';
3
3
  import type { IssuePredicate } from './issue-predicate';
4
+ import type { IssueDefaultSeverity } from './issue-severity';
4
5
  interface IssueConfig {
5
6
  predicate: IssuePredicate;
7
+ defaultSeverity: IssueDefaultSeverity;
6
8
  }
7
9
  declare function createIssueConfig(compiler: rspack.Compiler, options: IssueOptions | undefined): IssueConfig;
8
10
  export { IssueConfig, createIssueConfig };
@@ -1,8 +1,10 @@
1
1
  import type { IssueMatch } from './issue-match';
2
2
  import type { IssuePredicate } from './issue-predicate';
3
+ import type { IssueDefaultSeverity } from './issue-severity';
3
4
  type IssuePredicateOption = IssuePredicate | IssueMatch | (IssuePredicate | IssueMatch)[];
4
5
  interface IssueOptions {
5
6
  include?: IssuePredicateOption;
6
7
  exclude?: IssuePredicateOption;
8
+ defaultSeverity?: IssueDefaultSeverity;
7
9
  }
8
10
  export { IssueOptions, IssuePredicateOption };
@@ -1,4 +1,4 @@
1
- type IssueSeverity = 'error' | 'warning';
2
- declare function isIssueSeverity(value: unknown): value is IssueSeverity;
3
- declare function compareIssueSeverities(severityA: IssueSeverity, severityB: IssueSeverity): number;
4
- export { IssueSeverity, isIssueSeverity, compareIssueSeverities };
1
+ export type IssueSeverity = 'error' | 'warning';
2
+ export type IssueDefaultSeverity = IssueSeverity | 'auto';
3
+ export declare function isIssueSeverity(value: unknown): value is IssueSeverity;
4
+ export declare function compareIssueSeverities(severityA: IssueSeverity, severityB: IssueSeverity): number;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { FilesChange } from './files-change';
3
2
  import type { FilesMatch } from './files-match';
4
3
  import type { Issue } from './issue';
package/lib/plugin.d.ts CHANGED
@@ -29,7 +29,7 @@ declare class TsCheckerRspackPlugin {
29
29
  error: import("@rspack/lite-tapable").SyncHook<[unknown, rspack.Compilation], void, {
30
30
  _UnsetAdditionalOptions: true;
31
31
  }>;
32
- issues: import("@rspack/lite-tapable").SyncWaterfallHook<[import("./issue/issue").Issue[], rspack.Compilation | undefined], void>;
32
+ issues: import("@rspack/lite-tapable").SyncWaterfallHook<[import("./issue").Issue[], rspack.Compilation | undefined], void>;
33
33
  };
34
34
  apply(compiler: rspack.Compiler): void;
35
35
  }
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { ChildProcess } from 'child_process';
3
2
  import type { RpcMethod, RpcRemoteMethod } from './types';
4
3
  interface RpcWorkerBase {
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { ChildProcess } from 'child_process';
3
2
  import type { RpcRemoteMethod } from './types';
4
3
  export declare function wrapRpc<T extends (...args: any[]) => any>(childProcess: ChildProcess): RpcRemoteMethod<T>;
@@ -1,5 +1,5 @@
1
1
  import type { FilesChange } from '../../files-change';
2
- import type { Issue } from '../../issue';
3
- declare const getIssuesWorker: (change: FilesChange, watching: boolean) => Promise<Issue[]>;
2
+ import type { Issue, IssueDefaultSeverity } from '../../issue';
3
+ declare const getIssuesWorker: (change: FilesChange, watching: boolean, defaultSeverity: IssueDefaultSeverity) => Promise<Issue[]>;
4
4
  export type GetIssuesWorker = typeof getIssuesWorker;
5
5
  export {};
@@ -1,9 +1,9 @@
1
1
  import type * as ts from 'typescript';
2
2
  import type { FilesChange } from '../../../files-change';
3
3
  import type { FilesMatch } from '../../../files-match';
4
- import type { Issue } from '../../../issue';
4
+ import type { Issue, IssueDefaultSeverity } from '../../../issue';
5
5
  export declare function parseConfig(configFileName: string, configFileContext: string): ts.ParsedCommandLine;
6
- export declare function getParseConfigIssues(): Issue[];
6
+ export declare function getParseConfigIssues(defaultSeverity: IssueDefaultSeverity): Issue[];
7
7
  export declare function getParsedConfig(force?: boolean): ts.ParsedCommandLine;
8
8
  export declare function parseNextConfig(): readonly [ts.ParsedCommandLine | undefined, ts.ParsedCommandLine];
9
9
  export declare function invalidateConfig(): void;
@@ -1,7 +1,7 @@
1
1
  import type * as ts from 'typescript';
2
- import type { Issue } from '../../../issue';
2
+ import type { Issue, IssueDefaultSeverity } from '../../../issue';
3
3
  export declare function updateDiagnostics(configFile: string, diagnostics: ts.Diagnostic[]): void;
4
- export declare function getIssues(): Issue[];
4
+ export declare function getIssues(defaultSeverity: IssueDefaultSeverity): Issue[];
5
5
  export declare function invalidateDiagnostics(): void;
6
6
  export declare function getDiagnosticsOfProgram(program: ts.Program | ts.BuilderProgram): ts.Diagnostic[];
7
- export declare function createIssuesFromDiagnostics(diagnostics: ts.Diagnostic[]): Issue[];
7
+ export declare function createIssuesFromDiagnostics(diagnostics: ts.Diagnostic[], defaultSeverity: IssueDefaultSeverity): Issue[];
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { Dirent, Stats } from 'fs';
3
2
  /**
4
3
  * Interface to abstract file system implementation details.
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  declare class AbortError extends Error {
3
2
  constructor(message?: string);
4
3
  static throwIfAborted(signal: AbortSignal | undefined): void;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  type Task<T> = (signal?: AbortSignal) => Promise<T>;
3
2
  interface Pool {
4
3
  submit<T>(task: Task<T>, signal?: AbortSignal): Promise<T>;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { EventEmitter } from 'events';
3
2
  import type * as rspack from '@rspack/core';
4
3
  interface Watchpack extends EventEmitter {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-checker-rspack-plugin",
3
- "version": "1.1.7",
3
+ "version": "1.2.1",
4
4
  "description": "Runs typescript type checker and linter on separate process.",
5
5
  "keywords": [
6
6
  "rspack",
@@ -22,22 +22,23 @@
22
22
  "main": "lib/index.js",
23
23
  "types": "lib/index.d.ts",
24
24
  "scripts": {
25
- "build": "cross-env rimraf lib && cross-env tsc --version && cross-env tsc",
25
+ "build": "rslib build",
26
+ "dev": "rslib build -w",
26
27
  "lint": "echo lint",
27
28
  "test": "pnpm build && pnpm test:unit && pnpm test:e2e",
28
29
  "test:unit": "cross-env jest --config=test/unit/jest.config.js",
29
30
  "test:e2e": "cd test/e2e && pnpm test",
30
31
  "test:e2e:setup": "cd test/e2e && pnpm run setup",
31
32
  "precommit": "pnpm build && pnpm test:unit",
32
- "prepare": "husky install && pnpm build",
33
+ "prepare": "husky && pnpm build",
33
34
  "bump": "npx bumpp"
34
35
  },
35
36
  "dependencies": {
36
37
  "@babel/code-frame": "^7.27.1",
37
- "@rspack/lite-tapable": "^1.0.1",
38
+ "@rspack/lite-tapable": "^1.1.0",
38
39
  "chokidar": "^3.6.0",
39
40
  "is-glob": "^4.0.3",
40
- "memfs": "^4.50.0",
41
+ "memfs": "^4.51.1",
41
42
  "minimatch": "^9.0.5",
42
43
  "picocolors": "^1.1.1"
43
44
  },
@@ -52,28 +53,28 @@
52
53
  },
53
54
  "devDependencies": {
54
55
  "@jest/console": "^27.5.1",
55
- "@rspack/core": "^1.6.0",
56
+ "@rslib/core": "^0.18.2",
57
+ "@rspack/core": "^1.6.5",
56
58
  "@types/babel__code-frame": "^7.0.6",
57
59
  "@types/is-glob": "^4.0.4",
58
60
  "@types/jest": "^27.5.2",
59
61
  "@types/mock-fs": "^4.13.4",
60
62
  "@types/node": "^16.18.126",
61
63
  "cross-env": "^10.1.0",
62
- "husky": "^7.0.4",
64
+ "husky": "^9.1.7",
63
65
  "jest": "^27.5.1",
64
66
  "jest-circus": "^27.5.1",
65
67
  "jest-environment-node": "^27.5.1",
66
68
  "jest-runner": "^27.5.1",
67
69
  "mock-fs": "^5.5.0",
68
- "prettier": "^2.8.8",
69
- "rimraf": "^3.0.2",
70
+ "prettier": "^3.7.3",
70
71
  "strip-ansi": "^6.0.1",
71
72
  "ts-jest": "^27.1.5",
72
- "typescript": "^4.9.5"
73
+ "typescript": "^5.9.3"
73
74
  },
74
75
  "publishConfig": {
75
76
  "access": "public",
76
77
  "registry": "https://registry.npmjs.org/"
77
78
  },
78
- "packageManager": "pnpm@9.15.9"
79
+ "packageManager": "pnpm@10.24.0"
79
80
  }
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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}`));
7
- const compilerFilesChangeMap = new WeakMap();
8
- function getFilesChange(compiler) {
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
- };
17
- }
18
- exports.getFilesChange = getFilesChange;
19
- function consumeFilesChange(compiler) {
20
- const change = getFilesChange(compiler);
21
- clearFilesChange(compiler);
22
- return change;
23
- }
24
- exports.consumeFilesChange = consumeFilesChange;
25
- function updateFilesChange(compiler, change) {
26
- compilerFilesChangeMap.set(compiler, aggregateFilesChanges([getFilesChange(compiler), change]));
27
- }
28
- exports.updateFilesChange = updateFilesChange;
29
- function clearFilesChange(compiler) {
30
- compilerFilesChangeMap.delete(compiler);
31
- }
32
- exports.clearFilesChange = clearFilesChange;
33
- /**
34
- * Computes aggregated files change based on the subsequent files changes.
35
- *
36
- * @param changes List of subsequent files changes
37
- * @returns Files change that represents all subsequent changes as a one event
38
- */
39
- function aggregateFilesChanges(changes) {
40
- const changedFilesSet = new Set();
41
- const deletedFilesSet = new Set();
42
- for (const { changedFiles = [], deletedFiles = [] } of changes) {
43
- for (const changedFile of changedFiles) {
44
- changedFilesSet.add(changedFile);
45
- deletedFilesSet.delete(changedFile);
46
- }
47
- for (const deletedFile of deletedFiles) {
48
- changedFilesSet.delete(deletedFile);
49
- deletedFilesSet.add(deletedFile);
50
- }
51
- }
52
- return {
53
- changedFiles: Array.from(changedFilesSet),
54
- deletedFiles: Array.from(deletedFilesSet),
55
- };
56
- }
57
- exports.aggregateFilesChanges = aggregateFilesChanges;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,13 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createBasicFormatter = void 0;
7
- const picocolors_1 = __importDefault(require("picocolors"));
8
- function createBasicFormatter() {
9
- return function basicFormatter(issue) {
10
- return picocolors_1.default.gray(issue.code + ': ') + issue.message;
11
- };
12
- }
13
- exports.createBasicFormatter = createBasicFormatter;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createCodeFrameFormatter = void 0;
7
- const os_1 = __importDefault(require("os"));
8
- const code_frame_1 = require("@babel/code-frame");
9
- const node_fs_1 = __importDefault(require("node:fs"));
10
- const basic_formatter_1 = require("./basic-formatter");
11
- function createCodeFrameFormatter(options) {
12
- const basicFormatter = (0, basic_formatter_1.createBasicFormatter)();
13
- return function codeFrameFormatter(issue) {
14
- const source = issue.file && node_fs_1.default.existsSync(issue.file) && node_fs_1.default.readFileSync(issue.file, 'utf-8');
15
- let frame = '';
16
- if (source && issue.location) {
17
- frame = (0, code_frame_1.codeFrameColumns)(source, issue.location, {
18
- highlightCode: true,
19
- ...(options || {}),
20
- })
21
- .split('\n')
22
- .map((line) => ' ' + line)
23
- .join(os_1.default.EOL);
24
- }
25
- const lines = [basicFormatter(issue)];
26
- if (frame) {
27
- lines.push(frame);
28
- }
29
- return lines.join(os_1.default.EOL);
30
- };
31
- }
32
- exports.createCodeFrameFormatter = createCodeFrameFormatter;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createFormatterConfig = void 0;
4
- const basic_formatter_1 = require("./basic-formatter");
5
- const code_frame_formatter_1 = require("./code-frame-formatter");
6
- function createFormatterConfig(options) {
7
- if (typeof options === 'function') {
8
- return {
9
- format: options,
10
- pathType: 'relative',
11
- };
12
- }
13
- const type = options
14
- ? typeof options === 'object'
15
- ? options.type || 'codeframe'
16
- : options
17
- : 'codeframe';
18
- const pathType = options && typeof options === 'object' ? options.pathType || 'relative' : 'relative';
19
- if (!type || type === 'basic') {
20
- return {
21
- format: (0, basic_formatter_1.createBasicFormatter)(),
22
- pathType,
23
- };
24
- }
25
- if (type === 'codeframe') {
26
- const config = options && typeof options === 'object'
27
- ? options.options || {}
28
- : {};
29
- return {
30
- format: (0, code_frame_formatter_1.createCodeFrameFormatter)(config),
31
- pathType,
32
- };
33
- }
34
- throw new Error(`Unknown "${type}" formatter. Available types are: "basic", "codeframe" or a custom function.`);
35
- }
36
- exports.createFormatterConfig = createFormatterConfig;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,22 +0,0 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./formatter"), exports);
18
- __exportStar(require("./basic-formatter"), exports);
19
- __exportStar(require("./code-frame-formatter"), exports);
20
- __exportStar(require("./webpack-formatter"), exports);
21
- __exportStar(require("./formatter-options"), exports);
22
- __exportStar(require("./formatter-config"), exports);
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.statsFormatter = void 0;
7
- const picocolors_1 = __importDefault(require("picocolors"));
8
- // mimics Rspack's stats summary formatter
9
- function statsFormatter(issues, stats) {
10
- const errorsNumber = issues.filter((issue) => issue.severity === 'error').length;
11
- const warningsNumber = issues.filter((issue) => issue.severity === 'warning').length;
12
- const errorsFormatted = errorsNumber
13
- ? picocolors_1.default.bold(picocolors_1.default.red(`${errorsNumber} ${errorsNumber === 1 ? 'error' : 'errors'}`))
14
- : '';
15
- const warningsFormatted = warningsNumber
16
- ? picocolors_1.default.bold(picocolors_1.default.yellow(`${warningsNumber} ${warningsNumber === 1 ? 'warning' : 'warnings'}`))
17
- : '';
18
- const timeFormatted = stats.startTime ? Math.round(Date.now() - stats.startTime) : 0;
19
- if (!errorsFormatted && !warningsFormatted) {
20
- return picocolors_1.default.green(`[type-check] no errors found in ${timeFormatted} ms`);
21
- }
22
- return [
23
- '[type-check] found ',
24
- errorsFormatted,
25
- errorsFormatted && warningsFormatted ? ' and ' : '',
26
- warningsFormatted,
27
- timeFormatted ? ` in ${timeFormatted} ms` : '',
28
- ].join('');
29
- }
30
- exports.statsFormatter = statsFormatter;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- // Base on the type definitions for @babel/code-frame 7.0
3
- // Project: https://github.com/babel/babel/tree/main/packages/babel-code-frame, https://babeljs.io
4
- // Definitions by: Mohsen Azimi <https://github.com/mohsen1>
5
- // Forbes Lindesay <https://github.com/ForbesLindesay>
6
- // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
7
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,32 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createWebpackFormatter = void 0;
7
- const os_1 = __importDefault(require("os"));
8
- const path_1 = __importDefault(require("path"));
9
- const picocolors_1 = __importDefault(require("picocolors"));
10
- const issue_1 = require("../issue");
11
- const forward_slash_1 = require("../utils/path/forward-slash");
12
- const relative_to_context_1 = require("../utils/path/relative-to-context");
13
- function createWebpackFormatter(formatter, pathType) {
14
- // mimics webpack error formatter
15
- return function webpackFormatter(issue) {
16
- const color = issue.severity === 'warning' ? picocolors_1.default.yellow : picocolors_1.default.red;
17
- const severity = issue.severity.toUpperCase();
18
- if (issue.file) {
19
- let location = picocolors_1.default.bold(pathType === 'absolute'
20
- ? (0, forward_slash_1.forwardSlash)(path_1.default.resolve(issue.file))
21
- : (0, relative_to_context_1.relativeToContext)(issue.file, process.cwd()));
22
- if (issue.location) {
23
- location += `:${picocolors_1.default.bold(picocolors_1.default.green((0, issue_1.formatIssueLocation)(issue.location)))}`;
24
- }
25
- return [`${picocolors_1.default.bold(color(severity))} in ${location}`, formatter(issue), ''].join(os_1.default.EOL);
26
- }
27
- else {
28
- return [`${picocolors_1.default.bold(color(severity))} in ` + formatter(issue), ''].join(os_1.default.EOL);
29
- }
30
- };
31
- }
32
- exports.createWebpackFormatter = createWebpackFormatter;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.interceptDoneToGetDevServerTap = void 0;
4
- const infrastructure_logger_1 = require("../infrastructure-logger");
5
- function interceptDoneToGetDevServerTap(compiler, config, state) {
6
- const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
7
- // inspired by https://github.com/ypresto/fork-ts-checker-async-overlay-webpack-plugin
8
- compiler.hooks.done.intercept({
9
- register: (tap) => {
10
- if (['webpack-dev-server', 'rsbuild-dev-server'].includes(tap.name) && tap.type === 'sync' && config.devServer) {
11
- debug('Intercepting dev-server tap.');
12
- state.DevServerDoneTap = tap;
13
- }
14
- return tap;
15
- },
16
- });
17
- }
18
- exports.interceptDoneToGetDevServerTap = interceptDoneToGetDevServerTap;
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tapAfterCompileToAddDependencies = void 0;
4
- const infrastructure_logger_1 = require("../infrastructure-logger");
5
- const node_path_1 = require("node:path");
6
- const addTrailingSep = (dir) => (dir.endsWith(node_path_1.sep) ? dir : dir + node_path_1.sep);
7
- const isStrictSubdir = (parent, child) => {
8
- const parentDir = addTrailingSep(parent);
9
- const childDir = addTrailingSep(child);
10
- return parentDir !== childDir && childDir.startsWith(parentDir);
11
- };
12
- /**
13
- * Excludes the Rspack output directory from watched dependencies
14
- * when the entire project is being watched.
15
- *
16
- * If `writeToDisk` is enabled and the build output path is not ignored,
17
- * emitted files in `output.path` may leading to an infinite rebuild loop.
18
- **/
19
- function excludeOutputPath(dependencies, compiler) {
20
- const isContextIncluded = dependencies.dirs.includes(compiler.context);
21
- if (!isContextIncluded) {
22
- return dependencies;
23
- }
24
- const outputPath = typeof compiler.options.output?.path === 'string'
25
- ? compiler.options.output.path
26
- : compiler.outputPath;
27
- if (!outputPath ||
28
- // If output path is not a subdir of context, no need to exclude it
29
- !isStrictSubdir(compiler.context, outputPath) ||
30
- // If output path is explicitly included in dirs, should not exclude it
31
- dependencies.dirs.includes(outputPath)) {
32
- return dependencies;
33
- }
34
- const excluded = new Set(dependencies.excluded);
35
- excluded.add(outputPath);
36
- return {
37
- ...dependencies,
38
- excluded: Array.from(excluded),
39
- };
40
- }
41
- function tapAfterCompileToAddDependencies(compiler, config, state) {
42
- const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
43
- compiler.hooks.afterCompile.tapPromise('TsCheckerRspackPlugin', async (compilation) => {
44
- if (compilation.compiler !== compiler) {
45
- // run only for the compiler that the plugin was registered for
46
- return;
47
- }
48
- const dependencies = await state.dependenciesPromise;
49
- debug(`Got dependencies from the getDependenciesWorker.`, dependencies);
50
- if (dependencies) {
51
- const sanitizedDependencies = excludeOutputPath(dependencies, compiler);
52
- state.lastDependencies = sanitizedDependencies;
53
- sanitizedDependencies.files.forEach((file) => {
54
- compilation.fileDependencies.add(file);
55
- });
56
- }
57
- });
58
- }
59
- exports.tapAfterCompileToAddDependencies = tapAfterCompileToAddDependencies;
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tapAfterCompileToGetIssues = void 0;
4
- const infrastructure_logger_1 = require("../infrastructure-logger");
5
- const issue_webpack_error_1 = require("../issue/issue-webpack-error");
6
- const plugin_hooks_1 = require("../plugin-hooks");
7
- function tapAfterCompileToGetIssues(compiler, config, state) {
8
- const hooks = (0, plugin_hooks_1.getPluginHooks)(compiler);
9
- const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
10
- compiler.hooks.afterCompile.tapPromise('TsCheckerRspackPlugin', async (compilation) => {
11
- if (compilation.compiler !== compiler) {
12
- // run only for the compiler that the plugin was registered for
13
- return;
14
- }
15
- let issues = [];
16
- try {
17
- issues = await state.issuesPromise;
18
- }
19
- catch (error) {
20
- hooks.error.call(error, compilation);
21
- return;
22
- }
23
- debug('Got issues from getIssuesWorker.', issues?.length);
24
- if (!issues) {
25
- // some error has been thrown or it was canceled
26
- return;
27
- }
28
- // filter list of issues by provided issue predicate
29
- issues = issues.filter(config.issue.predicate);
30
- // modify list of issues in the plugin hooks
31
- issues = hooks.issues.call(issues, compilation);
32
- issues.forEach((issue) => {
33
- const error = new issue_webpack_error_1.IssueWebpackError(config.formatter.format(issue), config.formatter.pathType, issue);
34
- if (issue.severity === 'warning') {
35
- compilation.warnings.push(error);
36
- }
37
- else {
38
- compilation.errors.push(error);
39
- }
40
- });
41
- });
42
- }
43
- exports.tapAfterCompileToGetIssues = tapAfterCompileToGetIssues;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tapAfterEnvironmentToPatchWatching = void 0;
4
- const infrastructure_logger_1 = require("../infrastructure-logger");
5
- const inclusive_node_watch_file_system_1 = require("../watch/inclusive-node-watch-file-system");
6
- function tapAfterEnvironmentToPatchWatching(compiler, state) {
7
- const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
8
- compiler.hooks.afterEnvironment.tap('TsCheckerRspackPlugin', () => {
9
- const watchFileSystem = compiler.watchFileSystem;
10
- if (watchFileSystem) {
11
- debug("Overwriting webpack's watch file system.");
12
- // wrap original watch file system
13
- compiler.watchFileSystem = new inclusive_node_watch_file_system_1.InclusiveNodeWatchFileSystem(
14
- // we use some internals here
15
- watchFileSystem, compiler, state);
16
- }
17
- else {
18
- debug('No watch file system found - plugin may not work correctly.');
19
- }
20
- });
21
- }
22
- exports.tapAfterEnvironmentToPatchWatching = tapAfterEnvironmentToPatchWatching;