-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: under-prefetching — bundle graph missing dynamic dependencies #7417
Conversation
🦋 Changeset detectedLatest commit: 81b3c3b The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
@maiieul I think you can add the isPlan and we can merge this already as a bit of an improvement? |
Yup, I think it's actually quite a big improvement. Without |
530c02a
to
411dd87
Compare
ace867c
to
9c97fc7
Compare
9c97fc7
to
4e44b4f
Compare
4e44b4f
to
a339d69
Compare
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.
needs a little cleanup but I think we can merge this even though #7453 will follow soon
We need the |
68dc99a
to
0580036
Compare
0580036
to
81b3c3b
Compare
What is it?
Description
Repro: https://github.com/maiieul/qwik-under-prefetching-repro -> TLDR:
open.value && <Comp />
has always led to under-prefetching. This could be worked around (as was the case on the qwik.dev docs) by usingqwikVite
'sentryStrategy.manual
(https://qwik.dev/docs/guides/bundle/).I managed to get a pretty good result by checking for each bundle if their dynamic dependencies are entries, reducing the under-prefetching a lot. Then I noticed that removing
manualChunks
logic on top of that completely gets rid of it with the qwik-city ServiceWorkerRegister. The qwik PrefetchServiceWorker also works but is a bit buggy.Results https://github.com/QwikDev/qwik/pull/7417:
Remaining issues/questions:
PrefetchServiceWorker
doesn't prioritize the chunks on user interaction. This means if all the chunks need 5s to be prefetched, the app won’t be interactive before that point, and also that the user must re-interact to actually get a result.clearTransitiveDeps
and the direct<dynamic>
check do anything useful. They don’t seem to change anything on qwik.dev and qwik-ui.com I’m concerned these might lead to under-prefetching in some untested situations.Bonus: this also fixes the docs search 🥳
Malus: I disabled qwik insights because it was logging lots of
error
on the network tab 🤔Fixes #4149
list of PRs that created problems with prefetching:
entryStrategy.manual
for the docs search.document.dispatchEvent(new CustomEvent("qprefetch",{detail:${JSON.stringify(data)}}))
broke the qwik-city SW. Brought back in fix: qwikcity sw SSR prefetching #7286.manualChunks
, therefore preventing rollup to bundle those chunks with others, which affects the bundle-graph, creating even more over-prefetching but also under-prefetching.fix(prefetch-sw): only prefetch direct imports #6853 -> Fixed over-prefetching by only allowing tasks dynamic dependencies to be prefetched, because prefetching all kinds of dynamic imports can for example prefetch all dynamic imports from external dependencies (e.g. all of the shiki syntax definitions 😬 ), but also introduced more under-prefetching because some non tasks chunks also need to be prefetched.
Checklist
pnpm change