fork-ts-checker-webpack-plugin 7.0.0-alpha.12 → 7.0.0-alpha.13

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 CHANGED
@@ -85,13 +85,14 @@ you can place your configuration in the:
85
85
 
86
86
  Options passed to the plugin constructor will overwrite options from the cosmiconfig (using [deepmerge](https://github.com/TehShrike/deepmerge)).
87
87
 
88
- | Name | Type | Default value | Description |
89
- | ----------------- | ---------------------------------- | ------------------------------------------------------------------ | ----------- |
90
- | `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. |
91
- | `typescript` | `object` | `{}` | See [TypeScript options](#typescript-options). |
92
- | `issue` | `object` | `{}` | See [Issues options](#issues-options). |
93
- | `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> } }`. |
94
- | `logger` | `object` | `{ infrastructure: 'silent', issues: 'console', devServer: true }` | Available loggers are `silent`, `console`, and `webpack-infrastructure`. Infrastructure logger prints additional information, issue logger prints `issues` in the `async` mode. If `devServer` is set to `false`, errors will not be reported to Webpack Dev Server. |
88
+ | Name | Type | Default value | Description |
89
+ | ----------------- | ------------------------------------ | ----------------------------------------- | ----------- |
90
+ | `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. |
91
+ | `typescript` | `object` | `{}` | See [TypeScript options](#typescript-options). |
92
+ | `issue` | `object` | `{}` | See [Issues options](#issues-options). |
93
+ | `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> } }`. |
94
+ | `logger` | `{ log: function, error: function }` | `console` | Console-like object to print issues in `async` mode. |
95
+ | `devServer` | `boolean` | `true` | If set to `false`, errors will not be reported to Webpack Dev Server. |
95
96
 
96
97
  ### TypeScript options
97
98
 
@@ -105,7 +106,7 @@ Options for the TypeScript checker (`typescript` option object).
105
106
  | `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
107
  | `build` | `boolean` | `false` | The equivalent of the `--build` flag for the `tsc` command. |
107
108
  | `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` | `object` | `{ syntactic: false, semantic: true, declaration: false, global: false }` | Settings to select which diagnostics do we want to perform. |
109
+ | `diagnosticOptions` | `object` | `{ syntactic: false, semantic: true, declaration: false, global: false }` | Settings to select which diagnostics do we want to perform. |
109
110
  | `extensions` | `object` | `{}` | See [TypeScript extensions options](#typescript-extensions-options). |
110
111
  | `profile` | `boolean` | `false` | Measures and prints timings related to the TypeScript performance. |
111
112
  | `typescriptPath` | `string` | `require.resolve('typescript')` | If supplied this is a custom path where TypeScript can be found. |
@@ -7,7 +7,7 @@ function interceptDoneToGetDevServerTap(compiler, config, state) {
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.logger.devServer) {
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
  }
@@ -33,7 +33,7 @@ function tapDoneToAsyncGetIssues(compiler, config, state) {
33
33
  try {
34
34
  if (yield is_pending_1.isPending(issuesPromise)) {
35
35
  hooks.waiting.call(stats.compilation);
36
- config.logger.issues.log(chalk_1.default.cyan('Issues checking in progress...'));
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
@@ -57,10 +57,10 @@ function tapDoneToAsyncGetIssues(compiler, config, state) {
57
57
  const formatter = 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.issues.error(issues.map((issue) => formatter(issue)).join('\n'));
60
+ config.logger.error(issues.map((issue) => formatter(issue)).join('\n'));
61
61
  }
62
62
  else {
63
- config.logger.issues.log(chalk_1.default.green('No issues found.'));
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
@@ -10,15 +10,15 @@ const rpc_1 = require("../rpc");
10
10
  function tapErrorToLogMessage(compiler, config) {
11
11
  const hooks = plugin_hooks_1.getPluginHooks(compiler);
12
12
  hooks.error.tap('ForkTsCheckerWebpackPlugin', (error) => {
13
- config.logger.issues.error(String(error));
13
+ config.logger.error(String(error));
14
14
  if (error instanceof rpc_1.RpcExitError) {
15
15
  if (error.signal === 'SIGINT') {
16
- config.logger.issues.error(chalk_1.default.red('Issues checking service interrupted - If running in a docker container, this may be caused ' +
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.issues.error(chalk_1.default.red('Issues checking service aborted - probably out of memory. ' +
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
  }
@@ -1,6 +1,5 @@
1
1
  interface Logger {
2
- info: (message: string) => void;
3
2
  log: (message: string) => void;
4
3
  error: (message: string) => void;
5
4
  }
6
- export default Logger;
5
+ export { Logger };
File without changes
@@ -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 { LoggerConfig } from './logger/logger-config';
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: LoggerConfig;
12
+ logger: Logger;
13
+ devServer: boolean;
13
14
  }
14
15
  declare function createPluginConfig(compiler: webpack.Compiler, options?: ForkTsCheckerWebpackPluginOptions): ForkTsCheckerWebpackPluginConfig;
15
16
  export { ForkTsCheckerWebpackPluginConfig, createPluginConfig };
@@ -3,7 +3,6 @@ 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 {
@@ -11,7 +10,8 @@ function createPluginConfig(compiler, options = {}) {
11
10
  typescript: type_script_worker_config_1.createTypeScriptWorkerConfig(compiler, options.typescript),
12
11
  issue: issue_config_1.createIssueConfig(compiler, options.issue),
13
12
  formatter: formatter_1.createFormatterConfig(options.formatter),
14
- logger: logger_config_1.createLoggerConfig(compiler, options.logger),
13
+ logger: options.logger || console,
14
+ devServer: options.devServer !== false,
15
15
  };
16
16
  }
17
17
  exports.createPluginConfig = createPluginConfig;
@@ -1,12 +1,13 @@
1
1
  import type { FormatterOptions } from './formatter';
2
2
  import type { IssueOptions } from './issue/issue-options';
3
- import type LoggerOptions from './logger/logger-options';
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?: LoggerOptions;
10
+ logger?: Logger;
11
+ devServer?: boolean;
11
12
  }
12
13
  export { ForkTsCheckerWebpackPluginOptions };
@@ -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/TypeScriptReporterOptions"
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/LoggerOptions"
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
- "TypeScriptReporterOptions": {
108
+ "TypeScriptOptions": {
116
109
  "type": "object",
117
110
  "properties": {
118
111
  "memoryLimit": {
@@ -225,35 +218,6 @@
225
218
  "$ref": "#/definitions/IssuePredicateOption"
226
219
  }
227
220
  }
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
221
  }
258
222
  }
259
223
  }
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.0.0-alpha.12'; // will be replaced by the @semantic-release/exec
73
+ ForkTsCheckerWebpackPlugin.version = '7.0.0-alpha.13'; // 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.0.0-alpha.12",
3
+ "version": "7.0.0-alpha.13",
4
4
  "description": "Runs typescript type checker and linter on separate process.",
5
5
  "keywords": [
6
6
  "fast",
@@ -1,10 +0,0 @@
1
- import type webpack from 'webpack';
2
- import type Logger from './logger';
3
- import type LoggerOptions from './logger-options';
4
- interface LoggerConfig {
5
- infrastructure: Logger;
6
- issues: Logger;
7
- devServer: boolean;
8
- }
9
- declare function createLoggerConfig(compiler: webpack.Compiler, options: LoggerOptions | undefined): LoggerConfig;
10
- export { LoggerConfig, createLoggerConfig };
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createLoggerConfig = void 0;
4
- const logger_factory_1 = require("./logger-factory");
5
- function createLoggerConfig(compiler, options) {
6
- return {
7
- infrastructure: logger_factory_1.createLogger((options && options.infrastructure) || 'webpack-infrastructure', compiler),
8
- issues: logger_factory_1.createLogger((options && options.issues) || 'console', compiler),
9
- devServer: (options === null || options === void 0 ? void 0 : options.devServer) !== false,
10
- };
11
- }
12
- exports.createLoggerConfig = createLoggerConfig;
@@ -1,5 +0,0 @@
1
- import type webpack from 'webpack';
2
- import type Logger from './logger';
3
- declare type LoggerType = 'console' | 'webpack-infrastructure' | 'silent';
4
- declare function createLogger(type: LoggerType | Logger, compiler: webpack.Compiler): Logger;
5
- export { createLogger, LoggerType };
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createLogger = void 0;
4
- const partial_logger_1 = require("./partial-logger");
5
- const webpack_infrastructure_logger_1 = require("./webpack-infrastructure-logger");
6
- function createLogger(type, compiler) {
7
- if (typeof type !== 'string') {
8
- return type;
9
- }
10
- switch (type) {
11
- case 'webpack-infrastructure':
12
- return (webpack_infrastructure_logger_1.createWebpackInfrastructureLogger(compiler) ||
13
- partial_logger_1.createPartialLogger(['log', 'error'], console));
14
- case 'silent':
15
- return partial_logger_1.createPartialLogger([], console);
16
- case 'console':
17
- default:
18
- return console;
19
- }
20
- }
21
- exports.createLogger = createLogger;
@@ -1,8 +0,0 @@
1
- import type Logger from './logger';
2
- import type { LoggerType } from './logger-factory';
3
- declare type LoggerOptions = {
4
- infrastructure?: LoggerType | Logger;
5
- issues?: LoggerType | Logger;
6
- devServer?: boolean;
7
- };
8
- export default LoggerOptions;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +0,0 @@
1
- import type Logger from './logger';
2
- declare type LoggerMethods = 'info' | 'log' | 'error';
3
- declare function createPartialLogger(methods: LoggerMethods[], logger: Logger): Logger;
4
- export { createPartialLogger };
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createPartialLogger = void 0;
4
- function createPartialLogger(methods, logger) {
5
- return {
6
- info: (message) => (methods.includes('info') ? logger.info(message) : undefined),
7
- log: (message) => (methods.includes('log') ? logger.log(message) : undefined),
8
- error: (message) => (methods.includes('error') ? logger.error(message) : undefined),
9
- };
10
- }
11
- exports.createPartialLogger = createPartialLogger;
@@ -1,4 +0,0 @@
1
- import type webpack from 'webpack';
2
- import type Logger from './logger';
3
- declare function createWebpackInfrastructureLogger(compiler: webpack.Compiler): Logger | undefined;
4
- export { createWebpackInfrastructureLogger };
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createWebpackInfrastructureLogger = void 0;
4
- function isInfrastructureLoggerProvider(candidate) {
5
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
- return !!candidate.getInfrastructureLogger;
7
- }
8
- function createWebpackInfrastructureLogger(compiler) {
9
- return isInfrastructureLoggerProvider(compiler)
10
- ? compiler.getInfrastructureLogger('ForkTsCheckerWebpackPlugin')
11
- : undefined;
12
- }
13
- exports.createWebpackInfrastructureLogger = createWebpackInfrastructureLogger;