@bleedingdev/modern-js-runtime 3.9.0-ultramodern.2 → 3.9.0-ultramodern.21
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/code.js +3 -1
- package/dist/cjs/cli/ssr/index.js +2 -74
- package/dist/cjs/cli/ssr/loadable-bundler-plugin.js +2 -0
- package/dist/cjs/cli/template.server.js +1 -2
- package/dist/cjs/core/browser/hydrate.js +9 -10
- package/dist/cjs/core/browser/index.js +4 -5
- package/dist/cjs/core/context/index.js +12 -45
- package/dist/cjs/core/context/public.js +4 -7
- package/dist/cjs/core/context/runtime.js +10 -4
- package/dist/cjs/core/index.js +3 -3
- package/dist/cjs/core/plugin/index.js +2 -2
- package/dist/cjs/core/react/index.js +3 -3
- package/dist/cjs/core/react/wrapper.js +23 -67
- package/dist/cjs/core/server/helmet.js +5 -4
- package/dist/cjs/core/server/requestHandler.js +6 -7
- package/dist/cjs/core/server/requestResponse.js +4 -4
- package/dist/cjs/core/server/routerCleanup.js +2 -2
- package/dist/cjs/core/server/shared.js +171 -4
- package/dist/cjs/core/server/stream/afterTemplate.js +21 -16
- package/dist/cjs/core/server/stream/beforeTemplate.js +37 -28
- package/dist/cjs/core/server/stream/beforeTemplate.worker.js +30 -23
- package/dist/cjs/core/server/stream/createReadableStream.js +222 -125
- package/dist/cjs/core/server/stream/createReadableStream.worker.js +171 -90
- package/dist/cjs/core/server/stream/deferredScript.js +3 -3
- package/dist/cjs/core/server/stream/shared.js +6 -2
- package/dist/cjs/core/server/string/index.js +104 -66
- package/dist/cjs/core/server/string/loadable.js +38 -23
- package/dist/cjs/core/server/string/ssrData.js +5 -12
- package/dist/cjs/core/server/utils.js +1 -2
- package/dist/cjs/document/cli/index.js +14 -5
- package/dist/cjs/exports/head.js +7 -14
- package/dist/cjs/internal.js +2 -2
- package/dist/cjs/router/cli/code/nestedRoutes.js +1 -2
- package/dist/cjs/router/cli/code/templates.js +1 -1
- package/dist/cjs/router/cli/code/utils.js +2 -2
- package/dist/cjs/router/runtime/DeferredDataScripts.node.js +10 -9
- package/dist/cjs/router/runtime/PrefetchLink.js +69 -125
- package/dist/cjs/router/runtime/hooks.js +13 -2
- package/dist/cjs/router/runtime/internal.js +7 -45
- package/dist/cjs/router/runtime/plugin.js +19 -34
- package/dist/cjs/router/runtime/plugin.node.js +9 -37
- package/dist/cjs/router/runtime/redirect.js +1 -1
- package/dist/esm/cli/code.mjs +3 -1
- package/dist/esm/cli/ssr/index.mjs +3 -72
- package/dist/esm/cli/ssr/loadable-bundler-plugin.mjs +2 -0
- package/dist/esm/cli/template.server.mjs +1 -2
- package/dist/esm/core/browser/hydrate.mjs +10 -11
- package/dist/esm/core/browser/index.mjs +1 -2
- package/dist/esm/core/context/index.mjs +2 -5
- package/dist/esm/core/context/public.mjs +1 -5
- package/dist/esm/core/context/runtime.mjs +6 -3
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/core/plugin/index.mjs +1 -1
- package/dist/esm/core/react/index.mjs +1 -1
- package/dist/esm/core/react/wrapper.mjs +20 -67
- package/dist/esm/core/server/helmet.mjs +5 -4
- package/dist/esm/core/server/requestHandler.mjs +1 -2
- package/dist/esm/core/server/requestResponse.mjs +3 -3
- package/dist/esm/core/server/routerCleanup.mjs +1 -1
- package/dist/esm/core/server/shared.mjs +153 -1
- package/dist/esm/core/server/stream/afterTemplate.mjs +23 -18
- package/dist/esm/core/server/stream/beforeTemplate.mjs +40 -31
- package/dist/esm/core/server/stream/beforeTemplate.worker.mjs +33 -26
- package/dist/esm/core/server/stream/createReadableStream.mjs +220 -123
- package/dist/esm/core/server/stream/createReadableStream.worker.mjs +161 -90
- package/dist/esm/core/server/stream/deferredScript.mjs +3 -3
- package/dist/esm/core/server/stream/shared.mjs +4 -3
- package/dist/esm/core/server/string/index.mjs +106 -68
- package/dist/esm/core/server/string/loadable.mjs +38 -23
- package/dist/esm/core/server/string/ssrData.mjs +5 -12
- package/dist/esm/core/server/utils.mjs +1 -2
- package/dist/esm/document/cli/index.mjs +12 -6
- package/dist/esm/exports/head.mjs +7 -14
- package/dist/esm/internal.mjs +1 -1
- package/dist/esm/router/cli/code/nestedRoutes.mjs +1 -2
- package/dist/esm/router/cli/code/templates.mjs +1 -1
- package/dist/esm/router/cli/code/utils.mjs +2 -2
- package/dist/esm/router/runtime/DeferredDataScripts.node.mjs +10 -9
- package/dist/esm/router/runtime/PrefetchLink.mjs +68 -124
- package/dist/esm/router/runtime/hooks.mjs +9 -1
- package/dist/esm/router/runtime/internal.mjs +2 -33
- package/dist/esm/router/runtime/plugin.mjs +10 -25
- package/dist/esm/router/runtime/plugin.node.mjs +3 -31
- package/dist/esm/router/runtime/redirect.mjs +1 -1
- package/dist/esm-node/cli/code.mjs +3 -1
- package/dist/esm-node/cli/ssr/index.mjs +3 -72
- package/dist/esm-node/cli/ssr/loadable-bundler-plugin.mjs +2 -0
- package/dist/esm-node/cli/template.server.mjs +1 -2
- package/dist/esm-node/core/browser/hydrate.mjs +10 -11
- package/dist/esm-node/core/browser/index.mjs +1 -2
- package/dist/esm-node/core/context/index.mjs +2 -5
- package/dist/esm-node/core/context/public.mjs +1 -5
- package/dist/esm-node/core/context/runtime.mjs +6 -3
- package/dist/esm-node/core/index.mjs +1 -1
- package/dist/esm-node/core/plugin/index.mjs +1 -1
- package/dist/esm-node/core/react/index.mjs +1 -1
- package/dist/esm-node/core/react/wrapper.mjs +20 -67
- package/dist/esm-node/core/server/helmet.mjs +5 -4
- package/dist/esm-node/core/server/requestHandler.mjs +1 -2
- package/dist/esm-node/core/server/requestResponse.mjs +3 -3
- package/dist/esm-node/core/server/routerCleanup.mjs +1 -1
- package/dist/esm-node/core/server/shared.mjs +153 -1
- package/dist/esm-node/core/server/stream/afterTemplate.mjs +23 -18
- package/dist/esm-node/core/server/stream/beforeTemplate.mjs +40 -31
- package/dist/esm-node/core/server/stream/beforeTemplate.worker.mjs +33 -26
- package/dist/esm-node/core/server/stream/createReadableStream.mjs +220 -123
- package/dist/esm-node/core/server/stream/createReadableStream.worker.mjs +161 -90
- package/dist/esm-node/core/server/stream/deferredScript.mjs +3 -3
- package/dist/esm-node/core/server/stream/shared.mjs +4 -3
- package/dist/esm-node/core/server/string/index.mjs +106 -68
- package/dist/esm-node/core/server/string/loadable.mjs +38 -23
- package/dist/esm-node/core/server/string/ssrData.mjs +5 -12
- package/dist/esm-node/core/server/utils.mjs +1 -2
- package/dist/esm-node/document/cli/index.mjs +12 -6
- package/dist/esm-node/exports/head.mjs +7 -14
- package/dist/esm-node/internal.mjs +1 -1
- package/dist/esm-node/router/cli/code/nestedRoutes.mjs +1 -2
- package/dist/esm-node/router/cli/code/templates.mjs +1 -1
- package/dist/esm-node/router/cli/code/utils.mjs +2 -2
- package/dist/esm-node/router/runtime/DeferredDataScripts.node.mjs +10 -9
- package/dist/esm-node/router/runtime/PrefetchLink.mjs +68 -124
- package/dist/esm-node/router/runtime/hooks.mjs +9 -1
- package/dist/esm-node/router/runtime/internal.mjs +2 -33
- package/dist/esm-node/router/runtime/plugin.mjs +10 -25
- package/dist/esm-node/router/runtime/plugin.node.mjs +3 -31
- package/dist/esm-node/router/runtime/redirect.mjs +1 -1
- package/dist/types/cli/ssr/index.d.ts +0 -3
- package/dist/types/core/context/index.d.ts +4 -6
- package/dist/types/core/context/public.d.ts +1 -23
- package/dist/types/core/context/runtime.d.ts +26 -2
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/core/react/wrapper.d.ts +7 -1
- package/dist/types/core/server/helmet.d.ts +4 -5
- package/dist/types/core/server/requestHandler.d.ts +3 -3
- package/dist/types/core/server/requestResponse.d.ts +1 -1
- package/dist/types/core/server/routerCleanup.d.ts +1 -1
- package/dist/types/core/server/shared.d.ts +24 -1
- package/dist/types/core/server/stream/afterTemplate.d.ts +2 -1
- package/dist/types/core/server/stream/beforeTemplate.d.ts +4 -1
- package/dist/types/core/server/stream/beforeTemplate.worker.d.ts +4 -1
- package/dist/types/core/server/stream/shared.d.ts +16 -2
- package/dist/types/core/server/string/loadable.d.ts +6 -3
- package/dist/types/core/server/string/ssrData.d.ts +2 -1
- package/dist/types/core/server/string/types.d.ts +1 -5
- package/dist/types/core/server/tracer.d.ts +1 -1
- package/dist/types/core/server/utils.d.ts +1 -1
- package/dist/types/core/types.d.ts +1 -2
- package/dist/types/document/cli/index.d.ts +1 -0
- package/dist/types/exports/head.d.ts +2 -2
- package/dist/types/internal.d.ts +1 -1
- package/dist/types/router/runtime/PrefetchLink.d.ts +27 -2
- package/dist/types/router/runtime/hooks.d.ts +19 -2
- package/dist/types/router/runtime/internal.d.ts +4 -21
- package/dist/types/router/runtime/types.d.ts +2 -43
- package/package.json +18 -46
- package/rslib.config.mts +3 -0
- package/rstest.config.mts +28 -2
- package/dist/cjs/boundary-debugger/index.js +0 -317
- package/dist/cjs/core/context/extensions.js +0 -74
- package/dist/cjs/core/context/helmetContext.js +0 -54
- package/dist/cjs/core/server/federatedCss.js +0 -58
- package/dist/cjs/core/server/scriptOrder.js +0 -140
- package/dist/cjs/module-federation/consume-surface.js +0 -199
- package/dist/cjs/module-federation/distributed-ssr.js +0 -135
- package/dist/cjs/module-federation/index.js +0 -316
- package/dist/cjs/module-federation/last-known-good.js +0 -157
- package/dist/cjs/module-federation/manifest-recovery-runtime-plugin.js +0 -129
- package/dist/cjs/module-federation/surface-resolution-types.js +0 -61
- package/dist/cjs/router/runtime/lifecycle.js +0 -167
- package/dist/cjs/router/runtime/provider.js +0 -153
- package/dist/cjs/rsc/server.worker.js +0 -62
- package/dist/esm/boundary-debugger/index.mjs +0 -277
- package/dist/esm/core/context/extensions.mjs +0 -33
- package/dist/esm/core/context/helmetContext.mjs +0 -13
- package/dist/esm/core/server/federatedCss.mjs +0 -20
- package/dist/esm/core/server/scriptOrder.mjs +0 -90
- package/dist/esm/module-federation/consume-surface.mjs +0 -158
- package/dist/esm/module-federation/distributed-ssr.mjs +0 -82
- package/dist/esm/module-federation/index.mjs +0 -115
- package/dist/esm/module-federation/last-known-good.mjs +0 -113
- package/dist/esm/module-federation/manifest-recovery-runtime-plugin.mjs +0 -89
- package/dist/esm/module-federation/surface-resolution-types.mjs +0 -8
- package/dist/esm/router/runtime/lifecycle.mjs +0 -105
- package/dist/esm/router/runtime/provider.mjs +0 -100
- package/dist/esm/rsc/server.worker.mjs +0 -1
- package/dist/esm-node/boundary-debugger/index.mjs +0 -278
- package/dist/esm-node/core/context/extensions.mjs +0 -34
- package/dist/esm-node/core/context/helmetContext.mjs +0 -14
- package/dist/esm-node/core/server/federatedCss.mjs +0 -21
- package/dist/esm-node/core/server/scriptOrder.mjs +0 -91
- package/dist/esm-node/module-federation/consume-surface.mjs +0 -159
- package/dist/esm-node/module-federation/distributed-ssr.mjs +0 -83
- package/dist/esm-node/module-federation/index.mjs +0 -116
- package/dist/esm-node/module-federation/last-known-good.mjs +0 -114
- package/dist/esm-node/module-federation/manifest-recovery-runtime-plugin.mjs +0 -90
- package/dist/esm-node/module-federation/surface-resolution-types.mjs +0 -9
- package/dist/esm-node/router/runtime/lifecycle.mjs +0 -106
- package/dist/esm-node/router/runtime/provider.mjs +0 -101
- package/dist/esm-node/rsc/server.worker.mjs +0 -2
- package/dist/types/boundary-debugger/index.d.ts +0 -28
- package/dist/types/core/context/extensions.d.ts +0 -35
- package/dist/types/core/context/helmetContext.d.ts +0 -10
- package/dist/types/core/server/federatedCss.d.ts +0 -5
- package/dist/types/core/server/scriptOrder.d.ts +0 -25
- package/dist/types/module-federation/consume-surface.d.ts +0 -104
- package/dist/types/module-federation/distributed-ssr.d.ts +0 -61
- package/dist/types/module-federation/index.d.ts +0 -71
- package/dist/types/module-federation/last-known-good.d.ts +0 -52
- package/dist/types/module-federation/manifest-recovery-runtime-plugin.d.ts +0 -25
- package/dist/types/module-federation/surface-resolution-types.d.ts +0 -23
- package/dist/types/router/runtime/lifecycle.d.ts +0 -27
- package/dist/types/router/runtime/provider.d.ts +0 -78
- package/dist/types/rsc/server.worker.d.ts +0 -1
|
@@ -20,13 +20,13 @@ function isDeferredDataLike(v) {
|
|
|
20
20
|
return hasPending && hasData;
|
|
21
21
|
}
|
|
22
22
|
function isPromiseLike(value) {
|
|
23
|
-
return
|
|
23
|
+
return Boolean(value) && 'function' == typeof value.then;
|
|
24
24
|
}
|
|
25
25
|
function toErrorInfo(error) {
|
|
26
26
|
if (shouldRedactServerError()) return {
|
|
27
27
|
message: 'Unexpected Server Error'
|
|
28
28
|
};
|
|
29
|
-
if (error && 'object' == typeof error) {
|
|
29
|
+
if (null !== error && 'object' == typeof error) {
|
|
30
30
|
const maybeMsg = error.message;
|
|
31
31
|
const maybeStack = error.stack;
|
|
32
32
|
return {
|
|
@@ -41,7 +41,7 @@ function toErrorInfo(error) {
|
|
|
41
41
|
function buildDeferredDataScript(nonce, args) {
|
|
42
42
|
const payload = JSON.stringify(args);
|
|
43
43
|
const escaped = escapeAttr(payload);
|
|
44
|
-
const nonceAttr = nonce ? ` nonce="${nonce}"` : '';
|
|
44
|
+
const nonceAttr = void 0 !== nonce && '' !== nonce ? ` nonce="${nonce}"` : '';
|
|
45
45
|
return `<script async${nonceAttr} data-fn-name="r" data-script-src="modern-run-router-data-fn" data-fn-args='${escaped}' suppressHydrationWarning>${runRouterDataFnStr}</script>`;
|
|
46
46
|
}
|
|
47
47
|
function enqueueFromEntries(entries, nonce, emit) {
|
|
@@ -10,6 +10,7 @@ var shared_ShellChunkStatus = /*#__PURE__*/ function(ShellChunkStatus) {
|
|
|
10
10
|
ShellChunkStatus[ShellChunkStatus["FINISH"] = 1] = "FINISH";
|
|
11
11
|
return ShellChunkStatus;
|
|
12
12
|
}({});
|
|
13
|
+
const SHELL_PROGRESSIVE_CHUNK_SIZE = Number.MAX_SAFE_INTEGER;
|
|
13
14
|
const SHOULD_STREAM_ALL_HEADER = 'x-should-stream-all';
|
|
14
15
|
function parseShouldStreamAllFlag(value) {
|
|
15
16
|
if (!value) return;
|
|
@@ -63,7 +64,7 @@ function createRenderStreaming(createReadableStreamPromise) {
|
|
|
63
64
|
const end = time();
|
|
64
65
|
const { runtimeContext, config, resource } = options;
|
|
65
66
|
const { onError, onTiming } = options;
|
|
66
|
-
const { htmlTemplate, entryName
|
|
67
|
+
const { htmlTemplate, entryName } = resource;
|
|
67
68
|
const ssrConfig = getSSRConfigByEntry(entryName, config.ssr, config.ssrByEntries);
|
|
68
69
|
const StreamServerRootWrapper = ({ children })=>/*#__PURE__*/ jsxs(Fragment, {
|
|
69
70
|
children: [
|
|
@@ -83,7 +84,7 @@ function createRenderStreaming(createReadableStreamPromise) {
|
|
|
83
84
|
runtimeContext,
|
|
84
85
|
ssrConfig,
|
|
85
86
|
entryName,
|
|
86
|
-
|
|
87
|
+
resource,
|
|
87
88
|
rscClientManifest: options.rscClientManifest,
|
|
88
89
|
rscSSRManifest: options.rscSSRManifest,
|
|
89
90
|
rscServerManifest: options.rscServerManifest,
|
|
@@ -107,4 +108,4 @@ function createRenderStreaming(createReadableStreamPromise) {
|
|
|
107
108
|
return stream;
|
|
108
109
|
};
|
|
109
110
|
}
|
|
110
|
-
export { createRenderStreaming, encodeForWebStream, getReadableStreamFromString, resolveStreamingMode, shared_ShellChunkStatus as ShellChunkStatus };
|
|
111
|
+
export { SHELL_PROGRESSIVE_CHUNK_SIZE, createRenderStreaming, encodeForWebStream, getReadableStreamFromString, resolveStreamingMode, shared_ShellChunkStatus as ShellChunkStatus };
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
+
import { getGlobalEnableRsc, getGlobalInternalRuntimeContext } from "@modern-js/runtime/context";
|
|
1
2
|
import { time } from "@modern-js/runtime-utils/time";
|
|
2
3
|
import { SSR_HYDRATION_ID_PREFIX } from "@modern-js/utils/universal/constants";
|
|
3
4
|
import server from "react-dom/server";
|
|
4
5
|
import { RenderLevel } from "../../constants.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import { wrapRuntimeContextProvider } from "../../react/wrapper.mjs";
|
|
7
|
-
import { CHUNK_CSS_PLACEHOLDER, HTML_PLACEHOLDER, SSR_DATA_PLACEHOLDER } from "../constants.mjs";
|
|
6
|
+
import { getMonitors } from "../../context/monitors/index.mjs";
|
|
7
|
+
import { wrapRuntimeComponentResolver, wrapRuntimeContextProvider } from "../../react/wrapper.mjs";
|
|
8
|
+
import { CHUNK_CSS_PLACEHOLDER, CHUNK_JS_PLACEHOLDER, HTML_PLACEHOLDER, SSR_DATA_PLACEHOLDER } from "../constants.mjs";
|
|
8
9
|
import { createReplaceHelemt, getHelmetData } from "../helmet.mjs";
|
|
9
|
-
import {
|
|
10
|
-
import { buildHtml } from "../shared.mjs";
|
|
10
|
+
import { buildHtml, createSSRRenderLifecycle, replaceSSRTemplateChunk } from "../shared.mjs";
|
|
11
11
|
import { SSRErrors, SSRTimings } from "../tracer.mjs";
|
|
12
12
|
import { getSSRConfigByEntry, safeReplace } from "../utils.mjs";
|
|
13
13
|
import { LoadableCollector } from "./loadable.mjs";
|
|
14
14
|
import { SSRDataCollector } from "./ssrData.mjs";
|
|
15
|
-
import * as __rspack_external__modern_js_runtime_extensions_ce611631 from "@modern-js/runtime-extensions";
|
|
16
15
|
const renderString = async (request, serverRoot, options)=>{
|
|
17
16
|
const { resource, runtimeContext, config, onError, onTiming } = options;
|
|
18
17
|
const tracer = {
|
|
@@ -20,7 +19,7 @@ const renderString = async (request, serverRoot, options)=>{
|
|
|
20
19
|
onTiming
|
|
21
20
|
};
|
|
22
21
|
const routerContext = runtimeContext.routerContext;
|
|
23
|
-
const { htmlTemplate, entryName, loadableStats, routeManifest
|
|
22
|
+
const { htmlTemplate, entryName, loadableStats, routeManifest } = resource;
|
|
24
23
|
const ssrConfig = getSSRConfigByEntry(entryName, config.ssr, config.ssrByEntries);
|
|
25
24
|
const chunkSet = {
|
|
26
25
|
renderLevel: RenderLevel.CLIENT_RENDER,
|
|
@@ -28,83 +27,122 @@ const renderString = async (request, serverRoot, options)=>{
|
|
|
28
27
|
jsChunk: '',
|
|
29
28
|
cssChunk: ''
|
|
30
29
|
};
|
|
31
|
-
const collectors = [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
30
|
+
const collectors = [];
|
|
31
|
+
const lifecycle = createSSRRenderLifecycle(collectors);
|
|
32
|
+
const loadableCollector = new LoadableCollector({
|
|
33
|
+
stats: loadableStats,
|
|
34
|
+
nonce: config.nonce,
|
|
35
|
+
routeManifest,
|
|
36
|
+
template: htmlTemplate,
|
|
37
|
+
entryName,
|
|
38
|
+
chunkSet,
|
|
39
|
+
config,
|
|
40
|
+
lifecycle
|
|
41
|
+
});
|
|
42
|
+
collectors.push(loadableCollector, new SSRDataCollector({
|
|
43
|
+
runtimeContext,
|
|
44
|
+
request,
|
|
45
|
+
ssrConfig,
|
|
46
|
+
ssrContext: runtimeContext.ssrContext,
|
|
47
|
+
chunkSet,
|
|
48
|
+
routerContext,
|
|
49
|
+
nonce: config.nonce,
|
|
50
|
+
useJsonScript: config.useJsonScript,
|
|
51
|
+
lifecycle
|
|
52
|
+
}));
|
|
54
53
|
const internalRuntimeContext = getGlobalInternalRuntimeContext();
|
|
55
54
|
const hooks = internalRuntimeContext.hooks;
|
|
56
55
|
const extraCollectors = hooks.extendStringSSRCollectors.call({
|
|
57
|
-
chunkSet
|
|
56
|
+
chunkSet,
|
|
57
|
+
render: {
|
|
58
|
+
runtimeContext,
|
|
59
|
+
request,
|
|
60
|
+
resource,
|
|
61
|
+
config,
|
|
62
|
+
platform: 'node',
|
|
63
|
+
mode: 'string',
|
|
64
|
+
monitors: getMonitors(),
|
|
65
|
+
isRsc: true === getGlobalEnableRsc()
|
|
66
|
+
}
|
|
58
67
|
});
|
|
59
68
|
for (const c of extraCollectors)if (c) collectors.unshift(c);
|
|
60
|
-
|
|
69
|
+
let rootElement = wrapRuntimeContextProvider(serverRoot, Object.assign(runtimeContext, {
|
|
61
70
|
ssr: true
|
|
62
71
|
}));
|
|
63
|
-
|
|
72
|
+
if (true === getGlobalEnableRsc() && false === runtimeContext.isBrowser) rootElement = wrapRuntimeComponentResolver(rootElement, hooks);
|
|
73
|
+
const html = await generateHtml(rootElement, htmlTemplate, chunkSet, collectors, runtimeContext.ssrContext?.htmlModifiers || [], tracer, request.signal, lifecycle, loadableCollector.stylesheetInfo);
|
|
64
74
|
return html;
|
|
65
75
|
};
|
|
66
|
-
async function generateHtml(App, htmlTemplate, chunkSet, collectors, htmlModifiers,
|
|
76
|
+
async function generateHtml(App, htmlTemplate, chunkSet, collectors, htmlModifiers, { onError, onTiming }, signal, lifecycle, stylesheetInfo) {
|
|
67
77
|
let html = '';
|
|
68
78
|
let helmetData;
|
|
69
|
-
const finalApp = collectors.reduce((pre, creator)=>creator.collect?.(pre) || pre, App);
|
|
70
|
-
__rspack_external__modern_js_runtime_extensions_ce611631.beginHeadRender(runtimeContext);
|
|
71
79
|
try {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
80
|
+
signal.throwIfAborted();
|
|
81
|
+
try {
|
|
82
|
+
const finalApp = collectors.reduce((pre, creator)=>creator.collect?.(pre) || pre, App);
|
|
83
|
+
lifecycle.beforeReact();
|
|
84
|
+
const end = time();
|
|
85
|
+
html = server.renderToString(finalApp, {
|
|
86
|
+
identifierPrefix: SSR_HYDRATION_ID_PREFIX
|
|
87
|
+
});
|
|
88
|
+
html = lifecycle.completedBody(html, 'complete');
|
|
89
|
+
chunkSet.renderLevel = RenderLevel.SERVER_RENDER;
|
|
90
|
+
helmetData = getHelmetData(collectors);
|
|
91
|
+
const cost = end();
|
|
92
|
+
onTiming(SSRTimings.RENDER_HTML, cost);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
lifecycle.finish({
|
|
95
|
+
status: 'fallback',
|
|
96
|
+
error
|
|
97
|
+
});
|
|
98
|
+
html = '';
|
|
99
|
+
chunkSet.renderLevel = RenderLevel.CLIENT_RENDER;
|
|
100
|
+
onError(error, SSRErrors.RENDER_HTML);
|
|
101
|
+
}
|
|
102
|
+
await Promise.all(collectors.map((component)=>component.effect()));
|
|
103
|
+
signal.throwIfAborted();
|
|
104
|
+
const { ssrScripts, cssChunk, jsChunk } = chunkSet;
|
|
105
|
+
const finalHtml = await buildHtml(htmlTemplate, [
|
|
106
|
+
createReplaceHtml(html),
|
|
107
|
+
(template)=>replaceSSRTemplateChunk({
|
|
108
|
+
name: "scripts",
|
|
109
|
+
template,
|
|
110
|
+
placeholder: CHUNK_JS_PLACEHOLDER,
|
|
111
|
+
content: jsChunk
|
|
112
|
+
}, lifecycle),
|
|
113
|
+
(template)=>replaceSSRTemplateChunk({
|
|
114
|
+
name: 'styles',
|
|
115
|
+
template,
|
|
116
|
+
placeholder: CHUNK_CSS_PLACEHOLDER,
|
|
117
|
+
content: cssChunk,
|
|
118
|
+
...stylesheetInfo
|
|
119
|
+
}, lifecycle),
|
|
120
|
+
(template)=>replaceSSRTemplateChunk({
|
|
121
|
+
name: 'data',
|
|
122
|
+
template,
|
|
123
|
+
placeholder: SSR_DATA_PLACEHOLDER,
|
|
124
|
+
content: ssrScripts
|
|
125
|
+
}, lifecycle),
|
|
126
|
+
createReplaceHelemt(helmetData),
|
|
127
|
+
...htmlModifiers
|
|
128
|
+
]);
|
|
129
|
+
signal.throwIfAborted();
|
|
130
|
+
lifecycle.finish({
|
|
131
|
+
status: 'complete'
|
|
132
|
+
});
|
|
133
|
+
return finalHtml;
|
|
134
|
+
} catch (error) {
|
|
135
|
+
lifecycle.finish(signal.aborted ? {
|
|
136
|
+
status: 'cancelled',
|
|
137
|
+
reason: signal.reason
|
|
138
|
+
} : {
|
|
139
|
+
status: 'error',
|
|
140
|
+
error
|
|
75
141
|
});
|
|
76
|
-
|
|
77
|
-
chunkSet.renderLevel = RenderLevel.SERVER_RENDER;
|
|
78
|
-
helmetData = getHelmetData(runtimeContext);
|
|
79
|
-
const cost = end();
|
|
80
|
-
onTiming(SSRTimings.RENDER_HTML, cost);
|
|
81
|
-
} catch (e) {
|
|
82
|
-
__rspack_external__modern_js_runtime_extensions_ce611631.abortHeadRender(runtimeContext);
|
|
83
|
-
chunkSet.renderLevel = RenderLevel.CLIENT_RENDER;
|
|
84
|
-
onError(e, SSRErrors.RENDER_HTML);
|
|
142
|
+
throw error;
|
|
85
143
|
}
|
|
86
|
-
await Promise.all(collectors.map((component)=>component.effect()));
|
|
87
|
-
const { ssrScripts, cssChunk, jsChunk } = chunkSet;
|
|
88
|
-
const finalHtml = await buildHtml(htmlTemplate, [
|
|
89
|
-
createReplaceHtml(html),
|
|
90
|
-
createReplaceChunkJs(jsChunk, entryName),
|
|
91
|
-
createReplaceChunkCss(cssChunk),
|
|
92
|
-
createReplaceSSRDataScript(ssrScripts, entryName),
|
|
93
|
-
createReplaceHelemt(helmetData),
|
|
94
|
-
...htmlModifiers
|
|
95
|
-
]);
|
|
96
|
-
return finalHtml;
|
|
97
144
|
}
|
|
98
145
|
function createReplaceHtml(html) {
|
|
99
146
|
return (template)=>safeReplace(template, HTML_PLACEHOLDER, html);
|
|
100
147
|
}
|
|
101
|
-
function createReplaceSSRDataScript(data, entryName) {
|
|
102
|
-
return (template)=>replaceChunkJsPlaceholder(template, data, entryName, SSR_DATA_PLACEHOLDER);
|
|
103
|
-
}
|
|
104
|
-
function createReplaceChunkJs(js, entryName) {
|
|
105
|
-
return (template)=>replaceChunkJsPlaceholder(template, js, entryName);
|
|
106
|
-
}
|
|
107
|
-
function createReplaceChunkCss(css) {
|
|
108
|
-
return (template)=>safeReplace(template, CHUNK_CSS_PLACEHOLDER, css);
|
|
109
|
-
}
|
|
110
148
|
export { renderString };
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { ChunkExtractor } from "@loadable/server";
|
|
2
|
-
import { createFederatedCssLinks } from "../federatedCss.mjs";
|
|
3
|
-
import { getMatchedRouteChunks, orderHydrationScriptChunks } from "../scriptOrder.mjs";
|
|
4
2
|
import { attributesToString, checkIsNode, hasStylesheetLink } from "../utils.mjs";
|
|
5
3
|
const extname = (uri)=>{
|
|
6
4
|
if ('string' != typeof uri || !uri.includes('.')) return '';
|
|
7
5
|
return `.${uri?.split('.').pop()}` || '';
|
|
8
6
|
};
|
|
9
7
|
const generateChunks = (chunks, ext)=>chunks.filter((chunk)=>Boolean(chunk.url)).filter((chunk)=>extname(chunk.url).slice(1) === ext);
|
|
10
|
-
const
|
|
8
|
+
const assetToChunk = (asset)=>({
|
|
11
9
|
chunk: asset,
|
|
12
10
|
filename: asset.replace(/^\//, ''),
|
|
13
11
|
linkType: 'preload',
|
|
@@ -18,8 +16,8 @@ const routeAssetToChunk = (asset)=>({
|
|
|
18
16
|
});
|
|
19
17
|
const checkIsInline = (chunk, enableInline)=>{
|
|
20
18
|
if ('production' !== process.env.NODE_ENV) return false;
|
|
21
|
-
if (enableInline instanceof RegExp) return enableInline.test(chunk.url);
|
|
22
|
-
return Boolean(enableInline);
|
|
19
|
+
else if (enableInline instanceof RegExp) return enableInline.test(chunk.url);
|
|
20
|
+
else return Boolean(enableInline);
|
|
23
21
|
};
|
|
24
22
|
const readAsset = async (chunk)=>{
|
|
25
23
|
const fs = await import("fs/promises");
|
|
@@ -53,16 +51,32 @@ class LoadableCollector {
|
|
|
53
51
|
]));
|
|
54
52
|
} catch (e) {}
|
|
55
53
|
const collectedChunks = extractor ? extractor.getChunkAssets(extractor.chunks) : [];
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
54
|
+
const groups = [
|
|
55
|
+
{
|
|
56
|
+
name: 'async-entry',
|
|
57
|
+
assets: asyncChunks
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: 'loadable',
|
|
61
|
+
assets: collectedChunks
|
|
62
|
+
}
|
|
63
|
+
];
|
|
64
|
+
const nativeChunks = [
|
|
65
|
+
...asyncChunks,
|
|
66
|
+
...collectedChunks
|
|
67
|
+
];
|
|
68
|
+
const prepare = (kind)=>options.lifecycle?.transformAssets(groups, {
|
|
69
|
+
kind,
|
|
70
|
+
source: 'loadable',
|
|
71
|
+
template: options.template,
|
|
72
|
+
createAsset: assetToChunk
|
|
73
|
+
}) ?? nativeChunks;
|
|
74
|
+
const scriptChunks = generateChunks([
|
|
75
|
+
...prepare("script")
|
|
76
|
+
], 'js');
|
|
77
|
+
const styleChunks = generateChunks([
|
|
78
|
+
...prepare('style')
|
|
79
|
+
], 'css');
|
|
66
80
|
if (extractor) {
|
|
67
81
|
this.emitLoadableScripts(extractor);
|
|
68
82
|
await this.emitScriptAssets(scriptChunks);
|
|
@@ -96,12 +110,12 @@ class LoadableCollector {
|
|
|
96
110
|
const scripts = await Promise.all(chunks.filter((chunk)=>!existedScript.includes(chunk.url) && !this.existsAssets?.includes(chunk.path)).map(async (chunk)=>{
|
|
97
111
|
const script = `<script${attributes} src="${chunk.url}"></script>`;
|
|
98
112
|
if (checkIsNode() && checkIsInline(chunk, inlineStyles)) return readAsset(chunk).then((content)=>`<script>${content}</script>`).catch((_)=>script);
|
|
99
|
-
return script;
|
|
113
|
+
else return script;
|
|
100
114
|
}));
|
|
101
115
|
chunkSet.jsChunk += scripts.filter((script)=>Boolean(script)).join('');
|
|
102
116
|
}
|
|
103
117
|
async emitStyleAssets(chunks) {
|
|
104
|
-
const { template, chunkSet, config
|
|
118
|
+
const { template, chunkSet, config } = this.options;
|
|
105
119
|
const { inlineStyles } = config;
|
|
106
120
|
const atrributes = attributesToString(this.generateAttributes());
|
|
107
121
|
const emittedAssetUrls = new Set();
|
|
@@ -113,14 +127,11 @@ class LoadableCollector {
|
|
|
113
127
|
const css = await Promise.all(emittedChunks.map(async (chunk)=>{
|
|
114
128
|
const link = `<link${atrributes} href="${chunk.url}" rel="stylesheet" />`;
|
|
115
129
|
if (checkIsNode() && checkIsInline(chunk, inlineStyles)) return readAsset(chunk).then((content)=>`<style>${content}</style>`).catch((_)=>link);
|
|
116
|
-
return link;
|
|
130
|
+
else return link;
|
|
117
131
|
}));
|
|
118
132
|
chunkSet.cssChunk += css.filter((css)=>Boolean(css)).join('');
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
attributes: this.generateAttributes(),
|
|
122
|
-
existingAssets: emittedChunks.map((chunk)=>chunk.url)
|
|
123
|
-
});
|
|
133
|
+
this.stylesheetInfo.emittedAssets = emittedChunks.map((chunk)=>chunk.url);
|
|
134
|
+
this.stylesheetInfo.attributes = this.generateAttributes();
|
|
124
135
|
}
|
|
125
136
|
generateAttributes(extraAtr = {}) {
|
|
126
137
|
const { config } = this.options;
|
|
@@ -133,6 +144,10 @@ class LoadableCollector {
|
|
|
133
144
|
};
|
|
134
145
|
}
|
|
135
146
|
constructor(options){
|
|
147
|
+
this.stylesheetInfo = {
|
|
148
|
+
emittedAssets: [],
|
|
149
|
+
attributes: {}
|
|
150
|
+
};
|
|
136
151
|
this.options = options;
|
|
137
152
|
}
|
|
138
153
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { serializeJson } from "@modern-js/runtime-utils/node";
|
|
2
|
-
import { getRouterHydrationScripts, getRouterServerSnapshot } from "../../../router/runtime/lifecycle.mjs";
|
|
3
2
|
import { ROUTER_DATA_JSON_ID, SSR_DATA_JSON_ID } from "../../constants.mjs";
|
|
4
3
|
import { attributesToString, serializeErrors } from "../utils.mjs";
|
|
5
4
|
function _check_private_redeclaration(obj, privateCollection) {
|
|
@@ -88,20 +87,15 @@ function getSSRData() {
|
|
|
88
87
|
};
|
|
89
88
|
}
|
|
90
89
|
function getRouterData() {
|
|
91
|
-
const { routerContext,
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
loaderData:
|
|
95
|
-
errors: serializeErrors(
|
|
96
|
-
};
|
|
97
|
-
return routerContext ? {
|
|
98
|
-
loaderData: routerContext.loaderData,
|
|
99
|
-
errors: serializeErrors(routerContext.errors)
|
|
90
|
+
const { routerContext, lifecycle } = _class_private_field_get(this, _options);
|
|
91
|
+
const data = lifecycle?.getRouterData() ?? routerContext;
|
|
92
|
+
return data ? {
|
|
93
|
+
loaderData: data.loaderData,
|
|
94
|
+
errors: serializeErrors(data.errors || null)
|
|
100
95
|
} : void 0;
|
|
101
96
|
}
|
|
102
97
|
function getSSRDataScripts(ssrData, routerData) {
|
|
103
98
|
const { nonce, useJsonScript = false } = _class_private_field_get(this, _options);
|
|
104
|
-
const hydrationScripts = getRouterHydrationScripts(_class_private_field_get(this, _options).runtimeContext);
|
|
105
99
|
const serializeSSRData = serializeJson(ssrData);
|
|
106
100
|
const attrsStr = attributesToString({
|
|
107
101
|
nonce
|
|
@@ -111,7 +105,6 @@ function getSSRDataScripts(ssrData, routerData) {
|
|
|
111
105
|
const serializedRouterData = serializeJson(routerData);
|
|
112
106
|
ssrDataScripts += useJsonScript ? `\n<script type="application/json" id="${ROUTER_DATA_JSON_ID}">${serializedRouterData}</script>` : `\n<script${attrsStr}>window._ROUTER_DATA = ${serializedRouterData}</script>`;
|
|
113
107
|
}
|
|
114
|
-
if (hydrationScripts.length) ssrDataScripts += `\n${hydrationScripts.join('\n')}`;
|
|
115
108
|
return ssrDataScripts;
|
|
116
109
|
}
|
|
117
110
|
export { SSRDataCollector };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { escapeHtmlAttribute, isSafeHtmlAttributeName } from "@modern-js/runtime-extensions";
|
|
2
1
|
import { isRouteErrorResponse } from "../../router/runtime/routerHelper.mjs";
|
|
3
2
|
function attributesToString(attributes) {
|
|
4
|
-
return Object.entries(attributes).reduce((str, [key, value])=>void 0 !== value &&
|
|
3
|
+
return Object.entries(attributes).reduce((str, [key, value])=>void 0 !== value && /^[^\u0000-\u0020"'<>/=]+$/u.test(key) ? `${str} ${key}="${String(value).replaceAll('&', '&').replaceAll('"', '"').replaceAll('<', '<').replaceAll('>', '>')}"` : str, '');
|
|
5
4
|
}
|
|
6
5
|
function safeReplace(source, searchValue, replaceValue) {
|
|
7
6
|
return source.replace(searchValue, ()=>replaceValue);
|
|
@@ -124,6 +124,7 @@ g.__MODERN_DOC_RENDERERS__[${JSON.stringify(_entryName)}] = render;
|
|
|
124
124
|
|
|
125
125
|
export default { render: render };`;
|
|
126
126
|
};
|
|
127
|
+
const getDocumentTempEntry = (internalDirectory, compilerName, entryName)=>path.join(internalDirectory, CONSTANTS.DOCUMENT_OUTPUT_DIR, compilerName ?? '', `${CONSTANTS.TEMP_ENTRY_PREFIX}${entryName}.js`);
|
|
127
128
|
const processChildCompilation = async (entryName, docPath, compilation, compiler, appDirectory, internalDirectory)=>new Promise((resolve, reject)=>{
|
|
128
129
|
const outFile = path.posix.join(CONSTANTS.DOCUMENT_OUTPUT_DIR, `${CONSTANTS.HTML_OUTPUT_PREFIX}${entryName}${CONSTANTS.HTML_OUTPUT_SUFFIX}`);
|
|
129
130
|
const child = compilation.createChildCompiler(`${CONSTANTS.CHILD_COMPILER_PREFIX}${entryName}`, {
|
|
@@ -134,8 +135,7 @@ const processChildCompilation = async (entryName, docPath, compilation, compiler
|
|
|
134
135
|
}, []);
|
|
135
136
|
configureChildCompiler(child, compiler, appDirectory);
|
|
136
137
|
applyExternalsPlugin(child, compiler);
|
|
137
|
-
const
|
|
138
|
-
const tempEntry = path.join(entryDir, `${CONSTANTS.TEMP_ENTRY_PREFIX}${entryName}.js`);
|
|
138
|
+
const tempEntry = getDocumentTempEntry(internalDirectory, compiler.name, entryName);
|
|
139
139
|
const finalize = ()=>{
|
|
140
140
|
try {
|
|
141
141
|
const EntryPlugin = compiler.rspack?.EntryPlugin;
|
|
@@ -202,6 +202,7 @@ const documentPlugin = ()=>({
|
|
|
202
202
|
const tasks = [];
|
|
203
203
|
for (const ep of entrypoints || []){
|
|
204
204
|
const entryName = ep.entryName;
|
|
205
|
+
if (!this.htmlEntryNames.has(entryName)) continue;
|
|
205
206
|
const docPath = getDocumentByEntryName(entrypoints, entryName, appDirectory);
|
|
206
207
|
if (docPath) {
|
|
207
208
|
compilation.fileDependencies?.add?.(docPath);
|
|
@@ -218,14 +219,19 @@ const documentPlugin = ()=>({
|
|
|
218
219
|
}
|
|
219
220
|
});
|
|
220
221
|
}
|
|
221
|
-
constructor(){
|
|
222
|
+
constructor(htmlEntryNames){
|
|
223
|
+
this.htmlEntryNames = htmlEntryNames;
|
|
222
224
|
this.name = 'ModernJsDocumentChildCompilerPlugin';
|
|
223
225
|
}
|
|
224
226
|
}
|
|
225
227
|
api.config(()=>({
|
|
226
228
|
tools: {
|
|
227
|
-
bundlerChain: (chain)=>{
|
|
228
|
-
|
|
229
|
+
bundlerChain: (chain, { environment })=>{
|
|
230
|
+
const htmlEntryNames = new Set(Object.keys(environment.htmlPaths));
|
|
231
|
+
if (0 === htmlEntryNames.size) return;
|
|
232
|
+
chain.plugin('modernjs-document-child-compiler').use(ModernJsDocumentChildCompilerPlugin, [
|
|
233
|
+
htmlEntryNames
|
|
234
|
+
]);
|
|
229
235
|
}
|
|
230
236
|
}
|
|
231
237
|
}));
|
|
@@ -346,4 +352,4 @@ const documentPlugin = ()=>({
|
|
|
346
352
|
});
|
|
347
353
|
const cli = documentPlugin;
|
|
348
354
|
export default cli;
|
|
349
|
-
export { documentPlugin, getDocumentByEntryName, processScriptPlaceholders };
|
|
355
|
+
export { documentPlugin, getDocumentByEntryName, getDocumentTempEntry, processScriptPlaceholders };
|
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { RuntimeComponentResolverContext } from "@modern-js/runtime/context";
|
|
2
3
|
import react from "react";
|
|
3
4
|
import { Helmet, HelmetData, HelmetProvider } from "react-helmet-async";
|
|
4
|
-
import { InternalRuntimeContext } from "../core/context/index.mjs";
|
|
5
|
-
import { ensureHelmetContext } from "../core/context/helmetContext.mjs";
|
|
6
|
-
import * as __rspack_external__modern_js_runtime_extensions_ce611631 from "@modern-js/runtime-extensions";
|
|
7
|
-
const collectServerHelmet = (runtimeContext, props)=>{
|
|
8
|
-
const helmetContext = ensureHelmetContext(runtimeContext);
|
|
9
|
-
const createRecord = ()=>__rspack_external__modern_js_runtime_extensions_ce611631.createHelmetRecord(react, props);
|
|
10
|
-
const deriveState = (records)=>__rspack_external__modern_js_runtime_extensions_ce611631.deriveHelmetServerState(react, records);
|
|
11
|
-
const marker = __rspack_external__modern_js_runtime_extensions_ce611631.collectHeadState(runtimeContext, createRecord, deriveState, helmetContext);
|
|
12
|
-
if (void 0 !== marker) return marker;
|
|
13
|
-
helmetContext.helmet = __rspack_external__modern_js_runtime_extensions_ce611631.collectImmediateHelmetState(react, helmetContext, createRecord());
|
|
14
|
-
};
|
|
15
5
|
const head_Helmet = (props)=>{
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
const resolveComponent = react.useContext(RuntimeComponentResolverContext);
|
|
7
|
+
const Component = resolveComponent?.(Helmet, {
|
|
8
|
+
name: 'head.Helmet'
|
|
9
|
+
}) ?? Helmet;
|
|
10
|
+
if (Component === head_Helmet) throw new Error('A component resolver cannot resolve head.Helmet to itself.');
|
|
11
|
+
return react.createElement(Component, props);
|
|
19
12
|
};
|
|
20
13
|
const head = {
|
|
21
14
|
Helmet: head_Helmet,
|
package/dist/esm/internal.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { InternalRuntimeContext } from "
|
|
1
|
+
export { InternalRuntimeContext } from "@modern-js/runtime/context";
|
|
@@ -42,8 +42,7 @@ const optimizeRoute = (routeTree)=>{
|
|
|
42
42
|
children: optimizedChildren
|
|
43
43
|
}
|
|
44
44
|
];
|
|
45
|
-
}
|
|
46
|
-
{
|
|
45
|
+
} else {
|
|
47
46
|
const newRoutes = children.map((child)=>{
|
|
48
47
|
const routePath = routeTree.path ? `${routeTree.path}${child.path ? `/${child.path}` : ''}` : child.path || '';
|
|
49
48
|
const newRoute = {
|
|
@@ -10,7 +10,7 @@ const walkDirectory = (dir)=>fs_0.readdirSync(dir).reduce((previous, filename)=>
|
|
|
10
10
|
...previous,
|
|
11
11
|
...walkDirectory(filePath)
|
|
12
12
|
];
|
|
13
|
-
return [
|
|
13
|
+
else return [
|
|
14
14
|
...previous,
|
|
15
15
|
filePath
|
|
16
16
|
];
|
|
@@ -27,7 +27,7 @@ const isPageComponentFile = (filePath)=>{
|
|
|
27
27
|
};
|
|
28
28
|
const replaceWithAlias = (base, filePath, alias)=>{
|
|
29
29
|
if (filePath.includes(base)) return normalizeToPosixPath(path.join(alias, path.relative(base, filePath)));
|
|
30
|
-
return filePath;
|
|
30
|
+
else return filePath;
|
|
31
31
|
};
|
|
32
32
|
const parseModule = async ({ source, filename })=>{
|
|
33
33
|
let content = source;
|
|
@@ -51,7 +51,7 @@ const DeferredDataScripts = (props)=>{
|
|
|
51
51
|
serializeJson(key)
|
|
52
52
|
]
|
|
53
53
|
};
|
|
54
|
-
{
|
|
54
|
+
else {
|
|
55
55
|
const trackedPromise = deferredData.data[key];
|
|
56
56
|
if (void 0 !== trackedPromise._error) {
|
|
57
57
|
const error = toDeferredErrorInfo(trackedPromise._error);
|
|
@@ -63,15 +63,16 @@ const DeferredDataScripts = (props)=>{
|
|
|
63
63
|
serializeJson(error)
|
|
64
64
|
]
|
|
65
65
|
};
|
|
66
|
+
} else {
|
|
67
|
+
if (void 0 === trackedPromise._data) throw new Error(`The deferred data for ${key} was not resolved, did you forget to return data from a deferred promise`);
|
|
68
|
+
return {
|
|
69
|
+
key,
|
|
70
|
+
routerDataFnName: 'p',
|
|
71
|
+
routerDataFnArgs: [
|
|
72
|
+
serializeJson(trackedPromise._data)
|
|
73
|
+
]
|
|
74
|
+
};
|
|
66
75
|
}
|
|
67
|
-
if (void 0 === trackedPromise._data) throw new Error(`The deferred data for ${key} was not resolved, did you forget to return data from a deferred promise`);
|
|
68
|
-
return {
|
|
69
|
-
key,
|
|
70
|
-
routerDataFnName: 'p',
|
|
71
|
-
routerDataFnArgs: [
|
|
72
|
-
serializeJson(trackedPromise._data)
|
|
73
|
-
]
|
|
74
|
-
};
|
|
75
76
|
}
|
|
76
77
|
});
|
|
77
78
|
return {
|