-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(prefetch-sw): only prefetch direct imports #6853
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
Conversation
🦋 Changeset detectedLatest commit: da895f6 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 |
d345e1b
to
d4e9de3
Compare
commit: |
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
d4e9de3
to
db4bb86
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.
I don't think removing dynamic import is the right fix here. It is true that we are currently over fetching do to dynamic imports, but I think better fix is to encode which imports are dynamic into the graph (for example negative numbers are dynamic imports)
SW can than make decisions on this.
Also it would be great if we could differentiate dynamic import form useTask
(which will very likely be needed) from a route navigation, which is much less likely to be needed.
This is why I think the fix here is to encode more information so that SW can make more intelligent decisions.
In the past we ran into issues where SW would fetch static imports but not dynamic and than the site was slow because the initial click handler would get processed but subsequent useTask
etc... would be slow.
@mhevery We can differentiate imports, handlers, segments, and dynamic imports. We can differentiate by negative numbers indicating the type of what follows, -1 handlers, -2 segments, -3 dynamic. Alternatively, Qwik loader can just tell us which handlers are actually on the page and those then get fetched opportunistically, no differentiation needed, only direct imports. What do you think? 🤔 Or indeed any dynamically imported segments that are not handlers are likely to be tasks etc. Ah and we can sort by module size, should we fetch big or small modules first? Not for this PR, but the prefetch SW is also missing:
|
0e1931a
to
99e45f9
Compare
@mhevery I now detect tasks (by the fact that they also export _hW) and fetch them with lower priority. Other dynamic imports are left up to the qprefetch events. WDYT? |
99e45f9
to
a8ab039
Compare
a8ab039
to
3d7e733
Compare
- dynamic imports should be fetched separately - don't list deps that are already deps-of-deps
3d7e733
to
da895f6
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.
My understanding is that you and Shai had a chat and decided to add this as a temporary work around, and than fix it later. In that case this is good to go.
* fix(prefetch-sw): only prefetch direct imports - dynamic imports should be fetched separately - don't list deps that are already deps-of-deps * feat(prefetch-sw): reduce fetch prio for dynamic tasks * perf(prefetch-sw): pre-process bundle graph * perf(prefetch-sw): don't prefetch indirect deps of indirect deps * perf(prefetch-sw): limit concurrent low prio fetches * fix(manifest): better import path handling
It was adding dynamic imports, which is not correct. Those should be handled by Link prefetching and Insights.
Furthermore, the graph is reduced by not including dependencies that other dependencies already import.