UNPKG

react-router

Version:
32 lines (31 loc) 912 B
/** * react-router v8.0.0 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */ //#region lib/dom/ssr/routeModules.ts async function loadRouteModule(route, routeModulesCache) { if (route.id in routeModulesCache) return routeModulesCache[route.id]; try { let routeModule = await import( /* @vite-ignore */ /* webpackIgnore: true */ route.module ); routeModulesCache[route.id] = routeModule; return routeModule; } catch (error) { console.error(`Error loading route module \`${route.module}\`, reloading page...`); console.error(error); if (window.__reactRouterContext && window.__reactRouterContext.isSpaMode && import.meta.hot) throw error; window.location.reload(); return new Promise(() => {}); } } //#endregion export { loadRouteModule };