Skip to content

WIP: reduce build time#28970

Closed
MohamedH1998 wants to merge 3 commits intocloudflare:productionfrom
MohamedH1998:fix/sidebar-optms
Closed

WIP: reduce build time#28970
MohamedH1998 wants to merge 3 commits intocloudflare:productionfrom
MohamedH1998:fix/sidebar-optms

Conversation

@MohamedH1998
Copy link
Copy Markdown
Contributor

@MohamedH1998 MohamedH1998 commented Mar 13, 2026

Summary

Title: Optimize build: patch Starlight sidebar cloning (-14%)

Starlight deep-clones the full sidebar tree for every page (7,303x). Our Page.astro override replaces props.sidebar entirely, making this pure waste. Patching it out saves ~50s per build.

Changes:

  • patches/@astrojs+starlight+0.37.6.patch — skip structuredClone + setIntermediateSidebarCurrentEntry in getSidebarFromIntermediateSidebar
  • src/util/sidebar.ts — hoist flattenSidebar() out of O(n^2) loop
  • src/util/components.ts — scan-once caching for MDX file parsing
  • src/util/glossary.ts — collection caching with Map lookup, preserves original behavior

Benchmarks (cold builds):

Baseline Patched Delta
Run 1 (2 runs) 351.8s 302.7s -49.1s (-14.0%)
Run 2 (1 run) 396.8s 340.4s -56.4s (-14.2%)

For a detailed walkthrough and breakdown, read: investigation summary

Screenshots (optional)

Documentation checklist

  • Is there a changelog entry (guidelines)? If you don't add one for something awesome and new (however small) — how will our customers find out? Changelogs are automatically posted to RSS feeds, the Discord, and X.
  • The change adheres to the documentation style guide.
  • If a larger change - such as adding a new page- an issue has been opened in relation to any incorrect or out of date information that this PR fixes.
  • Files which have changed name or location have been allocated redirects.

@MohamedH1998
Copy link
Copy Markdown
Contributor Author

Resolved via: withastro/starlight#3761

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant