fix(nuxt): prefetch object-syntax routes with <NuxtLink>#19144
Conversation
|
|
danielroe
left a comment
There was a problem hiding this comment.
- we currently support prefetching external links if
experimental.crossOriginPrefetchis enabled, which the router won't be able to resolve. Maybe worth adding a check for whether a link is external? - if we resolve in the
link:prefetchhook we'll end up double-resolving - possible solution to 1 and reduction in resolutions - we can skip if
to.valueis already a string?
|
If it is an external link, |
<NuxtLink> to accept RouteLocationRaw values<NuxtLink>
|
FYI: Something in this PR broke NuxtLink (or perhaps #19309), and am now getting flooded with Example: The above doesn't error in 3.2.2, but does in 3.2.3. - I will try to create a repro of the error in a nuxt.new StackBlitz. |
|
StackBlitz with the error: |
|
That should be resolved in the edge channel, or in the next release with #19379 |
🔗 Linked issue
<NuxtLink>to execute prefetch whentotype props areRouteLocationRaw#19136❓ Type of change
📚 Description
Based on PR #19120, the
preloadRouteComponentsfunction now accepts aRouteLocationRawtype as a value. This update has also been made to<NuxtLink>to allowRouteLocationRawas a valid value type.This PR does not modify the type of hook
link:prefetch, but obtainsrouter.resolve(to.value).fullPathbefore calling the hook, because others still need string path, rash modification may cause Breaking change.nuxt/packages/nuxt/src/pages/runtime/plugins/prefetch.client.ts
Lines 23 to 40 in 7f67fce
nuxt/packages/nuxt/src/app/plugins/cross-origin-prefetch.client.ts
Lines 26 to 34 in 7f67fce
nuxt/packages/nuxt/src/app/plugins/payload.client.ts
Lines 14 to 18 in 7f67fce
📝 Checklist