Skip to content

Commit

Permalink
feat(@ngtools/webpack): redirect ngcc errors and warnings to webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-agius4 authored and alexeagle committed Apr 5, 2019
1 parent f9b4bdf commit 801f667
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/ngtools/webpack/src/angular_compiler_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,8 @@ export class AngularCompilerPlugin {
ngcc,
this._mainFields,
compilerWithFileSystems.inputFileSystem,
this._warnings,
this._errors,
);
}
}
Expand Down
27 changes: 27 additions & 0 deletions packages/ngtools/webpack/src/ngcc_processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

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

private _logger: NgccLogger;

constructor(
private readonly ngcc: typeof import('@angular/compiler-cli/ngcc'),
private readonly propertiesToConsider: string[],
private readonly inputFileSystem: InputFileSystem,
private readonly compilationWarnings: (Error | string)[],
private readonly compilationErrors: (Error | string)[],
) {
this._logger = new NgccLogger(this.compilationWarnings, this.compilationErrors);
}

processModule(
Expand Down Expand Up @@ -61,6 +67,7 @@ export class NgccProcessor {
propertiesToConsider: this.propertiesToConsider,
compileAllFormats: false,
createNewEntryPointFormats: true,
logger: this._logger,
});
timeEnd(timeLabel);

Expand Down Expand Up @@ -95,3 +102,23 @@ export class NgccProcessor {
}
}
}

class NgccLogger implements Logger {
constructor(
private readonly compilationWarnings: (Error | string)[],
private readonly compilationErrors: (Error | string)[],
) {
}

debug(..._args: string[]) { }

info(..._args: string[]) { }

warn(...args: string[]) {
this.compilationWarnings.push(args.join(' '));
}

error(...args: string[]) {
this.compilationErrors.push(new Error(args.join(' ')));
}
}

0 comments on commit 801f667

Please sign in to comment.