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(nuxt): prefetch object-syntax routes with <NuxtLink>
#19144
fix(nuxt): prefetch object-syntax routes with <NuxtLink>
#19144
Conversation
Β Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
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.
- we currently support prefetching external links if
experimental.crossOriginPrefetch
is 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:prefetch
hook we'll end up double-resolving - possible solution to 1 and reduction in resolutions - we can skip if
to.value
is 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 whento
type props areRouteLocationRaw
Β #19136β Type of change
π Description
Based on PR #19120, the
preloadRouteComponents
function now accepts aRouteLocationRaw
type as a value. This update has also been made to<NuxtLink>
to allowRouteLocationRaw
as a valid value type.This PR does not modify the type of hook
link:prefetch
, but obtainsrouter.resolve(to.value).fullPath
before 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