Skip to content

Commit 52c5110

Browse files
feat: add option to disable reporting to Webpack Dev Server (#496)
1 parent 83bc29c commit 52c5110

File tree

5 files changed

+20
-9
lines changed

5 files changed

+20
-9
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,14 @@ you can place your configuration in the:
143143

144144
Options passed to the plugin constructor will overwrite options from the cosmiconfig (using [deepmerge](https://github.com/TehShrike/deepmerge)).
145145

146-
| Name | Type | Default value | Description |
147-
| ----------------- | --------------------- | ------------------------------------------------ | ----------- |
148-
| `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. |
149-
| `typescript` | `object` or `boolean` | `true` | If a `boolean`, it enables/disables TypeScript checker. If an `object`, see [TypeScript options](#typescript-options). |
150-
| `eslint` | `object` | `undefined` | If `undefined`, it disables ESLint linter. If an `object`, see [ESLint options](#eslint-options). |
151-
| `issue` | `object` | `{}` | See [Issues options](#issues-options). |
152-
| `formatter` | `string` or `object` | `codeframe` | Available formatters are `basic` and `codeframe`. To [configure](https://babeljs.io/docs/en/babel-code-frame#options) `codeframe` formatter, pass object: `{ type: 'codeframe', options: { <coderame options> } }`. |
153-
| `logger` | `object` | `{ infrastructure: 'silent', issues: 'console' }` | Available loggers are `silent`, `console`, and `webpack-infrastructure`. Infrastructure logger prints additional information, issue logger prints `issues` in the `async` mode. |
146+
| Name | Type | Default value | Description |
147+
| ----------------- | --------------------- | ------------------------------------------------------------------ | ----------- |
148+
| `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. |
149+
| `typescript` | `object` or `boolean` | `true` | If a `boolean`, it enables/disables TypeScript checker. If an `object`, see [TypeScript options](#typescript-options). |
150+
| `eslint` | `object` | `undefined` | If `undefined`, it disables ESLint linter. If an `object`, see [ESLint options](#eslint-options). |
151+
| `issue` | `object` | `{}` | See [Issues options](#issues-options). |
152+
| `formatter` | `string` or `object` | `codeframe` | Available formatters are `basic` and `codeframe`. To [configure](https://babeljs.io/docs/en/babel-code-frame#options) `codeframe` formatter, pass object: `{ type: 'codeframe', options: { <coderame options> } }`. |
153+
| `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. |
154154

155155
### TypeScript options
156156

src/ForkTsCheckerWebpackPluginOptions.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,10 @@
287287
"$ref": "#/definitions/Logger"
288288
}
289289
]
290+
},
291+
"devServer": {
292+
"type": "boolean",
293+
"description": "Enable reporting to Webpack Dev Server."
290294
}
291295
}
292296
}

src/hooks/interceptDoneToGetWebpackDevServerTap.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ function interceptDoneToGetWebpackDevServerTap(
1010
// inspired by https://github.com/ypresto/fork-ts-checker-async-overlay-webpack-plugin
1111
compiler.hooks.done.intercept({
1212
register: (tap) => {
13-
if (tap.name === 'webpack-dev-server' && tap.type === 'sync') {
13+
if (
14+
tap.name === 'webpack-dev-server' &&
15+
tap.type === 'sync' &&
16+
configuration.logger.devServer
17+
) {
1418
state.webpackDevServerDoneTap = tap;
1519
}
1620
return tap;

src/logger/LoggerConfiguration.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { createLogger } from './LoggerFactory';
66
interface LoggerConfiguration {
77
infrastructure: Logger;
88
issues: Logger;
9+
devServer: boolean;
910
}
1011

1112
function createLoggerConfiguration(
@@ -15,6 +16,7 @@ function createLoggerConfiguration(
1516
return {
1617
infrastructure: createLogger((options && options.infrastructure) || 'silent', compiler),
1718
issues: createLogger((options && options.issues) || 'console', compiler),
19+
devServer: options?.devServer !== false,
1820
};
1921
}
2022

src/logger/LoggerOptions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Logger from './Logger';
44
type LoggerOptions = {
55
infrastructure?: LoggerType | Logger;
66
issues?: LoggerType | Logger;
7+
devServer?: boolean;
78
};
89

910
export default LoggerOptions;

0 commit comments

Comments
 (0)