Skip to content
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

fix: speed up build by ensuring stable cache #569

Merged
merged 7 commits into from
Oct 23, 2024
Merged

Conversation

dummdidumm
Copy link
Member

@dummdidumm dummdidumm commented Oct 23, 2024

Our builds got slower because the cache hash was always different. This happened because the dependencies were calculated based on the generated code after Vite compiled it, i.e. it would check stuff in .svelte-kit/output/server/chunks/...js. This seems to have worked fine for a while, but now Vite mashes things up such that code from svelte.dev/src/lib/server/content.ts is mixed in, which has loads of Vite hashes in it, and so the file content is always different. That in turn means our hash is always different, and so the snippet cache never hits.

The pragmatic solution is to hard-code the path to the original file and add a sanity check to ensure it's still accurate.

related to #307

Copy link

vercel bot commented Oct 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
kit-svelte-dev 🔄 Building (Inspect) Visit Preview 💬 Add feedback Oct 23, 2024 4:05pm
learn-svelte-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 23, 2024 4:05pm
omnisite ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 23, 2024 4:05pm
svelte-5-preview 🔄 Building (Inspect) Visit Preview 💬 Add feedback Oct 23, 2024 4:05pm
svelte-dev 🔄 Building (Inspect) Visit Preview 💬 Add feedback Oct 23, 2024 4:05pm

@dummdidumm
Copy link
Member Author

ok so the problem is that for some reason Vite mashes things up in a way that messes with the import graph, and so src/lib/server/content.ts is mashed up with utils stuff. And because content.js includes all the imports to our content, it's always different and then no match. We need to somehow tell it to use the original files.

@Rich-Harris
Copy link
Member

edited the comment to remove 'closes' — would like to keep #307 open as even with the cache it feels like things could be a hell of a lot faster. It definitely shouldn't take over a minute to render a few pages of markdown

…ges/index.md

Co-authored-by: Rich Harris <rich.harris@vercel.com>
@dummdidumm
Copy link
Member Author

In my local testing it barely took 50 seconds once the cache was properly in place

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.

2 participants