@modern-js/runtime 2.35.0 → 2.36.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 +48 -30
- package/dist/cjs/common.js +27 -18
- package/dist/cjs/config.js +15 -3
- package/dist/cjs/core/appConfig.js +25 -15
- package/dist/cjs/core/compatible.js +69 -53
- package/dist/cjs/core/index.js +47 -40
- package/dist/cjs/core/loader/index.js +35 -9
- package/dist/cjs/core/loader/loaderManager.js +37 -18
- package/dist/cjs/core/loader/useLoader.js +53 -31
- package/dist/cjs/core/plugin.js +41 -34
- package/dist/cjs/core/types.js +15 -3
- package/dist/cjs/document/Body.js +35 -19
- package/dist/cjs/document/Comment.js +29 -14
- package/dist/cjs/document/DocumentContext.js +36 -10
- package/dist/cjs/document/DocumentStructureContext.js +36 -10
- package/dist/cjs/document/Head.js +40 -31
- package/dist/cjs/document/Html.js +37 -23
- package/dist/cjs/document/Links.js +28 -13
- package/dist/cjs/document/Root.js +37 -28
- package/dist/cjs/document/Script.js +29 -14
- package/dist/cjs/document/Scripts.js +28 -13
- package/dist/cjs/document/Style.js +29 -14
- package/dist/cjs/document/cli/index.js +72 -57
- package/dist/cjs/document/constants.js +64 -72
- package/dist/cjs/document/index.js +42 -15
- package/dist/cjs/exports/head.js +38 -11
- package/dist/cjs/exports/loadable.js +38 -11
- package/dist/cjs/exports/server.js +24 -7
- package/dist/cjs/exports/styled.js +38 -11
- package/dist/cjs/index.js +41 -38
- package/dist/cjs/router/cli/index.js +32 -24
- package/dist/cjs/router/index.js +39 -18
- package/dist/cjs/router/runtime/DefaultNotFound.js +26 -11
- package/dist/cjs/router/runtime/DeferredDataScripts.js +21 -8
- package/dist/cjs/router/runtime/DeferredDataScripts.node.js +49 -38
- package/dist/cjs/router/runtime/PrefetchLink.js +64 -50
- package/dist/cjs/router/runtime/fetch.js +24 -7
- package/dist/cjs/router/runtime/fetch.node.js +25 -8
- package/dist/cjs/router/runtime/fetch.worker.js +24 -7
- package/dist/cjs/router/runtime/hooks.js +26 -9
- package/dist/cjs/router/runtime/index.js +155 -208
- package/dist/cjs/router/runtime/plugin.js +64 -50
- package/dist/cjs/router/runtime/plugin.node.js +66 -50
- package/dist/cjs/router/runtime/server.js +20 -4
- package/dist/cjs/router/runtime/types.js +15 -3
- package/dist/cjs/router/runtime/utils.js +64 -51
- package/dist/cjs/router/runtime/withRouter.js +30 -15
- package/dist/cjs/runtimeContext.js +28 -18
- package/dist/cjs/ssr/cli/babel-plugin-ssr-loader-id.js +40 -23
- package/dist/cjs/ssr/cli/index.js +57 -41
- package/dist/cjs/ssr/cli/loadable-bundler-plugin.js +31 -13
- package/dist/cjs/ssr/index.js +71 -52
- package/dist/cjs/ssr/index.node.js +45 -27
- package/dist/cjs/ssr/prefetch.js +31 -18
- package/dist/cjs/ssr/react/index.js +27 -17
- package/dist/cjs/ssr/react/nossr/index.js +38 -12
- package/dist/cjs/ssr/react/prerender/index.js +52 -27
- package/dist/cjs/ssr/react/prerender/type.js +15 -3
- package/dist/cjs/ssr/react/prerender/util.js +33 -28
- package/dist/cjs/ssr/react/withCallback/index.js +27 -11
- package/dist/cjs/ssr/serverRender/helmet.js +23 -15
- package/dist/cjs/ssr/serverRender/index.js +24 -11
- package/dist/cjs/ssr/serverRender/renderToStream/buildTemplate.after.js +30 -13
- package/dist/cjs/ssr/serverRender/renderToStream/buildTemplate.share.js +25 -15
- package/dist/cjs/ssr/serverRender/renderToStream/bulidTemplate.before.js +48 -26
- package/dist/cjs/ssr/serverRender/renderToStream/index.js +49 -23
- package/dist/cjs/ssr/serverRender/renderToStream/renderToPipe.js +35 -23
- package/dist/cjs/ssr/serverRender/renderToStream/renderToPipe.worker.js +33 -22
- package/dist/cjs/ssr/serverRender/renderToStream/template.js +28 -11
- package/dist/cjs/ssr/serverRender/renderToString/buildHtml.js +31 -24
- package/dist/cjs/ssr/serverRender/renderToString/entry.js +81 -59
- package/dist/cjs/ssr/serverRender/renderToString/index.js +44 -18
- package/dist/cjs/ssr/serverRender/renderToString/loadable.js +61 -33
- package/dist/cjs/ssr/serverRender/renderToString/render.js +39 -13
- package/dist/cjs/ssr/serverRender/renderToString/styledComponent.js +28 -11
- package/dist/cjs/ssr/serverRender/renderToString/type.js +24 -7
- package/dist/cjs/ssr/serverRender/tracker.js +27 -18
- package/dist/cjs/ssr/serverRender/types.js +25 -8
- package/dist/cjs/ssr/serverRender/utils.js +31 -24
- package/dist/cjs/ssr/utils.js +42 -25
- package/dist/cjs/state/cli/index.js +28 -19
- package/dist/cjs/state/index.js +39 -18
- package/dist/cjs/state/plugins.js +46 -29
- package/dist/cjs/state/runtime/index.js +39 -11
- package/dist/cjs/state/runtime/plugin.js +55 -28
- package/dist/esm/cli/index.js +6 -2
- package/dist/esm/common.js +8 -3
- package/dist/esm/config.js +0 -1
- package/dist/esm/core/appConfig.js +6 -2
- package/dist/esm/core/compatible.js +29 -25
- package/dist/esm/core/index.js +13 -3
- package/dist/esm/core/loader/index.js +4 -1
- package/dist/esm/core/loader/loaderManager.js +13 -9
- package/dist/esm/core/loader/useLoader.js +13 -10
- package/dist/esm/core/plugin.js +17 -13
- package/dist/esm/core/types.js +0 -1
- package/dist/esm/document/Body.js +4 -1
- package/dist/esm/document/Comment.js +4 -1
- package/dist/esm/document/DocumentContext.js +4 -1
- package/dist/esm/document/DocumentStructureContext.js +4 -1
- package/dist/esm/document/Head.js +6 -2
- package/dist/esm/document/Html.js +12 -10
- package/dist/esm/document/Links.js +4 -1
- package/dist/esm/document/Root.js +6 -2
- package/dist/esm/document/Script.js +4 -1
- package/dist/esm/document/Scripts.js +4 -1
- package/dist/esm/document/Style.js +4 -1
- package/dist/esm/document/cli/index.js +18 -14
- package/dist/esm/document/constants.js +42 -20
- package/dist/esm/exports/head.js +4 -1
- package/dist/esm/exports/loadable.js +4 -1
- package/dist/esm/exports/server.js +4 -1
- package/dist/esm/exports/styled.js +4 -1
- package/dist/esm/index.js +13 -2
- package/dist/esm/router/cli/index.js +12 -9
- package/dist/esm/router/index.js +6 -2
- package/dist/esm/router/runtime/DefaultNotFound.js +4 -1
- package/dist/esm/router/runtime/DeferredDataScripts.js +4 -1
- package/dist/esm/router/runtime/DeferredDataScripts.node.js +14 -13
- package/dist/esm/router/runtime/PrefetchLink.js +17 -17
- package/dist/esm/router/runtime/fetch.js +3 -1
- package/dist/esm/router/runtime/fetch.node.js +3 -1
- package/dist/esm/router/runtime/fetch.worker.js +3 -1
- package/dist/esm/router/runtime/hooks.js +3 -1
- package/dist/esm/router/runtime/index.js +72 -8
- package/dist/esm/router/runtime/plugin.js +26 -22
- package/dist/esm/router/runtime/plugin.node.js +26 -22
- package/dist/esm/router/runtime/server.js +1 -1
- package/dist/esm/router/runtime/types.js +0 -1
- package/dist/esm/router/runtime/utils.js +29 -20
- package/dist/esm/router/runtime/withRouter.js +8 -5
- package/dist/esm/runtimeContext.js +6 -2
- package/dist/esm/ssr/cli/babel-plugin-ssr-loader-id.js +107 -98
- package/dist/esm/ssr/cli/index.js +26 -24
- package/dist/esm/ssr/cli/loadable-bundler-plugin.js +105 -96
- package/dist/esm/ssr/index.js +19 -15
- package/dist/esm/ssr/index.node.js +15 -12
- package/dist/esm/ssr/prefetch.js +10 -7
- package/dist/esm/ssr/react/index.js +6 -2
- package/dist/esm/ssr/react/nossr/index.js +4 -1
- package/dist/esm/ssr/react/prerender/index.js +4 -1
- package/dist/esm/ssr/react/prerender/type.js +0 -1
- package/dist/esm/ssr/react/prerender/util.js +14 -9
- package/dist/esm/ssr/react/withCallback/index.js +4 -1
- package/dist/esm/ssr/serverRender/helmet.js +4 -1
- package/dist/esm/ssr/serverRender/index.js +4 -1
- package/dist/esm/ssr/serverRender/renderToStream/buildTemplate.after.js +8 -5
- package/dist/esm/ssr/serverRender/renderToStream/buildTemplate.share.js +6 -2
- package/dist/esm/ssr/serverRender/renderToStream/bulidTemplate.before.js +7 -6
- package/dist/esm/ssr/serverRender/renderToStream/index.js +6 -3
- package/dist/esm/ssr/serverRender/renderToStream/renderToPipe.js +9 -7
- package/dist/esm/ssr/serverRender/renderToStream/renderToPipe.worker.js +9 -6
- package/dist/esm/ssr/serverRender/renderToStream/template.js +6 -3
- package/dist/esm/ssr/serverRender/renderToString/buildHtml.js +12 -5
- package/dist/esm/ssr/serverRender/renderToString/entry.js +7 -5
- package/dist/esm/ssr/serverRender/renderToString/index.js +8 -5
- package/dist/esm/ssr/serverRender/renderToString/loadable.js +37 -20
- package/dist/esm/ssr/serverRender/renderToString/render.js +4 -1
- package/dist/esm/ssr/serverRender/renderToString/styledComponent.js +4 -1
- package/dist/esm/ssr/serverRender/renderToString/type.js +4 -1
- package/dist/esm/ssr/serverRender/tracker.js +8 -3
- package/dist/esm/ssr/serverRender/types.js +3 -1
- package/dist/esm/ssr/serverRender/utils.js +12 -5
- package/dist/esm/ssr/utils.js +13 -7
- package/dist/esm/state/cli/index.js +10 -6
- package/dist/esm/state/index.js +6 -2
- package/dist/esm/state/plugins.js +10 -4
- package/dist/esm/state/runtime/index.js +4 -1
- package/dist/esm/state/runtime/plugin.js +10 -7
- package/dist/esm-node/cli/index.js +6 -2
- package/dist/esm-node/common.js +8 -3
- package/dist/esm-node/config.js +0 -1
- package/dist/esm-node/core/appConfig.js +6 -2
- package/dist/esm-node/core/compatible.js +17 -13
- package/dist/esm-node/core/index.js +13 -3
- package/dist/esm-node/core/loader/index.js +4 -1
- package/dist/esm-node/core/loader/loaderManager.js +6 -2
- package/dist/esm-node/core/loader/useLoader.js +12 -9
- package/dist/esm-node/core/plugin.js +11 -7
- package/dist/esm-node/core/types.js +0 -1
- package/dist/esm-node/document/Body.js +4 -1
- package/dist/esm-node/document/Comment.js +4 -1
- package/dist/esm-node/document/DocumentContext.js +4 -1
- package/dist/esm-node/document/DocumentStructureContext.js +4 -1
- package/dist/esm-node/document/Head.js +6 -2
- package/dist/esm-node/document/Html.js +7 -5
- package/dist/esm-node/document/Links.js +4 -1
- package/dist/esm-node/document/Root.js +6 -2
- package/dist/esm-node/document/Script.js +4 -1
- package/dist/esm-node/document/Scripts.js +4 -1
- package/dist/esm-node/document/Style.js +4 -1
- package/dist/esm-node/document/cli/index.js +12 -9
- package/dist/esm-node/document/constants.js +42 -20
- package/dist/esm-node/exports/head.js +4 -1
- package/dist/esm-node/exports/loadable.js +4 -1
- package/dist/esm-node/exports/server.js +4 -1
- package/dist/esm-node/exports/styled.js +4 -1
- package/dist/esm-node/index.js +13 -2
- package/dist/esm-node/router/cli/index.js +7 -4
- package/dist/esm-node/router/index.js +6 -2
- package/dist/esm-node/router/runtime/DefaultNotFound.js +4 -1
- package/dist/esm-node/router/runtime/DeferredDataScripts.js +4 -1
- package/dist/esm-node/router/runtime/DeferredDataScripts.node.js +8 -7
- package/dist/esm-node/router/runtime/PrefetchLink.js +11 -11
- package/dist/esm-node/router/runtime/fetch.js +3 -1
- package/dist/esm-node/router/runtime/fetch.node.js +3 -1
- package/dist/esm-node/router/runtime/fetch.worker.js +3 -1
- package/dist/esm-node/router/runtime/hooks.js +3 -1
- package/dist/esm-node/router/runtime/index.js +72 -8
- package/dist/esm-node/router/runtime/plugin.js +14 -10
- package/dist/esm-node/router/runtime/plugin.node.js +14 -10
- package/dist/esm-node/router/runtime/server.js +1 -1
- package/dist/esm-node/router/runtime/types.js +0 -1
- package/dist/esm-node/router/runtime/utils.js +22 -13
- package/dist/esm-node/router/runtime/withRouter.js +5 -2
- package/dist/esm-node/runtimeContext.js +6 -2
- package/dist/esm-node/ssr/cli/babel-plugin-ssr-loader-id.js +108 -99
- package/dist/esm-node/ssr/cli/index.js +15 -13
- package/dist/esm-node/ssr/cli/loadable-bundler-plugin.js +92 -83
- package/dist/esm-node/ssr/index.js +7 -3
- package/dist/esm-node/ssr/index.node.js +7 -4
- package/dist/esm-node/ssr/prefetch.js +7 -4
- package/dist/esm-node/ssr/react/index.js +6 -2
- package/dist/esm-node/ssr/react/nossr/index.js +4 -1
- package/dist/esm-node/ssr/react/prerender/index.js +4 -1
- package/dist/esm-node/ssr/react/prerender/type.js +0 -1
- package/dist/esm-node/ssr/react/prerender/util.js +14 -9
- package/dist/esm-node/ssr/react/withCallback/index.js +4 -1
- package/dist/esm-node/ssr/serverRender/helmet.js +4 -1
- package/dist/esm-node/ssr/serverRender/index.js +4 -1
- package/dist/esm-node/ssr/serverRender/renderToStream/buildTemplate.after.js +5 -2
- package/dist/esm-node/ssr/serverRender/renderToStream/buildTemplate.share.js +6 -2
- package/dist/esm-node/ssr/serverRender/renderToStream/bulidTemplate.before.js +7 -8
- package/dist/esm-node/ssr/serverRender/renderToStream/index.js +6 -3
- package/dist/esm-node/ssr/serverRender/renderToStream/renderToPipe.js +9 -7
- package/dist/esm-node/ssr/serverRender/renderToStream/renderToPipe.worker.js +8 -7
- package/dist/esm-node/ssr/serverRender/renderToStream/template.js +4 -1
- package/dist/esm-node/ssr/serverRender/renderToString/buildHtml.js +12 -5
- package/dist/esm-node/ssr/serverRender/renderToString/entry.js +5 -3
- package/dist/esm-node/ssr/serverRender/renderToString/index.js +6 -3
- package/dist/esm-node/ssr/serverRender/renderToString/loadable.js +33 -19
- package/dist/esm-node/ssr/serverRender/renderToString/render.js +4 -1
- package/dist/esm-node/ssr/serverRender/renderToString/styledComponent.js +4 -1
- package/dist/esm-node/ssr/serverRender/renderToString/type.js +4 -1
- package/dist/esm-node/ssr/serverRender/tracker.js +8 -3
- package/dist/esm-node/ssr/serverRender/types.js +3 -1
- package/dist/esm-node/ssr/serverRender/utils.js +12 -5
- package/dist/esm-node/ssr/utils.js +10 -4
- package/dist/esm-node/state/cli/index.js +6 -2
- package/dist/esm-node/state/index.js +6 -2
- package/dist/esm-node/state/plugins.js +10 -4
- package/dist/esm-node/state/runtime/index.js +4 -1
- package/dist/esm-node/state/runtime/plugin.js +4 -1
- package/dist/types/router/runtime/PrefetchLink.d.ts +1 -1
- package/dist/types/router/runtime/hooks.d.ts +1 -1
- package/dist/types/router/runtime/index.d.ts +3 -3
- package/dist/types/router/runtime/server.d.ts +1 -1
- package/dist/types/router/runtime/types.d.ts +2 -2
- package/dist/types/router/runtime/utils.d.ts +1 -1
- package/dist/types/router/runtime/withRouter.d.ts +1 -1
- package/dist/types/runtimeContext.d.ts +1 -1
- package/dist/types/ssr/serverRender/renderToString/loadable.d.ts +1 -0
- package/package.json +10 -11
- package/dist/cjs/state/types.js +0 -4
- package/dist/esm/state/types.js +0 -1
- package/dist/esm-node/state/types.js +0 -1
- package/dist/types/state/types.d.ts +0 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "@modern-js/utils/
|
|
1
|
+
export * from "@modern-js/runtime-utils/node/router";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Route, isRouteErrorResponse } from "@modern-js/utils/
|
|
3
|
-
import { ErrorResponse } from "@modern-js/utils/
|
|
4
|
-
import { renderNestedRoute } from "@modern-js/utils/
|
|
2
|
+
import { Route, isRouteErrorResponse } from "@modern-js/runtime-utils/router";
|
|
3
|
+
import { ErrorResponse } from "@modern-js/runtime-utils/remix-router";
|
|
4
|
+
import { renderNestedRoute } from "@modern-js/runtime-utils/browser";
|
|
5
5
|
import { DefaultNotFound } from "./DefaultNotFound";
|
|
6
6
|
import DeferredDataScripts from "./DeferredDataScripts";
|
|
7
|
-
|
|
7
|
+
function getRouteComponents(routes, { globalApp, ssrMode, props, reporter }) {
|
|
8
8
|
const Layout = ({ Component, ...props2 }) => {
|
|
9
9
|
const GlobalLayout = globalApp;
|
|
10
10
|
if (!GlobalLayout) {
|
|
@@ -42,7 +42,7 @@ export function getRouteComponents(routes, { globalApp, ssrMode, props, reporter
|
|
|
42
42
|
}, "*"));
|
|
43
43
|
return routeElements;
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
function renderRoutes({ routesConfig, props, ssrMode, reporter }) {
|
|
46
46
|
if (!routesConfig) {
|
|
47
47
|
return null;
|
|
48
48
|
}
|
|
@@ -58,22 +58,22 @@ export function renderRoutes({ routesConfig, props, ssrMode, reporter }) {
|
|
|
58
58
|
});
|
|
59
59
|
return routeElements;
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
var
|
|
63
|
-
const { pathname, url } = (
|
|
64
|
-
const cleanUrl =
|
|
61
|
+
function getLocation(serverContext) {
|
|
62
|
+
var _url_replace;
|
|
63
|
+
const { pathname, url } = (serverContext === null || serverContext === void 0 ? void 0 : serverContext.request) || {};
|
|
64
|
+
const cleanUrl = url === null || url === void 0 ? void 0 : (_url_replace = url.replace("http://", "")) === null || _url_replace === void 0 ? void 0 : _url_replace.replace("https://", "");
|
|
65
65
|
const index = (cleanUrl || "").indexOf(pathname);
|
|
66
66
|
if (index === -1) {
|
|
67
67
|
return pathname;
|
|
68
68
|
}
|
|
69
69
|
return cleanUrl.substring(index);
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
const urlJoin = (...parts) => {
|
|
72
72
|
const separator = "/";
|
|
73
73
|
const replace = new RegExp(`${separator}{1,}`, "g");
|
|
74
74
|
return standardSlash(parts.join(separator).replace(replace, separator));
|
|
75
75
|
};
|
|
76
|
-
|
|
76
|
+
function standardSlash(str) {
|
|
77
77
|
let addr = str;
|
|
78
78
|
if (!addr || typeof addr !== "string") {
|
|
79
79
|
return addr;
|
|
@@ -89,7 +89,7 @@ export function standardSlash(str) {
|
|
|
89
89
|
}
|
|
90
90
|
return addr;
|
|
91
91
|
}
|
|
92
|
-
|
|
92
|
+
function serializeErrors(errors) {
|
|
93
93
|
if (!errors) {
|
|
94
94
|
return null;
|
|
95
95
|
}
|
|
@@ -113,7 +113,7 @@ export function serializeErrors(errors) {
|
|
|
113
113
|
}
|
|
114
114
|
return serialized;
|
|
115
115
|
}
|
|
116
|
-
|
|
116
|
+
function deserializeErrors(errors) {
|
|
117
117
|
if (!errors) {
|
|
118
118
|
return null;
|
|
119
119
|
}
|
|
@@ -132,3 +132,12 @@ export function deserializeErrors(errors) {
|
|
|
132
132
|
}
|
|
133
133
|
return serialized;
|
|
134
134
|
}
|
|
135
|
+
export {
|
|
136
|
+
deserializeErrors,
|
|
137
|
+
getLocation,
|
|
138
|
+
getRouteComponents,
|
|
139
|
+
renderRoutes,
|
|
140
|
+
serializeErrors,
|
|
141
|
+
standardSlash,
|
|
142
|
+
urlJoin
|
|
143
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useLocation, useNavigate, useParams } from "@modern-js/utils/
|
|
3
|
-
|
|
2
|
+
import { useLocation, useNavigate, useParams } from "@modern-js/runtime-utils/router";
|
|
3
|
+
const withRouter = (Component) => {
|
|
4
4
|
return (props) => {
|
|
5
5
|
const location = useLocation();
|
|
6
6
|
const params = useParams();
|
|
@@ -13,3 +13,6 @@ export const withRouter = (Component) => {
|
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
+
export {
|
|
17
|
+
withRouter
|
|
18
|
+
};
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import { createContext } from "react";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
const RuntimeReactContext = createContext({});
|
|
3
|
+
const ServerRouterContext = createContext({});
|
|
4
|
+
export {
|
|
5
|
+
RuntimeReactContext,
|
|
6
|
+
ServerRouterContext
|
|
7
|
+
};
|
|
@@ -1,110 +1,119 @@
|
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
|
+
};
|
|
1
5
|
import crypto from "crypto";
|
|
2
|
-
import { Buffer } from "buffer";
|
|
6
|
+
import { Buffer as Buffer2 } from "buffer";
|
|
3
7
|
import * as t from "@babel/types";
|
|
4
8
|
import { get } from "@modern-js/utils/lodash";
|
|
5
|
-
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const fsHash = crypto.createHash("md5");
|
|
18
|
-
const md5 = fsHash.update(fileBuf).digest("hex");
|
|
19
|
-
return md5;
|
|
20
|
-
}
|
|
21
|
-
function getUseLoaderPath(path, calleeName) {
|
|
22
|
-
const { node } = path;
|
|
23
|
-
if (!calleeName || node.callee.name !== calleeName) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
const arg1 = get(node, "arguments.0");
|
|
27
|
-
if (t.isFunction(arg1) || t.isFunctionExpression(arg1) || t.isArrowFunctionExpression(arg1) || t.isIdentifier(arg1) || t.isCallExpression(arg1) || t.isMemberExpression(arg1)) {
|
|
28
|
-
const loaderPath = path.get("arguments.0");
|
|
29
|
-
if (isDuplicateInnerLoader(loaderPath)) {
|
|
30
|
-
return false;
|
|
31
|
-
} else {
|
|
32
|
-
return loaderPath;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
console.warn("useLoader 中 loaderId 生成失败,请检查 useLoader");
|
|
36
|
-
throw path.buildCodeFrameError(`
|
|
37
|
-
please check the usage of ${path.node.name}
|
|
38
|
-
`);
|
|
39
|
-
}
|
|
40
|
-
function isDuplicateInnerLoader(path) {
|
|
41
|
-
const { node } = path;
|
|
42
|
-
if (t.isFunctionExpression(node.callee)) {
|
|
43
|
-
if (t.isBlockStatement(node.callee.body)) {
|
|
44
|
-
if (get(node.callee.body, "body.0.declarations.0.id.name") === "innerLoader" && get(node.callee.body, "body.2.argument.name") === "innerLoader") {
|
|
45
|
-
return true;
|
|
9
|
+
var require_babel_plugin_ssr_loader_id = __commonJS({
|
|
10
|
+
"src/ssr/cli/babel-plugin-ssr-loader-id.ts"(exports, module) {
|
|
11
|
+
const RUNTIME_PACKAGE_NAMES = [
|
|
12
|
+
"@modern-js/runtime"
|
|
13
|
+
];
|
|
14
|
+
const FUNCTION_USE_LOADER_NAME = "useLoader";
|
|
15
|
+
function getHash(filepath) {
|
|
16
|
+
const cwd = process.cwd();
|
|
17
|
+
const point = filepath.indexOf(cwd);
|
|
18
|
+
let relativePath = filepath;
|
|
19
|
+
if (point !== -1) {
|
|
20
|
+
relativePath = filepath.substring(point + cwd.length);
|
|
46
21
|
}
|
|
22
|
+
const fileBuf = Buffer2.from(relativePath);
|
|
23
|
+
const fsHash = crypto.createHash("md5");
|
|
24
|
+
const md5 = fsHash.update(fileBuf).digest("hex");
|
|
25
|
+
return md5;
|
|
47
26
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
t.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
t.returnStatement(t.identifier("innerLoader"))
|
|
58
|
-
])), []);
|
|
59
|
-
}
|
|
60
|
-
module.exports = function() {
|
|
61
|
-
let useLoader = null;
|
|
62
|
-
let hash = "";
|
|
63
|
-
let index = 0;
|
|
64
|
-
function genId() {
|
|
65
|
-
return `${hash}_${index++}`;
|
|
66
|
-
}
|
|
67
|
-
return {
|
|
68
|
-
name: "babel-plugin-ssr-loader-id",
|
|
69
|
-
pre() {
|
|
70
|
-
index = 0;
|
|
71
|
-
useLoader = null;
|
|
72
|
-
hash = "";
|
|
73
|
-
},
|
|
74
|
-
visitor: {
|
|
75
|
-
ImportDeclaration(path, state) {
|
|
76
|
-
if (useLoader) {
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
if (!RUNTIME_PACKAGE_NAMES.includes(get(path, "node.source.value"))) {
|
|
27
|
+
function getUseLoaderPath(path, calleeName) {
|
|
28
|
+
const { node } = path;
|
|
29
|
+
if (!calleeName || node.callee.name !== calleeName) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const arg1 = get(node, "arguments.0");
|
|
33
|
+
if (t.isFunction(arg1) || t.isFunctionExpression(arg1) || t.isArrowFunctionExpression(arg1) || t.isIdentifier(arg1) || t.isCallExpression(arg1) || t.isMemberExpression(arg1)) {
|
|
34
|
+
const loaderPath = path.get("arguments.0");
|
|
35
|
+
if (isDuplicateInnerLoader(loaderPath)) {
|
|
80
36
|
return false;
|
|
37
|
+
} else {
|
|
38
|
+
return loaderPath;
|
|
81
39
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
let loaderPath = getUseLoaderPath(path, useLoader);
|
|
95
|
-
if (loaderPath) {
|
|
96
|
-
if (!Array.isArray(loaderPath)) {
|
|
97
|
-
loaderPath = [
|
|
98
|
-
loaderPath
|
|
99
|
-
];
|
|
40
|
+
}
|
|
41
|
+
console.warn("useLoader 中 loaderId 生成失败,请检查 useLoader");
|
|
42
|
+
throw path.buildCodeFrameError(`
|
|
43
|
+
please check the usage of ${path.node.name}
|
|
44
|
+
`);
|
|
45
|
+
}
|
|
46
|
+
function isDuplicateInnerLoader(path) {
|
|
47
|
+
const { node } = path;
|
|
48
|
+
if (t.isFunctionExpression(node.callee)) {
|
|
49
|
+
if (t.isBlockStatement(node.callee.body)) {
|
|
50
|
+
if (get(node.callee.body, "body.0.declarations.0.id.name") === "innerLoader" && get(node.callee.body, "body.2.argument.name") === "innerLoader") {
|
|
51
|
+
return true;
|
|
100
52
|
}
|
|
101
|
-
loaderPath.forEach((p) => {
|
|
102
|
-
p.replaceWith(getSelfRunLoaderExpression(p.node, genId()));
|
|
103
|
-
});
|
|
104
|
-
return false;
|
|
105
53
|
}
|
|
106
|
-
return false;
|
|
107
54
|
}
|
|
55
|
+
return false;
|
|
108
56
|
}
|
|
109
|
-
|
|
110
|
-
|
|
57
|
+
function getSelfRunLoaderExpression(loaderExpression, id) {
|
|
58
|
+
return t.callExpression(t.functionExpression(null, [], t.blockStatement([
|
|
59
|
+
t.variableDeclaration("var", [
|
|
60
|
+
t.variableDeclarator(t.identifier("innerLoader"), loaderExpression)
|
|
61
|
+
]),
|
|
62
|
+
t.expressionStatement(t.assignmentExpression("=", t.memberExpression(t.identifier("innerLoader"), t.identifier("id")), t.stringLiteral(id))),
|
|
63
|
+
t.returnStatement(t.identifier("innerLoader"))
|
|
64
|
+
])), []);
|
|
65
|
+
}
|
|
66
|
+
module.exports = function() {
|
|
67
|
+
let useLoader = null;
|
|
68
|
+
let hash = "";
|
|
69
|
+
let index = 0;
|
|
70
|
+
function genId() {
|
|
71
|
+
return `${hash}_${index++}`;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
name: "babel-plugin-ssr-loader-id",
|
|
75
|
+
pre() {
|
|
76
|
+
index = 0;
|
|
77
|
+
useLoader = null;
|
|
78
|
+
hash = "";
|
|
79
|
+
},
|
|
80
|
+
visitor: {
|
|
81
|
+
ImportDeclaration(path, state) {
|
|
82
|
+
if (useLoader) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
if (!RUNTIME_PACKAGE_NAMES.includes(get(path, "node.source.value"))) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
hash = getHash(state.file.opts.filename);
|
|
89
|
+
get(path, "node.specifiers", []).forEach(({ imported, local }) => {
|
|
90
|
+
if (!imported) {
|
|
91
|
+
throw path.buildCodeFrameError(`please \`import { useLoader } from ${RUNTIME_PACKAGE_NAMES[0]}\``);
|
|
92
|
+
}
|
|
93
|
+
if (!useLoader && imported.name === FUNCTION_USE_LOADER_NAME) {
|
|
94
|
+
useLoader = local.name;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return false;
|
|
98
|
+
},
|
|
99
|
+
CallExpression(path) {
|
|
100
|
+
let loaderPath = getUseLoaderPath(path, useLoader);
|
|
101
|
+
if (loaderPath) {
|
|
102
|
+
if (!Array.isArray(loaderPath)) {
|
|
103
|
+
loaderPath = [
|
|
104
|
+
loaderPath
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
loaderPath.forEach((p) => {
|
|
108
|
+
p.replaceWith(getSelfRunLoaderExpression(p.node, genId()));
|
|
109
|
+
});
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
export default require_babel_plugin_ssr_loader_id();
|
|
@@ -2,13 +2,12 @@ import path from "path";
|
|
|
2
2
|
import { getEntryOptions, SERVER_RENDER_FUNCTION_NAME, LOADABLE_STATS_FILE, isUseSSRBundle, createRuntimeExportsUtils, isSSGEntry } from "@modern-js/utils";
|
|
3
3
|
const PLUGIN_IDENTIFIER = "ssr";
|
|
4
4
|
const hasStringSSREntry = (userConfig) => {
|
|
5
|
-
var _server, _server1;
|
|
6
5
|
const isStreaming = (ssr) => ssr && typeof ssr === "object" && ssr.mode === "stream";
|
|
7
6
|
const { server, output } = userConfig;
|
|
8
|
-
if (((
|
|
7
|
+
if (((server === null || server === void 0 ? void 0 : server.ssr) || output.ssg) && !isStreaming(server.ssr)) {
|
|
9
8
|
return true;
|
|
10
9
|
}
|
|
11
|
-
if ((
|
|
10
|
+
if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && typeof server.ssrByEntries === "object") {
|
|
12
11
|
for (const name of Object.keys(server.ssrByEntries)) {
|
|
13
12
|
if (!isStreaming(server.ssrByEntries[name])) {
|
|
14
13
|
return true;
|
|
@@ -18,11 +17,10 @@ const hasStringSSREntry = (userConfig) => {
|
|
|
18
17
|
return false;
|
|
19
18
|
};
|
|
20
19
|
const checkUseStringSSR = (config) => {
|
|
21
|
-
var _output;
|
|
22
20
|
const { output } = config;
|
|
23
|
-
return Boolean(
|
|
21
|
+
return Boolean(output === null || output === void 0 ? void 0 : output.ssg) || hasStringSSREntry(config);
|
|
24
22
|
};
|
|
25
|
-
|
|
23
|
+
const ssrPlugin = () => ({
|
|
26
24
|
name: "@modern-js/plugin-ssr",
|
|
27
25
|
required: [
|
|
28
26
|
"@modern-js/runtime"
|
|
@@ -63,8 +61,8 @@ export const ssrPlugin = () => ({
|
|
|
63
61
|
return {
|
|
64
62
|
source: {
|
|
65
63
|
alias: {
|
|
66
|
-
// ensure that all packages use the same storage in @modern-js/utils/
|
|
67
|
-
"@modern-js/utils/
|
|
64
|
+
// ensure that all packages use the same storage in @modern-js/runtime-utils/node
|
|
65
|
+
"@modern-js/runtime-utils/node$": require.resolve("@modern-js/runtime-utils/node"),
|
|
68
66
|
"@modern-js/runtime/plugins": pluginsExportsUtils.getPath()
|
|
69
67
|
},
|
|
70
68
|
globalVars: (values, { target }) => {
|
|
@@ -94,9 +92,9 @@ export const ssrPlugin = () => ({
|
|
|
94
92
|
pluginsExportsUtils.addExport(`export { default as ssr } from '@modern-js/runtime/ssr'`);
|
|
95
93
|
const ssrConfig = getEntryOptions(entryName, isMainEntry, userConfig.server.ssr, userConfig.server.ssrByEntries, packageName);
|
|
96
94
|
if (typeof ssrConfig === "object" && ssrConfig.mode === "stream") {
|
|
97
|
-
var _this
|
|
95
|
+
var _this;
|
|
98
96
|
const runtimeConfig = getEntryOptions(entryName, isMainEntry, userConfig.runtime, userConfig.runtimeByEntries, packageName);
|
|
99
|
-
if (((_this =
|
|
97
|
+
if (((_this = runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.router) === null || _this === void 0 ? void 0 : _this.mode) === "react-router-5") {
|
|
100
98
|
throw new Error(`router v5 plugin doesn't support streaming SSR, check your config 'runtime.router'`);
|
|
101
99
|
}
|
|
102
100
|
if (fileSystemRoutes && !entrypoint.nestedRoutesEntry) {
|
|
@@ -122,8 +120,8 @@ export const ssrPlugin = () => ({
|
|
|
122
120
|
},
|
|
123
121
|
modifyEntryRuntimePlugins({ entrypoint, plugins, bundlerConfigs }) {
|
|
124
122
|
if (ssrConfigMap.get(entrypoint.entryName)) {
|
|
125
|
-
var _bundlerConfigs_find_output, _bundlerConfigs_find,
|
|
126
|
-
const chunkLoadingGlobal =
|
|
123
|
+
var _bundlerConfigs_find_output, _bundlerConfigs_find, _config_server;
|
|
124
|
+
const chunkLoadingGlobal = bundlerConfigs === null || bundlerConfigs === void 0 ? void 0 : (_bundlerConfigs_find = bundlerConfigs.find((config2) => config2.name === "client")) === null || _bundlerConfigs_find === void 0 ? void 0 : (_bundlerConfigs_find_output = _bundlerConfigs_find.output) === null || _bundlerConfigs_find_output === void 0 ? void 0 : _bundlerConfigs_find_output.chunkLoadingGlobal;
|
|
127
125
|
const config = api.useResolvedConfigContext();
|
|
128
126
|
const { crossorigin, scriptLoading } = config.html;
|
|
129
127
|
const disablePrerender = typeof ((_config_server = config.server) === null || _config_server === void 0 ? void 0 : _config_server.ssr) === "object" ? Boolean(config.server.ssr.disablePrerender) : false;
|
|
@@ -163,4 +161,8 @@ export const ssrPlugin = () => ({
|
|
|
163
161
|
};
|
|
164
162
|
}
|
|
165
163
|
});
|
|
166
|
-
|
|
164
|
+
var cli_default = ssrPlugin;
|
|
165
|
+
export {
|
|
166
|
+
cli_default as default,
|
|
167
|
+
ssrPlugin
|
|
168
|
+
};
|
|
@@ -1,91 +1,100 @@
|
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
|
+
};
|
|
1
5
|
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
6
|
import path from "path";
|
|
3
7
|
import { fs } from "@modern-js/utils";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
var require_loadable_bundler_plugin = __commonJS({
|
|
9
|
+
"src/ssr/cli/loadable-bundler-plugin.ts"(exports, module) {
|
|
10
|
+
class LoadablePlugin {
|
|
11
|
+
apply(compiler) {
|
|
12
|
+
this.compiler = compiler;
|
|
13
|
+
compiler.options.output.chunkLoadingGlobal = this.opts.chunkLoadingGlobal;
|
|
14
|
+
if (this.opts.outputAsset || this.opts.writeToDisk) {
|
|
15
|
+
compiler.hooks.make.tap(LoadablePlugin.name, (compilation) => {
|
|
16
|
+
compilation.hooks.processAssets.tap({
|
|
17
|
+
name: LoadablePlugin.name,
|
|
18
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT
|
|
19
|
+
}, () => {
|
|
20
|
+
const asset = this.handleEmit(compilation);
|
|
21
|
+
if (asset) {
|
|
22
|
+
compilation.emitAsset(this.opts.filename, asset);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
handleEmit(compilation) {
|
|
29
|
+
const stats = compilation.getStats().toJson({
|
|
30
|
+
all: false,
|
|
31
|
+
assets: true,
|
|
32
|
+
// rspack not support cachedAssets,
|
|
33
|
+
cachedAssets: true,
|
|
34
|
+
chunks: true,
|
|
35
|
+
chunkGroups: true,
|
|
36
|
+
entrypoints: true,
|
|
37
|
+
// rspack not support chunkGroupChildren.
|
|
38
|
+
chunkGroupChildren: true,
|
|
39
|
+
hash: true,
|
|
40
|
+
ids: true,
|
|
41
|
+
outputPath: true,
|
|
42
|
+
publicPath: true
|
|
18
43
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
chunkGroupChildren: true,
|
|
33
|
-
hash: true,
|
|
34
|
-
ids: true,
|
|
35
|
-
outputPath: true,
|
|
36
|
-
publicPath: true
|
|
37
|
-
});
|
|
38
|
-
const output = {
|
|
39
|
-
...stats,
|
|
40
|
-
generator: "loadable-components",
|
|
41
|
-
chunks: [
|
|
42
|
-
...stats.chunks || []
|
|
43
|
-
].map((chunk) => {
|
|
44
|
-
return {
|
|
45
|
-
id: chunk.id,
|
|
46
|
-
files: [
|
|
47
|
-
...chunk.files || []
|
|
48
|
-
]
|
|
44
|
+
const output = {
|
|
45
|
+
...stats,
|
|
46
|
+
generator: "loadable-components",
|
|
47
|
+
chunks: [
|
|
48
|
+
...stats.chunks || []
|
|
49
|
+
].map((chunk) => {
|
|
50
|
+
return {
|
|
51
|
+
id: chunk.id,
|
|
52
|
+
files: [
|
|
53
|
+
...chunk.files || []
|
|
54
|
+
]
|
|
55
|
+
};
|
|
56
|
+
})
|
|
49
57
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (this.opts.writeToDisk) {
|
|
54
|
-
this.writeAssetsFile(result);
|
|
55
|
-
}
|
|
56
|
-
if (this.opts.outputAsset) {
|
|
57
|
-
return {
|
|
58
|
-
source() {
|
|
59
|
-
return result;
|
|
60
|
-
},
|
|
61
|
-
size() {
|
|
62
|
-
return result.length;
|
|
58
|
+
const result = JSON.stringify(output, null, 2);
|
|
59
|
+
if (this.opts.writeToDisk) {
|
|
60
|
+
this.writeAssetsFile(result);
|
|
63
61
|
}
|
|
64
|
-
|
|
62
|
+
if (this.opts.outputAsset) {
|
|
63
|
+
return {
|
|
64
|
+
source() {
|
|
65
|
+
return result;
|
|
66
|
+
},
|
|
67
|
+
size() {
|
|
68
|
+
return result.length;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
writeAssetsFile(manifest) {
|
|
75
|
+
var _this_compiler;
|
|
76
|
+
const outputFolder = (_this_compiler = this.compiler) === null || _this_compiler === void 0 ? void 0 : _this_compiler.options.output.path;
|
|
77
|
+
const outputFile = path.resolve(outputFolder || "", this.opts.filename);
|
|
78
|
+
fs.outputFileSync(outputFile, manifest);
|
|
79
|
+
}
|
|
80
|
+
constructor({ filename = "loadable-stats.json", path: path2, writeToDisk, outputAsset = true, chunkLoadingGlobal = "__LOADABLE_LOADED_CHUNKS__" } = {
|
|
81
|
+
filename: "loadable-stats.json",
|
|
82
|
+
outputAsset: true,
|
|
83
|
+
chunkLoadingGlobal: "__LOADABLE_LOADED_CHUNKS__"
|
|
84
|
+
}) {
|
|
85
|
+
_define_property(this, "opts", void 0);
|
|
86
|
+
_define_property(this, "compiler", void 0);
|
|
87
|
+
this.opts = {
|
|
88
|
+
filename,
|
|
89
|
+
path: path2,
|
|
90
|
+
writeToDisk,
|
|
91
|
+
outputAsset,
|
|
92
|
+
chunkLoadingGlobal
|
|
93
|
+
};
|
|
94
|
+
this.compiler = null;
|
|
95
|
+
}
|
|
65
96
|
}
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
writeAssetsFile(manifest) {
|
|
69
|
-
var _this_compiler;
|
|
70
|
-
const outputFolder = (_this_compiler = this.compiler) === null || _this_compiler === void 0 ? void 0 : _this_compiler.options.output.path;
|
|
71
|
-
const outputFile = path.resolve(outputFolder || "", this.opts.filename);
|
|
72
|
-
fs.outputFileSync(outputFile, manifest);
|
|
73
|
-
}
|
|
74
|
-
constructor({ filename = "loadable-stats.json", path: path2, writeToDisk, outputAsset = true, chunkLoadingGlobal = "__LOADABLE_LOADED_CHUNKS__" } = {
|
|
75
|
-
filename: "loadable-stats.json",
|
|
76
|
-
outputAsset: true,
|
|
77
|
-
chunkLoadingGlobal: "__LOADABLE_LOADED_CHUNKS__"
|
|
78
|
-
}) {
|
|
79
|
-
_define_property(this, "opts", void 0);
|
|
80
|
-
_define_property(this, "compiler", void 0);
|
|
81
|
-
this.opts = {
|
|
82
|
-
filename,
|
|
83
|
-
path: path2,
|
|
84
|
-
writeToDisk,
|
|
85
|
-
outputAsset,
|
|
86
|
-
chunkLoadingGlobal
|
|
87
|
-
};
|
|
88
|
-
this.compiler = null;
|
|
97
|
+
module.exports = LoadablePlugin;
|
|
89
98
|
}
|
|
90
|
-
}
|
|
91
|
-
|
|
99
|
+
});
|
|
100
|
+
export default require_loadable_bundler_plugin();
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { loadableReady } from "@loadable/component";
|
|
3
3
|
import hoistNonReactStatics from "hoist-non-react-statics";
|
|
4
|
-
import { parsedJSONFromElement } from "@modern-js/utils/
|
|
4
|
+
import { parsedJSONFromElement } from "@modern-js/runtime-utils/browser";
|
|
5
5
|
import { RenderLevel } from "./serverRender/types";
|
|
6
6
|
import { WithCallback } from "./react/withCallback";
|
|
7
7
|
import { formatClient, mockResponse, isReact18 } from "./utils";
|
|
8
8
|
import { ROUTER_DATA_JSON_ID, SSR_DATA_JSON_ID } from "./serverRender/utils";
|
|
9
|
-
|
|
9
|
+
const ssr = (config) => ({
|
|
10
10
|
name: "@modern-js/plugin-ssr",
|
|
11
11
|
setup: () => {
|
|
12
12
|
const mockResp = mockResponse();
|
|
@@ -128,5 +128,9 @@ export const ssr = (config) => ({
|
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
});
|
|
131
|
-
|
|
131
|
+
var ssr_default = ssr;
|
|
132
132
|
export * from "./react";
|
|
133
|
+
export {
|
|
134
|
+
ssr_default as default,
|
|
135
|
+
ssr
|
|
136
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { formatServer } from "./utils";
|
|
2
2
|
import render from "./serverRender";
|
|
3
3
|
import { createSSRTracker } from "./serverRender/tracker";
|
|
4
|
-
|
|
4
|
+
const ssr = (config = {}) => ({
|
|
5
5
|
name: "@modern-js/plugin-ssr",
|
|
6
6
|
setup: () => {
|
|
7
7
|
return {
|
|
@@ -26,8 +26,7 @@ export const ssr = (config = {}) => ({
|
|
|
26
26
|
});
|
|
27
27
|
},
|
|
28
28
|
pickContext: ({ context, pickedContext }, next) => {
|
|
29
|
-
|
|
30
|
-
const { request, response } = (_context = context) === null || _context === void 0 ? void 0 : _context.ssrContext;
|
|
29
|
+
const { request, response } = context === null || context === void 0 ? void 0 : context.ssrContext;
|
|
31
30
|
const { initialData } = context;
|
|
32
31
|
return next({
|
|
33
32
|
context,
|
|
@@ -42,5 +41,9 @@ export const ssr = (config = {}) => ({
|
|
|
42
41
|
};
|
|
43
42
|
}
|
|
44
43
|
});
|
|
45
|
-
|
|
44
|
+
var index_node_default = ssr;
|
|
46
45
|
export * from "./react";
|
|
46
|
+
export {
|
|
47
|
+
index_node_default as default,
|
|
48
|
+
ssr
|
|
49
|
+
};
|