-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Small build performance improvement #12760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for astro-docs-2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
ArmandPhilippot
left a comment
There was a problem hiding this 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 = { |
There was a problem hiding this comment.
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.
Description (required)
This PR optimizes how we access some remote data during builds to speed them up.
Before: each
<Version>and<Since>component call acachedFetch()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 ourcachedFetch()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!