ts-checker-rspack-plugin 1.1.7 → 1.2.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/lib/getDependenciesWorker.js +652 -0
- package/lib/getIssuesWorker.js +1091 -0
- package/lib/index.js +970 -4
- package/lib/plugin-state.d.ts +0 -1
- package/lib/plugin.d.ts +1 -1
- package/lib/rpc/rpc-worker.d.ts +0 -1
- package/lib/rpc/wrap-rpc.d.ts +0 -1
- package/lib/typescript/worker/lib/file-system/file-system.d.ts +0 -1
- package/lib/utils/async/abort-error.d.ts +0 -1
- package/lib/utils/async/pool.d.ts +0 -1
- package/lib/watch/watch-file-system.d.ts +0 -1
- package/package.json +9 -8
- package/lib/files-change.js +0 -57
- package/lib/files-match.js +0 -2
- package/lib/formatter/basic-formatter.js +0 -13
- package/lib/formatter/code-frame-formatter.js +0 -32
- package/lib/formatter/formatter-config.js +0 -36
- package/lib/formatter/formatter-options.js +0 -2
- package/lib/formatter/formatter.js +0 -2
- package/lib/formatter/index.js +0 -22
- package/lib/formatter/stats-formatter.js +0 -30
- package/lib/formatter/types/babel__code-frame.js +0 -7
- package/lib/formatter/webpack-formatter.js +0 -32
- package/lib/hooks/intercept-done-to-get-dev-server-tap.js +0 -18
- package/lib/hooks/tap-after-compile-to-add-dependencies.js +0 -59
- package/lib/hooks/tap-after-compile-to-get-issues.js +0 -43
- package/lib/hooks/tap-after-environment-to-patch-watching.js +0 -22
- package/lib/hooks/tap-done-to-async-get-issues.js +0 -74
- package/lib/hooks/tap-error-to-log-message.js +0 -32
- package/lib/hooks/tap-start-to-run-workers.js +0 -122
- package/lib/hooks/tap-stop-to-terminate-workers.js +0 -26
- package/lib/infrastructure-logger.js +0 -14
- package/lib/issue/index.js +0 -19
- package/lib/issue/issue-config.js +0 -29
- package/lib/issue/issue-location.js +0 -22
- package/lib/issue/issue-match.js +0 -20
- package/lib/issue/issue-options.js +0 -2
- package/lib/issue/issue-position.js +0 -16
- package/lib/issue/issue-predicate.js +0 -11
- package/lib/issue/issue-severity.js +0 -12
- package/lib/issue/issue-webpack-error.js +0 -31
- package/lib/issue/issue.js +0 -41
- package/lib/logger.js +0 -2
- package/lib/plugin-config.js +0 -26
- package/lib/plugin-hooks.js +0 -45
- package/lib/plugin-options.js +0 -2
- package/lib/plugin-pools.js +0 -32
- package/lib/plugin-state.js +0 -17
- package/lib/plugin.js +0 -74
- package/lib/rpc/expose-rpc.js +0 -69
- package/lib/rpc/index.js +0 -12
- package/lib/rpc/rpc-error.js +0 -12
- package/lib/rpc/rpc-worker.js +0 -86
- package/lib/rpc/types.js +0 -2
- package/lib/rpc/wrap-rpc.js +0 -70
- package/lib/typescript/type-script-config-overwrite.js +0 -2
- package/lib/typescript/type-script-diagnostics-options.js +0 -2
- package/lib/typescript/type-script-support.js +0 -31
- package/lib/typescript/type-script-worker-config.js +0 -36
- package/lib/typescript/type-script-worker-options.js +0 -2
- package/lib/typescript/worker/get-dependencies-worker.js +0 -15
- package/lib/typescript/worker/get-issues-worker.js +0 -70
- package/lib/typescript/worker/lib/artifacts.js +0 -94
- package/lib/typescript/worker/lib/config.js +0 -162
- package/lib/typescript/worker/lib/dependencies.js +0 -84
- package/lib/typescript/worker/lib/diagnostics.js +0 -112
- package/lib/typescript/worker/lib/emit.js +0 -13
- package/lib/typescript/worker/lib/file-system/file-system.js +0 -2
- package/lib/typescript/worker/lib/file-system/mem-file-system.js +0 -81
- package/lib/typescript/worker/lib/file-system/passive-file-system.js +0 -68
- package/lib/typescript/worker/lib/file-system/real-file-system.js +0 -171
- package/lib/typescript/worker/lib/host/compiler-host.js +0 -17
- package/lib/typescript/worker/lib/host/watch-compiler-host.js +0 -32
- package/lib/typescript/worker/lib/host/watch-solution-builder-host.js +0 -53
- package/lib/typescript/worker/lib/performance.js +0 -29
- package/lib/typescript/worker/lib/program/program.js +0 -37
- package/lib/typescript/worker/lib/program/solution-builder.js +0 -39
- package/lib/typescript/worker/lib/program/watch-program.js +0 -51
- package/lib/typescript/worker/lib/system.js +0 -229
- package/lib/typescript/worker/lib/tracing.js +0 -27
- package/lib/typescript/worker/lib/tsbuildinfo.js +0 -96
- package/lib/typescript/worker/lib/typescript.js +0 -6
- package/lib/typescript/worker/lib/worker-config.js +0 -5
- package/lib/utils/async/abort-error.js +0 -15
- package/lib/utils/async/controlled-promise.js +0 -17
- package/lib/utils/async/is-pending.js +0 -10
- package/lib/utils/async/pool.js +0 -36
- package/lib/utils/async/wait.js +0 -7
- package/lib/utils/path/forward-slash.js +0 -15
- package/lib/utils/path/is-inside-another-path.js +0 -22
- package/lib/utils/path/relative-to-context.js +0 -16
- package/lib/watch/inclusive-node-watch-file-system.js +0 -183
- package/lib/watch/watch-file-system.js +0 -2
package/lib/plugin-state.d.ts
CHANGED
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
|
|
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
|
}
|
package/lib/rpc/rpc-worker.d.ts
CHANGED
package/lib/rpc/wrap-rpc.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-checker-rspack-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Runs typescript type checker and linter on separate process.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rspack",
|
|
@@ -22,14 +22,15 @@
|
|
|
22
22
|
"main": "lib/index.js",
|
|
23
23
|
"types": "lib/index.d.ts",
|
|
24
24
|
"scripts": {
|
|
25
|
-
"build": "
|
|
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
|
|
33
|
+
"prepare": "husky && pnpm build",
|
|
33
34
|
"bump": "npx bumpp"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
@@ -52,6 +53,7 @@
|
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
55
|
"@jest/console": "^27.5.1",
|
|
56
|
+
"@rslib/core": "^0.17.0",
|
|
55
57
|
"@rspack/core": "^1.6.0",
|
|
56
58
|
"@types/babel__code-frame": "^7.0.6",
|
|
57
59
|
"@types/is-glob": "^4.0.4",
|
|
@@ -59,21 +61,20 @@
|
|
|
59
61
|
"@types/mock-fs": "^4.13.4",
|
|
60
62
|
"@types/node": "^16.18.126",
|
|
61
63
|
"cross-env": "^10.1.0",
|
|
62
|
-
"husky": "^
|
|
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": "^
|
|
69
|
-
"rimraf": "^3.0.2",
|
|
70
|
+
"prettier": "^3.6.2",
|
|
70
71
|
"strip-ansi": "^6.0.1",
|
|
71
72
|
"ts-jest": "^27.1.5",
|
|
72
|
-
"typescript": "^
|
|
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@
|
|
79
|
+
"packageManager": "pnpm@10.20.0"
|
|
79
80
|
}
|
package/lib/files-change.js
DELETED
|
@@ -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;
|
package/lib/files-match.js
DELETED
|
@@ -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;
|
package/lib/formatter/index.js
DELETED
|
@@ -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;
|
|
@@ -1,74 +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.tapDoneToAsyncGetIssues = void 0;
|
|
7
|
-
const picocolors_1 = __importDefault(require("picocolors"));
|
|
8
|
-
const stats_formatter_1 = require("../formatter/stats-formatter");
|
|
9
|
-
const webpack_formatter_1 = require("../formatter/webpack-formatter");
|
|
10
|
-
const infrastructure_logger_1 = require("../infrastructure-logger");
|
|
11
|
-
const issue_webpack_error_1 = require("../issue/issue-webpack-error");
|
|
12
|
-
const plugin_hooks_1 = require("../plugin-hooks");
|
|
13
|
-
const is_pending_1 = require("../utils/async/is-pending");
|
|
14
|
-
const wait_1 = require("../utils/async/wait");
|
|
15
|
-
function tapDoneToAsyncGetIssues(compiler, config, state) {
|
|
16
|
-
const hooks = (0, plugin_hooks_1.getPluginHooks)(compiler);
|
|
17
|
-
const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
|
|
18
|
-
compiler.hooks.done.tap('TsCheckerRspackPlugin', async (stats) => {
|
|
19
|
-
if (stats.compilation.compiler !== compiler) {
|
|
20
|
-
// run only for the compiler that the plugin was registered for
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const issuesPromise = state.issuesPromise;
|
|
24
|
-
let issues;
|
|
25
|
-
try {
|
|
26
|
-
if (await (0, is_pending_1.isPending)(issuesPromise)) {
|
|
27
|
-
hooks.waiting.call(stats.compilation);
|
|
28
|
-
config.logger.log(picocolors_1.default.cyan('[type-check] in progress...'));
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
// wait 10ms to log issues after webpack stats
|
|
32
|
-
await (0, wait_1.wait)(10);
|
|
33
|
-
}
|
|
34
|
-
issues = await issuesPromise;
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
hooks.error.call(error, stats.compilation);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (!issues || // some error has been thrown
|
|
41
|
-
state.issuesPromise !== issuesPromise // we have a new request - don't show results for the old one
|
|
42
|
-
) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
debug(`Got ${issues?.length || 0} issues from getIssuesWorker.`);
|
|
46
|
-
// filter list of issues by provided issue predicate
|
|
47
|
-
issues = issues.filter(config.issue.predicate);
|
|
48
|
-
// modify list of issues in the plugin hooks
|
|
49
|
-
issues = hooks.issues.call(issues, stats.compilation);
|
|
50
|
-
const formatter = (0, webpack_formatter_1.createWebpackFormatter)(config.formatter.format, config.formatter.pathType);
|
|
51
|
-
if (issues.length) {
|
|
52
|
-
// follow webpack's approach - one process.write to stderr with all errors and warnings
|
|
53
|
-
config.logger.error(issues.map((issue) => formatter(issue)).join('\n'));
|
|
54
|
-
}
|
|
55
|
-
// print stats of the compilation
|
|
56
|
-
config.logger.log((0, stats_formatter_1.statsFormatter)(issues, stats));
|
|
57
|
-
// report issues to dev-server (overlay), if it's listening
|
|
58
|
-
// skip reporting if there are no issues, to avoid an extra hot reload
|
|
59
|
-
if (issues.length && state.DevServerDoneTap) {
|
|
60
|
-
issues.forEach((issue) => {
|
|
61
|
-
const error = new issue_webpack_error_1.IssueWebpackError(config.formatter.format(issue), config.formatter.pathType, issue);
|
|
62
|
-
if (issue.severity === 'warning') {
|
|
63
|
-
stats.compilation.warnings.push(error);
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
stats.compilation.errors.push(error);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
debug('Sending issues to the dev-server.');
|
|
70
|
-
state.DevServerDoneTap.fn(stats);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
exports.tapDoneToAsyncGetIssues = tapDoneToAsyncGetIssues;
|
|
@@ -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.tapErrorToLogMessage = void 0;
|
|
7
|
-
const picocolors_1 = __importDefault(require("picocolors"));
|
|
8
|
-
const plugin_hooks_1 = require("../plugin-hooks");
|
|
9
|
-
const rpc_1 = require("../rpc");
|
|
10
|
-
const abort_error_1 = require("../utils/async/abort-error");
|
|
11
|
-
function tapErrorToLogMessage(compiler, config) {
|
|
12
|
-
const hooks = (0, plugin_hooks_1.getPluginHooks)(compiler);
|
|
13
|
-
hooks.error.tap('TsCheckerRspackPlugin', (error) => {
|
|
14
|
-
if (error instanceof abort_error_1.AbortError) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
config.logger.error(String(error));
|
|
18
|
-
if (error instanceof rpc_1.RpcExitError) {
|
|
19
|
-
if (error.signal === 'SIGINT') {
|
|
20
|
-
config.logger.error(picocolors_1.default.red('[type-check] Issues checking service interrupted - If running in a docker container, this may be caused ' +
|
|
21
|
-
"by the container running out of memory. If so, try increasing the container's memory limit " +
|
|
22
|
-
'or lowering the `memoryLimit` value in the TsCheckerRspackPlugin configuration.'));
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
config.logger.error(picocolors_1.default.red('[type-check] Issues checking service aborted - probably out of memory. ' +
|
|
26
|
-
'Check the `memoryLimit` option in the TsCheckerRspackPlugin configuration.\n' +
|
|
27
|
-
"If increasing the memory doesn't solve the issue, it's most probably a bug in the TypeScript."));
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
exports.tapErrorToLogMessage = tapErrorToLogMessage;
|