fix(#6965): fix build stats (#8122)

This commit is contained in:
Nate Moore 2023-08-17 15:34:36 -05:00 committed by GitHub
parent 442f946116
commit fa6b68a776
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Improve fidelity of time stats when running `astro build`

View file

@ -272,15 +272,17 @@ async function generatePage(
// Get paths for the route, calling getStaticPaths if needed.
const paths = await getPathsForRoute(pageData, pageModule, opts, builtPaths);
let prevTimeEnd = timeStart;
for (let i = 0; i < paths.length; i++) {
const path = paths[i];
await generatePath(path, opts, generationOptions, manifest, onRequest);
const timeEnd = performance.now();
const timeChange = getTimeStat(timeStart, timeEnd);
const timeChange = getTimeStat(prevTimeEnd, timeEnd);
const timeIncrease = `(+${timeChange})`;
const filePath = getOutputFilename(opts.settings.config, path, pageData.route.type);
const lineIcon = i === paths.length - 1 ? '└─' : '├─';
info(opts.logging, null, ` ${cyan(lineIcon)} ${dim(filePath)} ${dim(timeIncrease)}`);
prevTimeEnd = timeEnd;
}
}