Skip to content

Conversation

@delucis
Copy link
Member

@delucis delucis commented Nov 21, 2025

Description (required)

This PR optimizes how we access some remote data during builds to speed them up.

Before: each <Version> and <Since> component call a cachedFetch() function to request package metadata from the npm registry. This resulted in 16 requests for fairly large JSON files like https://registry.npmjs.org/astro/latest.

After: a content collection loads the same metadata using a single fetch() call using the https://npm.antfu.dev service (see https://github.com/antfu/fast-npm-meta). This single fetch returns data ~4x smaller than just one of the previous npm registry calls, so we use ~64x less bandwidth and avoid request overhead by only making one request instead of multiple.

While here, I also moved to use the same approach for the contributor data used in our <FacePile> component on the docs landing page. This meant I could remove our cachedFetch() utility and reduce our dependencies by 7 packages and 570 KB.

In some measurements on Netlify it looks like this might add up to a 15–20s saving in build times. Modest but still handy!

@netlify
Copy link

netlify bot commented Nov 21, 2025

Deploy Preview for astro-docs-2 ready!

Name Link
🔨 Latest commit 43d59e1
🔍 Latest deploy log https://app.netlify.com/projects/astro-docs-2/deploys/69209cd0a3b2c40008906799
😎 Deploy Preview https://deploy-preview-12760--astro-docs-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@delucis delucis changed the title Build perf investigation Small build performance improvement Nov 21, 2025
@delucis delucis marked this pull request as ready for review November 21, 2025 17:19
Copy link
Member

@ArmandPhilippot ArmandPhilippot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked different pages and couldn't spot any issues with our <Since /> component. I also tested the custom error locally out of curiosity. Well done, and nice saving! 🙌🏽

const { tagline, link, linkText } = Astro.props;
type Contributor = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we could now use CollectionEntry<"astroContributors">["data"] to avoid repeating the shape in two different places.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants