fork-ts-checker-webpack-plugin 7.0.0-alpha.12 → 7.0.0-alpha.16
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 +38 -23
- package/lib/formatter/code-frame-formatter.js +2 -2
- package/lib/formatter/formatter-config.js +2 -2
- package/lib/formatter/webpack-formatter.js +2 -2
- package/lib/hooks/intercept-done-to-get-dev-server-tap.js +2 -2
- package/lib/hooks/tap-after-compile-to-add-dependencies.js +1 -1
- package/lib/hooks/tap-after-compile-to-get-issues.js +2 -2
- package/lib/hooks/tap-after-environment-to-patch-watching.js +1 -1
- package/lib/hooks/tap-done-to-async-get-issues.js +8 -8
- package/lib/hooks/tap-error-to-log-message.js +4 -4
- package/lib/hooks/tap-start-to-run-workers.js +7 -7
- package/lib/hooks/tap-stop-to-terminate-workers.js +1 -1
- package/lib/issue/issue-config.js +4 -4
- package/lib/issue/issue-location.js +2 -2
- package/lib/issue/issue-match.js +1 -1
- package/lib/issue/issue-webpack-error.js +2 -2
- package/lib/issue/issue.js +3 -3
- package/lib/{logger/logger.d.ts → logger.d.ts} +1 -2
- package/lib/{logger/logger.js → logger.js} +0 -0
- package/lib/plugin-config.d.ts +3 -2
- package/lib/plugin-config.js +5 -5
- package/lib/plugin-hooks.d.ts +2 -2
- package/lib/plugin-options.d.ts +3 -2
- package/lib/plugin-options.json +9 -44
- package/lib/plugin-pools.js +2 -2
- package/lib/plugin.d.ts +1 -1
- package/lib/plugin.js +16 -16
- package/lib/rpc/rpc-worker.js +1 -1
- package/lib/typescript/extension/type-script-embedded-extension.js +2 -2
- package/lib/typescript/extension/vue/type-script-vue-extension-support.js +1 -1
- package/lib/typescript/extension/vue/type-script-vue-extension.js +1 -1
- package/lib/typescript/type-script-support.js +1 -1
- package/lib/typescript/type-script-worker-config.d.ts +1 -1
- package/lib/typescript/type-script-worker-config.js +1 -1
- package/lib/typescript/type-script-worker-options.d.ts +1 -1
- package/lib/typescript/worker/get-dependencies-worker.js +7 -7
- package/lib/typescript/worker/get-issues-worker.js +24 -25
- package/lib/typescript/worker/lib/artifacts.js +3 -3
- package/lib/typescript/worker/lib/config.js +3 -3
- package/lib/typescript/worker/lib/dependencies.js +2 -2
- package/lib/typescript/worker/lib/diagnostics.js +1 -1
- package/lib/typescript/worker/lib/extensions.js +1 -1
- package/lib/typescript/worker/lib/file-system/mem-file-system.js +2 -2
- package/lib/typescript/worker/lib/file-system/real-file-system.js +23 -23
- package/lib/typescript/worker/lib/host/watch-solution-builder-host.js +1 -1
- package/lib/typescript/worker/lib/program/program.js +3 -3
- package/lib/typescript/worker/lib/program/solution-builder.js +6 -6
- package/lib/typescript/worker/lib/program/watch-program.js +7 -7
- package/lib/typescript/worker/lib/system.js +27 -11
- package/lib/typescript/worker/lib/tracing.js +1 -1
- package/lib/typescript/worker/lib/tsbuildinfo.js +2 -2
- package/lib/typescript/worker/lib/worker-config.js +1 -1
- package/lib/utils/path/relative-to-context.js +1 -1
- package/lib/watch/inclusive-node-watch-file-system.js +10 -10
- package/package.json +39 -34
- package/lib/logger/logger-config.d.ts +0 -10
- package/lib/logger/logger-config.js +0 -12
- package/lib/logger/logger-factory.d.ts +0 -5
- package/lib/logger/logger-factory.js +0 -21
- package/lib/logger/logger-options.d.ts +0 -8
- package/lib/logger/logger-options.js +0 -2
- package/lib/logger/partial-logger.d.ts +0 -4
- package/lib/logger/partial-logger.js +0 -11
- package/lib/logger/webpack-infrastructure-logger.d.ts +0 -4
- package/lib/logger/webpack-infrastructure-logger.js +0 -13
package/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
+
<img alt="" width="300" src="./media/logo.svg" />
|
|
3
4
|
<h1>Fork TS Checker Webpack Plugin</h1>
|
|
4
5
|
<p>Webpack plugin that runs TypeScript type checker on a separate process.</p>
|
|
5
6
|
|
|
@@ -85,13 +86,14 @@ you can place your configuration in the:
|
|
|
85
86
|
|
|
86
87
|
Options passed to the plugin constructor will overwrite options from the cosmiconfig (using [deepmerge](https://github.com/TehShrike/deepmerge)).
|
|
87
88
|
|
|
88
|
-
| Name | Type
|
|
89
|
-
| ----------------- |
|
|
90
|
-
| `async` | `boolean`
|
|
91
|
-
| `typescript` | `object`
|
|
92
|
-
| `issue` | `object`
|
|
93
|
-
| `formatter` | `string` or `object` or `function`
|
|
94
|
-
| `logger` | `
|
|
89
|
+
| Name | Type | Default value | Description |
|
|
90
|
+
| ----------------- | ------------------------------------ | ----------------------------------------- | ----------- |
|
|
91
|
+
| `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. |
|
|
92
|
+
| `typescript` | `object` | `{}` | See [TypeScript options](#typescript-options). |
|
|
93
|
+
| `issue` | `object` | `{}` | See [Issues options](#issues-options). |
|
|
94
|
+
| `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 object: `{ type: 'codeframe', options: { <coderame options> } }`. |
|
|
95
|
+
| `logger` | `{ log: function, error: function }` | `console` | Console-like object to print issues in `async` mode. |
|
|
96
|
+
| `devServer` | `boolean` | `true` | If set to `false`, errors will not be reported to Webpack Dev Server. |
|
|
95
97
|
|
|
96
98
|
### TypeScript options
|
|
97
99
|
|
|
@@ -104,8 +106,8 @@ Options for the TypeScript checker (`typescript` option object).
|
|
|
104
106
|
| `configOverwrite` | `object` | `{ compilerOptions: { skipLibCheck: true, sourceMap: false, inlineSourceMap: false, declarationMap: false } }` | This configuration will overwrite configuration from the `tsconfig.json` file. Supported fields are: `extends`, `compilerOptions`, `include`, `exclude`, `files`, and `references`. |
|
|
105
107
|
| `context` | `string` | `dirname(configuration.configFile)` | The base path for finding files specified in the `tsconfig.json`. Same as the `context` option from the [ts-loader](https://github.com/TypeStrong/ts-loader#context). Useful if you want to keep your `tsconfig.json` in an external package. Keep in mind that **not** having a `tsconfig.json` in your project root can cause different behaviour between `fork-ts-checker-webpack-plugin` and `tsc`. When using editors like `VS Code` it is advised to add a `tsconfig.json` file to the root of the project and extend the config file referenced in option `configFile`. |
|
|
106
108
|
| `build` | `boolean` | `false` | The equivalent of the `--build` flag for the `tsc` command. |
|
|
107
|
-
| `mode` | `'readonly'` or `'write-tsbuildinfo'` or `'write-references'` | `'write-tsbuildinfo'` | If you use the `babel-loader`, it's recommended to use `write-references` mode to improve initial compilation time. If you use `ts-loader`, it's recommended to use `write-tsbuildinfo` mode to not overwrite files emitted by the `ts-loader`. |
|
|
108
|
-
| `diagnosticOptions`
|
|
109
|
+
| `mode` | `'readonly'` or `'write-tsbuildinfo'` or `'write-dts'` or `'write-references'` | `'write-tsbuildinfo'` | If you use the `babel-loader`, it's recommended to use `write-references` mode to improve initial compilation time. If you use `ts-loader`, it's recommended to use `write-tsbuildinfo` mode to not overwrite files emitted by the `ts-loader`. If you use `ts-loader` with `transpileOnly` flag set to `true`, use `'write-dts` to emit the type definition files. |
|
|
110
|
+
| `diagnosticOptions` | `object` | `{ syntactic: false, semantic: true, declaration: false, global: false }` | Settings to select which diagnostics do we want to perform. |
|
|
109
111
|
| `extensions` | `object` | `{}` | See [TypeScript extensions options](#typescript-extensions-options). |
|
|
110
112
|
| `profile` | `boolean` | `false` | Measures and prints timings related to the TypeScript performance. |
|
|
111
113
|
| `typescriptPath` | `string` | `require.resolve('typescript')` | If supplied this is a custom path where TypeScript can be found. |
|
|
@@ -297,24 +299,37 @@ When we call this method with a [webpack compiler instance](https://webpack.js.o
|
|
|
297
299
|
[tapable](https://github.com/webpack/tapable) hooks where you can pass in your callbacks.
|
|
298
300
|
|
|
299
301
|
```js
|
|
300
|
-
|
|
302
|
+
// ./src/webpack/MyWebpackPlugin.js
|
|
301
303
|
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
|
302
304
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
305
|
+
class MyWebpackPlugin {
|
|
306
|
+
apply(compiler) {
|
|
307
|
+
const hooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(compiler);
|
|
308
|
+
|
|
309
|
+
// log some message on waiting
|
|
310
|
+
hooks.waiting.tap('MyPlugin', () => {
|
|
311
|
+
console.log('waiting for issues');
|
|
312
|
+
});
|
|
313
|
+
// don't show warnings
|
|
314
|
+
hooks.issues.tap('MyPlugin', (issues) =>
|
|
315
|
+
issues.filter((issue) => issue.severity === 'error')
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
306
319
|
|
|
307
|
-
|
|
308
|
-
// **don't do this if already added through configuration**
|
|
309
|
-
new ForkTsCheckerWebpackPlugin().apply(compiler);
|
|
320
|
+
module.exports = MyWebpackPlugin;
|
|
310
321
|
|
|
311
|
-
//
|
|
312
|
-
const
|
|
322
|
+
// webpack.config.js
|
|
323
|
+
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
|
324
|
+
const MyWebpackPlugin = require('./src/webpack/MyWebpackPlugin');
|
|
313
325
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
326
|
+
module.exports = {
|
|
327
|
+
/* ... */
|
|
328
|
+
plugins: [
|
|
329
|
+
new ForkTsCheckerWebpackPlugin(),
|
|
330
|
+
new MyWebpackPlugin()
|
|
331
|
+
]
|
|
332
|
+
};
|
|
318
333
|
```
|
|
319
334
|
|
|
320
335
|
## Typings
|
|
@@ -332,7 +347,7 @@ yarn add --dev @types/webpack
|
|
|
332
347
|
|
|
333
348
|
## Profiling types resolution
|
|
334
349
|
|
|
335
|
-
Starting from TypeScript 4.1.0
|
|
350
|
+
Starting from TypeScript 4.1.0, you can profile long type checks by
|
|
336
351
|
setting "generateTrace" compiler option. This is an instruction from [microsoft/TypeScript#40063](https://github.com/microsoft/TypeScript/pull/40063):
|
|
337
352
|
|
|
338
353
|
1. Set "generateTrace": "{folderName}" in your `tsconfig.json`
|
|
@@ -9,12 +9,12 @@ const code_frame_1 = require("@babel/code-frame");
|
|
|
9
9
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
10
10
|
const basic_formatter_1 = require("./basic-formatter");
|
|
11
11
|
function createCodeFrameFormatter(options) {
|
|
12
|
-
const basicFormatter = basic_formatter_1.createBasicFormatter();
|
|
12
|
+
const basicFormatter = (0, basic_formatter_1.createBasicFormatter)();
|
|
13
13
|
return function codeFrameFormatter(issue) {
|
|
14
14
|
const source = issue.file && fs_extra_1.default.existsSync(issue.file) && fs_extra_1.default.readFileSync(issue.file, 'utf-8');
|
|
15
15
|
let frame = '';
|
|
16
16
|
if (source && issue.location) {
|
|
17
|
-
frame = code_frame_1.codeFrameColumns(source, issue.location, Object.assign({ highlightCode: true }, (options || {})))
|
|
17
|
+
frame = (0, code_frame_1.codeFrameColumns)(source, issue.location, Object.assign({ highlightCode: true }, (options || {})))
|
|
18
18
|
.split('\n')
|
|
19
19
|
.map((line) => ' ' + line)
|
|
20
20
|
.join(os_1.default.EOL);
|
|
@@ -13,13 +13,13 @@ function createFormatterConfig(options) {
|
|
|
13
13
|
: options
|
|
14
14
|
: 'codeframe';
|
|
15
15
|
if (!type || type === 'basic') {
|
|
16
|
-
return basic_formatter_1.createBasicFormatter();
|
|
16
|
+
return (0, basic_formatter_1.createBasicFormatter)();
|
|
17
17
|
}
|
|
18
18
|
if (type === 'codeframe') {
|
|
19
19
|
const config = options && typeof options === 'object'
|
|
20
20
|
? options.options || {}
|
|
21
21
|
: {};
|
|
22
|
-
return code_frame_formatter_1.createCodeFrameFormatter(config);
|
|
22
|
+
return (0, code_frame_formatter_1.createCodeFrameFormatter)(config);
|
|
23
23
|
}
|
|
24
24
|
throw new Error(`Unknown "${type}" formatter. Available types are: "basic", "codeframe" or a custom function.`);
|
|
25
25
|
}
|
|
@@ -14,9 +14,9 @@ function createWebpackFormatter(formatter) {
|
|
|
14
14
|
const color = issue.severity === 'warning' ? chalk_1.default.yellow.bold : chalk_1.default.red.bold;
|
|
15
15
|
const severity = issue.severity.toUpperCase();
|
|
16
16
|
if (issue.file) {
|
|
17
|
-
let location = chalk_1.default.whiteBright.bold(relative_to_context_1.relativeToContext(issue.file, process.cwd()));
|
|
17
|
+
let location = chalk_1.default.whiteBright.bold((0, relative_to_context_1.relativeToContext)(issue.file, process.cwd()));
|
|
18
18
|
if (issue.location) {
|
|
19
|
-
location += ` ${chalk_1.default.green.bold(issue_1.formatIssueLocation(issue.location))}`;
|
|
19
|
+
location += ` ${chalk_1.default.green.bold((0, issue_1.formatIssueLocation)(issue.location))}`;
|
|
20
20
|
}
|
|
21
21
|
return [`${color(severity)} in ${location}`, formatter(issue), ''].join(os_1.default.EOL);
|
|
22
22
|
}
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.interceptDoneToGetDevServerTap = void 0;
|
|
4
4
|
const infrastructure_logger_1 = require("../infrastructure-logger");
|
|
5
5
|
function interceptDoneToGetDevServerTap(compiler, config, state) {
|
|
6
|
-
const { debug } = infrastructure_logger_1.getInfrastructureLogger(compiler);
|
|
6
|
+
const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
|
|
7
7
|
// inspired by https://github.com/ypresto/fork-ts-checker-async-overlay-webpack-plugin
|
|
8
8
|
compiler.hooks.done.intercept({
|
|
9
9
|
register: (tap) => {
|
|
10
|
-
if (tap.name === 'webpack-dev-server' && tap.type === 'sync' && config.
|
|
10
|
+
if (tap.name === 'webpack-dev-server' && tap.type === 'sync' && config.devServer) {
|
|
11
11
|
debug('Intercepting webpack-dev-server tap.');
|
|
12
12
|
state.webpackDevServerDoneTap = tap;
|
|
13
13
|
}
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.tapAfterCompileToAddDependencies = void 0;
|
|
13
13
|
const infrastructure_logger_1 = require("../infrastructure-logger");
|
|
14
14
|
function tapAfterCompileToAddDependencies(compiler, config, state) {
|
|
15
|
-
const { debug } = infrastructure_logger_1.getInfrastructureLogger(compiler);
|
|
15
|
+
const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
|
|
16
16
|
compiler.hooks.afterCompile.tapPromise('ForkTsCheckerWebpackPlugin', (compilation) => __awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
if (compilation.compiler !== compiler) {
|
|
18
18
|
// run only for the compiler that the plugin was registered for
|
|
@@ -14,8 +14,8 @@ const infrastructure_logger_1 = require("../infrastructure-logger");
|
|
|
14
14
|
const issue_webpack_error_1 = require("../issue/issue-webpack-error");
|
|
15
15
|
const plugin_hooks_1 = require("../plugin-hooks");
|
|
16
16
|
function tapAfterCompileToGetIssues(compiler, config, state) {
|
|
17
|
-
const hooks = plugin_hooks_1.getPluginHooks(compiler);
|
|
18
|
-
const { debug } = infrastructure_logger_1.getInfrastructureLogger(compiler);
|
|
17
|
+
const hooks = (0, plugin_hooks_1.getPluginHooks)(compiler);
|
|
18
|
+
const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
|
|
19
19
|
compiler.hooks.afterCompile.tapPromise('ForkTsCheckerWebpackPlugin', (compilation) => __awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
if (compilation.compiler !== compiler) {
|
|
21
21
|
// run only for the compiler that the plugin was registered for
|
|
@@ -4,7 +4,7 @@ exports.tapAfterEnvironmentToPatchWatching = void 0;
|
|
|
4
4
|
const infrastructure_logger_1 = require("../infrastructure-logger");
|
|
5
5
|
const inclusive_node_watch_file_system_1 = require("../watch/inclusive-node-watch-file-system");
|
|
6
6
|
function tapAfterEnvironmentToPatchWatching(compiler, state) {
|
|
7
|
-
const { debug } = infrastructure_logger_1.getInfrastructureLogger(compiler);
|
|
7
|
+
const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
|
|
8
8
|
compiler.hooks.afterEnvironment.tap('ForkTsCheckerWebpackPlugin', () => {
|
|
9
9
|
const watchFileSystem = compiler.watchFileSystem;
|
|
10
10
|
if (watchFileSystem) {
|
|
@@ -21,8 +21,8 @@ const plugin_hooks_1 = require("../plugin-hooks");
|
|
|
21
21
|
const is_pending_1 = require("../utils/async/is-pending");
|
|
22
22
|
const wait_1 = require("../utils/async/wait");
|
|
23
23
|
function tapDoneToAsyncGetIssues(compiler, config, state) {
|
|
24
|
-
const hooks = plugin_hooks_1.getPluginHooks(compiler);
|
|
25
|
-
const { log, debug } = infrastructure_logger_1.getInfrastructureLogger(compiler);
|
|
24
|
+
const hooks = (0, plugin_hooks_1.getPluginHooks)(compiler);
|
|
25
|
+
const { log, debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
|
|
26
26
|
compiler.hooks.done.tap('ForkTsCheckerWebpackPlugin', (stats) => __awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
if (stats.compilation.compiler !== compiler) {
|
|
28
28
|
// run only for the compiler that the plugin was registered for
|
|
@@ -31,13 +31,13 @@ function tapDoneToAsyncGetIssues(compiler, config, state) {
|
|
|
31
31
|
const issuesPromise = state.issuesPromise;
|
|
32
32
|
let issues;
|
|
33
33
|
try {
|
|
34
|
-
if (yield is_pending_1.isPending(issuesPromise)) {
|
|
34
|
+
if (yield (0, is_pending_1.isPending)(issuesPromise)) {
|
|
35
35
|
hooks.waiting.call(stats.compilation);
|
|
36
|
-
config.logger.
|
|
36
|
+
config.logger.log(chalk_1.default.cyan('Issues checking in progress...'));
|
|
37
37
|
}
|
|
38
38
|
else {
|
|
39
39
|
// wait 10ms to log issues after webpack stats
|
|
40
|
-
yield wait_1.wait(10);
|
|
40
|
+
yield (0, wait_1.wait)(10);
|
|
41
41
|
}
|
|
42
42
|
issues = yield issuesPromise;
|
|
43
43
|
debug('Got issues from getIssuesWorker.', issues === null || issues === void 0 ? void 0 : issues.length);
|
|
@@ -54,13 +54,13 @@ function tapDoneToAsyncGetIssues(compiler, config, state) {
|
|
|
54
54
|
issues = issues.filter(config.issue.predicate);
|
|
55
55
|
// modify list of issues in the plugin hooks
|
|
56
56
|
issues = hooks.issues.call(issues, stats.compilation);
|
|
57
|
-
const formatter = webpack_formatter_1.createWebpackFormatter(config.formatter);
|
|
57
|
+
const formatter = (0, webpack_formatter_1.createWebpackFormatter)(config.formatter);
|
|
58
58
|
if (issues.length) {
|
|
59
59
|
// follow webpack's approach - one process.write to stderr with all errors and warnings
|
|
60
|
-
config.logger.
|
|
60
|
+
config.logger.error(issues.map((issue) => formatter(issue)).join('\n'));
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
63
|
-
config.logger.
|
|
63
|
+
config.logger.log(chalk_1.default.green('No issues found.'));
|
|
64
64
|
}
|
|
65
65
|
// report issues to webpack-dev-server, if it's listening
|
|
66
66
|
// skip reporting if there are no issues, to avoid an extra hot reload
|
|
@@ -8,17 +8,17 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
8
8
|
const plugin_hooks_1 = require("../plugin-hooks");
|
|
9
9
|
const rpc_1 = require("../rpc");
|
|
10
10
|
function tapErrorToLogMessage(compiler, config) {
|
|
11
|
-
const hooks = plugin_hooks_1.getPluginHooks(compiler);
|
|
11
|
+
const hooks = (0, plugin_hooks_1.getPluginHooks)(compiler);
|
|
12
12
|
hooks.error.tap('ForkTsCheckerWebpackPlugin', (error) => {
|
|
13
|
-
config.logger.
|
|
13
|
+
config.logger.error(String(error));
|
|
14
14
|
if (error instanceof rpc_1.RpcExitError) {
|
|
15
15
|
if (error.signal === 'SIGINT') {
|
|
16
|
-
config.logger.
|
|
16
|
+
config.logger.error(chalk_1.default.red('Issues checking service interrupted - If running in a docker container, this may be caused ' +
|
|
17
17
|
"by the container running out of memory. If so, try increasing the container's memory limit " +
|
|
18
18
|
'or lowering the `memoryLimit` value in the ForkTsCheckerWebpackPlugin configuration.'));
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
|
-
config.logger.
|
|
21
|
+
config.logger.error(chalk_1.default.red('Issues checking service aborted - probably out of memory. ' +
|
|
22
22
|
'Check the `memoryLimit` option in the ForkTsCheckerWebpackPlugin configuration.\n' +
|
|
23
23
|
"If increasing the memory doesn't solve the issue, it's most probably a bug in the TypeScript."));
|
|
24
24
|
}
|
|
@@ -18,14 +18,14 @@ const intercept_done_to_get_dev_server_tap_1 = require("./intercept-done-to-get-
|
|
|
18
18
|
const tap_after_compile_to_get_issues_1 = require("./tap-after-compile-to-get-issues");
|
|
19
19
|
const tap_done_to_async_get_issues_1 = require("./tap-done-to-async-get-issues");
|
|
20
20
|
function tapStartToRunWorkers(compiler, getIssuesWorker, getDependenciesWorker, config, state) {
|
|
21
|
-
const hooks = plugin_hooks_1.getPluginHooks(compiler);
|
|
22
|
-
const { log, debug } = infrastructure_logger_1.getInfrastructureLogger(compiler);
|
|
21
|
+
const hooks = (0, plugin_hooks_1.getPluginHooks)(compiler);
|
|
22
|
+
const { log, debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
|
|
23
23
|
compiler.hooks.run.tap('ForkTsCheckerWebpackPlugin', () => {
|
|
24
24
|
if (!state.initialized) {
|
|
25
25
|
debug('Initializing plugin for single run (not async).');
|
|
26
26
|
state.initialized = true;
|
|
27
27
|
state.watching = false;
|
|
28
|
-
tap_after_compile_to_get_issues_1.tapAfterCompileToGetIssues(compiler, config, state);
|
|
28
|
+
(0, tap_after_compile_to_get_issues_1.tapAfterCompileToGetIssues)(compiler, config, state);
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
compiler.hooks.watchRun.tap('ForkTsCheckerWebpackPlugin', () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -34,12 +34,12 @@ function tapStartToRunWorkers(compiler, getIssuesWorker, getDependenciesWorker,
|
|
|
34
34
|
state.watching = true;
|
|
35
35
|
if (config.async) {
|
|
36
36
|
debug('Initializing plugin for watch run (async).');
|
|
37
|
-
tap_done_to_async_get_issues_1.tapDoneToAsyncGetIssues(compiler, config, state);
|
|
38
|
-
intercept_done_to_get_dev_server_tap_1.interceptDoneToGetDevServerTap(compiler, config, state);
|
|
37
|
+
(0, tap_done_to_async_get_issues_1.tapDoneToAsyncGetIssues)(compiler, config, state);
|
|
38
|
+
(0, intercept_done_to_get_dev_server_tap_1.interceptDoneToGetDevServerTap)(compiler, config, state);
|
|
39
39
|
}
|
|
40
40
|
else {
|
|
41
41
|
debug('Initializing plugin for watch run (not async).');
|
|
42
|
-
tap_after_compile_to_get_issues_1.tapAfterCompileToGetIssues(compiler, config, state);
|
|
42
|
+
(0, tap_after_compile_to_get_issues_1.tapAfterCompileToGetIssues)(compiler, config, state);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
}));
|
|
@@ -51,7 +51,7 @@ function tapStartToRunWorkers(compiler, getIssuesWorker, getDependenciesWorker,
|
|
|
51
51
|
const iteration = ++state.iteration;
|
|
52
52
|
let change = {};
|
|
53
53
|
if (state.watching) {
|
|
54
|
-
change = files_change_1.consumeFilesChange(compiler);
|
|
54
|
+
change = (0, files_change_1.consumeFilesChange)(compiler);
|
|
55
55
|
log([
|
|
56
56
|
'Calling reporter service for incremental check.',
|
|
57
57
|
` Changed files: ${JSON.stringify(change.changedFiles)}`,
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.tapStopToTerminateWorkers = void 0;
|
|
4
4
|
const infrastructure_logger_1 = require("../infrastructure-logger");
|
|
5
5
|
function tapStopToTerminateWorkers(compiler, getIssuesWorker, getDependenciesWorker, state) {
|
|
6
|
-
const { debug } = infrastructure_logger_1.getInfrastructureLogger(compiler);
|
|
6
|
+
const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
|
|
7
7
|
const terminateWorkers = () => {
|
|
8
8
|
debug('Compiler is going to close - terminating workers...');
|
|
9
9
|
getIssuesWorker.terminate();
|
|
@@ -5,11 +5,11 @@ const issue_match_1 = require("./issue-match");
|
|
|
5
5
|
const issue_predicate_1 = require("./issue-predicate");
|
|
6
6
|
function createIssuePredicateFromOption(context, option) {
|
|
7
7
|
if (Array.isArray(option)) {
|
|
8
|
-
return issue_predicate_1.composeIssuePredicates(option.map((option) => typeof option === 'function' ? option : issue_match_1.createIssuePredicateFromIssueMatch(context, option)));
|
|
8
|
+
return (0, issue_predicate_1.composeIssuePredicates)(option.map((option) => typeof option === 'function' ? option : (0, issue_match_1.createIssuePredicateFromIssueMatch)(context, option)));
|
|
9
9
|
}
|
|
10
10
|
return typeof option === 'function'
|
|
11
11
|
? option
|
|
12
|
-
: issue_match_1.createIssuePredicateFromIssueMatch(context, option);
|
|
12
|
+
: (0, issue_match_1.createIssuePredicateFromIssueMatch)(context, option);
|
|
13
13
|
}
|
|
14
14
|
function createIssueConfig(compiler, options) {
|
|
15
15
|
const context = compiler.options.context || process.cwd();
|
|
@@ -18,10 +18,10 @@ function createIssueConfig(compiler, options) {
|
|
|
18
18
|
}
|
|
19
19
|
const include = options.include
|
|
20
20
|
? createIssuePredicateFromOption(context, options.include)
|
|
21
|
-
: issue_predicate_1.createTrivialIssuePredicate(true);
|
|
21
|
+
: (0, issue_predicate_1.createTrivialIssuePredicate)(true);
|
|
22
22
|
const exclude = options.exclude
|
|
23
23
|
? createIssuePredicateFromOption(context, options.exclude)
|
|
24
|
-
: issue_predicate_1.createTrivialIssuePredicate(false);
|
|
24
|
+
: (0, issue_predicate_1.createTrivialIssuePredicate)(false);
|
|
25
25
|
return {
|
|
26
26
|
predicate: (issue) => include(issue) && !exclude(issue),
|
|
27
27
|
};
|
|
@@ -12,8 +12,8 @@ function compareIssueLocations(locationA, locationB) {
|
|
|
12
12
|
if (!locationB) {
|
|
13
13
|
return 1;
|
|
14
14
|
}
|
|
15
|
-
return (issue_position_1.compareIssuePositions(locationA.start, locationB.start) ||
|
|
16
|
-
issue_position_1.compareIssuePositions(locationA.end, locationB.end));
|
|
15
|
+
return ((0, issue_position_1.compareIssuePositions)(locationA.start, locationB.start) ||
|
|
16
|
+
(0, issue_position_1.compareIssuePositions)(locationA.end, locationB.end));
|
|
17
17
|
}
|
|
18
18
|
exports.compareIssueLocations = compareIssueLocations;
|
|
19
19
|
function formatIssueLocation({ start, end }) {
|
package/lib/issue/issue-match.js
CHANGED
|
@@ -13,7 +13,7 @@ function createIssuePredicateFromIssueMatch(context, match) {
|
|
|
13
13
|
const matchesCode = !match.code || match.code === issue.code;
|
|
14
14
|
const matchesFile = !issue.file ||
|
|
15
15
|
(!!issue.file &&
|
|
16
|
-
(!match.file || minimatch_1.default(forward_slash_1.forwardSlash(path_1.default.relative(context, issue.file)), match.file)));
|
|
16
|
+
(!match.file || (0, minimatch_1.default)((0, forward_slash_1.forwardSlash)(path_1.default.relative(context, issue.file)), match.file)));
|
|
17
17
|
return matchesSeverity && matchesCode && matchesFile;
|
|
18
18
|
};
|
|
19
19
|
}
|
|
@@ -17,9 +17,9 @@ class IssueWebpackError extends webpack_1.default.WebpackError {
|
|
|
17
17
|
// should be a NormalModule instance.
|
|
18
18
|
// to avoid such a dependency, we do a workaround - error.file will contain formatted location instead
|
|
19
19
|
if (issue.file) {
|
|
20
|
-
this.file = relative_to_context_1.relativeToContext(issue.file, process.cwd());
|
|
20
|
+
this.file = (0, relative_to_context_1.relativeToContext)(issue.file, process.cwd());
|
|
21
21
|
if (issue.location) {
|
|
22
|
-
this.file += ` ${chalk_1.default.green.bold(issue_location_1.formatIssueLocation(issue.location))}`;
|
|
22
|
+
this.file += ` ${chalk_1.default.green.bold((0, issue_location_1.formatIssueLocation)(issue.location))}`;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
Error.captureStackTrace(this, this.constructor);
|
package/lib/issue/issue.js
CHANGED
|
@@ -6,7 +6,7 @@ const issue_severity_1 = require("./issue-severity");
|
|
|
6
6
|
function isIssue(value) {
|
|
7
7
|
return (!!value &&
|
|
8
8
|
typeof value === 'object' &&
|
|
9
|
-
issue_severity_1.isIssueSeverity(value.severity) &&
|
|
9
|
+
(0, issue_severity_1.isIssueSeverity)(value.severity) &&
|
|
10
10
|
!!value.code &&
|
|
11
11
|
!!value.message);
|
|
12
12
|
}
|
|
@@ -24,9 +24,9 @@ function compareStrings(stringA, stringB) {
|
|
|
24
24
|
return stringA.toString().localeCompare(stringB.toString());
|
|
25
25
|
}
|
|
26
26
|
function compareIssues(issueA, issueB) {
|
|
27
|
-
return (issue_severity_1.compareIssueSeverities(issueA.severity, issueB.severity) ||
|
|
27
|
+
return ((0, issue_severity_1.compareIssueSeverities)(issueA.severity, issueB.severity) ||
|
|
28
28
|
compareStrings(issueA.file, issueB.file) ||
|
|
29
|
-
issue_location_1.compareIssueLocations(issueA.location, issueB.location) ||
|
|
29
|
+
(0, issue_location_1.compareIssueLocations)(issueA.location, issueB.location) ||
|
|
30
30
|
compareStrings(issueA.code, issueB.code) ||
|
|
31
31
|
compareStrings(issueA.message, issueB.message) ||
|
|
32
32
|
0 /* EqualTo */);
|
|
File without changes
|
package/lib/plugin-config.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type webpack from 'webpack';
|
|
2
2
|
import type { FormatterConfig } from './formatter';
|
|
3
3
|
import type { IssueConfig } from './issue/issue-config';
|
|
4
|
-
import type {
|
|
4
|
+
import type { Logger } from './logger';
|
|
5
5
|
import type { ForkTsCheckerWebpackPluginOptions } from './plugin-options';
|
|
6
6
|
import type { TypeScriptWorkerConfig } from './typescript/type-script-worker-config';
|
|
7
7
|
interface ForkTsCheckerWebpackPluginConfig {
|
|
@@ -9,7 +9,8 @@ interface ForkTsCheckerWebpackPluginConfig {
|
|
|
9
9
|
typescript: TypeScriptWorkerConfig;
|
|
10
10
|
issue: IssueConfig;
|
|
11
11
|
formatter: FormatterConfig;
|
|
12
|
-
logger:
|
|
12
|
+
logger: Logger;
|
|
13
|
+
devServer: boolean;
|
|
13
14
|
}
|
|
14
15
|
declare function createPluginConfig(compiler: webpack.Compiler, options?: ForkTsCheckerWebpackPluginOptions): ForkTsCheckerWebpackPluginConfig;
|
|
15
16
|
export { ForkTsCheckerWebpackPluginConfig, createPluginConfig };
|
package/lib/plugin-config.js
CHANGED
|
@@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createPluginConfig = void 0;
|
|
4
4
|
const formatter_1 = require("./formatter");
|
|
5
5
|
const issue_config_1 = require("./issue/issue-config");
|
|
6
|
-
const logger_config_1 = require("./logger/logger-config");
|
|
7
6
|
const type_script_worker_config_1 = require("./typescript/type-script-worker-config");
|
|
8
7
|
function createPluginConfig(compiler, options = {}) {
|
|
9
8
|
return {
|
|
10
9
|
async: options.async === undefined ? compiler.options.mode === 'development' : options.async,
|
|
11
|
-
typescript: type_script_worker_config_1.createTypeScriptWorkerConfig(compiler, options.typescript),
|
|
12
|
-
issue: issue_config_1.createIssueConfig(compiler, options.issue),
|
|
13
|
-
formatter: formatter_1.createFormatterConfig(options.formatter),
|
|
14
|
-
logger:
|
|
10
|
+
typescript: (0, type_script_worker_config_1.createTypeScriptWorkerConfig)(compiler, options.typescript),
|
|
11
|
+
issue: (0, issue_config_1.createIssueConfig)(compiler, options.issue),
|
|
12
|
+
formatter: (0, formatter_1.createFormatterConfig)(options.formatter),
|
|
13
|
+
logger: options.logger || console,
|
|
14
|
+
devServer: options.devServer !== false,
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
exports.createPluginConfig = createPluginConfig;
|
package/lib/plugin-hooks.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ declare function createPluginHooks(): {
|
|
|
6
6
|
start: AsyncSeriesWaterfallHook<[FilesChange, webpack.Compilation], import("tapable").UnsetAdditionalOptions>;
|
|
7
7
|
waiting: SyncHook<[webpack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
|
|
8
8
|
canceled: SyncHook<[webpack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
|
|
9
|
-
error: SyncHook<[
|
|
9
|
+
error: SyncHook<[unknown, webpack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
|
|
10
10
|
issues: SyncWaterfallHook<[Issue[], webpack.Compilation | undefined], void>;
|
|
11
11
|
};
|
|
12
12
|
declare type ForkTsCheckerWebpackPluginHooks = ReturnType<typeof createPluginHooks>;
|
|
@@ -14,7 +14,7 @@ declare function getPluginHooks(compiler: webpack.Compiler | webpack.MultiCompil
|
|
|
14
14
|
start: AsyncSeriesWaterfallHook<[FilesChange, webpack.Compilation], import("tapable").UnsetAdditionalOptions>;
|
|
15
15
|
waiting: SyncHook<[webpack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
|
|
16
16
|
canceled: SyncHook<[webpack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
|
|
17
|
-
error: SyncHook<[
|
|
17
|
+
error: SyncHook<[unknown, webpack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
|
|
18
18
|
issues: SyncWaterfallHook<[Issue[], webpack.Compilation | undefined], void>;
|
|
19
19
|
};
|
|
20
20
|
export { getPluginHooks, ForkTsCheckerWebpackPluginHooks };
|
package/lib/plugin-options.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { FormatterOptions } from './formatter';
|
|
2
2
|
import type { IssueOptions } from './issue/issue-options';
|
|
3
|
-
import type
|
|
3
|
+
import type { Logger } from './logger';
|
|
4
4
|
import type { TypeScriptWorkerOptions } from './typescript/type-script-worker-options';
|
|
5
5
|
interface ForkTsCheckerWebpackPluginOptions {
|
|
6
6
|
async?: boolean;
|
|
7
7
|
typescript?: TypeScriptWorkerOptions;
|
|
8
8
|
formatter?: FormatterOptions;
|
|
9
9
|
issue?: IssueOptions;
|
|
10
|
-
logger?:
|
|
10
|
+
logger?: Logger;
|
|
11
|
+
devServer?: boolean;
|
|
11
12
|
}
|
|
12
13
|
export { ForkTsCheckerWebpackPluginOptions };
|
package/lib/plugin-options.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"description": "When true, plugin will not block compilation to finish issues checking"
|
|
8
8
|
},
|
|
9
9
|
"typescript": {
|
|
10
|
-
"$ref": "#/definitions/
|
|
10
|
+
"$ref": "#/definitions/TypeScriptOptions"
|
|
11
11
|
},
|
|
12
12
|
"formatter": {
|
|
13
13
|
"$ref": "#/definitions/FormatterOptions"
|
|
@@ -16,7 +16,11 @@
|
|
|
16
16
|
"$ref": "#/definitions/IssueOptions"
|
|
17
17
|
},
|
|
18
18
|
"logger": {
|
|
19
|
-
"$ref": "#/definitions/
|
|
19
|
+
"$ref": "#/definitions/Logger"
|
|
20
|
+
},
|
|
21
|
+
"devServer": {
|
|
22
|
+
"type": "boolean",
|
|
23
|
+
"description": "Enable reporting to Webpack Dev Server."
|
|
20
24
|
}
|
|
21
25
|
},
|
|
22
26
|
"additionalProperties": false,
|
|
@@ -90,29 +94,18 @@
|
|
|
90
94
|
}
|
|
91
95
|
]
|
|
92
96
|
},
|
|
93
|
-
"LoggerType": {
|
|
94
|
-
"type": "string",
|
|
95
|
-
"enum": [
|
|
96
|
-
"console",
|
|
97
|
-
"webpack-infrastructure",
|
|
98
|
-
"silent"
|
|
99
|
-
]
|
|
100
|
-
},
|
|
101
97
|
"Logger": {
|
|
102
98
|
"type": "object",
|
|
103
99
|
"properties": {
|
|
104
100
|
"error": {
|
|
105
101
|
"instanceof": "Function"
|
|
106
102
|
},
|
|
107
|
-
"info": {
|
|
108
|
-
"instanceof": "Function"
|
|
109
|
-
},
|
|
110
103
|
"log": {
|
|
111
104
|
"instanceof": "Function"
|
|
112
105
|
}
|
|
113
106
|
}
|
|
114
107
|
},
|
|
115
|
-
"
|
|
108
|
+
"TypeScriptOptions": {
|
|
116
109
|
"type": "object",
|
|
117
110
|
"properties": {
|
|
118
111
|
"memoryLimit": {
|
|
@@ -136,9 +129,10 @@
|
|
|
136
129
|
"enum": [
|
|
137
130
|
"readonly",
|
|
138
131
|
"write-tsbuildinfo",
|
|
132
|
+
"write-dts",
|
|
139
133
|
"write-references"
|
|
140
134
|
],
|
|
141
|
-
"description": "`readonly` keeps all emitted files in memory, `write-tsbuildinfo` which writes only .tsbuildinfo files and `write-references` which writes both .tsbuildinfo and referenced projects output"
|
|
135
|
+
"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"
|
|
142
136
|
},
|
|
143
137
|
"compilerOptions": {
|
|
144
138
|
"type": "object",
|
|
@@ -225,35 +219,6 @@
|
|
|
225
219
|
"$ref": "#/definitions/IssuePredicateOption"
|
|
226
220
|
}
|
|
227
221
|
}
|
|
228
|
-
},
|
|
229
|
-
"LoggerOptions": {
|
|
230
|
-
"type": "object",
|
|
231
|
-
"properties": {
|
|
232
|
-
"infrastructure": {
|
|
233
|
-
"oneOf": [
|
|
234
|
-
{
|
|
235
|
-
"$ref": "#/definitions/LoggerType"
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
"$ref": "#/definitions/Logger"
|
|
239
|
-
}
|
|
240
|
-
]
|
|
241
|
-
},
|
|
242
|
-
"issues": {
|
|
243
|
-
"oneOf": [
|
|
244
|
-
{
|
|
245
|
-
"$ref": "#/definitions/LoggerType"
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
"$ref": "#/definitions/Logger"
|
|
249
|
-
}
|
|
250
|
-
]
|
|
251
|
-
},
|
|
252
|
-
"devServer": {
|
|
253
|
-
"type": "boolean",
|
|
254
|
-
"description": "Enable reporting to Webpack Dev Server."
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
222
|
}
|
|
258
223
|
}
|
|
259
224
|
}
|
package/lib/plugin-pools.js
CHANGED
|
@@ -22,7 +22,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
22
22
|
exports.dependenciesPool = exports.issuesPool = void 0;
|
|
23
23
|
const os = __importStar(require("os"));
|
|
24
24
|
const pool_1 = require("./utils/async/pool");
|
|
25
|
-
const issuesPool = pool_1.createPool(Math.max(1, os.cpus().length));
|
|
25
|
+
const issuesPool = (0, pool_1.createPool)(Math.max(1, os.cpus().length));
|
|
26
26
|
exports.issuesPool = issuesPool;
|
|
27
|
-
const dependenciesPool = pool_1.createPool(Math.max(1, os.cpus().length));
|
|
27
|
+
const dependenciesPool = (0, pool_1.createPool)(Math.max(1, os.cpus().length));
|
|
28
28
|
exports.dependenciesPool = dependenciesPool;
|
package/lib/plugin.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ declare class ForkTsCheckerWebpackPlugin {
|
|
|
20
20
|
start: import("tapable").AsyncSeriesWaterfallHook<[import("./files-change").FilesChange, webpack.Compilation], import("tapable").UnsetAdditionalOptions>;
|
|
21
21
|
waiting: import("tapable").SyncHook<[webpack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
|
|
22
22
|
canceled: import("tapable").SyncHook<[webpack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
|
|
23
|
-
error: import("tapable").SyncHook<[
|
|
23
|
+
error: import("tapable").SyncHook<[unknown, webpack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
|
|
24
24
|
issues: import("tapable").SyncWaterfallHook<[import("./issue/issue").Issue[], webpack.Compilation | undefined], void>;
|
|
25
25
|
};
|
|
26
26
|
apply(compiler: webpack.Compiler): void;
|