ts-checker-rspack-plugin 1.0.0-beta.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.
- package/LICENSE +21 -0
- package/README.md +216 -0
- package/lib/files-change.d.ts +17 -0
- package/lib/files-change.js +57 -0
- package/lib/files-match.d.ts +7 -0
- package/lib/files-match.js +2 -0
- package/lib/formatter/basic-formatter.d.ts +3 -0
- package/lib/formatter/basic-formatter.js +13 -0
- package/lib/formatter/code-frame-formatter.d.ts +4 -0
- package/lib/formatter/code-frame-formatter.js +29 -0
- package/lib/formatter/formatter-config.d.ts +8 -0
- package/lib/formatter/formatter-config.js +36 -0
- package/lib/formatter/formatter-options.d.ts +14 -0
- package/lib/formatter/formatter-options.js +2 -0
- package/lib/formatter/formatter.d.ts +4 -0
- package/lib/formatter/formatter.js +2 -0
- package/lib/formatter/index.d.ts +6 -0
- package/lib/formatter/index.js +18 -0
- package/lib/formatter/stats-formatter.d.ts +3 -0
- package/lib/formatter/stats-formatter.js +28 -0
- package/lib/formatter/types/babel__code-frame.d.ts +21 -0
- package/lib/formatter/types/babel__code-frame.js +7 -0
- package/lib/formatter/webpack-formatter.d.ts +3 -0
- package/lib/formatter/webpack-formatter.js +32 -0
- package/lib/hooks/intercept-done-to-get-dev-server-tap.d.ts +5 -0
- package/lib/hooks/intercept-done-to-get-dev-server-tap.js +18 -0
- package/lib/hooks/tap-after-compile-to-add-dependencies.d.ts +5 -0
- package/lib/hooks/tap-after-compile-to-add-dependencies.js +31 -0
- package/lib/hooks/tap-after-compile-to-get-issues.d.ts +5 -0
- package/lib/hooks/tap-after-compile-to-get-issues.js +52 -0
- package/lib/hooks/tap-after-environment-to-patch-watching.d.ts +4 -0
- package/lib/hooks/tap-after-environment-to-patch-watching.js +22 -0
- package/lib/hooks/tap-done-to-async-get-issues.d.ts +5 -0
- package/lib/hooks/tap-done-to-async-get-issues.js +86 -0
- package/lib/hooks/tap-error-to-log-message.d.ts +4 -0
- package/lib/hooks/tap-error-to-log-message.js +32 -0
- package/lib/hooks/tap-start-to-run-workers.d.ts +8 -0
- package/lib/hooks/tap-start-to-run-workers.js +132 -0
- package/lib/hooks/tap-stop-to-terminate-workers.d.ts +5 -0
- package/lib/hooks/tap-stop-to-terminate-workers.js +26 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +5 -0
- package/lib/infrastructure-logger.d.ts +9 -0
- package/lib/infrastructure-logger.js +14 -0
- package/lib/issue/index.d.ts +3 -0
- package/lib/issue/index.js +15 -0
- package/lib/issue/issue-config.d.ts +8 -0
- package/lib/issue/issue-config.js +29 -0
- package/lib/issue/issue-location.d.ts +8 -0
- package/lib/issue/issue-location.js +22 -0
- package/lib/issue/issue-match.d.ts +5 -0
- package/lib/issue/issue-match.js +20 -0
- package/lib/issue/issue-options.d.ts +8 -0
- package/lib/issue/issue-options.js +2 -0
- package/lib/issue/issue-position.d.ts +6 -0
- package/lib/issue/issue-position.js +16 -0
- package/lib/issue/issue-predicate.d.ts +5 -0
- package/lib/issue/issue-predicate.js +11 -0
- package/lib/issue/issue-severity.d.ts +4 -0
- package/lib/issue/issue-severity.js +12 -0
- package/lib/issue/issue-webpack-error.d.ts +10 -0
- package/lib/issue/issue-webpack-error.js +51 -0
- package/lib/issue/issue.d.ts +12 -0
- package/lib/issue/issue.js +41 -0
- package/lib/logger.d.ts +5 -0
- package/lib/logger.js +2 -0
- package/lib/plugin-config.d.ts +16 -0
- package/lib/plugin-config.js +26 -0
- package/lib/plugin-hooks.d.ts +20 -0
- package/lib/plugin-hooks.js +45 -0
- package/lib/plugin-options.d.ts +13 -0
- package/lib/plugin-options.js +2 -0
- package/lib/plugin-options.json +197 -0
- package/lib/plugin-pools.d.ts +4 -0
- package/lib/plugin-pools.js +28 -0
- package/lib/plugin-state.d.ts +18 -0
- package/lib/plugin-state.js +17 -0
- package/lib/plugin.d.ts +29 -0
- package/lib/plugin.js +79 -0
- package/lib/rpc/expose-rpc.d.ts +1 -0
- package/lib/rpc/expose-rpc.js +78 -0
- package/lib/rpc/index.d.ts +5 -0
- package/lib/rpc/index.js +12 -0
- package/lib/rpc/rpc-error.d.ts +6 -0
- package/lib/rpc/rpc-error.js +12 -0
- package/lib/rpc/rpc-worker.d.ts +13 -0
- package/lib/rpc/rpc-worker.js +79 -0
- package/lib/rpc/types.d.ts +19 -0
- package/lib/rpc/types.js +2 -0
- package/lib/rpc/wrap-rpc.d.ts +4 -0
- package/lib/rpc/wrap-rpc.js +79 -0
- package/lib/typescript/type-script-config-overwrite.d.ts +12 -0
- package/lib/typescript/type-script-config-overwrite.js +2 -0
- package/lib/typescript/type-script-diagnostics-options.d.ts +7 -0
- package/lib/typescript/type-script-diagnostics-options.js +2 -0
- package/lib/typescript/type-script-support.d.ts +3 -0
- package/lib/typescript/type-script-support.js +63 -0
- package/lib/typescript/type-script-worker-config.d.ts +18 -0
- package/lib/typescript/type-script-worker-config.js +18 -0
- package/lib/typescript/type-script-worker-options.d.ts +14 -0
- package/lib/typescript/type-script-worker-options.js +2 -0
- package/lib/typescript/worker/get-dependencies-worker.d.ts +5 -0
- package/lib/typescript/worker/get-dependencies-worker.js +15 -0
- package/lib/typescript/worker/get-issues-worker.d.ts +5 -0
- package/lib/typescript/worker/get-issues-worker.js +80 -0
- package/lib/typescript/worker/lib/artifacts.d.ts +4 -0
- package/lib/typescript/worker/lib/artifacts.js +90 -0
- package/lib/typescript/worker/lib/config.d.ts +15 -0
- package/lib/typescript/worker/lib/config.js +131 -0
- package/lib/typescript/worker/lib/dependencies.d.ts +3 -0
- package/lib/typescript/worker/lib/dependencies.js +81 -0
- package/lib/typescript/worker/lib/diagnostics.d.ts +7 -0
- package/lib/typescript/worker/lib/diagnostics.js +108 -0
- package/lib/typescript/worker/lib/emit.d.ts +2 -0
- package/lib/typescript/worker/lib/emit.js +13 -0
- package/lib/typescript/worker/lib/file-system/file-system.d.ts +18 -0
- package/lib/typescript/worker/lib/file-system/file-system.js +2 -0
- package/lib/typescript/worker/lib/file-system/mem-file-system.d.ts +5 -0
- package/lib/typescript/worker/lib/file-system/mem-file-system.js +78 -0
- package/lib/typescript/worker/lib/file-system/passive-file-system.d.ts +5 -0
- package/lib/typescript/worker/lib/file-system/passive-file-system.js +65 -0
- package/lib/typescript/worker/lib/file-system/real-file-system.d.ts +5 -0
- package/lib/typescript/worker/lib/file-system/real-file-system.js +187 -0
- package/lib/typescript/worker/lib/host/compiler-host.d.ts +2 -0
- package/lib/typescript/worker/lib/host/compiler-host.js +10 -0
- package/lib/typescript/worker/lib/host/watch-compiler-host.d.ts +2 -0
- package/lib/typescript/worker/lib/host/watch-compiler-host.js +20 -0
- package/lib/typescript/worker/lib/host/watch-solution-builder-host.d.ts +2 -0
- package/lib/typescript/worker/lib/host/watch-solution-builder-host.js +47 -0
- package/lib/typescript/worker/lib/performance.d.ts +3 -0
- package/lib/typescript/worker/lib/performance.js +32 -0
- package/lib/typescript/worker/lib/program/program.d.ts +2 -0
- package/lib/typescript/worker/lib/program/program.js +37 -0
- package/lib/typescript/worker/lib/program/solution-builder.d.ts +2 -0
- package/lib/typescript/worker/lib/program/solution-builder.js +39 -0
- package/lib/typescript/worker/lib/program/watch-program.d.ts +3 -0
- package/lib/typescript/worker/lib/program/watch-program.js +51 -0
- package/lib/typescript/worker/lib/system.d.ts +19 -0
- package/lib/typescript/worker/lib/system.js +232 -0
- package/lib/typescript/worker/lib/tracing.d.ts +4 -0
- package/lib/typescript/worker/lib/tracing.js +29 -0
- package/lib/typescript/worker/lib/tsbuildinfo.d.ts +4 -0
- package/lib/typescript/worker/lib/tsbuildinfo.js +92 -0
- package/lib/typescript/worker/lib/typescript.d.ts +2 -0
- package/lib/typescript/worker/lib/typescript.js +6 -0
- package/lib/typescript/worker/lib/worker-config.d.ts +2 -0
- package/lib/typescript/worker/lib/worker-config.js +5 -0
- package/lib/utils/async/abort-error.d.ts +6 -0
- package/lib/utils/async/abort-error.js +15 -0
- package/lib/utils/async/controlled-promise.d.ts +6 -0
- package/lib/utils/async/controlled-promise.js +17 -0
- package/lib/utils/async/is-pending.d.ts +2 -0
- package/lib/utils/async/is-pending.js +10 -0
- package/lib/utils/async/pool.d.ts +10 -0
- package/lib/utils/async/pool.js +47 -0
- package/lib/utils/async/wait.d.ts +2 -0
- package/lib/utils/async/wait.js +7 -0
- package/lib/utils/path/forward-slash.d.ts +6 -0
- package/lib/utils/path/forward-slash.js +15 -0
- package/lib/utils/path/is-inside-another-path.d.ts +2 -0
- package/lib/utils/path/is-inside-another-path.js +22 -0
- package/lib/utils/path/relative-to-context.d.ts +2 -0
- package/lib/utils/path/relative-to-context.js +16 -0
- package/lib/watch/inclusive-node-watch-file-system.d.ts +15 -0
- package/lib/watch/inclusive-node-watch-file-system.js +166 -0
- package/lib/watch/watch-file-system.d.ts +16 -0
- package/lib/watch/watch-file-system.js +2 -0
- package/package.json +88 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.composeIssuePredicates = exports.createTrivialIssuePredicate = void 0;
|
|
4
|
+
function createTrivialIssuePredicate(result) {
|
|
5
|
+
return () => result;
|
|
6
|
+
}
|
|
7
|
+
exports.createTrivialIssuePredicate = createTrivialIssuePredicate;
|
|
8
|
+
function composeIssuePredicates(predicates) {
|
|
9
|
+
return (issue) => predicates.some((predicate) => predicate(issue));
|
|
10
|
+
}
|
|
11
|
+
exports.composeIssuePredicates = composeIssuePredicates;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare 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 };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compareIssueSeverities = exports.isIssueSeverity = void 0;
|
|
4
|
+
function isIssueSeverity(value) {
|
|
5
|
+
return ['error', 'warning'].includes(value);
|
|
6
|
+
}
|
|
7
|
+
exports.isIssueSeverity = isIssueSeverity;
|
|
8
|
+
function compareIssueSeverities(severityA, severityB) {
|
|
9
|
+
const [priorityA, priorityB] = [severityA, severityB].map((severity) => ['warning' /* 0 */, 'error' /* 1 */].indexOf(severity));
|
|
10
|
+
return Math.sign(priorityB - priorityA);
|
|
11
|
+
}
|
|
12
|
+
exports.compareIssueSeverities = compareIssueSeverities;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as rspack from '@rspack/core';
|
|
2
|
+
import type { FormatterPathType } from '../formatter';
|
|
3
|
+
import type { Issue } from './issue';
|
|
4
|
+
declare class IssueWebpackError extends rspack.WebpackError {
|
|
5
|
+
readonly issue: Issue;
|
|
6
|
+
readonly hideStack = true;
|
|
7
|
+
file?: string;
|
|
8
|
+
constructor(message: string, pathType: FormatterPathType, issue: Issue);
|
|
9
|
+
}
|
|
10
|
+
export { IssueWebpackError };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.IssueWebpackError = void 0;
|
|
26
|
+
const path_1 = __importDefault(require("path"));
|
|
27
|
+
const rspack = __importStar(require("@rspack/core"));
|
|
28
|
+
const forward_slash_1 = require("../utils/path/forward-slash");
|
|
29
|
+
const relative_to_context_1 = require("../utils/path/relative-to-context");
|
|
30
|
+
const issue_location_1 = require("./issue-location");
|
|
31
|
+
class IssueWebpackError extends rspack.WebpackError {
|
|
32
|
+
constructor(message, pathType, issue) {
|
|
33
|
+
super(message);
|
|
34
|
+
this.issue = issue;
|
|
35
|
+
this.hideStack = true;
|
|
36
|
+
// to display issue location using `loc` property, Rspack requires `error.module` which
|
|
37
|
+
// should be a NormalModule instance.
|
|
38
|
+
// to avoid such a dependency, we do a workaround - error.file will contain formatted location instead
|
|
39
|
+
if (issue.file) {
|
|
40
|
+
this.file =
|
|
41
|
+
pathType === 'absolute'
|
|
42
|
+
? (0, forward_slash_1.forwardSlash)(path_1.default.resolve(issue.file))
|
|
43
|
+
: (0, relative_to_context_1.relativeToContext)(issue.file, process.cwd());
|
|
44
|
+
if (issue.location) {
|
|
45
|
+
this.file += `:${(0, issue_location_1.formatIssueLocation)(issue.location)}`;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
Error.captureStackTrace(this, this.constructor);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.IssueWebpackError = IssueWebpackError;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IssueLocation } from './issue-location';
|
|
2
|
+
import type { IssueSeverity } from './issue-severity';
|
|
3
|
+
interface Issue {
|
|
4
|
+
severity: IssueSeverity;
|
|
5
|
+
code: string;
|
|
6
|
+
message: string;
|
|
7
|
+
file?: string;
|
|
8
|
+
location?: IssueLocation;
|
|
9
|
+
}
|
|
10
|
+
declare function isIssue(value: unknown): value is Issue;
|
|
11
|
+
declare function deduplicateAndSortIssues(issues: Issue[]): Issue[];
|
|
12
|
+
export { Issue, isIssue, deduplicateAndSortIssues };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deduplicateAndSortIssues = exports.isIssue = void 0;
|
|
4
|
+
const issue_location_1 = require("./issue-location");
|
|
5
|
+
const issue_severity_1 = require("./issue-severity");
|
|
6
|
+
function isIssue(value) {
|
|
7
|
+
return (!!value &&
|
|
8
|
+
typeof value === 'object' &&
|
|
9
|
+
(0, issue_severity_1.isIssueSeverity)(value.severity) &&
|
|
10
|
+
!!value.code &&
|
|
11
|
+
!!value.message);
|
|
12
|
+
}
|
|
13
|
+
exports.isIssue = isIssue;
|
|
14
|
+
function compareStrings(stringA, stringB) {
|
|
15
|
+
if (stringA === stringB) {
|
|
16
|
+
return 0;
|
|
17
|
+
}
|
|
18
|
+
if (stringA === undefined || stringA === null) {
|
|
19
|
+
return -1;
|
|
20
|
+
}
|
|
21
|
+
if (stringB === undefined || stringB === null) {
|
|
22
|
+
return 1;
|
|
23
|
+
}
|
|
24
|
+
return stringA.toString().localeCompare(stringB.toString());
|
|
25
|
+
}
|
|
26
|
+
function compareIssues(issueA, issueB) {
|
|
27
|
+
return ((0, issue_severity_1.compareIssueSeverities)(issueA.severity, issueB.severity) ||
|
|
28
|
+
compareStrings(issueA.file, issueB.file) ||
|
|
29
|
+
(0, issue_location_1.compareIssueLocations)(issueA.location, issueB.location) ||
|
|
30
|
+
compareStrings(issueA.code, issueB.code) ||
|
|
31
|
+
compareStrings(issueA.message, issueB.message) ||
|
|
32
|
+
0 /* EqualTo */);
|
|
33
|
+
}
|
|
34
|
+
function equalsIssues(issueA, issueB) {
|
|
35
|
+
return compareIssues(issueA, issueB) === 0;
|
|
36
|
+
}
|
|
37
|
+
function deduplicateAndSortIssues(issues) {
|
|
38
|
+
const sortedIssues = issues.filter(isIssue).sort(compareIssues);
|
|
39
|
+
return sortedIssues.filter((issue, index) => index === 0 || !equalsIssues(issue, sortedIssues[index - 1]));
|
|
40
|
+
}
|
|
41
|
+
exports.deduplicateAndSortIssues = deduplicateAndSortIssues;
|
package/lib/logger.d.ts
ADDED
package/lib/logger.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type * as rspack from '@rspack/core';
|
|
2
|
+
import type { FormatterConfig } from './formatter';
|
|
3
|
+
import type { IssueConfig } from './issue/issue-config';
|
|
4
|
+
import type { Logger } from './logger';
|
|
5
|
+
import type { TsCheckerRspackPluginOptions } from './plugin-options';
|
|
6
|
+
import type { TypeScriptWorkerConfig } from './typescript/type-script-worker-config';
|
|
7
|
+
interface TsCheckerRspackPluginConfig {
|
|
8
|
+
async: boolean;
|
|
9
|
+
typescript: TypeScriptWorkerConfig;
|
|
10
|
+
issue: IssueConfig;
|
|
11
|
+
formatter: FormatterConfig;
|
|
12
|
+
logger: Logger;
|
|
13
|
+
devServer: boolean;
|
|
14
|
+
}
|
|
15
|
+
declare function createPluginConfig(compiler: rspack.Compiler, options?: TsCheckerRspackPluginOptions): TsCheckerRspackPluginConfig;
|
|
16
|
+
export { TsCheckerRspackPluginConfig, createPluginConfig };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPluginConfig = void 0;
|
|
4
|
+
const formatter_1 = require("./formatter");
|
|
5
|
+
const infrastructure_logger_1 = require("./infrastructure-logger");
|
|
6
|
+
const issue_config_1 = require("./issue/issue-config");
|
|
7
|
+
const type_script_worker_config_1 = require("./typescript/type-script-worker-config");
|
|
8
|
+
function createPluginConfig(compiler, options = {}) {
|
|
9
|
+
return {
|
|
10
|
+
async: options.async === undefined ? compiler.options.mode === 'development' : options.async,
|
|
11
|
+
typescript: (0, type_script_worker_config_1.createTypeScriptWorkerConfig)(compiler, options.typescript),
|
|
12
|
+
issue: (0, issue_config_1.createIssueConfig)(compiler, options.issue),
|
|
13
|
+
formatter: (0, formatter_1.createFormatterConfig)(options.formatter),
|
|
14
|
+
logger: options.logger === 'webpack-infrastructure'
|
|
15
|
+
? (() => {
|
|
16
|
+
const { info, error } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
|
|
17
|
+
return {
|
|
18
|
+
log: info,
|
|
19
|
+
error,
|
|
20
|
+
};
|
|
21
|
+
})()
|
|
22
|
+
: options.logger || console,
|
|
23
|
+
devServer: options.devServer !== false,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.createPluginConfig = createPluginConfig;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SyncHook, SyncWaterfallHook, AsyncSeriesWaterfallHook } from 'tapable';
|
|
2
|
+
import type * as rspack from '@rspack/core';
|
|
3
|
+
import type { FilesChange } from './files-change';
|
|
4
|
+
import type { Issue } from './issue';
|
|
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>;
|
|
10
|
+
issues: SyncWaterfallHook<[Issue[], rspack.Compilation | undefined], void>;
|
|
11
|
+
};
|
|
12
|
+
declare type TsCheckerRspackPluginHooks = ReturnType<typeof createPluginHooks>;
|
|
13
|
+
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>;
|
|
18
|
+
issues: SyncWaterfallHook<[Issue[], rspack.Compilation | undefined], void>;
|
|
19
|
+
};
|
|
20
|
+
export { getPluginHooks, TsCheckerRspackPluginHooks };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPluginHooks = void 0;
|
|
4
|
+
const tapable_1 = require("tapable");
|
|
5
|
+
const compilerHookMap = new WeakMap();
|
|
6
|
+
function createPluginHooks() {
|
|
7
|
+
return {
|
|
8
|
+
start: new tapable_1.AsyncSeriesWaterfallHook([
|
|
9
|
+
'change',
|
|
10
|
+
'compilation',
|
|
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([
|
|
16
|
+
'issues',
|
|
17
|
+
'compilation',
|
|
18
|
+
]),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function forwardPluginHooks(source, target) {
|
|
22
|
+
source.start.tapPromise('TsCheckerRspackPlugin', target.start.promise);
|
|
23
|
+
source.waiting.tap('TsCheckerRspackPlugin', target.waiting.call);
|
|
24
|
+
source.canceled.tap('TsCheckerRspackPlugin', target.canceled.call);
|
|
25
|
+
source.error.tap('TsCheckerRspackPlugin', target.error.call);
|
|
26
|
+
source.issues.tap('TsCheckerRspackPlugin', target.issues.call);
|
|
27
|
+
}
|
|
28
|
+
function getPluginHooks(compiler) {
|
|
29
|
+
let hooks = compilerHookMap.get(compiler);
|
|
30
|
+
if (hooks === undefined) {
|
|
31
|
+
hooks = createPluginHooks();
|
|
32
|
+
compilerHookMap.set(compiler, hooks);
|
|
33
|
+
// proxy hooks for multi-compiler
|
|
34
|
+
if ('compilers' in compiler) {
|
|
35
|
+
compiler.compilers.forEach((childCompiler) => {
|
|
36
|
+
const childHooks = getPluginHooks(childCompiler);
|
|
37
|
+
if (hooks) {
|
|
38
|
+
forwardPluginHooks(childHooks, hooks);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return hooks;
|
|
44
|
+
}
|
|
45
|
+
exports.getPluginHooks = getPluginHooks;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FormatterOptions } from './formatter';
|
|
2
|
+
import type { IssueOptions } from './issue/issue-options';
|
|
3
|
+
import type { Logger } from './logger';
|
|
4
|
+
import type { TypeScriptWorkerOptions } from './typescript/type-script-worker-options';
|
|
5
|
+
interface TsCheckerRspackPluginOptions {
|
|
6
|
+
async?: boolean;
|
|
7
|
+
typescript?: TypeScriptWorkerOptions;
|
|
8
|
+
formatter?: FormatterOptions;
|
|
9
|
+
issue?: IssueOptions;
|
|
10
|
+
logger?: Logger | 'webpack-infrastructure';
|
|
11
|
+
devServer?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export { TsCheckerRspackPluginOptions };
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"async": {
|
|
6
|
+
"type": "boolean",
|
|
7
|
+
"description": "When true, plugin will not block compilation to finish issues checking"
|
|
8
|
+
},
|
|
9
|
+
"typescript": {
|
|
10
|
+
"$ref": "#/definitions/TypeScriptOptions"
|
|
11
|
+
},
|
|
12
|
+
"formatter": {
|
|
13
|
+
"$ref": "#/definitions/FormatterOptions"
|
|
14
|
+
},
|
|
15
|
+
"issue": {
|
|
16
|
+
"$ref": "#/definitions/IssueOptions"
|
|
17
|
+
},
|
|
18
|
+
"logger": {
|
|
19
|
+
"$ref": "#/definitions/Logger"
|
|
20
|
+
},
|
|
21
|
+
"devServer": {
|
|
22
|
+
"type": "boolean",
|
|
23
|
+
"description": "Enable reporting to Webpack Dev Server."
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"additionalProperties": false,
|
|
27
|
+
"definitions": {
|
|
28
|
+
"Formatter": {
|
|
29
|
+
"instanceof": "Function"
|
|
30
|
+
},
|
|
31
|
+
"ComplexFormatterPreferences": {
|
|
32
|
+
"type": "object",
|
|
33
|
+
"properties": {
|
|
34
|
+
"type": {
|
|
35
|
+
"$ref": "#/definitions/FormatterType"
|
|
36
|
+
},
|
|
37
|
+
"pathType": {
|
|
38
|
+
"$ref": "#/definitions/FormatterPathType"
|
|
39
|
+
},
|
|
40
|
+
"options": {
|
|
41
|
+
"type": "object",
|
|
42
|
+
"additionalProperties": true
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"required": ["type"]
|
|
46
|
+
},
|
|
47
|
+
"FormatterType": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"enum": ["basic", "codeframe"]
|
|
50
|
+
},
|
|
51
|
+
"FormatterPathType": {
|
|
52
|
+
"type": "string",
|
|
53
|
+
"enum": ["relative", "absolute"]
|
|
54
|
+
},
|
|
55
|
+
"IssueMatch": {
|
|
56
|
+
"type": "object",
|
|
57
|
+
"properties": {
|
|
58
|
+
"severity": {
|
|
59
|
+
"type": "string",
|
|
60
|
+
"enum": ["error", "warning"]
|
|
61
|
+
},
|
|
62
|
+
"code": {
|
|
63
|
+
"type": "string"
|
|
64
|
+
},
|
|
65
|
+
"file": {
|
|
66
|
+
"type": "string"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"IssuePredicate": {
|
|
71
|
+
"instanceof": "Function"
|
|
72
|
+
},
|
|
73
|
+
"IssuePredicateOption": {
|
|
74
|
+
"oneOf": [
|
|
75
|
+
{
|
|
76
|
+
"$ref": "#/definitions/IssuePredicate"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"$ref": "#/definitions/IssueMatch"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"type": "array",
|
|
83
|
+
"items": {
|
|
84
|
+
"oneOf": [
|
|
85
|
+
{
|
|
86
|
+
"$ref": "#/definitions/IssuePredicate"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"$ref": "#/definitions/IssueMatch"
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
"Logger": {
|
|
97
|
+
"oneOf": [
|
|
98
|
+
{
|
|
99
|
+
"type": "object",
|
|
100
|
+
"properties": {
|
|
101
|
+
"error": {
|
|
102
|
+
"instanceof": "Function"
|
|
103
|
+
},
|
|
104
|
+
"log": {
|
|
105
|
+
"instanceof": "Function"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"type": "string",
|
|
111
|
+
"enum": ["webpack-infrastructure"]
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
},
|
|
115
|
+
"TypeScriptOptions": {
|
|
116
|
+
"type": "object",
|
|
117
|
+
"properties": {
|
|
118
|
+
"memoryLimit": {
|
|
119
|
+
"type": "number",
|
|
120
|
+
"description": "Memory limit for TypeScript reporter process."
|
|
121
|
+
},
|
|
122
|
+
"configFile": {
|
|
123
|
+
"type": "string",
|
|
124
|
+
"description": "Path to tsconfig.json. By default plugin uses context or process.cwd() to localize tsconfig.json file."
|
|
125
|
+
},
|
|
126
|
+
"context": {
|
|
127
|
+
"type": "string",
|
|
128
|
+
"description": "The base path for finding files specified in the tsconfig.json. Same as context option from the ts-loader."
|
|
129
|
+
},
|
|
130
|
+
"build": {
|
|
131
|
+
"type": "boolean",
|
|
132
|
+
"description": "The equivalent of the `--build` flag from the `tsc`."
|
|
133
|
+
},
|
|
134
|
+
"mode": {
|
|
135
|
+
"type": "string",
|
|
136
|
+
"enum": ["readonly", "write-tsbuildinfo", "write-dts", "write-references"],
|
|
137
|
+
"description": "`readonly` keeps all emitted files in memory, `write-tsbuildinfo` which writes only .tsbuildinfo files, `write-dts` writes .tsbuildinfo and type definition files, and `write-references` which writes both .tsbuildinfo and referenced projects output"
|
|
138
|
+
},
|
|
139
|
+
"compilerOptions": {
|
|
140
|
+
"type": "object",
|
|
141
|
+
"description": "Custom compilerOptions to be passed to the TypeScript compiler.",
|
|
142
|
+
"additionalProperties": true
|
|
143
|
+
},
|
|
144
|
+
"diagnosticOptions": {
|
|
145
|
+
"type": "object",
|
|
146
|
+
"description": "Types of diagnostics to be reported.",
|
|
147
|
+
"properties": {
|
|
148
|
+
"syntactic": {
|
|
149
|
+
"type": "boolean"
|
|
150
|
+
},
|
|
151
|
+
"semantic": {
|
|
152
|
+
"type": "boolean"
|
|
153
|
+
},
|
|
154
|
+
"declaration": {
|
|
155
|
+
"type": "boolean"
|
|
156
|
+
},
|
|
157
|
+
"global": {
|
|
158
|
+
"type": "boolean"
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"profile": {
|
|
163
|
+
"type": "boolean",
|
|
164
|
+
"description": "Measures and prints timings related to the TypeScript performance."
|
|
165
|
+
},
|
|
166
|
+
"typescriptPath": {
|
|
167
|
+
"type": "string",
|
|
168
|
+
"description": "If supplied this is a custom path where TypeScript can be found."
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
"FormatterOptions": {
|
|
173
|
+
"oneOf": [
|
|
174
|
+
{
|
|
175
|
+
"$ref": "#/definitions/FormatterType"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"$ref": "#/definitions/ComplexFormatterPreferences"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"$ref": "#/definitions/Formatter"
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
},
|
|
185
|
+
"IssueOptions": {
|
|
186
|
+
"type": "object",
|
|
187
|
+
"properties": {
|
|
188
|
+
"include": {
|
|
189
|
+
"$ref": "#/definitions/IssuePredicateOption"
|
|
190
|
+
},
|
|
191
|
+
"exclude": {
|
|
192
|
+
"$ref": "#/definitions/IssuePredicateOption"
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.dependenciesPool = exports.issuesPool = void 0;
|
|
23
|
+
const os = __importStar(require("os"));
|
|
24
|
+
const pool_1 = require("./utils/async/pool");
|
|
25
|
+
const issuesPool = (0, pool_1.createPool)(Math.max(1, os.cpus().length));
|
|
26
|
+
exports.issuesPool = issuesPool;
|
|
27
|
+
const dependenciesPool = (0, pool_1.createPool)(Math.max(1, os.cpus().length));
|
|
28
|
+
exports.dependenciesPool = dependenciesPool;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AbortController } from 'node-abort-controller';
|
|
2
|
+
import type { FullTap } from 'tapable';
|
|
3
|
+
import type { FilesChange } from './files-change';
|
|
4
|
+
import type { FilesMatch } from './files-match';
|
|
5
|
+
import type { Issue } from './issue';
|
|
6
|
+
interface TsCheckerRspackPluginState {
|
|
7
|
+
issuesPromise: Promise<Issue[] | undefined>;
|
|
8
|
+
dependenciesPromise: Promise<FilesMatch | undefined>;
|
|
9
|
+
abortController: AbortController | undefined;
|
|
10
|
+
aggregatedFilesChange: FilesChange | undefined;
|
|
11
|
+
lastDependencies: FilesMatch | undefined;
|
|
12
|
+
watching: boolean;
|
|
13
|
+
initialized: boolean;
|
|
14
|
+
iteration: number;
|
|
15
|
+
webpackDevServerDoneTap: FullTap | undefined;
|
|
16
|
+
}
|
|
17
|
+
declare function createPluginState(): TsCheckerRspackPluginState;
|
|
18
|
+
export { TsCheckerRspackPluginState, createPluginState };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPluginState = void 0;
|
|
4
|
+
function createPluginState() {
|
|
5
|
+
return {
|
|
6
|
+
issuesPromise: Promise.resolve(undefined),
|
|
7
|
+
dependenciesPromise: Promise.resolve(undefined),
|
|
8
|
+
abortController: undefined,
|
|
9
|
+
aggregatedFilesChange: undefined,
|
|
10
|
+
lastDependencies: undefined,
|
|
11
|
+
watching: false,
|
|
12
|
+
initialized: false,
|
|
13
|
+
iteration: 0,
|
|
14
|
+
webpackDevServerDoneTap: undefined,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
exports.createPluginState = createPluginState;
|
package/lib/plugin.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type * as rspack from '@rspack/core';
|
|
2
|
+
import type { TsCheckerRspackPluginOptions } from './plugin-options';
|
|
3
|
+
declare class TsCheckerRspackPlugin {
|
|
4
|
+
/**
|
|
5
|
+
* Current version of the plugin
|
|
6
|
+
* TODO: use `define` to replace it
|
|
7
|
+
*/
|
|
8
|
+
static readonly version: string;
|
|
9
|
+
/**
|
|
10
|
+
* Default pools for the plugin concurrency limit
|
|
11
|
+
*/
|
|
12
|
+
static readonly issuesPool: import("./utils/async/pool").Pool;
|
|
13
|
+
static readonly dependenciesPool: import("./utils/async/pool").Pool;
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Use TsCheckerRspackPlugin.issuesPool instead
|
|
16
|
+
*/
|
|
17
|
+
static readonly pool: import("./utils/async/pool").Pool;
|
|
18
|
+
private readonly options;
|
|
19
|
+
constructor(options?: TsCheckerRspackPluginOptions);
|
|
20
|
+
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>;
|
|
26
|
+
};
|
|
27
|
+
apply(compiler: rspack.Compiler): void;
|
|
28
|
+
}
|
|
29
|
+
export { TsCheckerRspackPlugin };
|