"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "packages/angular_devkit/build_angular/src/webpack/utils/stats.ts" between
angular-cli-12.0.3.tar.gz and angular-cli-12.0.4.tar.gz

About: Angular CLI is a command line interface for Angular.

stats.ts  (angular-cli-12.0.3):stats.ts  (angular-cli-12.0.4)
skipping to change at line 14 skipping to change at line 14
* *
* Use of this source code is governed by an MIT-style license that can be * Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import { WebpackLoggingCallback } from '@angular-devkit/build-webpack'; import { WebpackLoggingCallback } from '@angular-devkit/build-webpack';
import { logging, tags } from '@angular-devkit/core'; import { logging, tags } from '@angular-devkit/core';
import * as path from 'path'; import * as path from 'path';
import * as textTable from 'text-table'; import * as textTable from 'text-table';
import { Configuration, StatsCompilation } from 'webpack'; import { Configuration, StatsCompilation } from 'webpack';
import { Schema as BrowserBuilderOptions } from '../../browser/schema';
import { colors as ansiColors, removeColor } from '../../utils/color'; import { colors as ansiColors, removeColor } from '../../utils/color';
import { getWebpackStatsConfig } from '../configs/stats'; import { getWebpackStatsConfig } from '../configs/stats';
import { markAsyncChunksNonInitial } from './async-chunks';
import { normalizeExtraEntryPoints } from './helpers';
export function formatSize(size: number): string { export function formatSize(size: number): string {
if (size <= 0) { if (size <= 0) {
return '0 bytes'; return '0 bytes';
} }
const abbreviations = ['bytes', 'kB', 'MB', 'GB']; const abbreviations = ['bytes', 'kB', 'MB', 'GB'];
const index = Math.floor(Math.log(size) / Math.log(1024)); const index = Math.floor(Math.log(size) / Math.log(1024));
const roundedSize = size / Math.pow(1024, index); const roundedSize = size / Math.pow(1024, index);
// bytes don't have a fraction // bytes don't have a fraction
skipping to change at line 45 skipping to change at line 48
export interface BundleStats { export interface BundleStats {
initial: boolean; initial: boolean;
stats: BundleStatsData; stats: BundleStatsData;
chunkType: ChunkType; chunkType: ChunkType;
} }
export function generateBundleStats(info: { export function generateBundleStats(info: {
size?: number; size?: number;
files?: string[]; files?: string[];
names?: string[]; names?: string[];
entry?: boolean;
initial?: boolean; initial?: boolean;
rendered?: boolean; rendered?: boolean;
chunkType?: ChunkType; chunkType?: ChunkType;
}): BundleStats { }): BundleStats {
const size = typeof info.size === 'number' ? info.size : '-'; const size = typeof info.size === 'number' ? info.size : '-';
const files = const files =
info.files info.files
?.filter((f) => !f.endsWith('.map')) ?.filter((f) => !f.endsWith('.map'))
.map((f) => path.basename(f)) .map((f) => path.basename(f))
.join(', ') ?? ''; .join(', ') ?? '';
const names = info.names?.length ? info.names.join(', ') : '-'; const names = info.names?.length ? info.names.join(', ') : '-';
const initial = !!(info.entry || info.initial); const initial = !!info.initial;
const chunkType = info.chunkType || 'unknown'; const chunkType = info.chunkType || 'unknown';
return { return {
chunkType, chunkType,
initial, initial,
stats: [files, names, size], stats: [files, names, size],
}; };
} }
function generateBuildStatsTable( function generateBuildStatsTable(
skipping to change at line 328 skipping to change at line 330
export function statsHasErrors(json: StatsCompilation): boolean { export function statsHasErrors(json: StatsCompilation): boolean {
return !!(json.errors?.length || json.children?.some((c) => c.errors?.length)) ; return !!(json.errors?.length || json.children?.some((c) => c.errors?.length)) ;
} }
export function statsHasWarnings(json: StatsCompilation): boolean { export function statsHasWarnings(json: StatsCompilation): boolean {
return !!(json.warnings?.length || json.children?.some((c) => c.warnings?.leng th)); return !!(json.warnings?.length || json.children?.some((c) => c.warnings?.leng th));
} }
export function createWebpackLoggingCallback( export function createWebpackLoggingCallback(
verbose: boolean, options: BrowserBuilderOptions,
logger: logging.LoggerApi, logger: logging.LoggerApi,
): WebpackLoggingCallback { ): WebpackLoggingCallback {
const { verbose = false, scripts = [], styles = [] } = options;
const extraEntryPoints = [
...normalizeExtraEntryPoints(styles, 'styles'),
...normalizeExtraEntryPoints(scripts, 'scripts'),
];
return (stats, config) => { return (stats, config) => {
if (verbose) { if (verbose) {
logger.info(stats.toString(config.stats)); logger.info(stats.toString(config.stats));
} }
webpackStatsLogger(logger, stats.toJson(getWebpackStatsConfig(false)), confi const rawStats = stats.toJson(getWebpackStatsConfig(false));
g); const webpackStats = {
...rawStats,
chunks: markAsyncChunksNonInitial(rawStats, extraEntryPoints),
};
webpackStatsLogger(logger, webpackStats, config);
}; };
} }
export function webpackStatsLogger( export function webpackStatsLogger(
logger: logging.LoggerApi, logger: logging.LoggerApi,
json: StatsCompilation, json: StatsCompilation,
config: Configuration, config: Configuration,
bundleStats?: BundleStats[], bundleStats?: BundleStats[],
): void { ): void {
logger.info(statsToString(json, config.stats, bundleStats)); logger.info(statsToString(json, config.stats, bundleStats));
 End of changes. 7 change blocks. 
5 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)