-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
feat: allow configuration of how route modules are loaded in the browser #12638
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
base: dev
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 84753c0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Note - this new API would need to be added to the new |
Alpha release created:
git log --pretty=oneline [email protected] |
@@ -582,6 +582,9 @@ export function RSCHydratedRouter({ | |||
}, | |||
routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" }, | |||
routeModules: {}, | |||
loadRouteModule: () => { | |||
throw new Error("Not required in RSC Mode"); |
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.
@jacob-ebey Can you confirm this is correct?
Alpha release created:
git log --pretty=oneline [email protected] |
Alpha release created:
git log --pretty=oneline [email protected] |
@ScriptedAlchemy - function customLoadRouteModule(route, routeModulesCache) {
if (route.id in routeModulesCache) {
return routeModulesCache[route.id] as RouteModule;
}
try {
// Load the module however you want
let routeModule = loadModulehoweverYouWant(route.module); // 👈
routeModulesCache[route.id] = routeModule;
return routeModule;
} catch (error: unknown) {
// Handle errors - see default handling in
// https://github.com/remix-run/react-router/blob/browser_module_loading/packages/react-router/lib/dom/ssr/routeModules.ts#L276
}
}
<HydratedRouter unstable_loadRouteModule={customLoadRouteModule} /> Would you want to take full control here including error handling or would you prefer letting RR continue to handle the errors in a default manner? |
Adds a new API for bundler plugin usage to take control over the loading of client modules: