Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ async function execute(
}
}

logBuildStats(context, metafile);
logBuildStats(context, metafile, initialFiles);

const buildTime = Number(process.hrtime.bigint() - startTime) / 10 ** 9;
context.logger.info(`Complete. [${buildTime.toFixed(3)} seconds]`);
Expand Down Expand Up @@ -727,11 +727,12 @@ export async function* buildEsbuildBrowser(

export default createBuilder(buildEsbuildBrowser);

function logBuildStats(context: BuilderContext, metafile: Metafile) {
function logBuildStats(context: BuilderContext, metafile: Metafile, initialFiles: FileInfo[]) {
const initial = new Map(initialFiles.map((info) => [info.file, info.name]));
const stats: BundleStats[] = [];
for (const [file, output] of Object.entries(metafile.outputs)) {
// Skip sourcemaps
if (file.endsWith('.map')) {
// Only display JavaScript and CSS files
if (!file.endsWith('.js') && !file.endsWith('.css')) {
continue;
}
// Skip internal component resources
Expand All @@ -741,8 +742,8 @@ function logBuildStats(context: BuilderContext, metafile: Metafile) {
}

stats.push({
initial: !!output.entryPoint,
stats: [file, '', output.bytes, ''],
initial: initial.has(file),
stats: [file, initial.get(file) ?? '', output.bytes, ''],
});
}

Expand Down
26 changes: 13 additions & 13 deletions packages/angular_devkit/build_angular/src/webpack/utils/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@ export function generateBuildStatsTable(
}
}

// Sort descending by raw size
data.sort((a, b) => {
if (a.stats[2] > b.stats[2]) {
return -1;
}

if (a.stats[2] < b.stats[2]) {
return 1;
}

return 0;
});

for (const { initial, stats } of data) {
const [files, names, rawSize, estimatedTransferSize] = stats;
const getRawSizeColor = getSizeColor(names, files);
Expand Down Expand Up @@ -274,19 +287,6 @@ function statsToString(

runsCache.add(json.outputPath || '');

// Sort chunks by size in descending order
changedChunksStats.sort((a, b) => {
if (a.stats[2] > b.stats[2]) {
return -1;
}

if (a.stats[2] < b.stats[2]) {
return 1;
}

return 0;
});

const statsTable = generateBuildStatsTable(
changedChunksStats,
colors,
Expand Down