@bleedingdev/modern-js-runtime 3.5.0-ultramodern.3 → 3.5.0-ultramodern.31
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/ssr/index.js +1 -2
- package/dist/cjs/core/context/public.js +49 -0
- package/dist/cjs/core/context/runtime.js +6 -8
- package/dist/cjs/core/react/wrapper.js +57 -0
- package/dist/cjs/core/server/federatedCss.js +7 -3
- package/dist/cjs/core/server/requestHandler.js +15 -45
- package/dist/cjs/core/server/requestResponse.js +83 -0
- package/dist/cjs/core/server/routerCleanup.js +21 -0
- package/dist/cjs/core/server/scriptOrder.js +13 -7
- package/dist/cjs/core/server/string/loadable.js +3 -11
- package/dist/cjs/index.js +7 -6
- package/dist/cjs/router/cli/code/templates.js +3 -2
- package/dist/cjs/router/runtime/hooks.js +7 -6
- package/dist/cjs/router/runtime/provider.js +1 -1
- package/dist/esm/cli/ssr/index.mjs +1 -2
- package/dist/esm/core/context/public.mjs +5 -0
- package/dist/esm/core/context/runtime.mjs +4 -6
- package/dist/esm/core/react/wrapper.mjs +58 -1
- package/dist/esm/core/server/federatedCss.mjs +7 -3
- package/dist/esm/core/server/requestHandler.mjs +15 -45
- package/dist/esm/core/server/requestResponse.mjs +39 -0
- package/dist/esm/core/server/routerCleanup.mjs +16 -1
- package/dist/esm/core/server/scriptOrder.mjs +11 -8
- package/dist/esm/core/server/string/loadable.mjs +3 -8
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/router/cli/code/templates.mjs +3 -2
- package/dist/esm/router/runtime/hooks.mjs +7 -6
- package/dist/esm/router/runtime/provider.mjs +1 -1
- package/dist/esm-node/cli/ssr/index.mjs +1 -2
- package/dist/esm-node/core/context/public.mjs +6 -0
- package/dist/esm-node/core/context/runtime.mjs +4 -6
- package/dist/esm-node/core/react/wrapper.mjs +58 -1
- package/dist/esm-node/core/server/federatedCss.mjs +7 -3
- package/dist/esm-node/core/server/requestHandler.mjs +15 -45
- package/dist/esm-node/core/server/requestResponse.mjs +40 -0
- package/dist/esm-node/core/server/routerCleanup.mjs +16 -1
- package/dist/esm-node/core/server/scriptOrder.mjs +11 -8
- package/dist/esm-node/core/server/string/loadable.mjs +3 -8
- package/dist/esm-node/index.mjs +2 -1
- package/dist/esm-node/router/cli/code/templates.mjs +3 -2
- package/dist/esm-node/router/runtime/hooks.mjs +7 -6
- package/dist/esm-node/router/runtime/provider.mjs +1 -1
- package/dist/types/boundary-debugger/index.d.ts +1 -1
- package/dist/types/common.d.ts +8 -1
- package/dist/types/core/context/index.d.ts +25 -9
- package/dist/types/core/context/monitors/default.d.ts +10 -2
- package/dist/types/core/context/monitors/index.d.ts +1 -1
- package/dist/types/core/context/monitors/index.server.d.ts +2 -2
- package/dist/types/core/context/public.d.ts +26 -0
- package/dist/types/core/context/runtime.d.ts +12 -22
- package/dist/types/core/react/index.d.ts +1 -1
- package/dist/types/core/server/requestResponse.d.ts +15 -0
- package/dist/types/core/server/routerCleanup.d.ts +2 -0
- package/dist/types/core/server/scriptOrder.d.ts +1 -0
- package/dist/types/core/server/stream/shared.d.ts +2 -2
- package/dist/types/core/server/string/loadable.d.ts +0 -2
- package/dist/types/index.d.ts +5 -5
- package/dist/types/internal.d.ts +0 -1
- package/dist/types/router/runtime/hooks.d.ts +10 -6
- package/dist/types/router/runtime/internal.d.ts +1 -1
- package/dist/types/router/runtime/plugin.d.ts +1 -1
- package/dist/types/router/runtime/plugin.node.d.ts +1 -1
- package/dist/types/router/runtime/provider.d.ts +1 -1
- package/dist/types/router/runtime/types.d.ts +27 -5
- package/package.json +8 -8
|
@@ -129,14 +129,13 @@ const ssrBuilderPlugin = (modernAPI, outputModule, exportLoadablePath)=>({
|
|
|
129
129
|
const hasServerRendering = hasServerRenderingConfig(userConfig);
|
|
130
130
|
const hasModuleFederationRuntimeMarker = hasServerRendering && shouldUseModuleFederationNodeOutput(config);
|
|
131
131
|
const hasExplicitMfSsrFlag = isModuleFederationAppSSREnabled(userConfig);
|
|
132
|
-
const isCloudflareWorkerSSR = 'workerSSR' === name && userConfig.deploy?.target === 'cloudflare';
|
|
133
132
|
const requireExplicitMfSsrFlag = 'true' === process.env.MODERN_MF_APP_SSR_REQUIRE_EXPLICIT;
|
|
134
133
|
if (hasServerRendering && hasModuleFederationRuntimeMarker && !hasExplicitMfSsrFlag) {
|
|
135
134
|
const warningMessage = '[modernjs][mf-ssr] Module Federation SSR was auto-detected from runtime markers. Set server.ssr.moduleFederationAppSSR=true explicitly in host and remotes to avoid heuristic drift.';
|
|
136
135
|
if (requireExplicitMfSsrFlag) throw new Error(`${warningMessage} (enforced by MODERN_MF_APP_SSR_REQUIRE_EXPLICIT=true)`);
|
|
137
136
|
console.warn(warningMessage);
|
|
138
137
|
}
|
|
139
|
-
const isModuleFederationAppSSR = hasServerRendering && hasExplicitMfSsrFlag
|
|
138
|
+
const isModuleFederationAppSSR = hasServerRendering && hasExplicitMfSsrFlag;
|
|
140
139
|
const ssrEnv = userConfig.deploy?.worker?.ssr || userConfig.server?.rsc ? 'edge' : 'node';
|
|
141
140
|
const appContext = modernAPI.getAppContext();
|
|
142
141
|
const { appDirectory, entrypoints } = appContext;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
ReactRuntimeContext: ()=>ReactRuntimeContext,
|
|
32
|
+
RuntimeContext: ()=>RuntimeContext,
|
|
33
|
+
useRuntimeContext: ()=>useRuntimeContext
|
|
34
|
+
});
|
|
35
|
+
const external_react_namespaceObject = require("react");
|
|
36
|
+
const RuntimeContext = (0, external_react_namespaceObject.createContext)({});
|
|
37
|
+
const ReactRuntimeContext = RuntimeContext;
|
|
38
|
+
const useRuntimeContext = ()=>(0, external_react_namespaceObject.useContext)(RuntimeContext);
|
|
39
|
+
exports.ReactRuntimeContext = __webpack_exports__.ReactRuntimeContext;
|
|
40
|
+
exports.RuntimeContext = __webpack_exports__.RuntimeContext;
|
|
41
|
+
exports.useRuntimeContext = __webpack_exports__.useRuntimeContext;
|
|
42
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
43
|
+
"ReactRuntimeContext",
|
|
44
|
+
"RuntimeContext",
|
|
45
|
+
"useRuntimeContext"
|
|
46
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
47
|
+
Object.defineProperty(exports, '__esModule', {
|
|
48
|
+
value: true
|
|
49
|
+
});
|
|
@@ -29,16 +29,15 @@ var __webpack_exports__ = {};
|
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
InternalRuntimeContext: ()=>InternalRuntimeContext,
|
|
32
|
-
ReactRuntimeContext: ()=>ReactRuntimeContext,
|
|
33
|
-
RuntimeContext: ()=>RuntimeContext,
|
|
32
|
+
ReactRuntimeContext: ()=>external_public_js_namespaceObject.ReactRuntimeContext,
|
|
33
|
+
RuntimeContext: ()=>external_public_js_namespaceObject.RuntimeContext,
|
|
34
34
|
getInitialContext: ()=>getInitialContext,
|
|
35
|
-
useRuntimeContext: ()=>useRuntimeContext
|
|
35
|
+
useRuntimeContext: ()=>external_public_js_namespaceObject.useRuntimeContext
|
|
36
36
|
});
|
|
37
|
-
const constants_namespaceObject = require("@modern-js/utils/universal/constants");
|
|
38
37
|
const external_react_namespaceObject = require("react");
|
|
38
|
+
const external_public_js_namespaceObject = require("./public.js");
|
|
39
|
+
const ROUTE_MANIFEST = '_MODERNJS_ROUTE_MANIFEST';
|
|
39
40
|
const InternalRuntimeContext = (0, external_react_namespaceObject.createContext)({});
|
|
40
|
-
const RuntimeContext = (0, external_react_namespaceObject.createContext)({});
|
|
41
|
-
const ReactRuntimeContext = RuntimeContext;
|
|
42
41
|
const getInitialContext = (isBrowser = true, routeManifest)=>{
|
|
43
42
|
const requestContext = {
|
|
44
43
|
request: {},
|
|
@@ -46,12 +45,11 @@ const getInitialContext = (isBrowser = true, routeManifest)=>{
|
|
|
46
45
|
};
|
|
47
46
|
return {
|
|
48
47
|
isBrowser,
|
|
49
|
-
routeManifest: routeManifest || "u" > typeof window && window[
|
|
48
|
+
routeManifest: routeManifest || "u" > typeof window && window[ROUTE_MANIFEST],
|
|
50
49
|
requestContext,
|
|
51
50
|
context: requestContext
|
|
52
51
|
};
|
|
53
52
|
};
|
|
54
|
-
const useRuntimeContext = ()=>(0, external_react_namespaceObject.useContext)(RuntimeContext);
|
|
55
53
|
exports.InternalRuntimeContext = __webpack_exports__.InternalRuntimeContext;
|
|
56
54
|
exports.ReactRuntimeContext = __webpack_exports__.ReactRuntimeContext;
|
|
57
55
|
exports.RuntimeContext = __webpack_exports__.RuntimeContext;
|
|
@@ -35,6 +35,42 @@ const external_react_helmet_async_namespaceObject = require("react-helmet-async"
|
|
|
35
35
|
const index_js_namespaceObject = require("../context/index.js");
|
|
36
36
|
const extensions_js_namespaceObject = require("../context/extensions.js");
|
|
37
37
|
const helmetContext_js_namespaceObject = require("../context/helmetContext.js");
|
|
38
|
+
function toRscSafeRecord(value) {
|
|
39
|
+
if (!value || 'object' != typeof value) return value;
|
|
40
|
+
return Object.fromEntries(Object.entries(value));
|
|
41
|
+
}
|
|
42
|
+
function createRscSafeSsrContext(ssrContext) {
|
|
43
|
+
if (!ssrContext) return ssrContext;
|
|
44
|
+
const { request } = ssrContext;
|
|
45
|
+
return {
|
|
46
|
+
nonce: ssrContext.nonce,
|
|
47
|
+
useJsonScript: ssrContext.useJsonScript,
|
|
48
|
+
htmlModifiers: [],
|
|
49
|
+
baseUrl: ssrContext.baseUrl,
|
|
50
|
+
request: request ? {
|
|
51
|
+
url: request.url,
|
|
52
|
+
userAgent: request.userAgent,
|
|
53
|
+
cookie: request.cookie,
|
|
54
|
+
pathname: request.pathname,
|
|
55
|
+
query: toRscSafeRecord(request.query),
|
|
56
|
+
params: toRscSafeRecord(request.params),
|
|
57
|
+
headers: toRscSafeRecord(request.headers),
|
|
58
|
+
host: request.host,
|
|
59
|
+
referer: request.referer
|
|
60
|
+
} : request,
|
|
61
|
+
mode: ssrContext.mode,
|
|
62
|
+
loaderFailureMode: ssrContext.loaderFailureMode
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function createRscSafeRequestContext(ssrContext) {
|
|
66
|
+
const safeSsrContext = createRscSafeSsrContext(ssrContext);
|
|
67
|
+
return {
|
|
68
|
+
request: safeSsrContext?.request || {},
|
|
69
|
+
response: {
|
|
70
|
+
locals: ssrContext?.response?.locals || {}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
38
74
|
function wrapRuntimeContextProvider(App, contextValue) {
|
|
39
75
|
const { isBrowser, initialData, routes, context, routeManifest, routerContext, unstable_getBlockNavState, ssrContext, _internalContext, _internalRouterBaseName, ...rest } = contextValue;
|
|
40
76
|
const internalContextValue = contextValue;
|
|
@@ -47,6 +83,27 @@ function wrapRuntimeContextProvider(App, contextValue) {
|
|
|
47
83
|
...rest
|
|
48
84
|
};
|
|
49
85
|
(0, extensions_js_namespaceObject.stripRuntimeContextExtensions)(runtimeContextValue);
|
|
86
|
+
if ((0, index_js_namespaceObject.getGlobalEnableRsc)() && !isBrowser) {
|
|
87
|
+
const rscSafeRequestContext = createRscSafeRequestContext(ssrContext);
|
|
88
|
+
const rscInternalContextValue = {
|
|
89
|
+
...internalContextValue,
|
|
90
|
+
context: rscSafeRequestContext,
|
|
91
|
+
requestContext: rscSafeRequestContext,
|
|
92
|
+
ssrContext: createRscSafeSsrContext(ssrContext)
|
|
93
|
+
};
|
|
94
|
+
const rscRuntimeContextValue = {
|
|
95
|
+
...runtimeContextValue,
|
|
96
|
+
context: rscSafeRequestContext,
|
|
97
|
+
requestContext: rscSafeRequestContext
|
|
98
|
+
};
|
|
99
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.InternalRuntimeContext.Provider, {
|
|
100
|
+
value: rscInternalContextValue,
|
|
101
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.RuntimeContext.Provider, {
|
|
102
|
+
value: rscRuntimeContextValue,
|
|
103
|
+
children: App
|
|
104
|
+
})
|
|
105
|
+
});
|
|
106
|
+
}
|
|
50
107
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.InternalRuntimeContext.Provider, {
|
|
51
108
|
value: internalContextValue,
|
|
52
109
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.RuntimeContext.Provider, {
|
|
@@ -31,14 +31,18 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
31
31
|
createFederatedCssLinks: ()=>createFederatedCssLinks
|
|
32
32
|
});
|
|
33
33
|
const external_utils_js_namespaceObject = require("./utils.js");
|
|
34
|
+
const escapeHtmlAttribute = (value)=>value.replaceAll('&', '&').replaceAll('"', '"').replaceAll('<', '<').replaceAll('>', '>');
|
|
34
35
|
const createFederatedCssLinks = (assets, options)=>{
|
|
35
36
|
if (void 0 === assets || 0 === assets.length) return '';
|
|
36
37
|
const seen = new Set(options.existingAssets || []);
|
|
37
38
|
const attributes = (0, external_utils_js_namespaceObject.attributesToString)(options.attributes || {});
|
|
38
39
|
const links = [];
|
|
39
|
-
for (const asset of assets)
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
for (const asset of assets){
|
|
41
|
+
const href = escapeHtmlAttribute(asset);
|
|
42
|
+
if (!('' === asset || seen.has(asset) || options.template.includes(asset) || options.template.includes(href))) {
|
|
43
|
+
seen.add(asset);
|
|
44
|
+
links.push(`<link${attributes} href="${href}" rel="stylesheet" />`);
|
|
45
|
+
}
|
|
42
46
|
}
|
|
43
47
|
return links.join('');
|
|
44
48
|
};
|
|
@@ -44,15 +44,13 @@ const node_namespaceObject = require("@modern-js/runtime-utils/node");
|
|
|
44
44
|
const request_namespaceObject = require("@modern-js/runtime-utils/universal/request");
|
|
45
45
|
const external_react_namespaceObject = require("react");
|
|
46
46
|
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
|
|
47
|
-
const lifecycle_js_namespaceObject = require("../../router/runtime/lifecycle.js");
|
|
48
|
-
const rsc_router_js_namespaceObject = require("../../router/runtime/rsc-router.js");
|
|
49
47
|
const index_js_namespaceObject = require("../context/index.js");
|
|
50
48
|
const runtime_js_namespaceObject = require("../context/runtime.js");
|
|
51
49
|
const serverPayload_index_js_namespaceObject = require("../context/serverPayload/index.js");
|
|
52
50
|
const external_react_index_js_namespaceObject = require("../react/index.js");
|
|
53
51
|
const external_constants_js_namespaceObject = require("./constants.js");
|
|
52
|
+
const external_requestResponse_js_namespaceObject = require("./requestResponse.js");
|
|
54
53
|
const external_routerCleanup_js_namespaceObject = require("./routerCleanup.js");
|
|
55
|
-
const external_tracer_js_namespaceObject = require("./tracer.js");
|
|
56
54
|
const external_utils_js_namespaceObject = require("./utils.js");
|
|
57
55
|
async function handleRSCRequest(request, Root, context, options, handleRequest) {
|
|
58
56
|
const serverPayload = (0, serverPayload_index_js_namespaceObject.getServerPayload)();
|
|
@@ -72,29 +70,6 @@ async function handleRSCRequest(request, Root, context, options, handleRequest)
|
|
|
72
70
|
runtimeContext: context
|
|
73
71
|
});
|
|
74
72
|
}
|
|
75
|
-
const isRedirectStatus = (status)=>status >= 300 && status <= 399;
|
|
76
|
-
const processRedirect = (headers, status, ctx)=>{
|
|
77
|
-
if (ctx.enableRsc && ctx.isRSCNavigation) return (0, rsc_router_js_namespaceObject.handleRSCRedirect)(headers, ctx.basename, status);
|
|
78
|
-
return new Response(null, {
|
|
79
|
-
status,
|
|
80
|
-
headers
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
const applyRouterSnapshotResult = (context, onError)=>{
|
|
84
|
-
const routerServerSnapshot = (0, lifecycle_js_namespaceObject.getRouterServerSnapshot)(context);
|
|
85
|
-
const routerStatusCode = routerServerSnapshot?.statusCode ?? context.routerContext?.statusCode;
|
|
86
|
-
if (routerStatusCode && 200 !== routerStatusCode) context.ssrContext?.response.status(routerStatusCode);
|
|
87
|
-
const errors = Object.values(routerServerSnapshot?.errors || context.routerContext?.errors || {});
|
|
88
|
-
if (errors.length > 0) onError(errors[0], external_tracer_js_namespaceObject.SSRErrors.LOADER_ERROR);
|
|
89
|
-
};
|
|
90
|
-
const createLoaderRedirectResponse = (beforeRenderResult, redirectCtx)=>{
|
|
91
|
-
if (!beforeRenderResult || !isRedirectStatus(beforeRenderResult.status)) return;
|
|
92
|
-
if (beforeRenderResult.headers.has('X-Modernjs-Redirect')) return beforeRenderResult;
|
|
93
|
-
const redirectUrl = beforeRenderResult.headers.get('Location') || '/';
|
|
94
|
-
return processRedirect(new Headers({
|
|
95
|
-
Location: redirectUrl
|
|
96
|
-
}), beforeRenderResult.status, redirectCtx);
|
|
97
|
-
};
|
|
98
73
|
const renderRequest = async (request, Root, context, options, handleRequest, enableRsc)=>{
|
|
99
74
|
if (enableRsc) return handleRSCRequest(request, Root, context, options, handleRequest);
|
|
100
75
|
return handleRequest(request, Root, {
|
|
@@ -102,17 +77,6 @@ const renderRequest = async (request, Root, context, options, handleRequest, ena
|
|
|
102
77
|
runtimeContext: context
|
|
103
78
|
});
|
|
104
79
|
};
|
|
105
|
-
const finalizeRenderResponse = (response, responseProxy, redirectCtx, routerCleanup)=>{
|
|
106
|
-
if (-1 !== responseProxy.status && isRedirectStatus(responseProxy.status) && responseProxy.headers.Location) return processRedirect(new Headers(responseProxy.headers), responseProxy.status, redirectCtx);
|
|
107
|
-
Object.entries(responseProxy.headers).forEach(([key, value])=>{
|
|
108
|
-
response.headers.set(key, value);
|
|
109
|
-
});
|
|
110
|
-
if (-1 !== responseProxy.status) return routerCleanup.deferUntilBodyDone(new Response(response.body, {
|
|
111
|
-
status: responseProxy.status,
|
|
112
|
-
headers: response.headers
|
|
113
|
-
}));
|
|
114
|
-
return routerCleanup.deferUntilBodyDone(response);
|
|
115
|
-
};
|
|
116
80
|
function createSSRContext(request, options) {
|
|
117
81
|
const { config, loaderContext, onError, onTiming, locals, resource, params, responseProxy, reporter } = options;
|
|
118
82
|
const { nonce, useJsonScript } = config;
|
|
@@ -208,20 +172,26 @@ const createRequestHandler = async (handleRequest, createRequestOptions)=>{
|
|
|
208
172
|
isRSCNavigation: 'true' === request.headers.get('x-rsc-tree'),
|
|
209
173
|
basename: ssrContext.baseUrl || '/'
|
|
210
174
|
};
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
175
|
+
const routerCleanup = (0, external_routerCleanup_js_namespaceObject.createRouterCleanup)(context, options.onError);
|
|
176
|
+
const beforeRenderResult = await (0, external_routerCleanup_js_namespaceObject.runWithRouterCleanupOnError)(routerCleanup, ()=>runBeforeRender(context));
|
|
177
|
+
await (0, external_routerCleanup_js_namespaceObject.runWithRouterCleanupOnError)(routerCleanup, ()=>{
|
|
178
|
+
(0, external_requestResponse_js_namespaceObject.applyRouterSnapshotResult)(context, options.onError);
|
|
179
|
+
});
|
|
180
|
+
if ("u" > typeof Response) {
|
|
181
|
+
const redirectResponse = await (0, external_routerCleanup_js_namespaceObject.runWithRouterCleanupOnError)(routerCleanup, ()=>(0, external_requestResponse_js_namespaceObject.createLoaderRedirectResponse)(beforeRenderResult, redirectCtx));
|
|
182
|
+
if (redirectResponse) {
|
|
183
|
+
await routerCleanup.run();
|
|
184
|
+
return redirectResponse;
|
|
217
185
|
}
|
|
186
|
+
}
|
|
187
|
+
await (0, external_routerCleanup_js_namespaceObject.runWithRouterCleanupOnError)(routerCleanup, ()=>{
|
|
218
188
|
if (!createRequestOptions?.enableRsc) {
|
|
219
189
|
const { htmlTemplate } = options.resource;
|
|
220
190
|
options.resource.htmlTemplate = htmlTemplate.replace('</head>', `${external_constants_js_namespaceObject.CHUNK_CSS_PLACEHOLDER}</head>`);
|
|
221
191
|
}
|
|
222
|
-
const response = await renderRequest(request, Root, context, options, handleRequest, !!createRequestOptions?.enableRsc);
|
|
223
|
-
return finalizeRenderResponse(response, responseProxy, redirectCtx, routerCleanup);
|
|
224
192
|
});
|
|
193
|
+
const response = await (0, external_routerCleanup_js_namespaceObject.runWithRouterCleanupOnError)(routerCleanup, ()=>renderRequest(request, Root, context, options, handleRequest, !!createRequestOptions?.enableRsc));
|
|
194
|
+
return (0, external_routerCleanup_js_namespaceObject.finishWithRouterCleanup)(routerCleanup, ()=>(0, external_requestResponse_js_namespaceObject.finalizeRenderResponse)(response, responseProxy, redirectCtx, routerCleanup));
|
|
225
195
|
});
|
|
226
196
|
};
|
|
227
197
|
return requestHandler;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
applyRouterSnapshotResult: ()=>applyRouterSnapshotResult,
|
|
32
|
+
createLoaderRedirectResponse: ()=>createLoaderRedirectResponse,
|
|
33
|
+
finalizeRenderResponse: ()=>finalizeRenderResponse
|
|
34
|
+
});
|
|
35
|
+
const lifecycle_js_namespaceObject = require("../../router/runtime/lifecycle.js");
|
|
36
|
+
const rsc_router_js_namespaceObject = require("../../router/runtime/rsc-router.js");
|
|
37
|
+
const external_tracer_js_namespaceObject = require("./tracer.js");
|
|
38
|
+
const isRedirectStatus = (status)=>status >= 300 && status <= 399;
|
|
39
|
+
const isNullBodyStatus = (status)=>204 === status || 205 === status || 304 === status;
|
|
40
|
+
const processRedirect = (headers, status, ctx)=>{
|
|
41
|
+
if (ctx.enableRsc && ctx.isRSCNavigation) return (0, rsc_router_js_namespaceObject.handleRSCRedirect)(headers, ctx.basename, status);
|
|
42
|
+
return new Response(null, {
|
|
43
|
+
status,
|
|
44
|
+
headers
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
const applyRouterSnapshotResult = (context, onError)=>{
|
|
48
|
+
const routerServerSnapshot = (0, lifecycle_js_namespaceObject.getRouterServerSnapshot)(context);
|
|
49
|
+
const routerStatusCode = routerServerSnapshot?.statusCode ?? context.routerContext?.statusCode;
|
|
50
|
+
if (routerStatusCode && 200 !== routerStatusCode) context.ssrContext?.response.status(routerStatusCode);
|
|
51
|
+
const errors = Object.values(routerServerSnapshot?.errors || context.routerContext?.errors || {});
|
|
52
|
+
if (errors.length > 0) onError(errors[0], external_tracer_js_namespaceObject.SSRErrors.LOADER_ERROR);
|
|
53
|
+
};
|
|
54
|
+
const createLoaderRedirectResponse = (beforeRenderResult, redirectCtx)=>{
|
|
55
|
+
if (!beforeRenderResult || !isRedirectStatus(beforeRenderResult.status)) return;
|
|
56
|
+
if (beforeRenderResult.headers.has('X-Modernjs-Redirect')) return beforeRenderResult;
|
|
57
|
+
const redirectUrl = beforeRenderResult.headers.get('Location') || '/';
|
|
58
|
+
return processRedirect(new Headers({
|
|
59
|
+
Location: redirectUrl
|
|
60
|
+
}), beforeRenderResult.status, redirectCtx);
|
|
61
|
+
};
|
|
62
|
+
const finalizeRenderResponse = (response, responseProxy, redirectCtx, routerCleanup)=>{
|
|
63
|
+
if (-1 !== responseProxy.status && isRedirectStatus(responseProxy.status) && responseProxy.headers.Location) return processRedirect(new Headers(responseProxy.headers), responseProxy.status, redirectCtx);
|
|
64
|
+
Object.entries(responseProxy.headers).forEach(([key, value])=>{
|
|
65
|
+
response.headers.set(key, value);
|
|
66
|
+
});
|
|
67
|
+
if (-1 !== responseProxy.status) return routerCleanup.deferUntilBodyDone(new Response(isNullBodyStatus(responseProxy.status) ? null : response.body, {
|
|
68
|
+
status: responseProxy.status,
|
|
69
|
+
headers: response.headers
|
|
70
|
+
}));
|
|
71
|
+
return routerCleanup.deferUntilBodyDone(response);
|
|
72
|
+
};
|
|
73
|
+
exports.applyRouterSnapshotResult = __webpack_exports__.applyRouterSnapshotResult;
|
|
74
|
+
exports.createLoaderRedirectResponse = __webpack_exports__.createLoaderRedirectResponse;
|
|
75
|
+
exports.finalizeRenderResponse = __webpack_exports__.finalizeRenderResponse;
|
|
76
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
77
|
+
"applyRouterSnapshotResult",
|
|
78
|
+
"createLoaderRedirectResponse",
|
|
79
|
+
"finalizeRenderResponse"
|
|
80
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
81
|
+
Object.defineProperty(exports, '__esModule', {
|
|
82
|
+
value: true
|
|
83
|
+
});
|
|
@@ -30,6 +30,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
ROUTER_CLEANUP_ERROR: ()=>ROUTER_CLEANUP_ERROR,
|
|
32
32
|
createRouterCleanup: ()=>createRouterCleanup,
|
|
33
|
+
finishWithRouterCleanup: ()=>finishWithRouterCleanup,
|
|
34
|
+
runWithRouterCleanupOnError: ()=>runWithRouterCleanupOnError,
|
|
33
35
|
withRouterCleanup: ()=>withRouterCleanup
|
|
34
36
|
});
|
|
35
37
|
const lifecycle_js_namespaceObject = require("../../router/runtime/lifecycle.js");
|
|
@@ -42,6 +44,21 @@ async function withRouterCleanup(runtimeContext, onError, callback) {
|
|
|
42
44
|
if (!routerCleanup.deferred) await routerCleanup.run();
|
|
43
45
|
}
|
|
44
46
|
}
|
|
47
|
+
async function runWithRouterCleanupOnError(routerCleanup, callback) {
|
|
48
|
+
try {
|
|
49
|
+
return await callback();
|
|
50
|
+
} catch (error) {
|
|
51
|
+
await routerCleanup.run();
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function finishWithRouterCleanup(routerCleanup, callback) {
|
|
56
|
+
try {
|
|
57
|
+
return await callback();
|
|
58
|
+
} finally{
|
|
59
|
+
if (!routerCleanup.deferred) await routerCleanup.run();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
45
62
|
function createRouterCleanup(runtimeContext, onError) {
|
|
46
63
|
let deferred = false;
|
|
47
64
|
let finished = false;
|
|
@@ -99,10 +116,14 @@ function createRouterCleanup(runtimeContext, onError) {
|
|
|
99
116
|
}
|
|
100
117
|
exports.ROUTER_CLEANUP_ERROR = __webpack_exports__.ROUTER_CLEANUP_ERROR;
|
|
101
118
|
exports.createRouterCleanup = __webpack_exports__.createRouterCleanup;
|
|
119
|
+
exports.finishWithRouterCleanup = __webpack_exports__.finishWithRouterCleanup;
|
|
120
|
+
exports.runWithRouterCleanupOnError = __webpack_exports__.runWithRouterCleanupOnError;
|
|
102
121
|
exports.withRouterCleanup = __webpack_exports__.withRouterCleanup;
|
|
103
122
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
104
123
|
"ROUTER_CLEANUP_ERROR",
|
|
105
124
|
"createRouterCleanup",
|
|
125
|
+
"finishWithRouterCleanup",
|
|
126
|
+
"runWithRouterCleanupOnError",
|
|
106
127
|
"withRouterCleanup"
|
|
107
128
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
108
129
|
Object.defineProperty(exports, '__esModule', {
|
|
@@ -30,6 +30,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
createRouteHydrationScriptTags: ()=>createRouteHydrationScriptTags,
|
|
32
32
|
getMatchedRouteAssets: ()=>getMatchedRouteAssets,
|
|
33
|
+
getMatchedRouteChunks: ()=>getMatchedRouteChunks,
|
|
33
34
|
injectBeforeHydrationEntryScript: ()=>injectBeforeHydrationEntryScript,
|
|
34
35
|
orderHydrationScriptChunks: ()=>orderHydrationScriptChunks,
|
|
35
36
|
replaceChunkJsPlaceholder: ()=>replaceChunkJsPlaceholder
|
|
@@ -78,6 +79,10 @@ function getMatchedRouteAssets(runtimeContext, routeManifest) {
|
|
|
78
79
|
const matchedRouteIds = (0, lifecycle_js_namespaceObject.getRouterMatchedRouteIds)(runtimeContext) ?? [];
|
|
79
80
|
return matchedRouteIds.flatMap((routeId)=>routeAssets[routeId]?.assets ?? []);
|
|
80
81
|
}
|
|
82
|
+
function getMatchedRouteChunks(runtimeContext, routeManifest, routeAssetToChunk) {
|
|
83
|
+
if (!routeManifest) return [];
|
|
84
|
+
return getMatchedRouteAssets(runtimeContext, routeManifest).map(routeAssetToChunk);
|
|
85
|
+
}
|
|
81
86
|
const orderHydrationScriptChunks = ({ asyncEntryChunks, collectedChunks, matchedRouteChunks, entryName })=>{
|
|
82
87
|
const asyncEntryScriptChunks = [];
|
|
83
88
|
const asyncEntryDependencyChunks = [];
|
|
@@ -108,23 +113,24 @@ function createRouteHydrationScriptTags(runtimeContext, entryName, options = {})
|
|
|
108
113
|
const { nonce, template } = options;
|
|
109
114
|
const routeAssets = getRouteAssets(runtimeContext);
|
|
110
115
|
if (void 0 === routeAssets) return '';
|
|
111
|
-
const
|
|
112
|
-
const
|
|
113
|
-
...
|
|
114
|
-
routeAssets[`async-${entryName}`]
|
|
115
|
-
].filter((
|
|
116
|
-
const jsAssets = Array.from(new Set(assetEntries.flatMap((entry)=>(entry.assets ?? []).filter((asset)=>asset.endsWith('.js')))));
|
|
116
|
+
const existingScriptSrcs = void 0 === template ? new Set() : new Set(getScriptTags(template).map(({ src })=>src));
|
|
117
|
+
const jsAssets = Array.from(new Set([
|
|
118
|
+
...getMatchedRouteAssets(runtimeContext),
|
|
119
|
+
...routeAssets[`async-${entryName}`]?.assets ?? []
|
|
120
|
+
].filter((asset)=>asset.endsWith('.js'))));
|
|
117
121
|
const nonceAttr = void 0 === nonce || '' === nonce ? '' : ` nonce="${nonce}"`;
|
|
118
|
-
return jsAssets.filter((asset)
|
|
122
|
+
return jsAssets.filter((asset)=>!existingScriptSrcs.has(asset)).map((asset)=>`<script src=${asset}${nonceAttr}></script>`).join(' ');
|
|
119
123
|
}
|
|
120
124
|
exports.createRouteHydrationScriptTags = __webpack_exports__.createRouteHydrationScriptTags;
|
|
121
125
|
exports.getMatchedRouteAssets = __webpack_exports__.getMatchedRouteAssets;
|
|
126
|
+
exports.getMatchedRouteChunks = __webpack_exports__.getMatchedRouteChunks;
|
|
122
127
|
exports.injectBeforeHydrationEntryScript = __webpack_exports__.injectBeforeHydrationEntryScript;
|
|
123
128
|
exports.orderHydrationScriptChunks = __webpack_exports__.orderHydrationScriptChunks;
|
|
124
129
|
exports.replaceChunkJsPlaceholder = __webpack_exports__.replaceChunkJsPlaceholder;
|
|
125
130
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
126
131
|
"createRouteHydrationScriptTags",
|
|
127
132
|
"getMatchedRouteAssets",
|
|
133
|
+
"getMatchedRouteChunks",
|
|
128
134
|
"injectBeforeHydrationEntryScript",
|
|
129
135
|
"orderHydrationScriptChunks",
|
|
130
136
|
"replaceChunkJsPlaceholder"
|
|
@@ -28,8 +28,7 @@ var __webpack_require__ = {};
|
|
|
28
28
|
var __webpack_exports__ = {};
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
-
LoadableCollector: ()=>LoadableCollector
|
|
32
|
-
orderHydrationScriptChunks: ()=>external_scriptOrder_js_namespaceObject.orderHydrationScriptChunks
|
|
31
|
+
LoadableCollector: ()=>LoadableCollector
|
|
33
32
|
});
|
|
34
33
|
const server_namespaceObject = require("@loadable/server");
|
|
35
34
|
const external_federatedCss_js_namespaceObject = require("../federatedCss.js");
|
|
@@ -61,11 +60,6 @@ const readAsset = async (chunk)=>{
|
|
|
61
60
|
return fs.readFile(filepath, 'utf-8');
|
|
62
61
|
};
|
|
63
62
|
class LoadableCollector {
|
|
64
|
-
getMatchedRouteChunks() {
|
|
65
|
-
const { routeManifest, runtimeContext } = this.options;
|
|
66
|
-
if (!routeManifest) return [];
|
|
67
|
-
return (0, external_scriptOrder_js_namespaceObject.getMatchedRouteAssets)(runtimeContext, routeManifest).map(routeAssetToChunk);
|
|
68
|
-
}
|
|
69
63
|
collect(comopnent) {
|
|
70
64
|
const { stats, entryName } = this.options;
|
|
71
65
|
if (!stats) return comopnent;
|
|
@@ -87,7 +81,7 @@ class LoadableCollector {
|
|
|
87
81
|
]));
|
|
88
82
|
} catch (e) {}
|
|
89
83
|
const collectedChunks = extractor ? extractor.getChunkAssets(extractor.chunks) : [];
|
|
90
|
-
const matchedRouteChunks =
|
|
84
|
+
const matchedRouteChunks = (0, external_scriptOrder_js_namespaceObject.getMatchedRouteChunks)(options.runtimeContext, options.routeManifest, routeAssetToChunk);
|
|
91
85
|
const orderedScriptChunks = (0, external_scriptOrder_js_namespaceObject.orderHydrationScriptChunks)({
|
|
92
86
|
asyncEntryChunks: asyncChunks,
|
|
93
87
|
collectedChunks,
|
|
@@ -166,10 +160,8 @@ class LoadableCollector {
|
|
|
166
160
|
}
|
|
167
161
|
}
|
|
168
162
|
exports.LoadableCollector = __webpack_exports__.LoadableCollector;
|
|
169
|
-
exports.orderHydrationScriptChunks = __webpack_exports__.orderHydrationScriptChunks;
|
|
170
163
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
171
|
-
"LoadableCollector"
|
|
172
|
-
"orderHydrationScriptChunks"
|
|
164
|
+
"LoadableCollector"
|
|
173
165
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
174
166
|
Object.defineProperty(exports, '__esModule', {
|
|
175
167
|
value: true
|
package/dist/cjs/index.js
CHANGED
|
@@ -28,19 +28,20 @@ var __webpack_require__ = {};
|
|
|
28
28
|
var __webpack_exports__ = {};
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
-
RuntimeContext: ()=>
|
|
32
|
-
defineRuntimeConfig: ()=>
|
|
33
|
-
getMonitors: ()=>
|
|
31
|
+
RuntimeContext: ()=>public_js_namespaceObject.RuntimeContext,
|
|
32
|
+
defineRuntimeConfig: ()=>config_js_namespaceObject.defineRuntimeConfig,
|
|
33
|
+
getMonitors: ()=>index_js_namespaceObject.getMonitors,
|
|
34
34
|
getRequest: ()=>request_index_js_namespaceObject.getRequest,
|
|
35
35
|
isBrowser: ()=>external_common_js_namespaceObject.isBrowser,
|
|
36
36
|
redirect: ()=>response_index_js_namespaceObject.redirect,
|
|
37
37
|
setHeaders: ()=>response_index_js_namespaceObject.setHeaders,
|
|
38
38
|
setStatus: ()=>response_index_js_namespaceObject.setStatus,
|
|
39
|
-
useRuntimeContext: ()=>
|
|
39
|
+
useRuntimeContext: ()=>public_js_namespaceObject.useRuntimeContext
|
|
40
40
|
});
|
|
41
41
|
const external_common_js_namespaceObject = require("./common.js");
|
|
42
|
-
const
|
|
43
|
-
const
|
|
42
|
+
const config_js_namespaceObject = require("./core/config.js");
|
|
43
|
+
const index_js_namespaceObject = require("./core/context/monitors/index.js");
|
|
44
|
+
const public_js_namespaceObject = require("./core/context/public.js");
|
|
44
45
|
const request_index_js_namespaceObject = require("./core/context/request/index.js");
|
|
45
46
|
const response_index_js_namespaceObject = require("./core/context/response/index.js");
|
|
46
47
|
exports.RuntimeContext = __webpack_exports__.RuntimeContext;
|
|
@@ -227,7 +227,8 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
|
|
|
227
227
|
component = `component_${components.length - 1}`;
|
|
228
228
|
}
|
|
229
229
|
const isClientComponent = 'nested' === route.type && Boolean(route._component) && Boolean(srcDirectory) && Boolean(internalSrcAlias) && await hasUseClientDirective(route._component, srcDirectory, internalSrcAlias);
|
|
230
|
-
const
|
|
230
|
+
const shouldHydrateRscRoute = isRscClientBundle && !isClientComponent && !route.loader && !route.data;
|
|
231
|
+
const shouldIncludeClientBundle = !isRscClientBundle || isClientComponent || shouldHydrateRscRoute;
|
|
231
232
|
const finalRoute = {
|
|
232
233
|
...route,
|
|
233
234
|
loading,
|
|
@@ -330,7 +331,7 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
|
|
|
330
331
|
${importLazyCode}
|
|
331
332
|
${!isRscClientBundle ? importComponentsCode : ''}
|
|
332
333
|
${importRuntimeRouterCode}
|
|
333
|
-
${
|
|
334
|
+
${rootLayoutCode}
|
|
334
335
|
${importLoadingCode}
|
|
335
336
|
${importErrorComponentsCode}
|
|
336
337
|
${importLoadersCode}
|
|
@@ -36,12 +36,13 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
36
36
|
onBeforeHydrateRouter: ()=>onBeforeHydrateRouter
|
|
37
37
|
});
|
|
38
38
|
const plugin_namespaceObject = require("@modern-js/plugin");
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
39
|
+
const createRouterSyncHook = ()=>(0, plugin_namespaceObject.createSyncHook)();
|
|
40
|
+
const modifyRoutes = createRouterSyncHook();
|
|
41
|
+
const onBeforeCreateRoutes = createRouterSyncHook();
|
|
42
|
+
const onBeforeCreateRouter = createRouterSyncHook();
|
|
43
|
+
const onAfterCreateRouter = createRouterSyncHook();
|
|
44
|
+
const onBeforeHydrateRouter = createRouterSyncHook();
|
|
45
|
+
const onAfterHydrateRouter = createRouterSyncHook();
|
|
45
46
|
exports.modifyRoutes = __webpack_exports__.modifyRoutes;
|
|
46
47
|
exports.onAfterCreateRouter = __webpack_exports__.onAfterCreateRouter;
|
|
47
48
|
exports.onAfterHydrateRouter = __webpack_exports__.onAfterHydrateRouter;
|
|
@@ -76,7 +76,7 @@ function registerRouterProvider(name, factory, options = {}) {
|
|
|
76
76
|
}
|
|
77
77
|
function resolveRouterProvider(framework, options = {}) {
|
|
78
78
|
const registry = getRegistry();
|
|
79
|
-
const name = framework ||
|
|
79
|
+
const name = framework || options.localDefault?.name || registry.defaultProvider;
|
|
80
80
|
if (void 0 === name) throw new Error('[@modern-js/runtime] No default router provider is registered. This is a bug in the runtime setup.');
|
|
81
81
|
if (void 0 !== options.localDefault && name === options.localDefault.name) return options.localDefault.factory;
|
|
82
82
|
const factory = registry.providers.get(name);
|
|
@@ -84,14 +84,13 @@ const ssrBuilderPlugin = (modernAPI, outputModule, exportLoadablePath)=>({
|
|
|
84
84
|
const hasServerRendering = hasServerRenderingConfig(userConfig);
|
|
85
85
|
const hasModuleFederationRuntimeMarker = hasServerRendering && shouldUseModuleFederationNodeOutput(config);
|
|
86
86
|
const hasExplicitMfSsrFlag = isModuleFederationAppSSREnabled(userConfig);
|
|
87
|
-
const isCloudflareWorkerSSR = 'workerSSR' === name && userConfig.deploy?.target === 'cloudflare';
|
|
88
87
|
const requireExplicitMfSsrFlag = 'true' === process.env.MODERN_MF_APP_SSR_REQUIRE_EXPLICIT;
|
|
89
88
|
if (hasServerRendering && hasModuleFederationRuntimeMarker && !hasExplicitMfSsrFlag) {
|
|
90
89
|
const warningMessage = '[modernjs][mf-ssr] Module Federation SSR was auto-detected from runtime markers. Set server.ssr.moduleFederationAppSSR=true explicitly in host and remotes to avoid heuristic drift.';
|
|
91
90
|
if (requireExplicitMfSsrFlag) throw new Error(`${warningMessage} (enforced by MODERN_MF_APP_SSR_REQUIRE_EXPLICIT=true)`);
|
|
92
91
|
console.warn(warningMessage);
|
|
93
92
|
}
|
|
94
|
-
const isModuleFederationAppSSR = hasServerRendering && hasExplicitMfSsrFlag
|
|
93
|
+
const isModuleFederationAppSSR = hasServerRendering && hasExplicitMfSsrFlag;
|
|
95
94
|
const ssrEnv = userConfig.deploy?.worker?.ssr || userConfig.server?.rsc ? 'edge' : 'node';
|
|
96
95
|
const appContext = modernAPI.getAppContext();
|
|
97
96
|
const { appDirectory, entrypoints } = appContext;
|