| 1 | |
| 2 | * react-router v8.3.0
|
| 3 | *
|
| 4 | * Copyright (c) Remix Software Inc.
|
| 5 | *
|
| 6 | * This source code is licensed under the MIT license found in the
|
| 7 | * LICENSE.md file in the root directory of this source tree.
|
| 8 | *
|
| 9 | * @license MIT
|
| 10 | */
|
| 11 |
|
| 12 | async function loadRouteModule(route, routeModulesCache) {
|
| 13 | if (route.id in routeModulesCache) return routeModulesCache[route.id];
|
| 14 | try {
|
| 15 | let routeModule = await import(
|
| 16 |
|
| 17 |
|
| 18 | route.module
|
| 19 | );
|
| 20 | routeModulesCache[route.id] = routeModule;
|
| 21 | return routeModule;
|
| 22 | } catch (error) {
|
| 23 | console.error(`Error loading route module \`${route.module}\`, reloading page...`);
|
| 24 | console.error(error);
|
| 25 | if (window.__reactRouterContext && window.__reactRouterContext.isSpaMode && import.meta.hot) throw error;
|
| 26 | window.location.reload();
|
| 27 | return new Promise(() => {});
|
| 28 | }
|
| 29 | }
|
| 30 |
|
| 31 | export { loadRouteModule };
|