mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-16 10:33:43 +08:00
perf(@angular-devkit/build-angular): remove Webpack Stats.toJson usage in karma plugin
Webpack's `Stats.toJson` function is an expensive operation and is recommended to be avoided where possible. In the case of the karma plugin, the compilation errors can be accessed directly without the need for the function call.
This commit is contained in:
parent
3affd28f5e
commit
699b641b85
@ -167,7 +167,7 @@ const init: any = (config: any, emitter: any) => {
|
||||
webpackConfig.output.path = `/${KARMA_APPLICATION_PATH}/`;
|
||||
webpackConfig.output.publicPath = `/${KARMA_APPLICATION_PATH}/`;
|
||||
|
||||
let compiler: any;
|
||||
let compiler;
|
||||
try {
|
||||
compiler = webpack(webpackConfig);
|
||||
} catch (e) {
|
||||
@ -200,11 +200,10 @@ const init: any = (config: any, emitter: any) => {
|
||||
|
||||
let lastCompilationHash: string | undefined;
|
||||
const statsConfig = getWebpackStatsConfig();
|
||||
compiler.hooks.done.tap('karma', (stats: any) => {
|
||||
if (stats.compilation.errors.length > 0) {
|
||||
const json = stats.toJson(config.stats);
|
||||
compiler.hooks.done.tap('karma', (stats) => {
|
||||
if (stats.hasErrors()) {
|
||||
// Print compilation errors.
|
||||
logger.error(statsErrorsToString(json, statsConfig));
|
||||
logger.error(statsErrorsToString(stats.compilation, statsConfig));
|
||||
lastCompilationHash = undefined;
|
||||
// Emit a failure build event if there are compilation errors.
|
||||
failureCb();
|
||||
|
Loading…
x
Reference in New Issue
Block a user