Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(@ngtools/webpack): consolidate diagnostic helper functions #21294

Merged
merged 1 commit into from
Jul 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/ngtools/webpack/src/ivy/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

import { Diagnostics, formatDiagnostics } from '@angular/compiler-cli';
import { DiagnosticCategory } from 'typescript';
import { Compilation } from 'webpack';
import { addError, addWarning } from '../webpack-diagnostics';
import type { Compilation } from 'webpack';

export type DiagnosticsReporter = (diagnostics: Diagnostics) => void;

Expand All @@ -25,3 +24,11 @@ export function createDiagnosticsReporter(compilation: Compilation): Diagnostics
}
};
}

export function addWarning(compilation: Compilation, message: string): void {
compilation.warnings.push(new compilation.compiler.webpack.WebpackError(message));
}

export function addError(compilation: Compilation, message: string): void {
compilation.errors.push(new compilation.compiler.webpack.WebpackError(message));
}
8 changes: 6 additions & 2 deletions packages/ngtools/webpack/src/ivy/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ import type { Compilation, Compiler, Module, NormalModule } from 'webpack';
import { NgccProcessor } from '../ngcc_processor';
import { TypeScriptPathsPlugin } from '../paths-plugin';
import { WebpackResourceLoader } from '../resource_loader';
import { addError, addWarning } from '../webpack-diagnostics';
import { SourceFileCache } from './cache';
import { DiagnosticsReporter, createDiagnosticsReporter } from './diagnostics';
import {
DiagnosticsReporter,
addError,
addWarning,
createDiagnosticsReporter,
} from './diagnostics';
import {
augmentHostWithCaching,
augmentHostWithDependencyCollection,
Expand Down
17 changes: 0 additions & 17 deletions packages/ngtools/webpack/src/webpack-diagnostics.ts

This file was deleted.