Open huseeiin opened 3 months ago
I do have some concerns about giving control here when it comes to future routing approaches including lazy route manifest shipping. It might be valuable to see what this feature looks like in other frameworks. I'm curious how Next, Sveltekit, Remix, Nuxt, etc handle this.
Would this work?
async function createEagerFileRoutes() {
const routes = <FileRoutes />;
const eagerRoutes = []
for (let route of (routes || [])) {
if (route.info?.eager) {
const component = await route['$component'].import();
eagerRoutes.push(<Route path={route.path} component={component} load={route.load} />)
} else {
eagerRoutes.push(route)
}
}
return (props) => eagerRoutes
}
const EagerFileRoutes = await createEagerFileRoutes();
Would this work?
async function createEagerFileRoutes() { const routes = <FileRoutes />; const eagerRoutes = [] for (let route of (routes || [])) { if (route.info?.eager) { const component = await route['$component'].import(); eagerRoutes.push(<Route path={route.path} component={component} load={route.load} />) } else { eagerRoutes.push(route) } } return (props) => eagerRoutes } const EagerFileRoutes = await createEagerFileRoutes();
i forgot the word "eager" here. important keyword.
Duplicates
Latest version
Summary 💡
currently,
FileRoutes
lazy-loades all routes by default which is sometimes undesired.Adding a
sync
option (that isfalse
by default) or aasync
option to enable lazy loading (that isfalse
by default) toFileRoutes
to disable lazy loading all routes will fix that.even better, this could be decided for each route separately.
Examples 🌈
a workaround is using custom
<Route />
s instead of using<FileRoutes />
:Motivation 🔦
No response