@modern-js/utils 2.8.0 → 2.8.1-alpha.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -50,7 +50,7 @@ const transformNestedRoutes = (routes) => {
50
50
  return (0, import_react_router_dom.createRoutesFromElements)(routeElements);
51
51
  };
52
52
  const renderNestedRoute = (nestedRoute, options = {}) => {
53
- const { children, index, id, component, isRoot } = nestedRoute;
53
+ const { children, index, id, component, isRoot, lazyImport } = nestedRoute;
54
54
  const Component = component;
55
55
  const { parent, DeferredDataComponent } = options;
56
56
  const routeProps = {
@@ -72,22 +72,24 @@ const renderNestedRoute = (nestedRoute, options = {}) => {
72
72
  }
73
73
  let element;
74
74
  if (Component) {
75
- if (parent == null ? void 0 : parent.loading) {
75
+ if ((parent == null ? void 0 : parent.loading) && lazyImport) {
76
76
  const Loading = parent.loading;
77
77
  if (isLoadableComponent(Component)) {
78
78
  element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {}) });
79
79
  } else {
80
80
  element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {}), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}) });
81
81
  }
82
- } else if (isLoadableComponent(Component)) {
82
+ } else if (isLoadableComponent(Component) && lazyImport) {
83
83
  element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {});
84
84
  } else if (isRoot) {
85
85
  element = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
86
86
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}),
87
87
  typeof document === "undefined" && DeferredDataComponent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DeferredDataComponent, {})
88
88
  ] });
89
- } else {
89
+ } else if (lazyImport) {
90
90
  element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}) });
91
+ } else {
92
+ element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {});
91
93
  }
92
94
  } else {
93
95
  nestedRoute.loading = parent == null ? void 0 : parent.loading;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.8.0",
14
+ "version": "2.8.1-alpha.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/index.d.ts",
17
17
  "main": "./dist/index.js",