Skip to content

Commit 801f667

Browse files
alan-agius4alexeagle
authored andcommitted
feat(@ngtools/webpack): redirect ngcc errors and warnings to webpack
1 parent f9b4bdf commit 801f667

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

packages/ngtools/webpack/src/angular_compiler_plugin.ts

+2
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,8 @@ export class AngularCompilerPlugin {
679679
ngcc,
680680
this._mainFields,
681681
compilerWithFileSystems.inputFileSystem,
682+
this._warnings,
683+
this._errors,
682684
);
683685
}
684686
}

packages/ngtools/webpack/src/ngcc_processor.ts

+27
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9+
import { Logger } from '@angular/compiler-cli/ngcc';
910
import * as ts from 'typescript';
1011
import { InputFileSystem } from 'webpack';
1112
import { time, timeEnd } from './benchmark';
@@ -24,11 +25,16 @@ import { workaroundResolve } from './utils';
2425
export class NgccProcessor {
2526
private _processedModules = new Set<string>();
2627

28+
private _logger: NgccLogger;
29+
2730
constructor(
2831
private readonly ngcc: typeof import('@angular/compiler-cli/ngcc'),
2932
private readonly propertiesToConsider: string[],
3033
private readonly inputFileSystem: InputFileSystem,
34+
private readonly compilationWarnings: (Error | string)[],
35+
private readonly compilationErrors: (Error | string)[],
3136
) {
37+
this._logger = new NgccLogger(this.compilationWarnings, this.compilationErrors);
3238
}
3339

3440
processModule(
@@ -61,6 +67,7 @@ export class NgccProcessor {
6167
propertiesToConsider: this.propertiesToConsider,
6268
compileAllFormats: false,
6369
createNewEntryPointFormats: true,
70+
logger: this._logger,
6471
});
6572
timeEnd(timeLabel);
6673

@@ -95,3 +102,23 @@ export class NgccProcessor {
95102
}
96103
}
97104
}
105+
106+
class NgccLogger implements Logger {
107+
constructor(
108+
private readonly compilationWarnings: (Error | string)[],
109+
private readonly compilationErrors: (Error | string)[],
110+
) {
111+
}
112+
113+
debug(..._args: string[]) { }
114+
115+
info(..._args: string[]) { }
116+
117+
warn(...args: string[]) {
118+
this.compilationWarnings.push(args.join(' '));
119+
}
120+
121+
error(...args: string[]) {
122+
this.compilationErrors.push(new Error(args.join(' ')));
123+
}
124+
}

0 commit comments

Comments
 (0)