Skip to content

Commit

Permalink
fix: logging build trace of pages
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Dec 5, 2023
1 parent 2f110a5 commit 0382896
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-cows-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fix logs of generated paths by component
21 changes: 9 additions & 12 deletions packages/astro/src/core/build/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,11 @@ async function generatePage(
// prepare information we need
const logger = pipeline.getLogger();
const config = pipeline.getConfig();
const manifest = pipeline.getManifest();
const pageModulePromise = ssrEntry.page;
const onRequest = ssrEntry.onRequest;
const pageInfo = getPageDataByComponent(pipeline.getInternals(), pageData.route.component);

// Calculate information of the page, like scripts, links and styles
const hoistedScripts = pageInfo?.hoistedScript ?? null;
const styles = pageData.styles
.sort(cssOrder)
.map(({ sheet }) => sheet)
Expand Down Expand Up @@ -294,6 +292,15 @@ async function generatePage(
};
// Now we explode the routes. A route render itself, and it can render its fallbacks (i18n routing)
for (const route of eachRouteInRouteData(pageData)) {
const icon =
route.type === 'page' || route.type === 'redirect' || route.type === 'fallback'
? green('▶')
: magenta('λ');
if (isRelativePath(route.component)) {
logger.info(null, `${icon} ${route.route}`);
} else {
logger.info(null, `${icon} ${route.component}`);
}
// Get paths for the route, calling getStaticPaths if needed.
const paths = await getPathsForRoute(route, pageModule, pipeline, builtPaths);
let timeStart = performance.now();
Expand Down Expand Up @@ -515,16 +522,6 @@ async function generatePath(
}
}

const icon =
route.type === 'page' || route.type === 'redirect' || route.type === 'fallback'
? green('▶')
: magenta('λ');
if (isRelativePath(route.component)) {
logger.info(null, `${icon} ${route.route}`);
} else {
logger.info(null, `${icon} ${route.component}`);
}

// This adds the page name to the array so it can be shown as part of stats.
if (route.type === 'page') {
addPageName(pathname, pipeline.getStaticBuildOptions());
Expand Down

0 comments on commit 0382896

Please sign in to comment.