-
Notifications
You must be signed in to change notification settings - Fork 12k
/
Copy pathwebpack-diagnostics.ts
31 lines (28 loc) · 1.04 KB
/
webpack-diagnostics.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import * as webpack from 'webpack';
import { isWebpackFiveOrHigher } from './webpack-version';
const WebpackError = require('webpack/lib/WebpackError');
export function addWarning(compilation: webpack.compilation.Compilation, message: string): void {
if (isWebpackFiveOrHigher()) {
compilation.warnings.push(new WebpackError(message));
} else {
// Allows building with either Webpack 4 or 5+ types
// tslint:disable-next-line: no-any
compilation.warnings.push(message as any);
}
}
export function addError(compilation: webpack.compilation.Compilation, message: string): void {
if (isWebpackFiveOrHigher()) {
compilation.errors.push(new WebpackError(message));
} else {
// Allows building with either Webpack 4 or 5+ types
// tslint:disable-next-line: no-any
compilation.errors.push(new Error(message) as any);
}
}