-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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(v2): restore prefetch functionality #3723
Conversation
Deploy preview for docusaurus-2 ready! Built with commit ae6e8fb |
Thanks, didn't notice that the prefetching was broken, as it seems preloading still works. I think this solution is already an improvement, but what about this case:
Imagine route to prefetch is What about:
|
Yes, it sounds good, but I still don't understand which of the routes we need to prefetch (with
But then we will lose the result of work from #3001?
Perhaps this is even the best solution, because we need both of them chunks? |
We should prefetch both. One is for the docs version layout (including version metatadata), the other is for the version home doc. We need all this data anyway to render /docs/
Not exactly, the goal is not to revert this PR. The problem with this issue is that:
Was merged into
The first component attribute was overridden by the 2nd. IE, we loose the information that we actually need the What we want instead is:
And if the user visit I'm thinking of something like this instead: const routesChunkNamesMatch = Object.entries(routesChunkNames).filter((r) =>
removeHash(r[0]) === match.route.path
)) |
Or just use |
yes, filter instead of find, as long as you get the 2 entries back instead of just one it should be fine |
but the problem is that if you are on / and filter for entries using starsWith("/"), you'll end up prefetching all chunks of the site instead of the ones we want to prefetch? |
@slorber I refactored initial code to get all needed chunk names, can you please check out this? |
the logic works fine Refactored/documented/improved TS before merge so that I remember what's going on in the future |
Size Change: +133 B (0%) Total Size: 152 kB ℹ️ View Unchanged
|
Motivation
PR #3001 apparently broke prefetching of chunk assets as hash was added to route name. In this PR I tried to fix it by finding needed route chunks by its key (without hash). I suppose that if similar logic worked earlier, then it is acceptable now. I just don't see any reason to include the
crypto-js
library and generate route md5 hash (if this is possible inside the client bundle, then performance will probably suffer and the bundle size will increase, so this filtering by key is probably the only alternative option.Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
See Network panel (#1375)
Related PRs
(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)