@modern-js/runtime 2.58.2 → 2.58.4-alpha.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/cli/index.js +11 -14
- package/dist/cjs/cli/ssr/babel-plugin-ssr-loader-id.js +1 -1
- package/dist/cjs/cli/template.js +1 -1
- package/dist/cjs/core/browser/hydrate.js +1 -1
- package/dist/cjs/core/browser/index.js +2 -2
- package/dist/cjs/core/compatible.js +4 -4
- package/dist/cjs/core/context/runtime.js +1 -1
- package/dist/cjs/core/loader/useLoader.js +1 -1
- package/dist/cjs/core/server/react/prerender/index.js +1 -1
- package/dist/cjs/core/server/requestHandler.js +8 -3
- package/dist/cjs/core/server/stream/afterTemplate.js +1 -1
- package/dist/cjs/core/server/stream/beforeTemplate.js +3 -3
- package/dist/cjs/core/server/stream/createReadableStream.js +2 -2
- package/dist/cjs/core/server/stream/createReadableStream.worker.js +2 -2
- package/dist/cjs/core/server/stream/shared.js +1 -1
- package/dist/cjs/core/server/stream/template.js +1 -1
- package/dist/cjs/core/server/string/index.js +18 -18
- package/dist/cjs/core/server/string/prefetch.js +5 -5
- package/dist/cjs/core/server/string/ssrData.js +1 -1
- package/dist/cjs/document/Body.js +1 -1
- package/dist/cjs/document/Head.js +1 -1
- package/dist/cjs/document/Root.js +1 -1
- package/dist/cjs/document/cli/index.js +2 -2
- package/dist/cjs/router/cli/code/getClientRoutes/getRoutes.js +1 -1
- package/dist/cjs/router/cli/code/getClientRoutes/getRoutesLegacy.js +1 -1
- package/dist/cjs/router/cli/code/index.js +18 -27
- package/dist/cjs/router/cli/code/templates.js +15 -8
- package/dist/cjs/router/cli/code/utils.js +1 -1
- package/dist/cjs/router/cli/handler.js +2 -2
- package/dist/cjs/router/runtime/DeferredDataScripts.node.js +2 -2
- package/dist/cjs/router/runtime/PrefetchLink.js +1 -1
- package/dist/cjs/router/runtime/plugin.js +4 -4
- package/dist/cjs/router/runtime/plugin.node.js +6 -6
- package/dist/cjs/router/runtime/utils.js +2 -2
- package/dist/cjs/state/plugins.js +1 -1
- package/dist/cjs/state/runtime/plugin.js +6 -6
- package/dist/esm/cli/code.js +1 -1
- package/dist/esm/cli/index.js +7 -10
- package/dist/esm/cli/ssr/babel-plugin-ssr-loader-id.js +1 -1
- package/dist/esm/cli/template.js +1 -1
- package/dist/esm/core/browser/hydrate.js +1 -1
- package/dist/esm/core/browser/index.js +2 -2
- package/dist/esm/core/browser/withCallback.js +1 -1
- package/dist/esm/core/compatible.js +4 -4
- package/dist/esm/core/context/runtime.js +1 -1
- package/dist/esm/core/loader/useLoader.js +1 -1
- package/dist/esm/core/plugin/base.js +1 -1
- package/dist/esm/core/plugin/index.js +1 -1
- package/dist/esm/core/server/react/prerender/index.js +2 -2
- package/dist/esm/core/server/requestHandler.js +8 -4
- package/dist/esm/core/server/stream/afterTemplate.js +1 -1
- package/dist/esm/core/server/stream/beforeTemplate.js +3 -3
- package/dist/esm/core/server/stream/createReadableStream.js +2 -2
- package/dist/esm/core/server/stream/createReadableStream.worker.js +2 -2
- package/dist/esm/core/server/stream/shared.js +1 -1
- package/dist/esm/core/server/stream/template.js +1 -1
- package/dist/esm/core/server/string/index.js +8 -8
- package/dist/esm/core/server/string/prefetch.js +2 -2
- package/dist/esm/core/server/string/ssrData.js +1 -1
- package/dist/esm/document/Body.js +1 -1
- package/dist/esm/document/Comment.js +1 -1
- package/dist/esm/document/Head.js +1 -1
- package/dist/esm/document/Root.js +1 -1
- package/dist/esm/document/Script.js +1 -1
- package/dist/esm/document/Style.js +1 -1
- package/dist/esm/document/cli/index.js +3 -3
- package/dist/esm/router/cli/code/getClientRoutes/getRoutes.js +2 -2
- package/dist/esm/router/cli/code/getClientRoutes/getRoutesLegacy.js +2 -2
- package/dist/esm/router/cli/code/getClientRoutes/utils.js +2 -2
- package/dist/esm/router/cli/code/index.js +36 -35
- package/dist/esm/router/cli/code/nestedRoutes.js +1 -1
- package/dist/esm/router/cli/code/templates.js +2 -2
- package/dist/esm/router/cli/code/utils.js +2 -2
- package/dist/esm/router/cli/entry.js +1 -1
- package/dist/esm/router/cli/handler.js +2 -2
- package/dist/esm/router/cli/index.js +1 -1
- package/dist/esm/router/runtime/DeferredDataScripts.node.js +2 -2
- package/dist/esm/router/runtime/PrefetchLink.js +1 -1
- package/dist/esm/router/runtime/plugin.js +4 -4
- package/dist/esm/router/runtime/plugin.node.js +6 -6
- package/dist/esm/router/runtime/utils.js +2 -2
- package/dist/esm/state/plugins.js +1 -1
- package/dist/esm/state/runtime/plugin.js +4 -4
- package/dist/esm-node/cli/code.js +1 -1
- package/dist/esm-node/cli/index.js +7 -10
- package/dist/esm-node/cli/ssr/babel-plugin-ssr-loader-id.js +1 -1
- package/dist/esm-node/cli/template.js +1 -1
- package/dist/esm-node/core/browser/hydrate.js +1 -1
- package/dist/esm-node/core/browser/index.js +2 -2
- package/dist/esm-node/core/browser/withCallback.js +1 -1
- package/dist/esm-node/core/compatible.js +4 -4
- package/dist/esm-node/core/context/runtime.js +1 -1
- package/dist/esm-node/core/loader/useLoader.js +1 -1
- package/dist/esm-node/core/plugin/base.js +1 -1
- package/dist/esm-node/core/plugin/index.js +1 -1
- package/dist/esm-node/core/server/react/prerender/index.js +2 -2
- package/dist/esm-node/core/server/requestHandler.js +8 -3
- package/dist/esm-node/core/server/stream/afterTemplate.js +1 -1
- package/dist/esm-node/core/server/stream/beforeTemplate.js +3 -3
- package/dist/esm-node/core/server/stream/createReadableStream.js +2 -2
- package/dist/esm-node/core/server/stream/createReadableStream.worker.js +2 -2
- package/dist/esm-node/core/server/stream/shared.js +1 -1
- package/dist/esm-node/core/server/stream/template.js +1 -1
- package/dist/esm-node/core/server/string/index.js +8 -8
- package/dist/esm-node/core/server/string/prefetch.js +2 -2
- package/dist/esm-node/core/server/string/ssrData.js +1 -1
- package/dist/esm-node/document/Body.js +1 -1
- package/dist/esm-node/document/Comment.js +1 -1
- package/dist/esm-node/document/Head.js +1 -1
- package/dist/esm-node/document/Root.js +1 -1
- package/dist/esm-node/document/Script.js +1 -1
- package/dist/esm-node/document/Style.js +1 -1
- package/dist/esm-node/document/cli/index.js +3 -3
- package/dist/esm-node/router/cli/code/getClientRoutes/getRoutes.js +2 -2
- package/dist/esm-node/router/cli/code/getClientRoutes/getRoutesLegacy.js +2 -2
- package/dist/esm-node/router/cli/code/getClientRoutes/utils.js +2 -2
- package/dist/esm-node/router/cli/code/index.js +15 -24
- package/dist/esm-node/router/cli/code/nestedRoutes.js +1 -1
- package/dist/esm-node/router/cli/code/templates.js +16 -9
- package/dist/esm-node/router/cli/code/utils.js +2 -2
- package/dist/esm-node/router/cli/entry.js +1 -1
- package/dist/esm-node/router/cli/handler.js +2 -2
- package/dist/esm-node/router/cli/index.js +1 -1
- package/dist/esm-node/router/runtime/DeferredDataScripts.node.js +2 -2
- package/dist/esm-node/router/runtime/PrefetchLink.js +1 -1
- package/dist/esm-node/router/runtime/plugin.js +4 -4
- package/dist/esm-node/router/runtime/plugin.node.js +6 -6
- package/dist/esm-node/router/runtime/utils.js +2 -2
- package/dist/esm-node/state/plugins.js +1 -1
- package/dist/esm-node/state/runtime/plugin.js +4 -4
- package/dist/types/cli/code.d.ts +1 -1
- package/dist/types/cli/index.d.ts +3 -3
- package/dist/types/cli/ssr/index.d.ts +1 -1
- package/dist/types/common.d.ts +1 -1
- package/dist/types/config.d.ts +1 -1
- package/dist/types/core/compatible.d.ts +1 -1
- package/dist/types/core/context/runtime.d.ts +2 -2
- package/dist/types/core/plugin/index.d.ts +1 -1
- package/dist/types/core/server/stream/afterTemplate.d.ts +2 -2
- package/dist/types/core/server/stream/template.d.ts +1 -1
- package/dist/types/core/server/string/loadable.d.ts +1 -1
- package/dist/types/core/server/string/prefetch.d.ts +1 -1
- package/dist/types/core/server/string/ssrData.d.ts +2 -2
- package/dist/types/core/server/string/styledComponent.d.ts +1 -1
- package/dist/types/core/server/utils.d.ts +1 -1
- package/dist/types/core/types.d.ts +1 -1
- package/dist/types/document/cli/index.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/router/cli/code/index.d.ts +1 -1
- package/dist/types/router/cli/code/templates.d.ts +1 -1
- package/dist/types/router/cli/handler.d.ts +2 -2
- package/dist/types/router/cli/index.d.ts +1 -1
- package/dist/types/router/runtime/PrefetchLink.d.ts +1 -1
- package/dist/types/router/runtime/index.d.ts +1 -1
- package/dist/types/router/runtime/types.d.ts +2 -2
- package/dist/types/router/runtime/utils.d.ts +2 -2
- package/dist/types/router/runtime/withRouter.d.ts +1 -1
- package/dist/types/state/cli/index.d.ts +1 -1
- package/package.json +10 -10
|
@@ -1,14 +1,14 @@
|
|
|
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, getEntryOptions, isRouterV5, isSSGEntry, isUseSSRBundle, logger,
|
|
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
|
-
import { FILE_SYSTEM_ROUTES_FILE_NAME } from "../constants";
|
|
7
6
|
import { ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME } from "../../../cli/constants";
|
|
8
|
-
import
|
|
7
|
+
import { FILE_SYSTEM_ROUTES_FILE_NAME } from "../constants";
|
|
9
8
|
import { getClientRoutes, getClientRoutesLegacy } from "./getClientRoutes";
|
|
10
|
-
import { getServerLoadersFile, getServerCombinedModueFile } from "./utils";
|
|
11
9
|
import { walk } from "./nestedRoutes";
|
|
10
|
+
import * as templates from "./templates";
|
|
11
|
+
import { getServerCombinedModueFile, getServerLoadersFile } from "./utils";
|
|
12
12
|
var generateCode = function() {
|
|
13
13
|
var _ref = _async_to_generator(function(appContext, config, entrypoints, api) {
|
|
14
14
|
var internalDirectory, srcDirectory, internalDirAlias, internalSrcAlias, packageName, hookRunners, isV5, getRoutes, oldVersion;
|
|
@@ -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
|
}
|
|
@@ -3,7 +3,7 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
|
3
3
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
4
4
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
5
5
|
import * as path from "path";
|
|
6
|
-
import {
|
|
6
|
+
import { fs, JS_EXTENSIONS, normalizeToPosixPath } from "@modern-js/utils";
|
|
7
7
|
import { NESTED_ROUTE } from "../constants";
|
|
8
8
|
import { getPathWithoutExt, hasAction, replaceWithAlias } from "./utils";
|
|
9
9
|
var conventionNames = Object.values(NESTED_ROUTE);
|
|
@@ -4,7 +4,7 @@ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
|
4
4
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
5
5
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
6
6
|
import path from "path";
|
|
7
|
-
import { findExists, formatImportPath,
|
|
7
|
+
import { fs, findExists, formatImportPath, getEntryOptions, isSSGEntry, slash } from "@modern-js/utils";
|
|
8
8
|
import { ROUTE_MODULES } from "@modern-js/utils/universal/constants";
|
|
9
9
|
import { APP_CONFIG_NAME, APP_INIT_EXPORTED, TEMP_LOADERS_DIR } from "../constants";
|
|
10
10
|
import { getPathWithoutExt, getServerLoadersFile, parseModule, replaceWithAlias } from "./utils";
|
|
@@ -414,7 +414,7 @@ function ssrLoaderCombinedModule(entrypoints, entrypoint, config, appContext) {
|
|
|
414
414
|
if (!config.source.enableAsyncEntry) {
|
|
415
415
|
return combinedModule;
|
|
416
416
|
}
|
|
417
|
-
return '
|
|
417
|
+
return '\n async function loadModules() {\n const [moduleA, moduleB] = await Promise.all([\n import("'.concat(slash(serverLoaderRuntime), '"),\n import("').concat(slash(serverLoadersFile), '")\n ]);\n\n return {\n ...moduleA,\n ...moduleB\n };\n }\n\n export { loadModules };\n ');
|
|
418
418
|
}
|
|
419
419
|
return null;
|
|
420
420
|
}
|
|
@@ -4,9 +4,9 @@ import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
|
4
4
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
5
5
|
import fs from "fs";
|
|
6
6
|
import path from "path";
|
|
7
|
-
import {
|
|
8
|
-
import { transform } from "esbuild";
|
|
7
|
+
import { JS_EXTENSIONS, fs as fse, normalizeToPosixPath } from "@modern-js/utils";
|
|
9
8
|
import { parse } from "es-module-lexer";
|
|
9
|
+
import { transform } from "esbuild";
|
|
10
10
|
import { ACTION_EXPORT_NAME, LOADER_EXPORT_NAME } from "../constants";
|
|
11
11
|
var walkDirectory = function(dir) {
|
|
12
12
|
return fs.readdirSync(dir).reduce(function(previous, filename) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
2
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import { JS_EXTENSIONS, findExists,
|
|
4
|
+
import { fs, JS_EXTENSIONS, findExists, isRouterV5 } from "@modern-js/utils";
|
|
5
5
|
import { hasApp } from "../../cli/entry";
|
|
6
6
|
import { FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT, NESTED_ROUTES_DIR, PAGES_DIR_NAME } from "./constants";
|
|
7
7
|
var hasPages = function(dir) {
|
|
@@ -2,9 +2,9 @@ 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
4
|
import { cloneDeep } from "@modern-js/utils/lodash";
|
|
5
|
-
import { modifyEntrypoints } from "./entry";
|
|
6
|
-
import { isPageComponentFile } from "./code/utils";
|
|
7
5
|
import * as templates from "./code/templates";
|
|
6
|
+
import { isPageComponentFile } from "./code/utils";
|
|
7
|
+
import { modifyEntrypoints } from "./entry";
|
|
8
8
|
var originEntrypoints = [];
|
|
9
9
|
function handleModifyEntrypoints(api, entrypoints) {
|
|
10
10
|
return _handleModifyEntrypoints.apply(this, arguments);
|
|
@@ -3,7 +3,7 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
|
3
3
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
4
4
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
5
5
|
import path from "node:path";
|
|
6
|
-
import { createRuntimeExportsUtils, filterRoutesForServer,
|
|
6
|
+
import { fs, NESTED_ROUTE_SPEC_FILE, createRuntimeExportsUtils, filterRoutesForServer, getEntryOptions, isRouterV5 as isV5 } from "@modern-js/utils";
|
|
7
7
|
import { isRouteEntry } from "./entry";
|
|
8
8
|
import { handleFileChange, handleGeneratorEntryCode, handleModifyEntrypoints } from "./handler";
|
|
9
9
|
import { isRouteEntry as isRouteEntry2 } from "./entry";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { Suspense, useEffect, useRef, useMemo } from "react";
|
|
4
|
-
import { Await, useAsyncError } from "@modern-js/runtime-utils/router";
|
|
5
3
|
import { serializeJson } from "@modern-js/runtime-utils/node";
|
|
4
|
+
import { Await, useAsyncError } from "@modern-js/runtime-utils/router";
|
|
5
|
+
import { Suspense, useEffect, useMemo, useRef } from "react";
|
|
6
6
|
import { serializeErrors } from "./utils";
|
|
7
7
|
var setupFnStr = "function s(r,e){_ROUTER_DATA.r=_ROUTER_DATA.r||{},_ROUTER_DATA.r[r]=_ROUTER_DATA.r[r]||{};return new Promise((function(A,R){_ROUTER_DATA.r[r][e]={resolve:A,reject:R}}))};";
|
|
8
8
|
var resolveFnStr = "function r(e,r,o,A){A?_ROUTER_DATA.r[e][r].reject(A):_ROUTER_DATA.r[e][r].resolve(o)};";
|
|
@@ -4,8 +4,8 @@ import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_
|
|
|
4
4
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
5
5
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
6
6
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
|
+
import { Link as RouterLink, NavLink as RouterNavLink, matchRoutes, useHref, useMatches, useResolvedPath } from "@modern-js/runtime-utils/router";
|
|
7
8
|
import React, { useContext, useMemo } from "react";
|
|
8
|
-
import { Link as RouterLink, matchRoutes, useResolvedPath, useHref, useMatches, NavLink as RouterNavLink } from "@modern-js/runtime-utils/router";
|
|
9
9
|
import { RuntimeReactContext } from "../../core";
|
|
10
10
|
function composeEventHandlers(theirHandler, ourHandler) {
|
|
11
11
|
return function(event) {
|
|
@@ -2,12 +2,12 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
|
2
2
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
3
3
|
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
import { useContext, useMemo } from "react";
|
|
6
|
-
import { createBrowserRouter, createHashRouter, RouterProvider, createRoutesFromElements, useMatches, useLocation, useHref } from "@modern-js/runtime-utils/router";
|
|
7
|
-
import { parsedJSONFromElement } from "@modern-js/runtime-utils/parsed";
|
|
8
5
|
import { merge } from "@modern-js/runtime-utils/merge";
|
|
9
|
-
import {
|
|
6
|
+
import { parsedJSONFromElement } from "@modern-js/runtime-utils/parsed";
|
|
7
|
+
import { RouterProvider, createBrowserRouter, createHashRouter, createRoutesFromElements, useHref, useLocation, useMatches } from "@modern-js/runtime-utils/router";
|
|
8
|
+
import { useContext, useMemo } from "react";
|
|
10
9
|
import { RuntimeReactContext } from "../../core";
|
|
10
|
+
import { getGlobalLayoutApp, getGlobalRoutes } from "../../core/context";
|
|
11
11
|
import { modifyRoutes as modifyRoutesHook } from "./hooks";
|
|
12
12
|
import { deserializeErrors, renderRoutes, urlJoin } from "./utils";
|
|
13
13
|
var finalRouteConfig = {
|
|
@@ -4,20 +4,20 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
|
4
4
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
5
5
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
6
6
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
|
-
import {
|
|
7
|
+
import { merge } from "@modern-js/runtime-utils/merge";
|
|
8
|
+
import { createRequestContext, reporterCtx } from "@modern-js/runtime-utils/node";
|
|
9
|
+
import { StaticRouterProvider, createStaticRouter } from "@modern-js/runtime-utils/node/router";
|
|
8
10
|
import { createStaticHandler } from "@modern-js/runtime-utils/remix-router";
|
|
9
|
-
import { createStaticRouter, StaticRouterProvider } from "@modern-js/runtime-utils/node/router";
|
|
10
11
|
import { createRoutesFromElements } from "@modern-js/runtime-utils/router";
|
|
11
|
-
import { reporterCtx, createRequestContext } from "@modern-js/runtime-utils/node";
|
|
12
12
|
import { time } from "@modern-js/runtime-utils/time";
|
|
13
13
|
import { LOADER_REPORTER_NAME } from "@modern-js/utils/universal/constants";
|
|
14
|
-
import {
|
|
14
|
+
import { useContext } from "react";
|
|
15
15
|
import { JSX_SHELL_STREAM_END_MARK } from "../../common";
|
|
16
16
|
import { RuntimeReactContext } from "../../core";
|
|
17
17
|
import { getGlobalLayoutApp, getGlobalRoutes } from "../../core/context";
|
|
18
|
-
import { renderRoutes, urlJoin } from "./utils";
|
|
19
|
-
import { modifyRoutes as modifyRoutesHook } from "./hooks";
|
|
20
18
|
import DeferredDataScripts from "./DeferredDataScripts.node";
|
|
19
|
+
import { modifyRoutes as modifyRoutesHook } from "./hooks";
|
|
20
|
+
import { renderRoutes, urlJoin } from "./utils";
|
|
21
21
|
function createRemixReuqest(request) {
|
|
22
22
|
var method = "GET";
|
|
23
23
|
var headers = request.headers;
|
|
@@ -4,9 +4,9 @@ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
|
4
4
|
import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
|
|
5
5
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
import { Route, isRouteErrorResponse } from "@modern-js/runtime-utils/router";
|
|
8
|
-
import { UNSAFE_ErrorResponseImpl as ErrorResponseImpl } from "@modern-js/runtime-utils/remix-router";
|
|
9
7
|
import { renderNestedRoute } from "@modern-js/runtime-utils/browser";
|
|
8
|
+
import { UNSAFE_ErrorResponseImpl as ErrorResponseImpl } from "@modern-js/runtime-utils/remix-router";
|
|
9
|
+
import { Route, isRouteErrorResponse } from "@modern-js/runtime-utils/router";
|
|
10
10
|
import { DefaultNotFound } from "./DefaultNotFound";
|
|
11
11
|
import DeferredDataScripts from "./DeferredDataScripts";
|
|
12
12
|
function getRouteComponents(routes, param) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { plugin as effectsPlugin } from "@modern-js-reduck/plugin-effects";
|
|
2
1
|
import autoActionsPlugin from "@modern-js-reduck/plugin-auto-actions";
|
|
2
|
+
import { plugin as effectsPlugin } from "@modern-js-reduck/plugin-effects";
|
|
3
3
|
import immerPlugin from "@modern-js-reduck/plugin-immutable";
|
|
4
4
|
import { default as default2 } from "@modern-js-reduck/plugin-devtools";
|
|
5
5
|
var effects = function() {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
2
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
-
import { useContext } from "react";
|
|
5
|
-
import { createStore } from "@modern-js-reduck/store";
|
|
6
4
|
import { Provider } from "@modern-js-reduck/react";
|
|
5
|
+
import { createStore } from "@modern-js-reduck/store";
|
|
7
6
|
import { merge } from "@modern-js/runtime-utils/merge";
|
|
8
|
-
import {
|
|
9
|
-
import { RuntimeReactContext } from "../../core";
|
|
7
|
+
import { useContext } from "react";
|
|
10
8
|
import { isBrowser } from "../../common";
|
|
9
|
+
import { RuntimeReactContext } from "../../core";
|
|
10
|
+
import { autoActions, devtools, effects, immer } from "../plugins";
|
|
11
11
|
var StatePluginHandleMap = {
|
|
12
12
|
immer,
|
|
13
13
|
effects,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { fs } from "@modern-js/utils";
|
|
3
|
-
import {
|
|
3
|
+
import { ENTRY_BOOTSTRAP_FILE_NAME, ENTRY_POINT_FILE_NAME, ENTRY_POINT_REGISTER_FILE_NAME, ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME, ENTRY_POINT_RUNTIME_REGISTER_FILE_NAME, ENTRY_SERVER_BOOTSTRAP_FILE_NAME, INDEX_FILE_NAME, SERVER_ENTRY_POINT_FILE_NAME } from "./constants";
|
|
4
4
|
import * as template from "./template";
|
|
5
5
|
import * as serverTemplate from "./template.server";
|
|
6
6
|
function getSSRMode(entry, config) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { isReact18 as checkIsReact18, cleanRequireCache, createRuntimeExportsUtils } from "@modern-js/utils";
|
|
3
|
-
import { statePlugin } from "../state/cli";
|
|
4
|
-
import { routerPlugin } from "../router/cli";
|
|
5
3
|
import { documentPlugin } from "../document/cli";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { ENTRY_BOOTSTRAP_FILE_NAME, ENTRY_POINT_FILE_NAME } from "./constants";
|
|
9
|
-
import { generateCode } from "./code";
|
|
4
|
+
import { routerPlugin } from "../router/cli";
|
|
5
|
+
import { statePlugin } from "../state/cli";
|
|
10
6
|
import { builderPluginAlias } from "./alias";
|
|
7
|
+
import { generateCode } from "./code";
|
|
8
|
+
import { ENTRY_BOOTSTRAP_FILE_NAME, ENTRY_POINT_FILE_NAME } from "./constants";
|
|
9
|
+
import { isRuntimeEntry } from "./entry";
|
|
10
|
+
import { ssrPlugin } from "./ssr";
|
|
11
11
|
import { isRuntimeEntry as isRuntimeEntry2 } from "./entry";
|
|
12
12
|
const runtimePlugin = (params) => ({
|
|
13
13
|
name: "@modern-js/runtime",
|
|
@@ -103,10 +103,7 @@ const runtimePlugin = (params) => ({
|
|
|
103
103
|
]
|
|
104
104
|
},
|
|
105
105
|
bundlerChain: (chain) => {
|
|
106
|
-
chain.module.rule("modern-entry").test(
|
|
107
|
-
/\.js$/,
|
|
108
|
-
/\.jsx$/
|
|
109
|
-
]).include.add(path.resolve(appDirectory, "node_modules", `.${metaName}`)).end().sideEffects(true);
|
|
106
|
+
chain.module.rule("modern-entry").test(/\.jsx?$/).include.add(path.resolve(appDirectory, "node_modules", `.${metaName}`)).end().sideEffects(true);
|
|
110
107
|
},
|
|
111
108
|
/**
|
|
112
109
|
* Add IgnorePlugin to fix react-dom/client import error when use react17
|
|
@@ -2,8 +2,8 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
2
2
|
var __commonJS = (cb, mod) => function __require() {
|
|
3
3
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
4
|
};
|
|
5
|
-
import crypto from "crypto";
|
|
6
5
|
import { Buffer as Buffer2 } from "buffer";
|
|
6
|
+
import crypto from "crypto";
|
|
7
7
|
import * as t from "@babel/types";
|
|
8
8
|
import { get } from "@modern-js/utils/lodash";
|
|
9
9
|
var require_babel_plugin_ssr_loader_id = __commonJS({
|
|
@@ -53,7 +53,7 @@ const runtimeGlobalContext = ({ srcDirectory, internalSrcAlias, metaName, entry,
|
|
|
53
53
|
return `import { setGlobalContext } from '@${metaName}/runtime/context'
|
|
54
54
|
|
|
55
55
|
import App from '${// We need to get the path of App.tsx here, but the entry is `src/entry.tsx`
|
|
56
|
-
formatImportPath(customEntry ? entry.replace("entry.tsx", "App
|
|
56
|
+
formatImportPath(customEntry ? entry.replace("entry.tsx", "App").replace(srcDirectory, internalSrcAlias) : entry.replace(srcDirectory, internalSrcAlias).replace(".tsx", ""))}';
|
|
57
57
|
|
|
58
58
|
setGlobalContext({
|
|
59
59
|
App,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { normalizePathname } from "@modern-js/runtime-utils/url";
|
|
3
2
|
import { loadableReady } from "@loadable/component";
|
|
3
|
+
import { normalizePathname } from "@modern-js/runtime-utils/url";
|
|
4
4
|
import { RenderLevel } from "../constants";
|
|
5
5
|
import { wrapRuntimeContextProvider } from "../react/wrapper";
|
|
6
6
|
import { WithCallback } from "./withCallback";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import cookieTool from "cookie";
|
|
2
1
|
import { parsedJSONFromElement } from "@modern-js/runtime-utils/parsed";
|
|
2
|
+
import cookieTool from "cookie";
|
|
3
|
+
import { ROUTER_DATA_JSON_ID, SSR_DATA_JSON_ID } from "../constants";
|
|
3
4
|
import { getGlobalAppInit } from "../context";
|
|
4
5
|
import { getInitialContext } from "../context/runtime";
|
|
5
6
|
import { createLoaderManager } from "../loader/loaderManager";
|
|
6
7
|
import { getGlobalRunner } from "../plugin/runner";
|
|
7
8
|
import { wrapRuntimeContextProvider } from "../react/wrapper";
|
|
8
|
-
import { ROUTER_DATA_JSON_ID, SSR_DATA_JSON_ID } from "../constants";
|
|
9
9
|
import { hydrateRoot } from "./hydrate";
|
|
10
10
|
const IS_REACT18 = process.env.IS_REACT18 === "true";
|
|
11
11
|
const getQuery = () => window.location.search.substring(1).split("&").reduce((res, item) => {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import React, { useContext, useMemo } from "react";
|
|
3
2
|
import { ROUTE_MANIFEST } from "@modern-js/utils/universal/constants";
|
|
3
|
+
import React, { useContext, useMemo } from "react";
|
|
4
|
+
import { hydrateRoot as ModernHydrateRoot } from "./browser/hydrate";
|
|
5
|
+
import { getGlobalAppInit } from "./context";
|
|
4
6
|
import { RuntimeReactContext } from "./context/runtime";
|
|
5
|
-
import { registerPlugin } from "./plugin";
|
|
6
7
|
import { createLoaderManager } from "./loader/loaderManager";
|
|
8
|
+
import { registerPlugin } from "./plugin";
|
|
7
9
|
import { getGlobalRunner } from "./plugin/runner";
|
|
8
|
-
import { getGlobalAppInit } from "./context";
|
|
9
|
-
import { hydrateRoot as ModernHydrateRoot } from "./browser/hydrate";
|
|
10
10
|
import { wrapRuntimeContextProvider } from "./react/wrapper";
|
|
11
11
|
const IS_REACT18 = process.env.IS_REACT18 === "true";
|
|
12
12
|
function isClientArgs(id) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createContext } from "react";
|
|
2
1
|
import { ROUTE_MANIFEST } from "@modern-js/utils/universal/constants";
|
|
2
|
+
import { createContext } from "react";
|
|
3
3
|
import { createLoaderManager } from "../loader/loaderManager";
|
|
4
4
|
const RuntimeReactContext = createContext({});
|
|
5
5
|
const ServerRouterContext = createContext({});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useContext, useRef, useMemo, useState, useCallback, useEffect } from "react";
|
|
2
1
|
import invariant from "invariant";
|
|
2
|
+
import { useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { RuntimeReactContext } from "../context/runtime";
|
|
4
4
|
import { LoaderStatus } from "./loaderManager";
|
|
5
5
|
const useLoader = (loaderFn, options = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createAsyncInterruptWorkflow, createContext, createManager, createSyncParallelWorkflow, createWaterfall } from "@modern-js/plugin";
|
|
2
2
|
const RuntimeConfigContext = createContext({});
|
|
3
3
|
const useRuntimeConfigContext = () => RuntimeConfigContext.use().value;
|
|
4
4
|
const wrapRoot = createWaterfall();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { merge } from "@modern-js/runtime-utils/merge";
|
|
2
|
-
import {
|
|
2
|
+
import { RuntimeConfigContext, runtime } from "./base";
|
|
3
3
|
import { getGlobalRunner, setGlobalRunner } from "./runner";
|
|
4
4
|
export * from "./base";
|
|
5
5
|
function setupConfigContext() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import withSideEffect from "react-side-effect";
|
|
2
1
|
import React, { createElement } from "react";
|
|
3
|
-
import
|
|
2
|
+
import withSideEffect from "react-side-effect";
|
|
3
|
+
import { aggKeysFromPropsList, aggMatchesFromPropsList, exist, getOutermostProperty } from "./util";
|
|
4
4
|
const PROP_NAMES = {
|
|
5
5
|
INTERVAL: "interval",
|
|
6
6
|
STALE_LIMIT: "staleLimit",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { getPathname, parseCookie, parseHeaders, parseQuery } from "@modern-js/runtime-utils/universal/request";
|
|
2
|
-
import { createRoot } from "../react";
|
|
3
2
|
import { getGlobalAppInit } from "../context";
|
|
4
|
-
import { getGlobalRunner } from "../plugin/runner";
|
|
5
3
|
import { getInitialContext } from "../context/runtime";
|
|
6
4
|
import { createLoaderManager } from "../loader/loaderManager";
|
|
7
|
-
import {
|
|
5
|
+
import { getGlobalRunner } from "../plugin/runner";
|
|
6
|
+
import { createRoot } from "../react";
|
|
8
7
|
import { CHUNK_CSS_PLACEHOLDER } from "./constants";
|
|
8
|
+
import { getSSRConfigByEntry, getSSRMode } from "./utils";
|
|
9
9
|
function createSSRContext(request, options) {
|
|
10
10
|
const { config, loaderContext, onError, onTiming, locals, resource, params, responseProxy, logger, metrics, reporter } = options;
|
|
11
11
|
const { nonce } = config;
|
|
@@ -63,6 +63,7 @@ function createSSRContext(request, options) {
|
|
|
63
63
|
}
|
|
64
64
|
const createRequestHandler = async (handleRequest) => {
|
|
65
65
|
const requestHandler = async (request, options) => {
|
|
66
|
+
var _context_routerContext, _context_routerContext1;
|
|
66
67
|
const Root = createRoot();
|
|
67
68
|
const runner = getGlobalRunner();
|
|
68
69
|
const { routeManifest } = options.resource;
|
|
@@ -110,6 +111,10 @@ const createRequestHandler = async (handleRequest) => {
|
|
|
110
111
|
return void 0;
|
|
111
112
|
};
|
|
112
113
|
const initialData = await runBeforeRender(context);
|
|
114
|
+
if (((_context_routerContext = context.routerContext) === null || _context_routerContext === void 0 ? void 0 : _context_routerContext.statusCode) && ((_context_routerContext1 = context.routerContext) === null || _context_routerContext1 === void 0 ? void 0 : _context_routerContext1.statusCode) !== 200) {
|
|
115
|
+
var _context_routerContext2, _context_ssrContext;
|
|
116
|
+
(_context_ssrContext = context.ssrContext) === null || _context_ssrContext === void 0 ? void 0 : _context_ssrContext.response.status((_context_routerContext2 = context.routerContext) === null || _context_routerContext2 === void 0 ? void 0 : _context_routerContext2.statusCode);
|
|
117
|
+
}
|
|
113
118
|
context.initialData = initialData;
|
|
114
119
|
const redirectResponse = getRedirectResponse(initialData);
|
|
115
120
|
if (redirectResponse) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { serializeJson } from "@modern-js/runtime-utils/node";
|
|
2
|
-
import { attributesToString, safeReplace } from "../utils";
|
|
3
2
|
import { SSR_DATA_PLACEHOLDER } from "../constants";
|
|
4
3
|
import { buildHtml } from "../shared";
|
|
4
|
+
import { attributesToString, safeReplace } from "../utils";
|
|
5
5
|
function buildShellAfterTemplate(afterAppTemplate, options) {
|
|
6
6
|
const { request, config, ssrConfig, runtimeContext, renderLevel, entryName } = options;
|
|
7
7
|
const callbacks = [
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import ReactHelmet from "react-helmet";
|
|
2
1
|
import { matchRoutes } from "@modern-js/runtime-utils/router";
|
|
3
|
-
import
|
|
2
|
+
import ReactHelmet from "react-helmet";
|
|
4
3
|
import { CHUNK_CSS_PLACEHOLDER } from "../constants";
|
|
5
|
-
import {
|
|
4
|
+
import { createReplaceHelemt } from "../helmet";
|
|
6
5
|
import { buildHtml } from "../shared";
|
|
6
|
+
import { checkIsNode, safeReplace } from "../utils";
|
|
7
7
|
const readAsset = async (chunk) => {
|
|
8
8
|
const fs = await import("fs/promises");
|
|
9
9
|
const path = await import("path");
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Transform } from "stream";
|
|
2
2
|
import { createReadableStreamFromReadable } from "@modern-js/runtime-utils/node";
|
|
3
|
-
import { ServerStyleSheet } from "styled-components";
|
|
4
3
|
import checkIsBot from "isbot";
|
|
4
|
+
import { ServerStyleSheet } from "styled-components";
|
|
5
5
|
import { ESCAPED_SHELL_STREAM_END_MARK } from "../../../common";
|
|
6
6
|
import { RenderLevel } from "../../constants";
|
|
7
|
-
import { getTemplates } from "./template";
|
|
8
7
|
import { ShellChunkStatus, getReadableStreamFromString } from "./shared";
|
|
8
|
+
import { getTemplates } from "./template";
|
|
9
9
|
const createReadableStreamFromElement = async (request, rootElement, options) => {
|
|
10
10
|
const { renderToPipeableStream } = await import("react-dom/server");
|
|
11
11
|
const { runtimeContext, htmlTemplate, config, ssrConfig, entryName } = options;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { renderToReadableStream } from "react-dom/server";
|
|
2
1
|
import checkIsBot from "isbot";
|
|
3
|
-
import {
|
|
2
|
+
import { renderToReadableStream } from "react-dom/server";
|
|
4
3
|
import { ESCAPED_SHELL_STREAM_END_MARK } from "../../../common";
|
|
4
|
+
import { RenderLevel } from "../../constants";
|
|
5
5
|
import { ShellChunkStatus, encodeForWebStream, getReadableStreamFromString } from "./shared";
|
|
6
6
|
import { getTemplates } from "./template";
|
|
7
7
|
const createReadableStreamFromElement = async (request, rootElement, options) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { run } from "@modern-js/runtime-utils/node";
|
|
1
2
|
import { time } from "@modern-js/runtime-utils/time";
|
|
2
3
|
import { parseHeaders } from "@modern-js/runtime-utils/universal/request";
|
|
3
|
-
import { run } from "@modern-js/runtime-utils/node";
|
|
4
4
|
import { wrapRuntimeContextProvider } from "../../react/wrapper";
|
|
5
5
|
import { SSRErrors, SSRTimings, createOnError, createOnTiming } from "../tracer";
|
|
6
6
|
import { getSSRConfigByEntry } from "../utils";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { buildShellBeforeTemplate } from "./beforeTemplate";
|
|
2
1
|
import { buildShellAfterTemplate } from "./afterTemplate";
|
|
2
|
+
import { buildShellBeforeTemplate } from "./beforeTemplate";
|
|
3
3
|
const HTML_SEPARATOR = "<!--<?- html ?>-->";
|
|
4
4
|
const getTemplates = async (htmlTemplate, options) => {
|
|
5
5
|
const [beforeAppTemplate = "", afterAppHtmlTemplate = ""] = htmlTemplate.split(HTML_SEPARATOR) || [];
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import ReactHelmet from "react-helmet";
|
|
2
|
-
import ReactDomServer from "react-dom/server";
|
|
3
|
-
import { time } from "@modern-js/runtime-utils/time";
|
|
4
1
|
import { run } from "@modern-js/runtime-utils/node";
|
|
2
|
+
import { time } from "@modern-js/runtime-utils/time";
|
|
5
3
|
import { parseHeaders } from "@modern-js/runtime-utils/universal/request";
|
|
4
|
+
import ReactDomServer from "react-dom/server";
|
|
5
|
+
import ReactHelmet from "react-helmet";
|
|
6
|
+
import { RenderLevel } from "../../constants";
|
|
6
7
|
import { wrapRuntimeContextProvider } from "../../react/wrapper";
|
|
7
|
-
import { createReplaceHelemt } from "../helmet";
|
|
8
|
-
import { getSSRConfigByEntry, safeReplace } from "../utils";
|
|
9
8
|
import { CHUNK_CSS_PLACEHOLDER, CHUNK_JS_PLACEHOLDER, HTML_PLACEHOLDER, SSR_DATA_PLACEHOLDER } from "../constants";
|
|
9
|
+
import { createReplaceHelemt } from "../helmet";
|
|
10
10
|
import { buildHtml } from "../shared";
|
|
11
11
|
import { SSRErrors, SSRTimings, createOnError, createOnTiming } from "../tracer";
|
|
12
|
-
import {
|
|
13
|
-
import { SSRDataCollector } from "./ssrData";
|
|
12
|
+
import { getSSRConfigByEntry, safeReplace } from "../utils";
|
|
14
13
|
import { LoadableCollector } from "./loadable";
|
|
15
|
-
import { StyledCollector } from "./styledComponent";
|
|
16
14
|
import { prefetch } from "./prefetch";
|
|
15
|
+
import { SSRDataCollector } from "./ssrData";
|
|
16
|
+
import { StyledCollector } from "./styledComponent";
|
|
17
17
|
const renderString = async (request, serverRoot, options) => {
|
|
18
18
|
const headersData = parseHeaders(request);
|
|
19
19
|
return run(headersData, async () => {
|