
Astro 7.4
Astro 7.4 is here! The headline feature is a new --timings flag for astro build that shows exactly where your build spends its time. This release also lets you use different image services for prerendered and on-demand …
以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。
Astro 7.4 is here! The headline feature is a new --timings flag for astro build that shows exactly where your build spends its time. This release also lets you use different image services for prerendered and on-demand pages, adds a notFound() handler for custom entrypoints, and warns you about font settings your provider can’t serve. Two new experimental features round it out: parallel prerendering across worker threads and a custom redirect page for static builds.
To upgrade an existing project, use the automated @astrojs/upgrade CLI tool. Alternatively, upgrade manually by running the upgrade command for your package manager:
Recommended:
npx @astrojs/upgrade
Manual:
npm install astro@latest
pnpm upgrade astro --latest
yarn upgrade astro --latest
Build timings
When a build gets slow, it’s not always obvious why. Is it a Vite plugin, syntax highlighting, image processing, or rendering one particularly heavy page?
astro build now accepts a --timings flag:
astro build --timings
When the build finishes, Astro prints a summary of where the time went: build phases, Vite plugins, Markdown processing and syntax highlighting, page rendering, images, and integrations.
Here’s what that looks like in practice. We took the blog starter and added a <CommentSection> component to its blog post layout. It fetches a post’s comments, and each <Comment> inside it then fetches the commenter’s profile:
const { comment } = Astro.props;
// Look up the commenter's profile for every comment
const res = await fetch(https://jsonplaceholder.typicode.com/users?email=${comment.email});
const [user] = await res.json();
<article>
<strong>{user?.name ?? comment.name}</strong>
<p>{comment.body}</p> </article> {user?.name ?? comment.name} {comment.body}
正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。