Describe the feature
Currently, preloadRouteComponents() only allows the first parameter to be a string, but sometimes we may pass an object for to of <NuxtLink />. This can cause many of the same routes path to be considered not preloaded, like bellow:
<!-- Passing a string -->
<NuxtLink to="/home"> Home </NuxtLink>
<!-- Passing a string with query string -->
<!-- `router.resolve('/home?year=2023').path` is `/home` -->
<NuxtLink to="/home?year=2023"> Home </NuxtLink>
<!-- Passing a object -->
<!-- `router.resolve({ name: 'home', query: { year: '2023' } }).path` is `/home` -->
<NuxtLink :to="{ name: 'home', query: { year: '2023' } }"> Home </NuxtLink>
These routing paths are all '/home', but all of them will run preload without early return, although the request will not actually be sent.
Maybe we can allow passing an object or string of type RouteLocationRaw and use the path returned by router.resolve() as the preloaded record?
The preloadRouteComponents() will like bellow:
function preloadRouteComponents(to: RouteLocationRaw, router?: Router): Promise<void>
I don't know if it fits the core team's thinking.
Additional information
Final checks
Describe the feature
Currently,
preloadRouteComponents()only allows the first parameter to be a string, but sometimes we may pass an object fortoof<NuxtLink />. This can cause many of the same routes path to be considered not preloaded, like bellow:These routing paths are all '/home', but all of them will run preload without early return, although the request will not actually be sent.
Maybe we can allow passing an object or string of type
RouteLocationRawand use thepathreturned byrouter.resolve()as the preloaded record?The
preloadRouteComponents()will like bellow:I don't know if it fits the core team's thinking.
Additional information
Final checks