fork-ts-checker-webpack-plugin 7.2.13 → 7.3.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/README.md +15 -9
- package/lib/formatter/formatter-config.d.ts +5 -2
- package/lib/formatter/formatter-config.js +13 -3
- package/lib/formatter/formatter-options.d.ts +3 -1
- package/lib/formatter/formatter.d.ts +2 -1
- package/lib/formatter/webpack-formatter.d.ts +2 -2
- package/lib/formatter/webpack-formatter.js +6 -2
- package/lib/hooks/tap-after-compile-to-get-issues.js +1 -1
- package/lib/hooks/tap-done-to-async-get-issues.js +2 -2
- package/lib/issue/issue-webpack-error.d.ts +2 -1
- package/lib/issue/issue-webpack-error.js +7 -2
- package/lib/plugin-options.json +7 -0
- package/lib/plugin.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -61,7 +61,13 @@ module.exports = {
|
|
|
61
61
|
}
|
|
62
62
|
]
|
|
63
63
|
},
|
|
64
|
-
plugins: [new ForkTsCheckerWebpackPlugin()]
|
|
64
|
+
plugins: [new ForkTsCheckerWebpackPlugin()],
|
|
65
|
+
watchOptions: {
|
|
66
|
+
// for some systems, watching many files can result in a lot of CPU or memory usage
|
|
67
|
+
// https://webpack.js.org/configuration/watch/#watchoptionsignored
|
|
68
|
+
// don't use this pattern, if you have a monorepo with linked packages
|
|
69
|
+
ignored: /node_modules/,
|
|
70
|
+
},
|
|
65
71
|
};
|
|
66
72
|
```
|
|
67
73
|
|
|
@@ -87,14 +93,14 @@ you can place your configuration in the:
|
|
|
87
93
|
|
|
88
94
|
Options passed to the plugin constructor will overwrite options from the cosmiconfig (using [deepmerge](https://github.com/TehShrike/deepmerge)).
|
|
89
95
|
|
|
90
|
-
| Name | Type | Default value | Description
|
|
91
|
-
|
|
92
|
-
| `async` | `boolean` | `compiler.options.mode === 'development'` | If `true`, reports issues **after** webpack's compilation is done. Thanks to that it doesn't block the compilation. Used only in the `watch` mode.
|
|
93
|
-
| `typescript` | `object` | `{}` | See [TypeScript options](#typescript-options).
|
|
94
|
-
| `issue` | `object` | `{}` | See [Issues options](#issues-options).
|
|
95
|
-
| `formatter` | `string` or `object` or `function` | `codeframe` | Available formatters are `basic`, `codeframe` and a custom `function`. To [configure](https://babeljs.io/docs/en/babel-code-frame#options) `codeframe` formatter, pass
|
|
96
|
-
| `logger` | `{ log: function, error: function }` or `webpack-infrastructure` | `console`
|
|
97
|
-
| `devServer` | `boolean` | `true` | If set to `false`, errors will not be reported to Webpack Dev Server.
|
|
96
|
+
| Name | Type | Default value | Description |
|
|
97
|
+
|--------------|--------------------------------------|-------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
98
|
+
| `async` | `boolean` | `compiler.options.mode === 'development'` | If `true`, reports issues **after** webpack's compilation is done. Thanks to that it doesn't block the compilation. Used only in the `watch` mode. |
|
|
99
|
+
| `typescript` | `object` | `{}` | See [TypeScript options](#typescript-options). |
|
|
100
|
+
| `issue` | `object` | `{}` | See [Issues options](#issues-options). |
|
|
101
|
+
| `formatter` | `string` or `object` or `function` | `codeframe` | Available formatters are `basic`, `codeframe` and a custom `function`. To [configure](https://babeljs.io/docs/en/babel-code-frame#options) `codeframe` formatter, pass: `{ type: 'codeframe', options: { <coderame options> } }`. To use absolute file path, pass: `{ type: 'codeframe', pathType: 'absolute' }`. |
|
|
102
|
+
| `logger` | `{ log: function, error: function }` or `webpack-infrastructure` | `console` | Console-like object to print issues in `async` mode. |
|
|
103
|
+
| `devServer` | `boolean` | `true` | If set to `false`, errors will not be reported to Webpack Dev Server. |
|
|
98
104
|
|
|
99
105
|
### TypeScript options
|
|
100
106
|
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import type { Formatter } from './formatter';
|
|
1
|
+
import type { Formatter, FormatterPathType } from './formatter';
|
|
2
2
|
import type { FormatterOptions } from './formatter-options';
|
|
3
|
-
declare type FormatterConfig =
|
|
3
|
+
declare type FormatterConfig = {
|
|
4
|
+
format: Formatter;
|
|
5
|
+
pathType: FormatterPathType;
|
|
6
|
+
};
|
|
4
7
|
declare function createFormatterConfig(options: FormatterOptions | undefined): FormatterConfig;
|
|
5
8
|
export { FormatterConfig, createFormatterConfig };
|
|
@@ -5,21 +5,31 @@ const basic_formatter_1 = require("./basic-formatter");
|
|
|
5
5
|
const code_frame_formatter_1 = require("./code-frame-formatter");
|
|
6
6
|
function createFormatterConfig(options) {
|
|
7
7
|
if (typeof options === 'function') {
|
|
8
|
-
return
|
|
8
|
+
return {
|
|
9
|
+
format: options,
|
|
10
|
+
pathType: 'relative',
|
|
11
|
+
};
|
|
9
12
|
}
|
|
10
13
|
const type = options
|
|
11
14
|
? typeof options === 'object'
|
|
12
15
|
? options.type || 'codeframe'
|
|
13
16
|
: options
|
|
14
17
|
: 'codeframe';
|
|
18
|
+
const pathType = options && typeof options === 'object' ? options.pathType || 'relative' : 'relative';
|
|
15
19
|
if (!type || type === 'basic') {
|
|
16
|
-
return
|
|
20
|
+
return {
|
|
21
|
+
format: (0, basic_formatter_1.createBasicFormatter)(),
|
|
22
|
+
pathType,
|
|
23
|
+
};
|
|
17
24
|
}
|
|
18
25
|
if (type === 'codeframe') {
|
|
19
26
|
const config = options && typeof options === 'object'
|
|
20
27
|
? options.options || {}
|
|
21
28
|
: {};
|
|
22
|
-
return
|
|
29
|
+
return {
|
|
30
|
+
format: (0, code_frame_formatter_1.createCodeFrameFormatter)(config),
|
|
31
|
+
pathType,
|
|
32
|
+
};
|
|
23
33
|
}
|
|
24
34
|
throw new Error(`Unknown "${type}" formatter. Available types are: "basic", "codeframe" or a custom function.`);
|
|
25
35
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import type { Formatter } from './formatter';
|
|
1
|
+
import type { Formatter, FormatterPathType } from './formatter';
|
|
2
2
|
import type { BabelCodeFrameOptions } from './types/babel__code-frame';
|
|
3
3
|
declare type FormatterType = 'basic' | 'codeframe';
|
|
4
4
|
declare type BasicFormatterOptions = {
|
|
5
5
|
type: 'basic';
|
|
6
|
+
pathType?: FormatterPathType;
|
|
6
7
|
};
|
|
7
8
|
declare type CodeframeFormatterOptions = {
|
|
8
9
|
type: 'codeframe';
|
|
10
|
+
pathType?: FormatterPathType;
|
|
9
11
|
options?: BabelCodeFrameOptions;
|
|
10
12
|
};
|
|
11
13
|
declare type FormatterOptions = undefined | FormatterType | BasicFormatterOptions | CodeframeFormatterOptions | Formatter;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Formatter } from './formatter';
|
|
2
|
-
declare function createWebpackFormatter(formatter: Formatter): Formatter;
|
|
1
|
+
import type { Formatter, FormatterPathType } from './formatter';
|
|
2
|
+
declare function createWebpackFormatter(formatter: Formatter, pathType: FormatterPathType): Formatter;
|
|
3
3
|
export { createWebpackFormatter };
|
|
@@ -5,16 +5,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createWebpackFormatter = void 0;
|
|
7
7
|
const os_1 = __importDefault(require("os"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
8
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
10
|
const issue_1 = require("../issue");
|
|
11
|
+
const forward_slash_1 = require("../utils/path/forward-slash");
|
|
10
12
|
const relative_to_context_1 = require("../utils/path/relative-to-context");
|
|
11
|
-
function createWebpackFormatter(formatter) {
|
|
13
|
+
function createWebpackFormatter(formatter, pathType) {
|
|
12
14
|
// mimics webpack error formatter
|
|
13
15
|
return function webpackFormatter(issue) {
|
|
14
16
|
const color = issue.severity === 'warning' ? chalk_1.default.yellow.bold : chalk_1.default.red.bold;
|
|
15
17
|
const severity = issue.severity.toUpperCase();
|
|
16
18
|
if (issue.file) {
|
|
17
|
-
let location = chalk_1.default.bold(
|
|
19
|
+
let location = chalk_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()));
|
|
18
22
|
if (issue.location) {
|
|
19
23
|
location += `:${chalk_1.default.green.bold((0, issue_1.formatIssueLocation)(issue.location))}`;
|
|
20
24
|
}
|
|
@@ -39,7 +39,7 @@ function tapAfterCompileToGetIssues(compiler, config, state) {
|
|
|
39
39
|
// modify list of issues in the plugin hooks
|
|
40
40
|
issues = hooks.issues.call(issues, compilation);
|
|
41
41
|
issues.forEach((issue) => {
|
|
42
|
-
const error = new issue_webpack_error_1.IssueWebpackError(config.formatter(issue), issue);
|
|
42
|
+
const error = new issue_webpack_error_1.IssueWebpackError(config.formatter.format(issue), config.formatter.pathType, issue);
|
|
43
43
|
if (issue.severity === 'warning') {
|
|
44
44
|
compilation.warnings.push(error);
|
|
45
45
|
}
|
|
@@ -56,7 +56,7 @@ function tapDoneToAsyncGetIssues(compiler, config, state) {
|
|
|
56
56
|
issues = issues.filter(config.issue.predicate);
|
|
57
57
|
// modify list of issues in the plugin hooks
|
|
58
58
|
issues = hooks.issues.call(issues, stats.compilation);
|
|
59
|
-
const formatter = (0, webpack_formatter_1.createWebpackFormatter)(config.formatter);
|
|
59
|
+
const formatter = (0, webpack_formatter_1.createWebpackFormatter)(config.formatter.format, config.formatter.pathType);
|
|
60
60
|
if (issues.length) {
|
|
61
61
|
// follow webpack's approach - one process.write to stderr with all errors and warnings
|
|
62
62
|
config.logger.error(issues.map((issue) => formatter(issue)).join('\n'));
|
|
@@ -70,7 +70,7 @@ function tapDoneToAsyncGetIssues(compiler, config, state) {
|
|
|
70
70
|
// skip reporting if there are no issues, to avoid an extra hot reload
|
|
71
71
|
if (issues.length && state.webpackDevServerDoneTap) {
|
|
72
72
|
issues.forEach((issue) => {
|
|
73
|
-
const error = new issue_webpack_error_1.IssueWebpackError(config.formatter(issue), issue);
|
|
73
|
+
const error = new issue_webpack_error_1.IssueWebpackError(config.formatter.format(issue), config.formatter.pathType, issue);
|
|
74
74
|
if (issue.severity === 'warning') {
|
|
75
75
|
stats.compilation.warnings.push(error);
|
|
76
76
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import webpack from 'webpack';
|
|
2
|
+
import type { FormatterPathType } from '../formatter';
|
|
2
3
|
import type { Issue } from './issue';
|
|
3
4
|
declare class IssueWebpackError extends webpack.WebpackError {
|
|
4
5
|
readonly issue: Issue;
|
|
5
6
|
readonly hideStack = true;
|
|
6
|
-
constructor(message: string, issue: Issue);
|
|
7
|
+
constructor(message: string, pathType: FormatterPathType, issue: Issue);
|
|
7
8
|
}
|
|
8
9
|
export { IssueWebpackError };
|
|
@@ -4,12 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.IssueWebpackError = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
7
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
9
|
const webpack_1 = __importDefault(require("webpack"));
|
|
10
|
+
const forward_slash_1 = require("../utils/path/forward-slash");
|
|
9
11
|
const relative_to_context_1 = require("../utils/path/relative-to-context");
|
|
10
12
|
const issue_location_1 = require("./issue-location");
|
|
11
13
|
class IssueWebpackError extends webpack_1.default.WebpackError {
|
|
12
|
-
constructor(message, issue) {
|
|
14
|
+
constructor(message, pathType, issue) {
|
|
13
15
|
super(message);
|
|
14
16
|
this.issue = issue;
|
|
15
17
|
this.hideStack = true;
|
|
@@ -17,7 +19,10 @@ class IssueWebpackError extends webpack_1.default.WebpackError {
|
|
|
17
19
|
// should be a NormalModule instance.
|
|
18
20
|
// to avoid such a dependency, we do a workaround - error.file will contain formatted location instead
|
|
19
21
|
if (issue.file) {
|
|
20
|
-
this.file =
|
|
22
|
+
this.file =
|
|
23
|
+
pathType === 'absolute'
|
|
24
|
+
? (0, forward_slash_1.forwardSlash)(path_1.default.resolve(issue.file))
|
|
25
|
+
: (0, relative_to_context_1.relativeToContext)(issue.file, process.cwd());
|
|
21
26
|
if (issue.location) {
|
|
22
27
|
this.file += `:${chalk_1.default.green.bold((0, issue_location_1.formatIssueLocation)(issue.location))}`;
|
|
23
28
|
}
|
package/lib/plugin-options.json
CHANGED
|
@@ -34,6 +34,9 @@
|
|
|
34
34
|
"type": {
|
|
35
35
|
"$ref": "#/definitions/FormatterType"
|
|
36
36
|
},
|
|
37
|
+
"pathType": {
|
|
38
|
+
"$ref": "#/definitions/FormatterPathType"
|
|
39
|
+
},
|
|
37
40
|
"options": {
|
|
38
41
|
"type": "object",
|
|
39
42
|
"additionalProperties": true
|
|
@@ -45,6 +48,10 @@
|
|
|
45
48
|
"type": "string",
|
|
46
49
|
"enum": ["basic", "codeframe"]
|
|
47
50
|
},
|
|
51
|
+
"FormatterPathType": {
|
|
52
|
+
"type": "string",
|
|
53
|
+
"enum": ["relative", "absolute"]
|
|
54
|
+
},
|
|
48
55
|
"IssueMatch": {
|
|
49
56
|
"type": "object",
|
|
50
57
|
"properties": {
|
package/lib/plugin.js
CHANGED
|
@@ -70,7 +70,7 @@ exports.ForkTsCheckerWebpackPlugin = ForkTsCheckerWebpackPlugin;
|
|
|
70
70
|
/**
|
|
71
71
|
* Current version of the plugin
|
|
72
72
|
*/
|
|
73
|
-
ForkTsCheckerWebpackPlugin.version = '7.
|
|
73
|
+
ForkTsCheckerWebpackPlugin.version = '7.3.0'; // will be replaced by the @semantic-release/exec
|
|
74
74
|
/**
|
|
75
75
|
* Default pools for the plugin concurrency limit
|
|
76
76
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fork-ts-checker-webpack-plugin",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.0",
|
|
4
4
|
"description": "Runs typescript type checker and linter on separate process.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"author": "Piotr Oleś <piotrek.oles@gmail.com>",
|
|
24
24
|
"contributors": [
|
|
25
25
|
"Piotr Oleś <piotrek.oles@gmail.com> (https://github.com/piotr-oles)",
|
|
26
|
-
"John Reilly <johnny_reilly@hotmail.com> (https://
|
|
26
|
+
"John Reilly <johnny_reilly@hotmail.com> (https://johnnyreilly.com)"
|
|
27
27
|
],
|
|
28
28
|
"files": [
|
|
29
29
|
"lib"
|