UNPKG

1.29 kBJavaScriptView Raw
1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.addError = exports.addWarning = exports.createDiagnosticsReporter = void 0;
11const compiler_cli_1 = require("@angular/compiler-cli");
12const typescript_1 = require("typescript");
13function createDiagnosticsReporter(compilation) {
14 return (diagnostics) => {
15 for (const diagnostic of diagnostics) {
16 const text = compiler_cli_1.formatDiagnostics([diagnostic]);
17 if (diagnostic.category === typescript_1.DiagnosticCategory.Error) {
18 addError(compilation, text);
19 }
20 else {
21 addWarning(compilation, text);
22 }
23 }
24 };
25}
26exports.createDiagnosticsReporter = createDiagnosticsReporter;
27function addWarning(compilation, message) {
28 compilation.warnings.push(new compilation.compiler.webpack.WebpackError(message));
29}
30exports.addWarning = addWarning;
31function addError(compilation, message) {
32 compilation.errors.push(new compilation.compiler.webpack.WebpackError(message));
33}
34exports.addError = addError;