@modern-js/runtime 2.58.3 → 2.58.4-alpha.1
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.
|
@@ -84,7 +84,7 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
84
84
|
const config2 = api.useResolvedConfigContext();
|
|
85
85
|
const ssrByRouteIds = config2.server.ssrByRouteIds || [];
|
|
86
86
|
const clonedRoutes = (0, import_lodash.cloneDeep)(initialRoutes);
|
|
87
|
-
const markedRoutes = ssrByRouteIds.length > 0 ? markRoutes(clonedRoutes, ssrByRouteIds) : initialRoutes;
|
|
87
|
+
const markedRoutes = ssrByRouteIds.length > 0 ? (0, import_utils.markRoutes)(clonedRoutes, ssrByRouteIds) : initialRoutes;
|
|
88
88
|
const { routes } = await hookRunners.modifyFileSystemRoutes({
|
|
89
89
|
entrypoint,
|
|
90
90
|
routes: markedRoutes
|
|
@@ -115,7 +115,7 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
115
115
|
})
|
|
116
116
|
});
|
|
117
117
|
if (entrypoint.nestedRoutesEntry && (0, import_utils.isUseSSRBundle)(config2)) {
|
|
118
|
-
var _config_output1;
|
|
118
|
+
var _config_output1, _config_output2;
|
|
119
119
|
const routesServerFile = (0, import_utils2.getServerLoadersFile)(internalDirectory, entryName);
|
|
120
120
|
const filtedRoutesForServer = (0, import_utils.filterRoutesForServer)(routes);
|
|
121
121
|
const routesForServerLoaderMatches = (0, import_utils.filterRoutesLoader)(routes);
|
|
@@ -134,6 +134,16 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
134
134
|
splitRouteChunks: config2 === null || config2 === void 0 ? void 0 : (_config_output1 = config2.output) === null || _config_output1 === void 0 ? void 0 : _config_output1.splitRouteChunks
|
|
135
135
|
});
|
|
136
136
|
await import_utils.fs.outputFile(import_path.default.resolve(internalDirectory, `./${entryName}/routes.server.js`), serverRoutesCode, "utf8");
|
|
137
|
+
const mfServerRoutesCode = await templates.fileSystemRoutes({
|
|
138
|
+
metaName,
|
|
139
|
+
routes,
|
|
140
|
+
ssrMode: useSSG ? "string" : mode,
|
|
141
|
+
nestedRoutesEntry: entrypoint.nestedRoutesEntry,
|
|
142
|
+
entryName: entrypoint.entryName,
|
|
143
|
+
internalDirectory,
|
|
144
|
+
splitRouteChunks: config2 === null || config2 === void 0 ? void 0 : (_config_output2 = config2.output) === null || _config_output2 === void 0 ? void 0 : _config_output2.splitRouteChunks
|
|
145
|
+
});
|
|
146
|
+
await import_utils.fs.outputFile(import_path.default.resolve(internalDirectory, `./${entryName}/mf-routes.js`), mfServerRoutesCode, "utf8");
|
|
137
147
|
}
|
|
138
148
|
const serverLoaderCombined = templates.ssrLoaderCombinedModule(entrypoints, entrypoint, config2, appContext);
|
|
139
149
|
if (serverLoaderCombined) {
|
|
@@ -145,25 +155,6 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
145
155
|
}
|
|
146
156
|
}
|
|
147
157
|
};
|
|
148
|
-
function markRoutes(routes, routeIds) {
|
|
149
|
-
return routes.map((route) => {
|
|
150
|
-
if (route.type !== "nested") {
|
|
151
|
-
return route;
|
|
152
|
-
}
|
|
153
|
-
if (route.children && route.children.length > 0) {
|
|
154
|
-
route.children = markRoutes(route.children, routeIds);
|
|
155
|
-
}
|
|
156
|
-
if (route.children && route.children.length > 0) {
|
|
157
|
-
route.inValidSSRRoute = route.children.every((child) => {
|
|
158
|
-
var _child_inValidSSRRoute;
|
|
159
|
-
return (_child_inValidSSRRoute = child.inValidSSRRoute) !== null && _child_inValidSSRRoute !== void 0 ? _child_inValidSSRRoute : false;
|
|
160
|
-
});
|
|
161
|
-
} else if (route.id) {
|
|
162
|
-
route.inValidSSRRoute = !routeIds.includes(route.id);
|
|
163
|
-
}
|
|
164
|
-
return route;
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
158
|
function generatorRegisterCode(internalDirectory, entryName, code) {
|
|
168
159
|
import_utils.fs.outputFileSync(import_path.default.resolve(internalDirectory, `./${entryName}/${import_constants.ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME}`), code, "utf8");
|
|
169
160
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import { fs, filterRoutesForServer, filterRoutesLoader, getEntryOptions, isRouterV5, isSSGEntry, isUseSSRBundle, logger } from "@modern-js/utils";
|
|
4
|
+
import { fs, filterRoutesForServer, filterRoutesLoader, getEntryOptions, isRouterV5, isSSGEntry, isUseSSRBundle, logger, markRoutes } from "@modern-js/utils";
|
|
5
5
|
import { cloneDeep } from "@modern-js/utils/lodash";
|
|
6
6
|
import { ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME } from "../../../cli/constants";
|
|
7
7
|
import { FILE_SYSTEM_ROUTES_FILE_NAME } from "../constants";
|
|
@@ -17,7 +17,7 @@ var generateCode = function() {
|
|
|
17
17
|
}
|
|
18
18
|
function _generateEntryCode() {
|
|
19
19
|
_generateEntryCode = _async_to_generator(function(entrypoint) {
|
|
20
|
-
var entryName, isMainEntry, isAutoMount, pageRoutesEntry, nestedRoutesEntry, metaName, _config_output, initialRoutes, nestedRoutes, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, route, _$config, ssrByRouteIds, clonedRoutes, markedRoutes, routes, ssr, useSSG, mode, hasPageRoute, code, _, _tmp, _config_output1, routesServerFile, filtedRoutesForServer, routesForServerLoaderMatches, code1, serverRoutesCode, serverLoaderCombined, serverLoaderFile;
|
|
20
|
+
var entryName, isMainEntry, isAutoMount, pageRoutesEntry, nestedRoutesEntry, metaName, _config_output, initialRoutes, nestedRoutes, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, route, _$config, ssrByRouteIds, clonedRoutes, markedRoutes, routes, ssr, useSSG, mode, hasPageRoute, code, _, _tmp, _config_output1, _config_output2, routesServerFile, filtedRoutesForServer, routesForServerLoaderMatches, code1, serverRoutesCode, mfServerRoutesCode, serverLoaderCombined, serverLoaderFile;
|
|
21
21
|
return _ts_generator(this, function(_state) {
|
|
22
22
|
switch (_state.label) {
|
|
23
23
|
case 0:
|
|
@@ -26,12 +26,12 @@ var generateCode = function() {
|
|
|
26
26
|
if (!isAutoMount)
|
|
27
27
|
return [
|
|
28
28
|
3,
|
|
29
|
-
|
|
29
|
+
16
|
|
30
30
|
];
|
|
31
31
|
if (!(pageRoutesEntry || nestedRoutesEntry))
|
|
32
32
|
return [
|
|
33
33
|
3,
|
|
34
|
-
|
|
34
|
+
16
|
|
35
35
|
];
|
|
36
36
|
initialRoutes = [];
|
|
37
37
|
nestedRoutes = null;
|
|
@@ -142,7 +142,7 @@ var generateCode = function() {
|
|
|
142
142
|
if (!(entrypoint.nestedRoutesEntry && isUseSSRBundle(_$config)))
|
|
143
143
|
return [
|
|
144
144
|
3,
|
|
145
|
-
|
|
145
|
+
12
|
|
146
146
|
];
|
|
147
147
|
routesServerFile = getServerLoadersFile(internalDirectory, entryName);
|
|
148
148
|
filtedRoutesForServer = filterRoutesForServer(routes);
|
|
@@ -182,31 +182,51 @@ var generateCode = function() {
|
|
|
182
182
|
];
|
|
183
183
|
case 9:
|
|
184
184
|
_state.sent();
|
|
185
|
-
|
|
185
|
+
return [
|
|
186
|
+
4,
|
|
187
|
+
templates.fileSystemRoutes({
|
|
188
|
+
metaName,
|
|
189
|
+
routes,
|
|
190
|
+
ssrMode: useSSG ? "string" : mode,
|
|
191
|
+
nestedRoutesEntry: entrypoint.nestedRoutesEntry,
|
|
192
|
+
entryName: entrypoint.entryName,
|
|
193
|
+
internalDirectory,
|
|
194
|
+
splitRouteChunks: _$config === null || _$config === void 0 ? void 0 : (_config_output2 = _$config.output) === null || _config_output2 === void 0 ? void 0 : _config_output2.splitRouteChunks
|
|
195
|
+
})
|
|
196
|
+
];
|
|
186
197
|
case 10:
|
|
198
|
+
mfServerRoutesCode = _state.sent();
|
|
199
|
+
return [
|
|
200
|
+
4,
|
|
201
|
+
fs.outputFile(path.resolve(internalDirectory, "./".concat(entryName, "/mf-routes.js")), mfServerRoutesCode, "utf8")
|
|
202
|
+
];
|
|
203
|
+
case 11:
|
|
204
|
+
_state.sent();
|
|
205
|
+
_state.label = 12;
|
|
206
|
+
case 12:
|
|
187
207
|
serverLoaderCombined = templates.ssrLoaderCombinedModule(entrypoints, entrypoint, _$config, appContext);
|
|
188
208
|
if (!serverLoaderCombined)
|
|
189
209
|
return [
|
|
190
210
|
3,
|
|
191
|
-
|
|
211
|
+
14
|
|
192
212
|
];
|
|
193
213
|
serverLoaderFile = getServerCombinedModueFile(internalDirectory, entryName);
|
|
194
214
|
return [
|
|
195
215
|
4,
|
|
196
216
|
fs.outputFile(serverLoaderFile, serverLoaderCombined)
|
|
197
217
|
];
|
|
198
|
-
case
|
|
218
|
+
case 13:
|
|
199
219
|
_state.sent();
|
|
200
|
-
_state.label =
|
|
201
|
-
case
|
|
220
|
+
_state.label = 14;
|
|
221
|
+
case 14:
|
|
202
222
|
return [
|
|
203
223
|
4,
|
|
204
224
|
fs.outputFile(path.resolve(internalDirectory, "./".concat(entryName, "/").concat(FILE_SYSTEM_ROUTES_FILE_NAME)), code, "utf8")
|
|
205
225
|
];
|
|
206
|
-
case
|
|
226
|
+
case 15:
|
|
207
227
|
_state.sent();
|
|
208
|
-
_state.label =
|
|
209
|
-
case
|
|
228
|
+
_state.label = 16;
|
|
229
|
+
case 16:
|
|
210
230
|
return [
|
|
211
231
|
2
|
|
212
232
|
];
|
|
@@ -239,25 +259,6 @@ var generateCode = function() {
|
|
|
239
259
|
return _ref.apply(this, arguments);
|
|
240
260
|
};
|
|
241
261
|
}();
|
|
242
|
-
function markRoutes(routes, routeIds) {
|
|
243
|
-
return routes.map(function(route) {
|
|
244
|
-
if (route.type !== "nested") {
|
|
245
|
-
return route;
|
|
246
|
-
}
|
|
247
|
-
if (route.children && route.children.length > 0) {
|
|
248
|
-
route.children = markRoutes(route.children, routeIds);
|
|
249
|
-
}
|
|
250
|
-
if (route.children && route.children.length > 0) {
|
|
251
|
-
route.inValidSSRRoute = route.children.every(function(child) {
|
|
252
|
-
var _child_inValidSSRRoute;
|
|
253
|
-
return (_child_inValidSSRRoute = child.inValidSSRRoute) !== null && _child_inValidSSRRoute !== void 0 ? _child_inValidSSRRoute : false;
|
|
254
|
-
});
|
|
255
|
-
} else if (route.id) {
|
|
256
|
-
route.inValidSSRRoute = !routeIds.includes(route.id);
|
|
257
|
-
}
|
|
258
|
-
return route;
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
262
|
function generatorRegisterCode(internalDirectory, entryName, code) {
|
|
262
263
|
fs.outputFileSync(path.resolve(internalDirectory, "./".concat(entryName, "/").concat(ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME)), code, "utf8");
|
|
263
264
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import { fs, filterRoutesForServer, filterRoutesLoader, getEntryOptions, isRouterV5, isSSGEntry, isUseSSRBundle, logger } from "@modern-js/utils";
|
|
2
|
+
import { fs, filterRoutesForServer, filterRoutesLoader, getEntryOptions, isRouterV5, isSSGEntry, isUseSSRBundle, logger, markRoutes } from "@modern-js/utils";
|
|
3
3
|
import { cloneDeep } from "@modern-js/utils/lodash";
|
|
4
4
|
import { ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME } from "../../../cli/constants";
|
|
5
5
|
import { FILE_SYSTEM_ROUTES_FILE_NAME } from "../constants";
|
|
@@ -81,7 +81,7 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
81
81
|
})
|
|
82
82
|
});
|
|
83
83
|
if (entrypoint.nestedRoutesEntry && isUseSSRBundle(config2)) {
|
|
84
|
-
var _config_output1;
|
|
84
|
+
var _config_output1, _config_output2;
|
|
85
85
|
const routesServerFile = getServerLoadersFile(internalDirectory, entryName);
|
|
86
86
|
const filtedRoutesForServer = filterRoutesForServer(routes);
|
|
87
87
|
const routesForServerLoaderMatches = filterRoutesLoader(routes);
|
|
@@ -100,6 +100,16 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
100
100
|
splitRouteChunks: config2 === null || config2 === void 0 ? void 0 : (_config_output1 = config2.output) === null || _config_output1 === void 0 ? void 0 : _config_output1.splitRouteChunks
|
|
101
101
|
});
|
|
102
102
|
await fs.outputFile(path.resolve(internalDirectory, `./${entryName}/routes.server.js`), serverRoutesCode, "utf8");
|
|
103
|
+
const mfServerRoutesCode = await templates.fileSystemRoutes({
|
|
104
|
+
metaName,
|
|
105
|
+
routes,
|
|
106
|
+
ssrMode: useSSG ? "string" : mode,
|
|
107
|
+
nestedRoutesEntry: entrypoint.nestedRoutesEntry,
|
|
108
|
+
entryName: entrypoint.entryName,
|
|
109
|
+
internalDirectory,
|
|
110
|
+
splitRouteChunks: config2 === null || config2 === void 0 ? void 0 : (_config_output2 = config2.output) === null || _config_output2 === void 0 ? void 0 : _config_output2.splitRouteChunks
|
|
111
|
+
});
|
|
112
|
+
await fs.outputFile(path.resolve(internalDirectory, `./${entryName}/mf-routes.js`), mfServerRoutesCode, "utf8");
|
|
103
113
|
}
|
|
104
114
|
const serverLoaderCombined = templates.ssrLoaderCombinedModule(entrypoints, entrypoint, config2, appContext);
|
|
105
115
|
if (serverLoaderCombined) {
|
|
@@ -111,25 +121,6 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
111
121
|
}
|
|
112
122
|
}
|
|
113
123
|
};
|
|
114
|
-
function markRoutes(routes, routeIds) {
|
|
115
|
-
return routes.map((route) => {
|
|
116
|
-
if (route.type !== "nested") {
|
|
117
|
-
return route;
|
|
118
|
-
}
|
|
119
|
-
if (route.children && route.children.length > 0) {
|
|
120
|
-
route.children = markRoutes(route.children, routeIds);
|
|
121
|
-
}
|
|
122
|
-
if (route.children && route.children.length > 0) {
|
|
123
|
-
route.inValidSSRRoute = route.children.every((child) => {
|
|
124
|
-
var _child_inValidSSRRoute;
|
|
125
|
-
return (_child_inValidSSRRoute = child.inValidSSRRoute) !== null && _child_inValidSSRRoute !== void 0 ? _child_inValidSSRRoute : false;
|
|
126
|
-
});
|
|
127
|
-
} else if (route.id) {
|
|
128
|
-
route.inValidSSRRoute = !routeIds.includes(route.id);
|
|
129
|
-
}
|
|
130
|
-
return route;
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
124
|
function generatorRegisterCode(internalDirectory, entryName, code) {
|
|
134
125
|
fs.outputFileSync(path.resolve(internalDirectory, `./${entryName}/${ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME}`), code, "utf8");
|
|
135
126
|
}
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.58.
|
|
18
|
+
"version": "2.58.4-alpha.1",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=14.17.6"
|
|
21
21
|
},
|
|
@@ -199,11 +199,11 @@
|
|
|
199
199
|
"react-is": "^18",
|
|
200
200
|
"react-side-effect": "^2.1.1",
|
|
201
201
|
"styled-components": "^5.3.1",
|
|
202
|
-
"@modern-js/plugin": "2.58.3",
|
|
203
202
|
"@modern-js/plugin-data-loader": "2.58.3",
|
|
204
|
-
"@modern-js/
|
|
203
|
+
"@modern-js/plugin": "2.58.3",
|
|
204
|
+
"@modern-js/utils": "2.58.4-alpha.0",
|
|
205
205
|
"@modern-js/runtime-utils": "2.58.3",
|
|
206
|
-
"@modern-js/
|
|
206
|
+
"@modern-js/types": "2.58.3"
|
|
207
207
|
},
|
|
208
208
|
"peerDependencies": {
|
|
209
209
|
"react": ">=17",
|
|
@@ -226,10 +226,10 @@
|
|
|
226
226
|
"ts-jest": "^29.1.0",
|
|
227
227
|
"typescript": "^5",
|
|
228
228
|
"webpack": "^5.93.0",
|
|
229
|
+
"@modern-js/core": "2.58.3",
|
|
229
230
|
"@modern-js/app-tools": "2.58.3",
|
|
230
|
-
"@scripts/jest-config": "2.58.3",
|
|
231
231
|
"@scripts/build": "2.58.3",
|
|
232
|
-
"@
|
|
232
|
+
"@scripts/jest-config": "2.58.3"
|
|
233
233
|
},
|
|
234
234
|
"sideEffects": false,
|
|
235
235
|
"publishConfig": {
|