@modern-js/runtime 2.64.2 → 2.64.3
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.
|
@@ -146,6 +146,10 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
|
|
|
146
146
|
}
|
|
147
147
|
return "";
|
|
148
148
|
};
|
|
149
|
+
const createLazyImport = ({ componentPath, routeId, webpackChunkName, eager }) => {
|
|
150
|
+
const importOptions = webpackChunkName ? `/* webpackChunkName: "${routeId}" */ ` : eager ? `/* webpackMode: "eager" */ ` : "";
|
|
151
|
+
return `() => import(${importOptions}'${componentPath}').then(routeModule => handleRouteModule(routeModule, "${routeId}")).catch(handleRouteModuleError)`;
|
|
152
|
+
};
|
|
149
153
|
const traverseRouteTree = (route) => {
|
|
150
154
|
let children;
|
|
151
155
|
if ("children" in route && route.children) {
|
|
@@ -194,24 +198,32 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
|
|
|
194
198
|
configsMap[config] = route.config;
|
|
195
199
|
}
|
|
196
200
|
if (route._component) {
|
|
197
|
-
if (
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
201
|
+
if (route.isRoot) {
|
|
202
|
+
lazyImport = createLazyImport({
|
|
203
|
+
componentPath: route._component,
|
|
204
|
+
routeId: route.id
|
|
205
|
+
});
|
|
206
|
+
rootLayoutCode = `import RootLayout from '${route._component}'`;
|
|
207
|
+
component = "RootLayout";
|
|
208
|
+
} else if (splitRouteChunks) {
|
|
209
|
+
lazyImport = createLazyImport({
|
|
210
|
+
componentPath: route._component,
|
|
211
|
+
routeId: route.id,
|
|
212
|
+
webpackChunkName: true
|
|
213
|
+
});
|
|
214
|
+
component = ssrMode === "string" ? `loadable(${lazyImport})` : `lazy(${lazyImport})`;
|
|
215
|
+
} else {
|
|
216
|
+
if (ssrMode === "string") {
|
|
217
|
+
components.push(route._component);
|
|
218
|
+
component = `component_${components.length - 1}`;
|
|
205
219
|
} else {
|
|
206
|
-
lazyImport =
|
|
220
|
+
lazyImport = createLazyImport({
|
|
221
|
+
componentPath: route._component,
|
|
222
|
+
routeId: route.id,
|
|
223
|
+
eager: true
|
|
224
|
+
});
|
|
207
225
|
component = `lazy(${lazyImport})`;
|
|
208
226
|
}
|
|
209
|
-
} else if (ssrMode === "string") {
|
|
210
|
-
components.push(route._component);
|
|
211
|
-
component = `component_${components.length - 1}`;
|
|
212
|
-
} else {
|
|
213
|
-
lazyImport = `() => import(/* webpackMode: "eager" */ '${route._component}').then(routeModule => handleRouteModule(routeModule, "${route.id}")).catch(handleRouteModuleError) `;
|
|
214
|
-
component = `lazy(${lazyImport})`;
|
|
215
227
|
}
|
|
216
228
|
}
|
|
217
229
|
} else if (route._component) {
|
|
@@ -120,7 +120,7 @@ var createMatchReg = function(keyword) {
|
|
|
120
120
|
};
|
|
121
121
|
var fileSystemRoutes = function() {
|
|
122
122
|
var _ref = _async_to_generator(function(param) {
|
|
123
|
-
var metaName, routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, _param_splitRouteChunks, splitRouteChunks, components, loadings, errors, loaders, loadersMap, configs, configsMap, loadersMapFile, importLazyCode, rootLayoutCode, getDataLoaderPath, traverseRouteTree, routeComponentsCode, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, route, newRoute, routeStr, keywords, regs, newRouteStr, component, finalRoute, keywords1, routeStr1, regs1, newRouteStr1, importLoadingCode, importComponentsCode, importErrorComponentsCode, importLoadersCode, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _step_value, key, loaderInfo, route1, importConfigsCode, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _step_value1, key1, configPath, importRuntimeRouterCode, routeModulesCode;
|
|
123
|
+
var metaName, routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, _param_splitRouteChunks, splitRouteChunks, components, loadings, errors, loaders, loadersMap, configs, configsMap, loadersMapFile, importLazyCode, rootLayoutCode, getDataLoaderPath, createLazyImport, traverseRouteTree, routeComponentsCode, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, route, newRoute, routeStr, keywords, regs, newRouteStr, component, finalRoute, keywords1, routeStr1, regs1, newRouteStr1, importLoadingCode, importComponentsCode, importErrorComponentsCode, importLoadersCode, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _step_value, key, loaderInfo, route1, importConfigsCode, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _step_value1, key1, configPath, importRuntimeRouterCode, routeModulesCode;
|
|
124
124
|
return _ts_generator(this, function(_state) {
|
|
125
125
|
switch (_state.label) {
|
|
126
126
|
case 0:
|
|
@@ -147,6 +147,11 @@ var fileSystemRoutes = function() {
|
|
|
147
147
|
}
|
|
148
148
|
return "";
|
|
149
149
|
};
|
|
150
|
+
createLazyImport = function(param2) {
|
|
151
|
+
var componentPath = param2.componentPath, routeId = param2.routeId, webpackChunkName = param2.webpackChunkName, eager = param2.eager;
|
|
152
|
+
var importOptions = webpackChunkName ? '/* webpackChunkName: "'.concat(routeId, '" */ ') : eager ? '/* webpackMode: "eager" */ ' : "";
|
|
153
|
+
return "() => import(".concat(importOptions, "'").concat(componentPath, `').then(routeModule => handleRouteModule(routeModule, "`).concat(routeId, '")).catch(handleRouteModuleError)');
|
|
154
|
+
};
|
|
150
155
|
traverseRouteTree = function(route2) {
|
|
151
156
|
var children;
|
|
152
157
|
if ("children" in route2 && route2.children) {
|
|
@@ -195,24 +200,32 @@ var fileSystemRoutes = function() {
|
|
|
195
200
|
configsMap[config] = route2.config;
|
|
196
201
|
}
|
|
197
202
|
if (route2._component) {
|
|
198
|
-
if (
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
203
|
+
if (route2.isRoot) {
|
|
204
|
+
lazyImport = createLazyImport({
|
|
205
|
+
componentPath: route2._component,
|
|
206
|
+
routeId: route2.id
|
|
207
|
+
});
|
|
208
|
+
rootLayoutCode = "import RootLayout from '".concat(route2._component, "'");
|
|
209
|
+
component2 = "RootLayout";
|
|
210
|
+
} else if (splitRouteChunks) {
|
|
211
|
+
lazyImport = createLazyImport({
|
|
212
|
+
componentPath: route2._component,
|
|
213
|
+
routeId: route2.id,
|
|
214
|
+
webpackChunkName: true
|
|
215
|
+
});
|
|
216
|
+
component2 = ssrMode === "string" ? "loadable(".concat(lazyImport, ")") : "lazy(".concat(lazyImport, ")");
|
|
217
|
+
} else {
|
|
218
|
+
if (ssrMode === "string") {
|
|
219
|
+
components.push(route2._component);
|
|
220
|
+
component2 = "component_".concat(components.length - 1);
|
|
206
221
|
} else {
|
|
207
|
-
lazyImport =
|
|
222
|
+
lazyImport = createLazyImport({
|
|
223
|
+
componentPath: route2._component,
|
|
224
|
+
routeId: route2.id,
|
|
225
|
+
eager: true
|
|
226
|
+
});
|
|
208
227
|
component2 = "lazy(".concat(lazyImport, ")");
|
|
209
228
|
}
|
|
210
|
-
} else if (ssrMode === "string") {
|
|
211
|
-
components.push(route2._component);
|
|
212
|
-
component2 = "component_".concat(components.length - 1);
|
|
213
|
-
} else {
|
|
214
|
-
lazyImport = `() => import(/* webpackMode: "eager" */ '`.concat(route2._component, `').then(routeModule => handleRouteModule(routeModule, "`).concat(route2.id, '")).catch(handleRouteModuleError) ');
|
|
215
|
-
component2 = "lazy(".concat(lazyImport, ")");
|
|
216
229
|
}
|
|
217
230
|
}
|
|
218
231
|
} else if (route2._component) {
|
|
@@ -110,6 +110,10 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
|
|
|
110
110
|
}
|
|
111
111
|
return "";
|
|
112
112
|
};
|
|
113
|
+
const createLazyImport = ({ componentPath, routeId, webpackChunkName, eager }) => {
|
|
114
|
+
const importOptions = webpackChunkName ? `/* webpackChunkName: "${routeId}" */ ` : eager ? `/* webpackMode: "eager" */ ` : "";
|
|
115
|
+
return `() => import(${importOptions}'${componentPath}').then(routeModule => handleRouteModule(routeModule, "${routeId}")).catch(handleRouteModuleError)`;
|
|
116
|
+
};
|
|
113
117
|
const traverseRouteTree = (route) => {
|
|
114
118
|
let children;
|
|
115
119
|
if ("children" in route && route.children) {
|
|
@@ -158,24 +162,32 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
|
|
|
158
162
|
configsMap[config] = route.config;
|
|
159
163
|
}
|
|
160
164
|
if (route._component) {
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
if (route.isRoot) {
|
|
166
|
+
lazyImport = createLazyImport({
|
|
167
|
+
componentPath: route._component,
|
|
168
|
+
routeId: route.id
|
|
169
|
+
});
|
|
170
|
+
rootLayoutCode = `import RootLayout from '${route._component}'`;
|
|
171
|
+
component = "RootLayout";
|
|
172
|
+
} else if (splitRouteChunks) {
|
|
173
|
+
lazyImport = createLazyImport({
|
|
174
|
+
componentPath: route._component,
|
|
175
|
+
routeId: route.id,
|
|
176
|
+
webpackChunkName: true
|
|
177
|
+
});
|
|
178
|
+
component = ssrMode === "string" ? `loadable(${lazyImport})` : `lazy(${lazyImport})`;
|
|
179
|
+
} else {
|
|
180
|
+
if (ssrMode === "string") {
|
|
181
|
+
components.push(route._component);
|
|
182
|
+
component = `component_${components.length - 1}`;
|
|
169
183
|
} else {
|
|
170
|
-
lazyImport =
|
|
184
|
+
lazyImport = createLazyImport({
|
|
185
|
+
componentPath: route._component,
|
|
186
|
+
routeId: route.id,
|
|
187
|
+
eager: true
|
|
188
|
+
});
|
|
171
189
|
component = `lazy(${lazyImport})`;
|
|
172
190
|
}
|
|
173
|
-
} else if (ssrMode === "string") {
|
|
174
|
-
components.push(route._component);
|
|
175
|
-
component = `component_${components.length - 1}`;
|
|
176
|
-
} else {
|
|
177
|
-
lazyImport = `() => import(/* webpackMode: "eager" */ '${route._component}').then(routeModule => handleRouteModule(routeModule, "${route.id}")).catch(handleRouteModuleError) `;
|
|
178
|
-
component = `lazy(${lazyImport})`;
|
|
179
191
|
}
|
|
180
192
|
}
|
|
181
193
|
} else if (route._component) {
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.64.
|
|
18
|
+
"version": "2.64.3",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=14.17.6"
|
|
21
21
|
},
|
|
@@ -216,13 +216,13 @@
|
|
|
216
216
|
"react-is": "^18",
|
|
217
217
|
"react-side-effect": "^2.1.1",
|
|
218
218
|
"styled-components": "^5.3.1",
|
|
219
|
-
"@modern-js/plugin": "2.64.
|
|
220
|
-
"@modern-js/plugin-data-loader": "2.64.
|
|
221
|
-
"@modern-js/plugin-v2": "2.64.
|
|
222
|
-
"@modern-js/
|
|
223
|
-
"@modern-js/
|
|
224
|
-
"@modern-js/
|
|
225
|
-
"@modern-js/utils": "2.64.
|
|
219
|
+
"@modern-js/plugin": "2.64.3",
|
|
220
|
+
"@modern-js/plugin-data-loader": "2.64.3",
|
|
221
|
+
"@modern-js/plugin-v2": "2.64.3",
|
|
222
|
+
"@modern-js/render": "2.64.3",
|
|
223
|
+
"@modern-js/runtime-utils": "2.64.3",
|
|
224
|
+
"@modern-js/types": "2.64.3",
|
|
225
|
+
"@modern-js/utils": "2.64.3"
|
|
226
226
|
},
|
|
227
227
|
"peerDependencies": {
|
|
228
228
|
"react": ">=17",
|
|
@@ -230,7 +230,7 @@
|
|
|
230
230
|
},
|
|
231
231
|
"devDependencies": {
|
|
232
232
|
"@remix-run/web-fetch": "^4.1.3",
|
|
233
|
-
"@rsbuild/core": "1.2.
|
|
233
|
+
"@rsbuild/core": "1.2.8",
|
|
234
234
|
"@testing-library/react": "^13.4.0",
|
|
235
235
|
"@types/cookie": "0.6.0",
|
|
236
236
|
"@types/invariant": "^2.2.30",
|
|
@@ -245,10 +245,10 @@
|
|
|
245
245
|
"ts-jest": "^29.1.0",
|
|
246
246
|
"ts-node": "^10.9.1",
|
|
247
247
|
"typescript": "^5",
|
|
248
|
-
"webpack": "^5.
|
|
249
|
-
"@
|
|
250
|
-
"@scripts/
|
|
251
|
-
"@
|
|
248
|
+
"webpack": "^5.98.0",
|
|
249
|
+
"@scripts/build": "2.64.3",
|
|
250
|
+
"@scripts/jest-config": "2.64.3",
|
|
251
|
+
"@modern-js/app-tools": "2.64.3"
|
|
252
252
|
},
|
|
253
253
|
"sideEffects": false,
|
|
254
254
|
"publishConfig": {
|