@modern-js/runtime 2.42.1 → 2.43.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 +2 -3
- package/dist/cjs/ssr/cli/index.js +6 -4
- package/dist/cjs/ssr/index.js +11 -3
- package/dist/cjs/ssr/react/prerender/index.js +1 -0
- package/dist/cjs/ssr/serverRender/{renderToString/type.js → constants.js} +21 -11
- package/dist/cjs/ssr/serverRender/helmet.js +5 -4
- package/dist/cjs/ssr/serverRender/index.js +2 -2
- package/dist/cjs/ssr/serverRender/renderToStream/buildTemplate.after.js +2 -1
- package/dist/cjs/ssr/serverRender/renderToStream/bulidTemplate.before.js +2 -1
- package/dist/cjs/ssr/serverRender/renderToStream/index.js +0 -5
- package/dist/cjs/ssr/serverRender/renderToString/buildHtml.js +6 -8
- package/dist/cjs/ssr/serverRender/renderToString/entry.js +15 -13
- package/dist/cjs/ssr/serverRender/renderToString/index.js +0 -5
- package/dist/cjs/ssr/serverRender/types.js +7 -2
- package/dist/cjs/ssr/serverRender/utils.js +7 -11
- package/dist/esm/cli/index.js +2 -3
- package/dist/esm/ssr/cli/index.js +6 -4
- package/dist/esm/ssr/index.js +10 -2
- package/dist/esm/ssr/react/prerender/index.js +1 -0
- package/dist/esm/ssr/serverRender/constants.js +14 -0
- package/dist/esm/ssr/serverRender/helmet.js +5 -4
- package/dist/esm/ssr/serverRender/index.js +2 -2
- package/dist/esm/ssr/serverRender/renderToStream/buildTemplate.after.js +3 -2
- package/dist/esm/ssr/serverRender/renderToStream/bulidTemplate.before.js +3 -2
- package/dist/esm/ssr/serverRender/renderToStream/index.js +0 -5
- package/dist/esm/ssr/serverRender/renderToString/buildHtml.js +6 -8
- package/dist/esm/ssr/serverRender/renderToString/entry.js +21 -15
- package/dist/esm/ssr/serverRender/renderToString/index.js +1 -6
- package/dist/esm/ssr/serverRender/types.js +6 -1
- package/dist/esm/ssr/serverRender/utils.js +7 -7
- package/dist/esm-node/cli/index.js +2 -3
- package/dist/esm-node/ssr/cli/index.js +6 -4
- package/dist/esm-node/ssr/index.js +9 -1
- package/dist/esm-node/ssr/react/prerender/index.js +1 -0
- package/dist/esm-node/ssr/serverRender/constants.js +14 -0
- package/dist/esm-node/ssr/serverRender/helmet.js +5 -4
- package/dist/esm-node/ssr/serverRender/index.js +2 -2
- package/dist/esm-node/ssr/serverRender/renderToStream/buildTemplate.after.js +3 -2
- package/dist/esm-node/ssr/serverRender/renderToStream/bulidTemplate.before.js +3 -2
- package/dist/esm-node/ssr/serverRender/renderToStream/index.js +0 -5
- package/dist/esm-node/ssr/serverRender/renderToString/buildHtml.js +6 -8
- package/dist/esm-node/ssr/serverRender/renderToString/entry.js +14 -12
- package/dist/esm-node/ssr/serverRender/renderToString/index.js +0 -5
- package/dist/esm-node/ssr/serverRender/types.js +6 -1
- package/dist/esm-node/ssr/serverRender/utils.js +5 -7
- package/dist/types/exports/server.d.ts +1 -0
- package/dist/types/ssr/react/prerender/index.d.ts +4 -0
- package/dist/types/ssr/serverRender/constants.d.ts +6 -0
- package/dist/types/ssr/serverRender/renderToString/entry.d.ts +1 -2
- package/dist/types/ssr/serverRender/renderToString/loadable.d.ts +1 -2
- package/dist/types/ssr/serverRender/renderToString/styledComponent.d.ts +1 -1
- package/dist/types/ssr/serverRender/types.d.ts +15 -2
- package/dist/types/ssr/serverRender/utils.d.ts +7 -3
- package/package.json +12 -12
- package/dist/esm/ssr/serverRender/renderToString/type.js +0 -9
- package/dist/esm-node/ssr/serverRender/renderToString/type.js +0 -9
- package/dist/types/ssr/serverRender/renderToString/type.d.ts +0 -13
package/dist/cjs/cli/index.js
CHANGED
|
@@ -32,7 +32,6 @@ __export(cli_exports, {
|
|
|
32
32
|
runtimePlugin: () => runtimePlugin
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(cli_exports);
|
|
35
|
-
var import_path = __toESM(require("path"));
|
|
36
35
|
var import_utils = require("@modern-js/utils");
|
|
37
36
|
var import_cli = require("../state/cli");
|
|
38
37
|
var import_cli2 = require("../ssr/cli");
|
|
@@ -57,8 +56,8 @@ const runtimePlugin = () => ({
|
|
|
57
56
|
setup: (api) => {
|
|
58
57
|
return {
|
|
59
58
|
config() {
|
|
60
|
-
const
|
|
61
|
-
process.env.IS_REACT18 = (0, import_utils.isReact18)(
|
|
59
|
+
const appDir = api.useAppContext().appDirectory;
|
|
60
|
+
process.env.IS_REACT18 = (0, import_utils.isReact18)(appDir).toString();
|
|
62
61
|
return {
|
|
63
62
|
runtime: {},
|
|
64
63
|
runtimeByEntries: {},
|
|
@@ -104,11 +104,11 @@ const ssrPlugin = () => ({
|
|
|
104
104
|
}
|
|
105
105
|
},
|
|
106
106
|
tools: {
|
|
107
|
-
bundlerChain(chain, { isServer, isServiceWorker
|
|
107
|
+
bundlerChain(chain, { isServer, isServiceWorker }) {
|
|
108
108
|
const userConfig = api.useResolvedConfigContext();
|
|
109
109
|
if ((0, import_utils.isUseSSRBundle)(userConfig) && !isServer && !isServiceWorker && checkUseStringSSR(userConfig)) {
|
|
110
110
|
const LoadableBundlerPlugin = require("./loadable-bundler-plugin.js");
|
|
111
|
-
chain.plugin(
|
|
111
|
+
chain.plugin("loadable").use(LoadableBundlerPlugin, [
|
|
112
112
|
{
|
|
113
113
|
filename: import_utils.LOADABLE_STATS_FILE
|
|
114
114
|
}
|
|
@@ -154,12 +154,13 @@ const ssrPlugin = () => ({
|
|
|
154
154
|
},
|
|
155
155
|
modifyEntryRuntimePlugins({ entrypoint, plugins, bundlerConfigs }) {
|
|
156
156
|
if (ssrConfigMap.get(entrypoint.entryName)) {
|
|
157
|
-
var _bundlerConfigs_find_output, _bundlerConfigs_find, _config_server;
|
|
157
|
+
var _bundlerConfigs_find_output, _bundlerConfigs_find, _config_server, _config_server1;
|
|
158
158
|
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;
|
|
159
159
|
const config = api.useResolvedConfigContext();
|
|
160
160
|
const { enableInlineScripts, enableInlineStyles } = config.output;
|
|
161
161
|
const { crossorigin, scriptLoading } = config.html;
|
|
162
162
|
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
|
+
const unsafeHeaders = typeof ((_config_server1 = config.server) === null || _config_server1 === void 0 ? void 0 : _config_server1.ssr) === "object" ? config.server.ssr.unsafeHeaders : void 0;
|
|
163
164
|
plugins.push({
|
|
164
165
|
name: PLUGIN_IDENTIFIER,
|
|
165
166
|
options: JSON.stringify({
|
|
@@ -169,7 +170,8 @@ const ssrPlugin = () => ({
|
|
|
169
170
|
chunkLoadingGlobal,
|
|
170
171
|
disablePrerender,
|
|
171
172
|
enableInlineScripts: typeof enableInlineScripts === "function" ? void 0 : enableInlineScripts,
|
|
172
|
-
enableInlineStyles: typeof enableInlineStyles === "function" ? void 0 : enableInlineStyles
|
|
173
|
+
enableInlineStyles: typeof enableInlineStyles === "function" ? void 0 : enableInlineStyles,
|
|
174
|
+
unsafeHeaders
|
|
173
175
|
})
|
|
174
176
|
});
|
|
175
177
|
}
|
package/dist/cjs/ssr/index.js
CHANGED
|
@@ -40,15 +40,15 @@ var import_parsed = require("@modern-js/runtime-utils/parsed");
|
|
|
40
40
|
var import_types = require("./serverRender/types");
|
|
41
41
|
var import_withCallback = require("./react/withCallback");
|
|
42
42
|
var import_utils = require("./utils");
|
|
43
|
-
var
|
|
43
|
+
var import_constants = require("./serverRender/constants");
|
|
44
44
|
__reExport(ssr_exports, require("./react"), module.exports);
|
|
45
45
|
const ssr = (config) => ({
|
|
46
46
|
name: "@modern-js/plugin-ssr",
|
|
47
47
|
setup: () => {
|
|
48
48
|
const mockResp = (0, import_utils.mockResponse)();
|
|
49
49
|
if (config.inlineScript === false) {
|
|
50
|
-
window._SSR_DATA = (0, import_parsed.parsedJSONFromElement)(
|
|
51
|
-
window._ROUTER_DATA = (0, import_parsed.parsedJSONFromElement)(
|
|
50
|
+
window._SSR_DATA = (0, import_parsed.parsedJSONFromElement)(import_constants.SSR_DATA_JSON_ID);
|
|
51
|
+
window._ROUTER_DATA = (0, import_parsed.parsedJSONFromElement)(import_constants.ROUTER_DATA_JSON_ID);
|
|
52
52
|
}
|
|
53
53
|
return {
|
|
54
54
|
client: async ({ App, context, ModernRender, ModernHydrate }) => {
|
|
@@ -60,6 +60,14 @@ const ssr = (config) => ({
|
|
|
60
60
|
},
|
|
61
61
|
_hydration: true
|
|
62
62
|
};
|
|
63
|
+
const { ssrContext } = hydrateContext;
|
|
64
|
+
const { pathname: initialPathname } = ssrContext.request;
|
|
65
|
+
const currentPathname = window.location.pathname;
|
|
66
|
+
if (initialPathname !== currentPathname) {
|
|
67
|
+
const errorMsg = `The initial URL ${initialPathname} and the URL ${currentPathname} to be hydrated do not match, reload.`;
|
|
68
|
+
console.error(errorMsg);
|
|
69
|
+
window.location.reload();
|
|
70
|
+
}
|
|
63
71
|
const callback = () => {
|
|
64
72
|
delete hydrateContext._hydration;
|
|
65
73
|
};
|
|
@@ -101,6 +101,7 @@ function factory(Component) {
|
|
|
101
101
|
if (!validate) {
|
|
102
102
|
throw new Error("invalid props, check usage");
|
|
103
103
|
}
|
|
104
|
+
console.error("[Warn] PreRender has been deprecated, please use SSR Cache instead. reference to docs: https://modernjs.dev/guides/advanced-features/ssr.html");
|
|
104
105
|
return (0, import_react.createElement)(Component, {
|
|
105
106
|
...newProps
|
|
106
107
|
});
|
|
@@ -16,18 +16,28 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var constants_exports = {};
|
|
20
|
+
__export(constants_exports, {
|
|
21
|
+
CHUNK_CSS_PLACEHOLDER: () => CHUNK_CSS_PLACEHOLDER,
|
|
22
|
+
CHUNK_JS_PLACEHOLDER: () => CHUNK_JS_PLACEHOLDER,
|
|
23
|
+
HTML_PLACEHOLDER: () => HTML_PLACEHOLDER,
|
|
24
|
+
ROUTER_DATA_JSON_ID: () => ROUTER_DATA_JSON_ID,
|
|
25
|
+
SSR_DATA_JSON_ID: () => SSR_DATA_JSON_ID,
|
|
26
|
+
SSR_DATA_PLACEHOLDER: () => SSR_DATA_PLACEHOLDER
|
|
22
27
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
module.exports = __toCommonJS(constants_exports);
|
|
29
|
+
const HTML_PLACEHOLDER = "<!--<?- html ?>-->";
|
|
30
|
+
const SSR_DATA_PLACEHOLDER = "<!--<?- SSRDataScript ?>-->";
|
|
31
|
+
const CHUNK_JS_PLACEHOLDER = "<!--<?- chunksMap.js ?>-->";
|
|
32
|
+
const CHUNK_CSS_PLACEHOLDER = "<!--<?- chunksMap.css ?>-->";
|
|
33
|
+
const SSR_DATA_JSON_ID = "__MODERN_SSR_DATA__";
|
|
34
|
+
const ROUTER_DATA_JSON_ID = "__MODERN_ROUTER_DATA__";
|
|
30
35
|
// Annotate the CommonJS export names for ESM import in node:
|
|
31
36
|
0 && (module.exports = {
|
|
32
|
-
|
|
37
|
+
CHUNK_CSS_PLACEHOLDER,
|
|
38
|
+
CHUNK_JS_PLACEHOLDER,
|
|
39
|
+
HTML_PLACEHOLDER,
|
|
40
|
+
ROUTER_DATA_JSON_ID,
|
|
41
|
+
SSR_DATA_JSON_ID,
|
|
42
|
+
SSR_DATA_PLACEHOLDER
|
|
33
43
|
});
|
|
@@ -22,6 +22,7 @@ __export(helmet_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(helmet_exports);
|
|
24
24
|
var import_os = require("os");
|
|
25
|
+
var import_utils = require("./utils");
|
|
25
26
|
const RE_HTML_ATTR = /<html[^>]*>/;
|
|
26
27
|
const RE_BODY_ATTR = /<body[^>]*>/;
|
|
27
28
|
const RE_LAST_IN_HEAD = /<\/head>/;
|
|
@@ -31,11 +32,11 @@ function helmet(content, helmetData) {
|
|
|
31
32
|
let result = content;
|
|
32
33
|
const bodyAttributes = helmetData.bodyAttributes.toString();
|
|
33
34
|
if (bodyAttributes) {
|
|
34
|
-
result =
|
|
35
|
+
result = (0, import_utils.safeReplace)(result, RE_BODY_ATTR, `<body ${bodyAttributes}>`);
|
|
35
36
|
}
|
|
36
37
|
const htmlAttributes = helmetData.htmlAttributes.toString();
|
|
37
38
|
if (htmlAttributes) {
|
|
38
|
-
result =
|
|
39
|
+
result = (0, import_utils.safeReplace)(result, RE_HTML_ATTR, `<html ${htmlAttributes}>`);
|
|
39
40
|
}
|
|
40
41
|
const base = helmetData.base.toString();
|
|
41
42
|
const link = helmetData.link.toString();
|
|
@@ -47,7 +48,7 @@ function helmet(content, helmetData) {
|
|
|
47
48
|
const existTitleTag = RE_TITLE.test(content);
|
|
48
49
|
const shouldReplaceTitle = existTitleTag && TEST_TITLE_CONTENT.test(title.trim());
|
|
49
50
|
if (shouldReplaceTitle) {
|
|
50
|
-
result =
|
|
51
|
+
result = (0, import_utils.safeReplace)(result, RE_TITLE, title);
|
|
51
52
|
}
|
|
52
53
|
const helmetStr = [
|
|
53
54
|
base,
|
|
@@ -60,5 +61,5 @@ function helmet(content, helmetData) {
|
|
|
60
61
|
].reduce((pre, cur) => {
|
|
61
62
|
return pre + (cur.length > 0 ? ` ${cur}${import_os.EOL}` : "");
|
|
62
63
|
}, "");
|
|
63
|
-
return
|
|
64
|
+
return (0, import_utils.safeReplace)(result, RE_LAST_IN_HEAD, `${helmetStr}</head>`);
|
|
64
65
|
}
|
|
@@ -22,12 +22,12 @@ __export(serverRender_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(serverRender_exports);
|
|
24
24
|
var import_utils = require("../utils");
|
|
25
|
-
var
|
|
25
|
+
var import_constants = require("./constants");
|
|
26
26
|
async function serverRender(options) {
|
|
27
27
|
var _options_context_ssrContext;
|
|
28
28
|
if ((_options_context_ssrContext = options.context.ssrContext) === null || _options_context_ssrContext === void 0 ? void 0 : _options_context_ssrContext.template) {
|
|
29
29
|
var _options_context_ssrContext1;
|
|
30
|
-
options.context.ssrContext.template = (_options_context_ssrContext1 = options.context.ssrContext) === null || _options_context_ssrContext1 === void 0 ? void 0 : _options_context_ssrContext1.template.replace("</head>", `${
|
|
30
|
+
options.context.ssrContext.template = (_options_context_ssrContext1 = options.context.ssrContext) === null || _options_context_ssrContext1 === void 0 ? void 0 : _options_context_ssrContext1.template.replace("</head>", `${import_constants.CHUNK_CSS_PLACEHOLDER}</head>`);
|
|
31
31
|
}
|
|
32
32
|
if ((0, import_utils.isReact18)() && options.config.mode === "stream") {
|
|
33
33
|
const pipe = await require("./renderToStream").render(options);
|
|
@@ -23,6 +23,7 @@ __export(buildTemplate_after_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(buildTemplate_after_exports);
|
|
24
24
|
var import_node = require("@modern-js/runtime-utils/node");
|
|
25
25
|
var import_utils = require("../utils");
|
|
26
|
+
var import_constants = require("../constants");
|
|
26
27
|
var import_buildTemplate = require("./buildTemplate.share");
|
|
27
28
|
function buildShellAfterTemplate(afterAppTemplate, options) {
|
|
28
29
|
const callbacks = [
|
|
@@ -31,7 +32,7 @@ function buildShellAfterTemplate(afterAppTemplate, options) {
|
|
|
31
32
|
return (0, import_buildTemplate.buildTemplate)(afterAppTemplate, callbacks);
|
|
32
33
|
function injectSSRDataScript(template) {
|
|
33
34
|
const ssrDataScript = buildSSRDataScript();
|
|
34
|
-
return
|
|
35
|
+
return (0, import_utils.safeReplace)(template, import_constants.SSR_DATA_PLACEHOLDER, ssrDataScript);
|
|
35
36
|
function buildSSRDataScript() {
|
|
36
37
|
const { context: { ssrContext, initialData, __i18nData__ }, renderLevel } = options;
|
|
37
38
|
const { request, enableUnsafeCtx, nonce, tracker } = ssrContext;
|
|
@@ -34,6 +34,7 @@ module.exports = __toCommonJS(bulidTemplate_before_exports);
|
|
|
34
34
|
var import_react_helmet = __toESM(require("react-helmet"));
|
|
35
35
|
var import_router = require("@modern-js/runtime-utils/router");
|
|
36
36
|
var import_helmet = __toESM(require("../helmet"));
|
|
37
|
+
var import_constants = require("../constants");
|
|
37
38
|
var import_utils = require("../utils");
|
|
38
39
|
var import_buildTemplate = require("./buildTemplate.share");
|
|
39
40
|
function getHeadTemplate(beforeEntryTemplate, context) {
|
|
@@ -51,7 +52,7 @@ function getHeadTemplate(beforeEntryTemplate, context) {
|
|
|
51
52
|
}
|
|
52
53
|
return (0, import_buildTemplate.buildTemplate)(headTemplate, callbacks);
|
|
53
54
|
function injectCss(headTemplate2) {
|
|
54
|
-
return
|
|
55
|
+
return (0, import_utils.safeReplace)(headTemplate2, import_constants.CHUNK_CSS_PLACEHOLDER, getCssChunks());
|
|
55
56
|
function getCssChunks() {
|
|
56
57
|
const { routeManifest, routerContext, routes } = context;
|
|
57
58
|
if (!routeManifest || !routerContext || !routes) {
|
|
@@ -34,7 +34,6 @@ module.exports = __toCommonJS(renderToStream_exports);
|
|
|
34
34
|
var import_react = require("react");
|
|
35
35
|
var import_node = require("@modern-js/runtime-utils/node");
|
|
36
36
|
var import_time = require("@modern-js/runtime-utils/time");
|
|
37
|
-
var import_prerender = require("../../react/prerender");
|
|
38
37
|
var import_tracker = require("../tracker");
|
|
39
38
|
var import_renderToPipe = __toESM(require("./renderToPipe"));
|
|
40
39
|
const render = ({ App, context }) => {
|
|
@@ -52,10 +51,6 @@ const render = ({ App, context }) => {
|
|
|
52
51
|
const { tracker } = ssrContext;
|
|
53
52
|
const pipe = (0, import_renderToPipe.default)(rootElement, context, {
|
|
54
53
|
onShellReady() {
|
|
55
|
-
const cacheConfig = import_prerender.PreRender.config();
|
|
56
|
-
if (cacheConfig) {
|
|
57
|
-
ssrContext.cacheConfig = cacheConfig;
|
|
58
|
-
}
|
|
59
54
|
const cost = end();
|
|
60
55
|
tracker.trackTiming(import_tracker.SSRTimings.RENDER_SHELL, cost);
|
|
61
56
|
},
|
|
@@ -25,24 +25,22 @@ __export(buildHtml_exports, {
|
|
|
25
25
|
createReplaceSSRDataScript: () => createReplaceSSRDataScript
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(buildHtml_exports);
|
|
28
|
+
var import_utils = require("../utils");
|
|
29
|
+
var import_constants = require("../constants");
|
|
28
30
|
function buildHtml(template, callbacks) {
|
|
29
31
|
return callbacks.reduce((tmp, cb) => cb(tmp), template);
|
|
30
32
|
}
|
|
31
33
|
function createReplaceHtml(html) {
|
|
32
|
-
|
|
33
|
-
return (template) => template.replace(HTML_REG, html);
|
|
34
|
+
return (template) => (0, import_utils.safeReplace)(template, import_constants.HTML_PLACEHOLDER, html);
|
|
34
35
|
}
|
|
35
36
|
function createReplaceSSRDataScript(data) {
|
|
36
|
-
|
|
37
|
-
return (template) => template.replace(SSR_DATA_REG, data);
|
|
37
|
+
return (template) => (0, import_utils.safeReplace)(template, import_constants.SSR_DATA_PLACEHOLDER, data);
|
|
38
38
|
}
|
|
39
39
|
function createReplaceChunkJs(js) {
|
|
40
|
-
|
|
41
|
-
return (template) => template.replace(CHUNK_JS_REG, js);
|
|
40
|
+
return (template) => (0, import_utils.safeReplace)(template, import_constants.CHUNK_JS_PLACEHOLDER, js);
|
|
42
41
|
}
|
|
43
42
|
function createReplaceChunkCss(css) {
|
|
44
|
-
|
|
45
|
-
return (template) => template.replace(CHUNK_CSS_REG, css);
|
|
43
|
+
return (template) => (0, import_utils.safeReplace)(template, import_constants.CHUNK_CSS_PLACEHOLDER, css);
|
|
46
44
|
}
|
|
47
45
|
// Annotate the CommonJS export names for ESM import in node:
|
|
48
46
|
0 && (module.exports = {
|
|
@@ -40,17 +40,20 @@ var import_utils = require("../../../router/runtime/utils");
|
|
|
40
40
|
var import_helmet = __toESM(require("../helmet"));
|
|
41
41
|
var import_types = require("../types");
|
|
42
42
|
var import_prefetch = __toESM(require("../../prefetch"));
|
|
43
|
+
var import_constants = require("../constants");
|
|
43
44
|
var import_utils2 = require("../utils");
|
|
44
45
|
var import_tracker = require("../tracker");
|
|
45
46
|
var import_loadable = require("./loadable");
|
|
46
47
|
var import_render = require("./render");
|
|
47
48
|
var import_styledComponent = require("./styledComponent");
|
|
48
49
|
var import_buildHtml = require("./buildHtml");
|
|
49
|
-
const buildTemplateData = (context, data, renderLevel, tracker) => {
|
|
50
|
-
const { request
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
const buildTemplateData = (context, data, renderLevel, tracker, config) => {
|
|
51
|
+
const { request } = context;
|
|
52
|
+
const { unsafeHeaders } = config;
|
|
53
|
+
const headers = unsafeHeaders ? Object.fromEntries(Object.entries(request.headers).filter(([key, _]) => {
|
|
54
|
+
var _unsafeHeaders_map;
|
|
55
|
+
return unsafeHeaders === null || unsafeHeaders === void 0 ? void 0 : (_unsafeHeaders_map = unsafeHeaders.map((header) => header.toLowerCase())) === null || _unsafeHeaders_map === void 0 ? void 0 : _unsafeHeaders_map.includes(key.toLowerCase());
|
|
56
|
+
})) : void 0;
|
|
54
57
|
return {
|
|
55
58
|
data,
|
|
56
59
|
context: {
|
|
@@ -60,7 +63,7 @@ const buildTemplateData = (context, data, renderLevel, tracker) => {
|
|
|
60
63
|
pathname: request.pathname,
|
|
61
64
|
host: request.host,
|
|
62
65
|
url: request.url,
|
|
63
|
-
|
|
66
|
+
headers
|
|
64
67
|
},
|
|
65
68
|
reporter: {
|
|
66
69
|
sessionId: tracker.sessionId
|
|
@@ -69,8 +72,7 @@ const buildTemplateData = (context, data, renderLevel, tracker) => {
|
|
|
69
72
|
renderLevel
|
|
70
73
|
};
|
|
71
74
|
};
|
|
72
|
-
|
|
73
|
-
Entry = class Entry2 {
|
|
75
|
+
class Entry {
|
|
74
76
|
async renderToHtml(context) {
|
|
75
77
|
var _ssrContext_redirection, _ssrContext_redirection1, _ssrContext_redirection2;
|
|
76
78
|
const ssrContext = context.ssrContext;
|
|
@@ -92,13 +94,13 @@ Entry = class Entry2 {
|
|
|
92
94
|
loaderData: routerContext.loaderData,
|
|
93
95
|
errors: (0, import_utils.serializeErrors)(routerContext.errors)
|
|
94
96
|
} : void 0;
|
|
95
|
-
const templateData = buildTemplateData(ssrContext, prefetchData, this.result.renderLevel, this.tracker);
|
|
97
|
+
const templateData = buildTemplateData(ssrContext, prefetchData, this.result.renderLevel, this.tracker, this.pluginConfig);
|
|
96
98
|
const ssrDataScripts = this.getSSRDataScript(templateData, routerData);
|
|
97
99
|
const html = (0, import_buildHtml.buildHtml)(this.template, [
|
|
98
100
|
(0, import_buildHtml.createReplaceChunkCss)(this.result.chunksMap.css),
|
|
99
101
|
(0, import_buildHtml.createReplaceChunkJs)(this.result.chunksMap.js),
|
|
100
|
-
(0, import_buildHtml.createReplaceHtml)(this.result.html || ""),
|
|
101
102
|
(0, import_buildHtml.createReplaceSSRDataScript)(ssrDataScripts),
|
|
103
|
+
(0, import_buildHtml.createReplaceHtml)(this.result.html || ""),
|
|
102
104
|
...this.htmlModifiers
|
|
103
105
|
]);
|
|
104
106
|
const helmetData = import_react_helmet.default.renderStatic();
|
|
@@ -147,12 +149,12 @@ Entry = class Entry2 {
|
|
|
147
149
|
const attrsStr = (0, import_utils2.attributesToString)({
|
|
148
150
|
nonce: this.nonce
|
|
149
151
|
});
|
|
150
|
-
let ssrDataScripts = useInlineScript ? `<script${attrsStr}>window._SSR_DATA = ${ssrData}</script>` : `<script type="application/json" id="${
|
|
152
|
+
let ssrDataScripts = useInlineScript ? `<script${attrsStr}>window._SSR_DATA = ${ssrData}</script>` : `<script type="application/json" id="${import_constants.SSR_DATA_JSON_ID}">${ssrData}</script>`;
|
|
151
153
|
if (routerData) {
|
|
152
154
|
const serializedRouterData = (0, import_node.serializeJson)(routerData);
|
|
153
155
|
ssrDataScripts += useInlineScript ? `
|
|
154
156
|
<script${attrsStr}>window._ROUTER_DATA = ${serializedRouterData}</script>` : `
|
|
155
|
-
<script type="application/json" id="${
|
|
157
|
+
<script type="application/json" id="${import_constants.ROUTER_DATA_JSON_ID}">${serializedRouterData}</script>`;
|
|
156
158
|
}
|
|
157
159
|
return ssrDataScripts;
|
|
158
160
|
}
|
|
@@ -187,4 +189,4 @@ Entry = class Entry2 {
|
|
|
187
189
|
}
|
|
188
190
|
};
|
|
189
191
|
}
|
|
190
|
-
}
|
|
192
|
+
}
|
|
@@ -32,7 +32,6 @@ __export(renderToString_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(renderToString_exports);
|
|
34
34
|
var import_node = require("@modern-js/runtime-utils/node");
|
|
35
|
-
var import_prerender = require("../../react/prerender");
|
|
36
35
|
var import_entry = __toESM(require("./entry"));
|
|
37
36
|
const render = ({ App, context, config }) => {
|
|
38
37
|
const ssrContext = context.ssrContext;
|
|
@@ -44,10 +43,6 @@ const render = ({ App, context, config }) => {
|
|
|
44
43
|
});
|
|
45
44
|
entry.metrics.emitCounter("app.visit.count", 1);
|
|
46
45
|
const html = await entry.renderToHtml(context);
|
|
47
|
-
const cacheConfig = import_prerender.PreRender.config();
|
|
48
|
-
if (cacheConfig) {
|
|
49
|
-
context.ssrContext.cacheConfig = cacheConfig;
|
|
50
|
-
}
|
|
51
46
|
return html;
|
|
52
47
|
});
|
|
53
48
|
};
|
|
@@ -18,10 +18,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var types_exports = {};
|
|
20
20
|
__export(types_exports, {
|
|
21
|
-
RenderLevel: () =>
|
|
21
|
+
RenderLevel: () => RenderLevel
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(types_exports);
|
|
24
|
-
var
|
|
24
|
+
var RenderLevel;
|
|
25
|
+
(function(RenderLevel2) {
|
|
26
|
+
RenderLevel2[RenderLevel2["CLIENT_RENDER"] = 0] = "CLIENT_RENDER";
|
|
27
|
+
RenderLevel2[RenderLevel2["SERVER_PREFETCH"] = 1] = "SERVER_PREFETCH";
|
|
28
|
+
RenderLevel2[RenderLevel2["SERVER_RENDER"] = 2] = "SERVER_RENDER";
|
|
29
|
+
})(RenderLevel || (RenderLevel = {}));
|
|
25
30
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
31
|
0 && (module.exports = {
|
|
27
32
|
RenderLevel
|
|
@@ -18,24 +18,20 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var utils_exports = {};
|
|
20
20
|
__export(utils_exports, {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
SSR_DATA_JSON_ID: () => SSR_DATA_JSON_ID,
|
|
24
|
-
attributesToString: () => attributesToString
|
|
21
|
+
attributesToString: () => attributesToString,
|
|
22
|
+
safeReplace: () => safeReplace
|
|
25
23
|
});
|
|
26
24
|
module.exports = __toCommonJS(utils_exports);
|
|
27
|
-
const CSS_CHUNKS_PLACEHOLDER = "<!--<?- chunksMap.css ?>-->";
|
|
28
|
-
const SSR_DATA_JSON_ID = "__MODERN_SSR_DATA__";
|
|
29
|
-
const ROUTER_DATA_JSON_ID = "__MODERN_ROUTER_DATA__";
|
|
30
25
|
function attributesToString(attributes) {
|
|
31
26
|
return Object.entries(attributes).reduce((str, [key, value]) => {
|
|
32
27
|
return value === void 0 ? str : `${str} ${key}="${value}"`;
|
|
33
28
|
}, "");
|
|
34
29
|
}
|
|
30
|
+
function safeReplace(source, searchValue, replaceValue) {
|
|
31
|
+
return source.replace(searchValue, () => replaceValue);
|
|
32
|
+
}
|
|
35
33
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
34
|
0 && (module.exports = {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
SSR_DATA_JSON_ID,
|
|
40
|
-
attributesToString
|
|
35
|
+
attributesToString,
|
|
36
|
+
safeReplace
|
|
41
37
|
});
|
package/dist/esm/cli/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
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
|
-
import path from "path";
|
|
4
3
|
import { isReact18, cleanRequireCache } from "@modern-js/utils";
|
|
5
4
|
import { statePlugin } from "../state/cli";
|
|
6
5
|
import { ssrPlugin } from "../ssr/cli";
|
|
@@ -26,8 +25,8 @@ var runtimePlugin = function() {
|
|
|
26
25
|
setup: function(api) {
|
|
27
26
|
return {
|
|
28
27
|
config: function config() {
|
|
29
|
-
var
|
|
30
|
-
process.env.IS_REACT18 = isReact18(
|
|
28
|
+
var appDir = api.useAppContext().appDirectory;
|
|
29
|
+
process.env.IS_REACT18 = isReact18(appDir).toString();
|
|
31
30
|
return {
|
|
32
31
|
runtime: {},
|
|
33
32
|
runtimeByEntries: {},
|
|
@@ -94,11 +94,11 @@ var ssrPlugin = function() {
|
|
|
94
94
|
},
|
|
95
95
|
tools: {
|
|
96
96
|
bundlerChain: function bundlerChain(chain, param) {
|
|
97
|
-
var isServer = param.isServer, isServiceWorker = param.isServiceWorker
|
|
97
|
+
var isServer = param.isServer, isServiceWorker = param.isServiceWorker;
|
|
98
98
|
var userConfig = api.useResolvedConfigContext();
|
|
99
99
|
if (isUseSSRBundle(userConfig) && !isServer && !isServiceWorker && checkUseStringSSR(userConfig)) {
|
|
100
100
|
var LoadableBundlerPlugin = require("./loadable-bundler-plugin.js");
|
|
101
|
-
chain.plugin(
|
|
101
|
+
chain.plugin("loadable").use(LoadableBundlerPlugin, [
|
|
102
102
|
{
|
|
103
103
|
filename: LOADABLE_STATS_FILE
|
|
104
104
|
}
|
|
@@ -146,7 +146,7 @@ var ssrPlugin = function() {
|
|
|
146
146
|
modifyEntryRuntimePlugins: function modifyEntryRuntimePlugins(param) {
|
|
147
147
|
var entrypoint = param.entrypoint, plugins = param.plugins, bundlerConfigs = param.bundlerConfigs;
|
|
148
148
|
if (ssrConfigMap.get(entrypoint.entryName)) {
|
|
149
|
-
var _bundlerConfigs_find_output, _bundlerConfigs_find, _config_server;
|
|
149
|
+
var _bundlerConfigs_find_output, _bundlerConfigs_find, _config_server, _config_server1;
|
|
150
150
|
var chunkLoadingGlobal = bundlerConfigs === null || bundlerConfigs === void 0 ? void 0 : (_bundlerConfigs_find = bundlerConfigs.find(function(config2) {
|
|
151
151
|
return config2.name === "client";
|
|
152
152
|
})) === 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;
|
|
@@ -154,6 +154,7 @@ var ssrPlugin = function() {
|
|
|
154
154
|
var _config_output = config.output, enableInlineScripts = _config_output.enableInlineScripts, enableInlineStyles = _config_output.enableInlineStyles;
|
|
155
155
|
var _config_html = config.html, crossorigin = _config_html.crossorigin, scriptLoading = _config_html.scriptLoading;
|
|
156
156
|
var disablePrerender = typeof ((_config_server = config.server) === null || _config_server === void 0 ? void 0 : _config_server.ssr) === "object" ? Boolean(config.server.ssr.disablePrerender) : false;
|
|
157
|
+
var unsafeHeaders = typeof ((_config_server1 = config.server) === null || _config_server1 === void 0 ? void 0 : _config_server1.ssr) === "object" ? config.server.ssr.unsafeHeaders : void 0;
|
|
157
158
|
plugins.push({
|
|
158
159
|
name: PLUGIN_IDENTIFIER,
|
|
159
160
|
options: JSON.stringify(_object_spread_props(_object_spread({}, ssrConfigMap.get(entrypoint.entryName) || {}), {
|
|
@@ -162,7 +163,8 @@ var ssrPlugin = function() {
|
|
|
162
163
|
chunkLoadingGlobal,
|
|
163
164
|
disablePrerender,
|
|
164
165
|
enableInlineScripts: typeof enableInlineScripts === "function" ? void 0 : enableInlineScripts,
|
|
165
|
-
enableInlineStyles: typeof enableInlineStyles === "function" ? void 0 : enableInlineStyles
|
|
166
|
+
enableInlineStyles: typeof enableInlineStyles === "function" ? void 0 : enableInlineStyles,
|
|
167
|
+
unsafeHeaders
|
|
166
168
|
}))
|
|
167
169
|
});
|
|
168
170
|
}
|
package/dist/esm/ssr/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { parsedJSONFromElement } from "@modern-js/runtime-utils/parsed";
|
|
|
9
9
|
import { RenderLevel } from "./serverRender/types";
|
|
10
10
|
import { WithCallback } from "./react/withCallback";
|
|
11
11
|
import { formatClient, mockResponse, isReact18 } from "./utils";
|
|
12
|
-
import { ROUTER_DATA_JSON_ID, SSR_DATA_JSON_ID } from "./serverRender/
|
|
12
|
+
import { ROUTER_DATA_JSON_ID, SSR_DATA_JSON_ID } from "./serverRender/constants";
|
|
13
13
|
var ssr = function(config) {
|
|
14
14
|
return {
|
|
15
15
|
name: "@modern-js/plugin-ssr",
|
|
@@ -22,7 +22,7 @@ var ssr = function(config) {
|
|
|
22
22
|
return {
|
|
23
23
|
client: function() {
|
|
24
24
|
var _ref = _async_to_generator(function(param) {
|
|
25
|
-
var App, context, ModernRender, ModernHydrate, _window__SSR_DATA, _window, hydrateContext, callback, renderLevel;
|
|
25
|
+
var App, context, ModernRender, ModernHydrate, _window__SSR_DATA, _window, hydrateContext, ssrContext, _ssrContext_request, initialPathname, currentPathname, errorMsg, callback, renderLevel;
|
|
26
26
|
function stringSSRHydrate() {
|
|
27
27
|
if (renderLevel === RenderLevel.CLIENT_RENDER || renderLevel === RenderLevel.SERVER_PREFETCH) {
|
|
28
28
|
ModernRender(/* @__PURE__ */ _jsx(App, {
|
|
@@ -85,6 +85,14 @@ var ssr = function(config) {
|
|
|
85
85
|
},
|
|
86
86
|
_hydration: true
|
|
87
87
|
});
|
|
88
|
+
ssrContext = hydrateContext.ssrContext;
|
|
89
|
+
_ssrContext_request = ssrContext.request, initialPathname = _ssrContext_request.pathname;
|
|
90
|
+
currentPathname = window.location.pathname;
|
|
91
|
+
if (initialPathname !== currentPathname) {
|
|
92
|
+
errorMsg = "The initial URL ".concat(initialPathname, " and the URL ").concat(currentPathname, " to be hydrated do not match, reload.");
|
|
93
|
+
console.error(errorMsg);
|
|
94
|
+
window.location.reload();
|
|
95
|
+
}
|
|
88
96
|
callback = function() {
|
|
89
97
|
delete hydrateContext._hydration;
|
|
90
98
|
};
|
|
@@ -76,6 +76,7 @@ function factory(Component) {
|
|
|
76
76
|
if (!validate) {
|
|
77
77
|
throw new Error("invalid props, check usage");
|
|
78
78
|
}
|
|
79
|
+
console.error("[Warn] PreRender has been deprecated, please use SSR Cache instead. reference to docs: https://modernjs.dev/guides/advanced-features/ssr.html");
|
|
79
80
|
return createElement(Component, _object_spread({}, newProps));
|
|
80
81
|
}
|
|
81
82
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
var HTML_PLACEHOLDER = "<!--<?- html ?>-->";
|
|
2
|
+
var SSR_DATA_PLACEHOLDER = "<!--<?- SSRDataScript ?>-->";
|
|
3
|
+
var CHUNK_JS_PLACEHOLDER = "<!--<?- chunksMap.js ?>-->";
|
|
4
|
+
var CHUNK_CSS_PLACEHOLDER = "<!--<?- chunksMap.css ?>-->";
|
|
5
|
+
var SSR_DATA_JSON_ID = "__MODERN_SSR_DATA__";
|
|
6
|
+
var ROUTER_DATA_JSON_ID = "__MODERN_ROUTER_DATA__";
|
|
7
|
+
export {
|
|
8
|
+
CHUNK_CSS_PLACEHOLDER,
|
|
9
|
+
CHUNK_JS_PLACEHOLDER,
|
|
10
|
+
HTML_PLACEHOLDER,
|
|
11
|
+
ROUTER_DATA_JSON_ID,
|
|
12
|
+
SSR_DATA_JSON_ID,
|
|
13
|
+
SSR_DATA_PLACEHOLDER
|
|
14
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EOL } from "os";
|
|
2
|
+
import { safeReplace } from "./utils";
|
|
2
3
|
var RE_HTML_ATTR = /<html[^>]*>/;
|
|
3
4
|
var RE_BODY_ATTR = /<body[^>]*>/;
|
|
4
5
|
var RE_LAST_IN_HEAD = /<\/head>/;
|
|
@@ -8,11 +9,11 @@ function helmet(content, helmetData) {
|
|
|
8
9
|
var result = content;
|
|
9
10
|
var bodyAttributes = helmetData.bodyAttributes.toString();
|
|
10
11
|
if (bodyAttributes) {
|
|
11
|
-
result = result
|
|
12
|
+
result = safeReplace(result, RE_BODY_ATTR, "<body ".concat(bodyAttributes, ">"));
|
|
12
13
|
}
|
|
13
14
|
var htmlAttributes = helmetData.htmlAttributes.toString();
|
|
14
15
|
if (htmlAttributes) {
|
|
15
|
-
result = result
|
|
16
|
+
result = safeReplace(result, RE_HTML_ATTR, "<html ".concat(htmlAttributes, ">"));
|
|
16
17
|
}
|
|
17
18
|
var base = helmetData.base.toString();
|
|
18
19
|
var link = helmetData.link.toString();
|
|
@@ -24,7 +25,7 @@ function helmet(content, helmetData) {
|
|
|
24
25
|
var existTitleTag = RE_TITLE.test(content);
|
|
25
26
|
var shouldReplaceTitle = existTitleTag && TEST_TITLE_CONTENT.test(title.trim());
|
|
26
27
|
if (shouldReplaceTitle) {
|
|
27
|
-
result = result
|
|
28
|
+
result = safeReplace(result, RE_TITLE, title);
|
|
28
29
|
}
|
|
29
30
|
var helmetStr = [
|
|
30
31
|
base,
|
|
@@ -37,7 +38,7 @@ function helmet(content, helmetData) {
|
|
|
37
38
|
].reduce(function(pre, cur) {
|
|
38
39
|
return pre + (cur.length > 0 ? " ".concat(cur).concat(EOL) : "");
|
|
39
40
|
}, "");
|
|
40
|
-
return result
|
|
41
|
+
return safeReplace(result, RE_LAST_IN_HEAD, "".concat(helmetStr, "</head>"));
|
|
41
42
|
}
|
|
42
43
|
export {
|
|
43
44
|
helmet as default
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
3
|
import { isReact18 } from "../utils";
|
|
4
|
-
import {
|
|
4
|
+
import { CHUNK_CSS_PLACEHOLDER } from "./constants";
|
|
5
5
|
function serverRender(options) {
|
|
6
6
|
return _serverRender.apply(this, arguments);
|
|
7
7
|
}
|
|
@@ -13,7 +13,7 @@ function _serverRender() {
|
|
|
13
13
|
case 0:
|
|
14
14
|
if ((_options_context_ssrContext = options.context.ssrContext) === null || _options_context_ssrContext === void 0 ? void 0 : _options_context_ssrContext.template) {
|
|
15
15
|
;
|
|
16
|
-
options.context.ssrContext.template = (_options_context_ssrContext1 = options.context.ssrContext) === null || _options_context_ssrContext1 === void 0 ? void 0 : _options_context_ssrContext1.template.replace("</head>", "".concat(
|
|
16
|
+
options.context.ssrContext.template = (_options_context_ssrContext1 = options.context.ssrContext) === null || _options_context_ssrContext1 === void 0 ? void 0 : _options_context_ssrContext1.template.replace("</head>", "".concat(CHUNK_CSS_PLACEHOLDER, "</head>"));
|
|
17
17
|
}
|
|
18
18
|
if (!(isReact18() && options.config.mode === "stream"))
|
|
19
19
|
return [
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
2
|
import { serializeJson } from "@modern-js/runtime-utils/node";
|
|
3
|
-
import { attributesToString } from "../utils";
|
|
3
|
+
import { attributesToString, safeReplace } from "../utils";
|
|
4
|
+
import { SSR_DATA_PLACEHOLDER } from "../constants";
|
|
4
5
|
import { buildTemplate } from "./buildTemplate.share";
|
|
5
6
|
function buildShellAfterTemplate(afterAppTemplate, options) {
|
|
6
7
|
var callbacks = [
|
|
@@ -9,7 +10,7 @@ function buildShellAfterTemplate(afterAppTemplate, options) {
|
|
|
9
10
|
return buildTemplate(afterAppTemplate, callbacks);
|
|
10
11
|
function injectSSRDataScript(template) {
|
|
11
12
|
var ssrDataScript = buildSSRDataScript();
|
|
12
|
-
return template
|
|
13
|
+
return safeReplace(template, SSR_DATA_PLACEHOLDER, ssrDataScript);
|
|
13
14
|
function buildSSRDataScript() {
|
|
14
15
|
var _options_context = options.context, ssrContext = _options_context.ssrContext, initialData = _options_context.initialData, __i18nData__ = _options_context.__i18nData__, renderLevel = options.renderLevel;
|
|
15
16
|
var request = ssrContext.request, enableUnsafeCtx = ssrContext.enableUnsafeCtx, nonce = ssrContext.nonce, tracker = ssrContext.tracker;
|