Description
Describe the problem
Today, import { resolveRoute } from '$app/paths'
is defined as follows:
function resolveRoute(
id: string,
params: Record<string, string | undefined>
): string;
Several potential direct improvements
1/ id
could be typed with RouteId
2/ params
could be typed with inferred params from the route (optionals, matcher)
(today, there is a message: Error: Missing parameter 'id' in route /city/[id]
)
Describe the proposed solution
To overcome this, I did: vite-plugin-kit-routes, and a lot of people asked only one thing: "Why not having it IN SvelteKit
directly?" starting point of this issue 👍
The scope of kit-routes
is a bit bigger than today's resolveRoute
, but I'll be happy to full depreciate it if we manage the same functionalities somehow.
3/ express SearchParams
of a route.
In the plugin it's done in the config like that. I could imagine a spacial export keyword in +page.(t|j).s
?
4/ support SERVERS
routes
The plugin is showing the verb to be explicit, but I'm not 100% set on this.
5/ support ACTIONS
routes
Today in the plugin, it's only "absolute path", but I would love to have also relative... that would probably be achieved with ./$types
and even tomorrow with Zero-effort type safety.
6/ LINKS
?
In the plugin, you can configure some links (with params & search params, optional, types, ...) it was convenient as everything is in the same place and using same ideas... But I don't really see it in resolveRoute
. Any ideas? Opinions?
Maybe looking at the actual output is the most helpful to get an overview: https://github.com/jycouet/kitql/blob/main/packages/vite-plugin-kit-routes/src/test/ROUTES_format-route-path.ts
Alternatives considered
No response
Importance
would make my life easier
Additional Information
No response