Describe the problem
preloadCode is a bit of an odd API — it loads data for a route, but accepts a pathname as its argument. If you don't yet know the pathname, then you can just shove in any old string. The docs suggest that if you want to preload the code for /blog/[slug] you could call preloadCode('/blog/*'). This is obviously very kludgy!
Describe the proposed solution
Given that we now export an array of routes from $app/manifest, it feels like maybe it would be better if preloadCode accepted a RouteId instead:
await preloadCode('/blog/[slug]');
If you did have a pathname, you could always do this:
const matched = await match('/blog/hello');
await matched && preloadCode(matched.id);
Alternatives considered
A valid response would be 'eh, it's fine, why bother changing it'. Which is fair. I'm probably the only person who cares about this. It would likely involve some finicky work, and the match solution is probably more waterfally than what we have now?
But if we were to change the API on account of its inherent weirdness, now would be the time.
Importance
nice to have
Additional Information
No response
Describe the problem
preloadCodeis a bit of an odd API — it loads data for a route, but accepts a pathname as its argument. If you don't yet know the pathname, then you can just shove in any old string. The docs suggest that if you want to preload the code for/blog/[slug]you could callpreloadCode('/blog/*'). This is obviously very kludgy!Describe the proposed solution
Given that we now export an array of
routesfrom$app/manifest, it feels like maybe it would be better ifpreloadCodeaccepted aRouteIdinstead:If you did have a pathname, you could always do this:
Alternatives considered
A valid response would be 'eh, it's fine, why bother changing it'. Which is fair. I'm probably the only person who cares about this. It would likely involve some finicky work, and the
matchsolution is probably more waterfally than what we have now?But if we were to change the API on account of its inherent weirdness, now would be the time.
Importance
nice to have
Additional Information
No response