Skip to content

Commit

Permalink
fix(@angular/build): exclude unmodified files from logs with `--local…
Browse files Browse the repository at this point in the history
…ize`

Ensures that only modified files are displayed in logs when using the `--localize` flag, preventing unnecessary noise.

Closes #29586
  • Loading branch information
alan-agius4 committed Feb 10, 2025
1 parent dca408b commit 880a50c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,6 @@ export async function executeBuild(

executionResult.outputFiles.push(...outputFiles);

const changedFiles =
rebuildState && executionResult.findChangedFiles(rebuildState.previousOutputInfo);

// Analyze files for bundle budget failures if present
let budgetFailures: BudgetCalculatorResult[] | undefined;
if (options.budgets) {
Expand Down Expand Up @@ -288,6 +285,8 @@ export async function executeBuild(
}

if (!jsonLogs) {
const changedFiles =
rebuildState && executionResult.findChangedFiles(rebuildState.previousOutputInfo);
executionResult.addLog(
logBuildStats(
metafile,
Expand Down
7 changes: 6 additions & 1 deletion packages/angular/build/src/tools/esbuild/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ export function logBuildStats(
ssrOutputEnabled?: boolean,
verbose?: boolean,
): string {
// Remove the i18n subpath in case the build is using i18n.
// en-US/main.js -> main.js
const normalizedChangedFiles: Set<string> = new Set(
[...(changedFiles ?? [])].map((f) => basename(f)),
);
const browserStats: BundleStats[] = [];
const serverStats: BundleStats[] = [];
let unchangedCount = 0;
Expand All @@ -52,7 +57,7 @@ export function logBuildStats(
}

// Show only changed files if a changed list is provided
if (changedFiles && !changedFiles.has(file)) {
if (normalizedChangedFiles.size && !normalizedChangedFiles.has(file)) {
++unchangedCount;
continue;
}
Expand Down

0 comments on commit 880a50c

Please sign in to comment.