@modern-js/runtime-utils 3.9.3 → 3.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/browser/nestedRoutes.js +5 -2
- package/dist/esm/browser/nestedRoutes.mjs +5 -2
- package/dist/esm-node/browser/nestedRoutes.mjs +5 -2
- package/dist/types/node/loaderContext/index.d.ts +1 -1
- package/package.json +8 -9
- package/{rslib.config.mts → rstack.config.mts} +2 -2
- package/rstest.config.mts +5 -0
|
@@ -108,10 +108,13 @@ const renderNestedRoute = (nestedRoute, options = {})=>{
|
|
|
108
108
|
function isPlainObject(value) {
|
|
109
109
|
return null != value && 'object' == typeof value && Object.getPrototypeOf(value) === Object.prototype;
|
|
110
110
|
}
|
|
111
|
+
function preloadRouteModule(lazyImport) {
|
|
112
|
+
lazyImport().catch(()=>{});
|
|
113
|
+
}
|
|
111
114
|
function createLoader(route) {
|
|
112
115
|
const { loader } = route;
|
|
113
116
|
if (loader) return async (args)=>{
|
|
114
|
-
if ('function' == typeof route.lazyImport) route.lazyImport
|
|
117
|
+
if ('function' == typeof route.lazyImport) preloadRouteModule(route.lazyImport);
|
|
115
118
|
const end = (0, external_time_js_namespaceObject.time)();
|
|
116
119
|
const res = await loader(args);
|
|
117
120
|
let activeDeferreds = null;
|
|
@@ -128,7 +131,7 @@ function createLoader(route) {
|
|
|
128
131
|
return res;
|
|
129
132
|
};
|
|
130
133
|
else return ()=>{
|
|
131
|
-
if ('function' == typeof route.lazyImport) route.lazyImport
|
|
134
|
+
if ('function' == typeof route.lazyImport) preloadRouteModule(route.lazyImport);
|
|
132
135
|
return null;
|
|
133
136
|
};
|
|
134
137
|
}
|
|
@@ -75,10 +75,13 @@ const renderNestedRoute = (nestedRoute, options = {})=>{
|
|
|
75
75
|
function isPlainObject(value) {
|
|
76
76
|
return null != value && 'object' == typeof value && Object.getPrototypeOf(value) === Object.prototype;
|
|
77
77
|
}
|
|
78
|
+
function preloadRouteModule(lazyImport) {
|
|
79
|
+
lazyImport().catch(()=>{});
|
|
80
|
+
}
|
|
78
81
|
function createLoader(route) {
|
|
79
82
|
const { loader } = route;
|
|
80
83
|
if (loader) return async (args)=>{
|
|
81
|
-
if ('function' == typeof route.lazyImport) route.lazyImport
|
|
84
|
+
if ('function' == typeof route.lazyImport) preloadRouteModule(route.lazyImport);
|
|
82
85
|
const end = time();
|
|
83
86
|
const res = await loader(args);
|
|
84
87
|
let activeDeferreds = null;
|
|
@@ -95,7 +98,7 @@ function createLoader(route) {
|
|
|
95
98
|
return res;
|
|
96
99
|
};
|
|
97
100
|
else return ()=>{
|
|
98
|
-
if ('function' == typeof route.lazyImport) route.lazyImport
|
|
101
|
+
if ('function' == typeof route.lazyImport) preloadRouteModule(route.lazyImport);
|
|
99
102
|
return null;
|
|
100
103
|
};
|
|
101
104
|
}
|
|
@@ -76,10 +76,13 @@ const renderNestedRoute = (nestedRoute, options = {})=>{
|
|
|
76
76
|
function isPlainObject(value) {
|
|
77
77
|
return null != value && 'object' == typeof value && Object.getPrototypeOf(value) === Object.prototype;
|
|
78
78
|
}
|
|
79
|
+
function preloadRouteModule(lazyImport) {
|
|
80
|
+
lazyImport().catch(()=>{});
|
|
81
|
+
}
|
|
79
82
|
function createLoader(route) {
|
|
80
83
|
const { loader } = route;
|
|
81
84
|
if (loader) return async (args)=>{
|
|
82
|
-
if ('function' == typeof route.lazyImport) route.lazyImport
|
|
85
|
+
if ('function' == typeof route.lazyImport) preloadRouteModule(route.lazyImport);
|
|
83
86
|
const end = time();
|
|
84
87
|
const res = await loader(args);
|
|
85
88
|
let activeDeferreds = null;
|
|
@@ -96,7 +99,7 @@ function createLoader(route) {
|
|
|
96
99
|
return res;
|
|
97
100
|
};
|
|
98
101
|
else return ()=>{
|
|
99
|
-
if ('function' == typeof route.lazyImport) route.lazyImport
|
|
102
|
+
if ('function' == typeof route.lazyImport) preloadRouteModule(route.lazyImport);
|
|
100
103
|
return null;
|
|
101
104
|
};
|
|
102
105
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Reporter } from '@modern-js/types';
|
|
2
|
-
export { createRequestContext, type RequestContext
|
|
2
|
+
export { createRequestContext, type RequestContext } from './createRequestCtx.js';
|
|
3
3
|
export type { LoaderContext } from './createLoaderCtx.js';
|
|
4
4
|
export declare const reporterCtx: import("./createLoaderCtx.js").LoaderContext<Reporter>;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "3.
|
|
18
|
+
"version": "3.10.0",
|
|
19
19
|
"_comment": "Provide ESM and CJS exports, ESM is used by runtime package, for treeshaking",
|
|
20
20
|
"exports": {
|
|
21
21
|
"./router": {
|
|
@@ -158,9 +158,9 @@
|
|
|
158
158
|
"@swc/helpers": "^0.5.17",
|
|
159
159
|
"lru-cache": "^10.4.3",
|
|
160
160
|
"react-router": "7.18.4",
|
|
161
|
-
"serialize-javascript": "^7.
|
|
162
|
-
"@modern-js/
|
|
163
|
-
"@modern-js/
|
|
161
|
+
"serialize-javascript": "^7.1.2",
|
|
162
|
+
"@modern-js/types": "3.10.0",
|
|
163
|
+
"@modern-js/utils": "3.10.0"
|
|
164
164
|
},
|
|
165
165
|
"peerDependencies": {
|
|
166
166
|
"react": ">=18.3.1",
|
|
@@ -175,21 +175,20 @@
|
|
|
175
175
|
}
|
|
176
176
|
},
|
|
177
177
|
"devDependencies": {
|
|
178
|
-
"@rslib/core": "1.0.1",
|
|
179
178
|
"@types/ioredis-mock": "^8.2.8",
|
|
180
179
|
"@types/node": "^20",
|
|
181
180
|
"@types/serialize-javascript": "^5.0.4",
|
|
182
181
|
"ioredis-mock": "^8.13.1",
|
|
183
|
-
"react": "^19.
|
|
184
|
-
"react-dom": "^19.
|
|
182
|
+
"react": "^19.3.0",
|
|
183
|
+
"react-dom": "^19.3.0",
|
|
185
184
|
"typescript": "^5",
|
|
186
185
|
"@modern-js/rslib": "2.68.10",
|
|
187
186
|
"@scripts/rstest-config": "2.66.0"
|
|
188
187
|
},
|
|
189
188
|
"sideEffects": false,
|
|
190
189
|
"scripts": {
|
|
191
|
-
"dev": "
|
|
192
|
-
"build": "
|
|
190
|
+
"dev": "rs lib --watch",
|
|
191
|
+
"build": "rs lib",
|
|
193
192
|
"test": "rstest --passWithNoTests"
|
|
194
193
|
}
|
|
195
194
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { rslibConfig } from '@modern-js/rslib';
|
|
2
|
-
import {
|
|
2
|
+
import { define } from 'rstack';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
define.lib({
|
|
5
5
|
...rslibConfig,
|
|
6
6
|
lib: rslibConfig.lib?.map(libConfig => {
|
|
7
7
|
const isWebTarget = libConfig.output?.target === 'web';
|