@modern-js/runtime 3.1.5 → 3.2.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/code.js +31 -2
- package/dist/cjs/cli/index.js +2 -2
- package/dist/cjs/cli/template.js +3 -3
- package/dist/cjs/cli/template.server.js +2 -2
- package/dist/cjs/core/browser/index.js +3 -3
- package/dist/cjs/core/context/index.js +11 -11
- package/dist/cjs/core/context/response/index.server.js +3 -3
- package/dist/cjs/core/context/runtime.js +2 -2
- package/dist/cjs/core/server/helmet.js +2 -2
- package/dist/cjs/core/server/index.js +1 -1
- package/dist/cjs/core/server/react/index.js +2 -2
- package/dist/cjs/core/server/server.js +2 -2
- package/dist/cjs/core/server/stream/createReadableStream.js +1 -1
- package/dist/cjs/core/server/stream/deferredScript.js +4 -4
- package/dist/cjs/core/server/stream/shared.js +2 -2
- package/dist/cjs/core/server/utils.js +4 -4
- package/dist/cjs/document/Head.js +2 -2
- package/dist/cjs/document/cli/index.js +1 -1
- package/dist/cjs/document/constants.js +16 -16
- package/dist/cjs/index.js +6 -6
- package/dist/cjs/react-server.js +2 -2
- package/dist/cjs/router/cli/code/index.js +1 -1
- package/dist/cjs/router/cli/code/nestedRoutes.js +1 -1
- package/dist/cjs/router/cli/code/templates.js +3 -3
- package/dist/cjs/router/cli/code/utils.js +6 -6
- package/dist/cjs/router/cli/index.js +3 -3
- package/dist/cjs/router/runtime/PrefetchLink.js +2 -2
- package/dist/cjs/router/runtime/constants.js +4 -4
- package/dist/cjs/router/runtime/internal.js +1 -1
- package/dist/cjs/router/runtime/plugin.js +3 -3
- package/dist/cjs/router/runtime/plugin.node.js +2 -2
- package/dist/cjs/router/runtime/rsc-router.js +2 -2
- package/dist/cjs/router/runtime/utils.js +5 -5
- package/dist/esm/cli/code.mjs +32 -3
- package/dist/esm/core/server/stream/createReadableStream.mjs +1 -1
- package/dist/esm/router/runtime/plugin.node.mjs +2 -2
- package/dist/esm-node/cli/code.mjs +32 -3
- package/dist/esm-node/core/server/stream/createReadableStream.mjs +1 -1
- package/dist/esm-node/router/runtime/plugin.node.mjs +2 -2
- package/dist/types/router/runtime/constants.d.ts +1 -1
- package/package.json +14 -14
package/dist/cjs/cli/code.js
CHANGED
|
@@ -42,10 +42,24 @@ const external_constants_js_namespaceObject = require("./constants.js");
|
|
|
42
42
|
const mode_js_namespaceObject = require("./ssr/mode.js");
|
|
43
43
|
const external_template_js_namespaceObject = require("./template.js");
|
|
44
44
|
const external_template_server_js_namespaceObject = require("./template.server.js");
|
|
45
|
+
const normalizePreEntry = (preEntry)=>{
|
|
46
|
+
if (!preEntry) return [];
|
|
47
|
+
if (Array.isArray(preEntry)) return preEntry.filter((v)=>'string' == typeof v && v.length > 0);
|
|
48
|
+
if ('string' == typeof preEntry) return preEntry ? [
|
|
49
|
+
preEntry
|
|
50
|
+
] : [];
|
|
51
|
+
return [];
|
|
52
|
+
};
|
|
53
|
+
const resolvePreEntryImportPath = ({ preEntry, appDirectory, srcDirectory, internalSrcAlias })=>{
|
|
54
|
+
const absPath = external_path_default().isAbsolute(preEntry) ? preEntry : external_path_default().resolve(appDirectory, preEntry);
|
|
55
|
+
if (absPath.startsWith(srcDirectory)) return (0, utils_namespaceObject.formatImportPath)(absPath.replace(srcDirectory, internalSrcAlias));
|
|
56
|
+
return (0, utils_namespaceObject.formatImportPath)(absPath);
|
|
57
|
+
};
|
|
45
58
|
const generateCode = async (entrypoints, appContext, config, hooks)=>{
|
|
46
59
|
const { mountId } = config.html;
|
|
47
|
-
const { enableAsyncEntry } = config.source;
|
|
48
|
-
const
|
|
60
|
+
const { enableAsyncEntry, enableAsyncPreEntry, preEntry } = config.source;
|
|
61
|
+
const shouldInjectAsyncPreEntry = !!enableAsyncEntry && !!enableAsyncPreEntry;
|
|
62
|
+
const { appDirectory, runtimeConfigFile, internalDirectory, internalSrcAlias, metaName, srcDirectory, serverRoutes } = appContext;
|
|
49
63
|
await Promise.all(entrypoints.map(async (entrypoint)=>{
|
|
50
64
|
const { entryName, isAutoMount, entry, customEntry, customServerEntry, nestedRoutesEntry } = entrypoint;
|
|
51
65
|
const { plugins: runtimePlugins } = await hooks._internalRuntimePlugins.call({
|
|
@@ -76,6 +90,21 @@ const generateCode = async (entrypoints, appContext, config, hooks)=>{
|
|
|
76
90
|
urlPath: serverRoutes.find((route)=>route.entryName === entryName)?.urlPath,
|
|
77
91
|
isNestedRouter: entrypoint.nestedRoutesEntry
|
|
78
92
|
});
|
|
93
|
+
if (shouldInjectAsyncPreEntry) {
|
|
94
|
+
const preEntries = normalizePreEntry(preEntry);
|
|
95
|
+
if (preEntries.length > 0) {
|
|
96
|
+
const injected = preEntries.map((item)=>{
|
|
97
|
+
const importPath = resolvePreEntryImportPath({
|
|
98
|
+
preEntry: item,
|
|
99
|
+
appDirectory,
|
|
100
|
+
srcDirectory,
|
|
101
|
+
internalSrcAlias
|
|
102
|
+
});
|
|
103
|
+
return `import '${importPath}';`;
|
|
104
|
+
}).join('\n');
|
|
105
|
+
indexCode = `${injected}\n${indexCode}`;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
79
108
|
const indexFile = external_path_default().resolve(internalDirectory, `./${entryName}/${external_constants_js_namespaceObject.ENTRY_POINT_FILE_NAME}`);
|
|
80
109
|
await utils_namespaceObject.fs.outputFile(indexFile, indexCode, 'utf8');
|
|
81
110
|
if (enableAsyncEntry) {
|
package/dist/cjs/cli/index.js
CHANGED
|
@@ -34,10 +34,10 @@ var __webpack_exports__ = {};
|
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
36
|
default: ()=>cli,
|
|
37
|
-
routerPlugin: ()=>external_router_cli_index_js_namespaceObject.routerPlugin,
|
|
38
37
|
documentPlugin: ()=>index_js_namespaceObject.documentPlugin,
|
|
39
|
-
runtimePlugin: ()=>runtimePlugin,
|
|
40
38
|
isRuntimeEntry: ()=>external_entry_js_namespaceObject.isRuntimeEntry,
|
|
39
|
+
routerPlugin: ()=>external_router_cli_index_js_namespaceObject.routerPlugin,
|
|
40
|
+
runtimePlugin: ()=>runtimePlugin,
|
|
41
41
|
ssrPlugin: ()=>external_ssr_index_js_namespaceObject.ssrPlugin
|
|
42
42
|
});
|
|
43
43
|
const external_path_namespaceObject = require("path");
|
package/dist/cjs/cli/template.js
CHANGED
|
@@ -33,14 +33,14 @@ var __webpack_require__ = {};
|
|
|
33
33
|
var __webpack_exports__ = {};
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
AppProxyForRSC: ()=>AppProxyForRSC,
|
|
36
37
|
entryForCSRWithRSC: ()=>entryForCSRWithRSC,
|
|
37
38
|
index: ()=>index,
|
|
38
|
-
|
|
39
|
+
register: ()=>register,
|
|
39
40
|
runtimeGlobalContext: ()=>runtimeGlobalContext,
|
|
40
|
-
runtimeRegister: ()=>runtimeRegister,
|
|
41
41
|
runtimeGlobalContextForRSCClient: ()=>runtimeGlobalContextForRSCClient,
|
|
42
42
|
runtimeGlobalContextForRSCServer: ()=>runtimeGlobalContextForRSCServer,
|
|
43
|
-
|
|
43
|
+
runtimeRegister: ()=>runtimeRegister
|
|
44
44
|
});
|
|
45
45
|
const external_path_namespaceObject = require("path");
|
|
46
46
|
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
@@ -24,8 +24,8 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
entryForCSRWithRSC: ()=>entryForCSRWithRSC,
|
|
28
|
+
serverIndex: ()=>serverIndex
|
|
29
29
|
});
|
|
30
30
|
const utils_namespaceObject = require("@modern-js/utils");
|
|
31
31
|
const SERVER_ENTRY = `
|
|
@@ -33,11 +33,11 @@ var __webpack_require__ = {};
|
|
|
33
33
|
var __webpack_exports__ = {};
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
hydrateWithReact18: ()=>hydrateWithReact18,
|
|
37
36
|
hydrateWithReact17: ()=>hydrateWithReact17,
|
|
37
|
+
hydrateWithReact18: ()=>hydrateWithReact18,
|
|
38
38
|
render: ()=>render,
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
renderWithReact17: ()=>renderWithReact17,
|
|
40
|
+
renderWithReact18: ()=>renderWithReact18
|
|
41
41
|
});
|
|
42
42
|
const constants_namespaceObject = require("@modern-js/utils/universal/constants");
|
|
43
43
|
const external_cookie_namespaceObject = require("cookie");
|
|
@@ -25,21 +25,21 @@ var __webpack_exports__ = {};
|
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
InternalRuntimeContext: ()=>external_runtime_js_namespaceObject.InternalRuntimeContext,
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
RuntimeContext: ()=>external_runtime_js_namespaceObject.RuntimeContext,
|
|
29
|
+
getCurrentEntryName: ()=>getCurrentEntryName,
|
|
30
30
|
getGlobalApp: ()=>getGlobalApp,
|
|
31
|
-
getGlobalEnableRsc: ()=>getGlobalEnableRsc,
|
|
32
|
-
setGlobalInternalRuntimeContext: ()=>setGlobalInternalRuntimeContext,
|
|
33
|
-
getInitialContext: ()=>external_runtime_js_namespaceObject.getInitialContext,
|
|
34
|
-
setGlobalContext: ()=>setGlobalContext,
|
|
35
31
|
getGlobalBasename: ()=>getGlobalBasename,
|
|
36
|
-
|
|
37
|
-
getGlobalIsRscClient: ()=>getGlobalIsRscClient,
|
|
38
|
-
getCurrentEntryName: ()=>getCurrentEntryName,
|
|
32
|
+
getGlobalEnableRsc: ()=>getGlobalEnableRsc,
|
|
39
33
|
getGlobalInternalRuntimeContext: ()=>getGlobalInternalRuntimeContext,
|
|
40
|
-
|
|
34
|
+
getGlobalIsRscClient: ()=>getGlobalIsRscClient,
|
|
35
|
+
getGlobalLayoutApp: ()=>getGlobalLayoutApp,
|
|
36
|
+
getGlobalRSCRoot: ()=>getGlobalRSCRoot,
|
|
41
37
|
getGlobalRoutes: ()=>getGlobalRoutes,
|
|
42
|
-
|
|
38
|
+
getInitialContext: ()=>external_runtime_js_namespaceObject.getInitialContext,
|
|
39
|
+
getServerPayload: ()=>index_js_namespaceObject.getServerPayload,
|
|
40
|
+
setGlobalContext: ()=>setGlobalContext,
|
|
41
|
+
setGlobalInternalRuntimeContext: ()=>setGlobalInternalRuntimeContext,
|
|
42
|
+
setServerPayload: ()=>index_js_namespaceObject.setServerPayload
|
|
43
43
|
});
|
|
44
44
|
const external_runtime_js_namespaceObject = require("./runtime.js");
|
|
45
45
|
const index_js_namespaceObject = require("./serverPayload/index.js");
|
|
@@ -24,10 +24,10 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
redirect: ()=>redirect,
|
|
28
|
-
setStatus: ()=>setStatus,
|
|
29
27
|
getResponseProxy: ()=>getResponseProxy,
|
|
30
|
-
|
|
28
|
+
redirect: ()=>redirect,
|
|
29
|
+
setHeaders: ()=>setHeaders,
|
|
30
|
+
setStatus: ()=>setStatus
|
|
31
31
|
});
|
|
32
32
|
const node_namespaceObject = require("@modern-js/runtime-utils/node");
|
|
33
33
|
const getResponseProxy = ()=>{
|
|
@@ -25,10 +25,10 @@ var __webpack_exports__ = {};
|
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
InternalRuntimeContext: ()=>InternalRuntimeContext,
|
|
28
|
+
ReactRuntimeContext: ()=>ReactRuntimeContext,
|
|
28
29
|
RuntimeContext: ()=>RuntimeContext,
|
|
29
|
-
useRuntimeContext: ()=>useRuntimeContext,
|
|
30
30
|
getInitialContext: ()=>getInitialContext,
|
|
31
|
-
|
|
31
|
+
useRuntimeContext: ()=>useRuntimeContext
|
|
32
32
|
});
|
|
33
33
|
const constants_namespaceObject = require("@modern-js/utils/universal/constants");
|
|
34
34
|
const external_react_namespaceObject = require("react");
|
|
@@ -24,8 +24,8 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
createReplaceHelemt: ()=>createReplaceHelemt,
|
|
28
|
+
helmetReplace: ()=>helmetReplace
|
|
29
29
|
});
|
|
30
30
|
const external_os_namespaceObject = require("os");
|
|
31
31
|
const external_utils_js_namespaceObject = require("./utils.js");
|
|
@@ -24,9 +24,9 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
default: ()=>server,
|
|
28
27
|
NoSSR: ()=>index_js_namespaceObject.NoSSR,
|
|
29
28
|
NoSSRCache: ()=>index_js_namespaceObject.NoSSRCache,
|
|
29
|
+
default: ()=>server,
|
|
30
30
|
ssr: ()=>ssr
|
|
31
31
|
});
|
|
32
32
|
const index_js_namespaceObject = require("./react/index.js");
|
|
@@ -24,8 +24,8 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
NoSSR: ()=>index_js_namespaceObject.NoSSR,
|
|
28
|
+
NoSSRCache: ()=>external_no_ssr_cache_index_js_namespaceObject.NoSSRCache
|
|
29
29
|
});
|
|
30
30
|
const index_js_namespaceObject = require("./nossr/index.js");
|
|
31
31
|
const external_no_ssr_cache_index_js_namespaceObject = require("./no-ssr-cache/index.js");
|
|
@@ -25,8 +25,8 @@ var __webpack_exports__ = {};
|
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
createRequestHandler: ()=>external_requestHandler_js_namespaceObject.createRequestHandler,
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
renderStreaming: ()=>external_stream_index_js_namespaceObject.renderStreaming,
|
|
29
|
+
renderString: ()=>index_js_namespaceObject.renderString
|
|
30
30
|
});
|
|
31
31
|
const index_js_namespaceObject = require("./string/index.js");
|
|
32
32
|
const external_stream_index_js_namespaceObject = require("./stream/index.js");
|
|
@@ -99,7 +99,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
|
|
|
99
99
|
} else this.push(chunk);
|
|
100
100
|
callback();
|
|
101
101
|
} catch (e) {
|
|
102
|
-
e instanceof Error ? callback(e) : callback(new Error('Received
|
|
102
|
+
e instanceof Error ? callback(e) : callback(new Error('Received unknown error when streaming'));
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
});
|
|
@@ -24,13 +24,13 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
escapeAttr: ()=>escapeAttr,
|
|
28
27
|
buildDeferredDataScript: ()=>buildDeferredDataScript,
|
|
28
|
+
enqueueFromEntries: ()=>enqueueFromEntries,
|
|
29
|
+
escapeAttr: ()=>escapeAttr,
|
|
29
30
|
isDeferredDataLike: ()=>isDeferredDataLike,
|
|
30
|
-
isRecord: ()=>isRecord,
|
|
31
|
-
toErrorInfo: ()=>toErrorInfo,
|
|
32
31
|
isPromiseLike: ()=>isPromiseLike,
|
|
33
|
-
|
|
32
|
+
isRecord: ()=>isRecord,
|
|
33
|
+
toErrorInfo: ()=>toErrorInfo
|
|
34
34
|
});
|
|
35
35
|
const constants_js_namespaceObject = require("../../../router/runtime/constants.js");
|
|
36
36
|
const HTML_ESCAPE_MAP = {
|
|
@@ -36,8 +36,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
36
36
|
ShellChunkStatus: ()=>shared_ShellChunkStatus,
|
|
37
37
|
createRenderStreaming: ()=>createRenderStreaming,
|
|
38
38
|
encodeForWebStream: ()=>encodeForWebStream,
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
getReadableStreamFromString: ()=>getReadableStreamFromString,
|
|
40
|
+
resolveStreamingMode: ()=>resolveStreamingMode
|
|
41
41
|
});
|
|
42
42
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
43
43
|
const time_namespaceObject = require("@modern-js/runtime-utils/time");
|
|
@@ -24,12 +24,12 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
safeReplace: ()=>safeReplace,
|
|
28
|
-
getSSRConfigByEntry: ()=>getSSRConfigByEntry,
|
|
29
|
-
serializeErrors: ()=>serializeErrors,
|
|
30
27
|
attributesToString: ()=>attributesToString,
|
|
31
28
|
checkIsNode: ()=>checkIsNode,
|
|
32
|
-
|
|
29
|
+
getSSRConfigByEntry: ()=>getSSRConfigByEntry,
|
|
30
|
+
getSSRMode: ()=>getSSRMode,
|
|
31
|
+
safeReplace: ()=>safeReplace,
|
|
32
|
+
serializeErrors: ()=>serializeErrors
|
|
33
33
|
});
|
|
34
34
|
const router_namespaceObject = require("@modern-js/runtime-utils/router");
|
|
35
35
|
function attributesToString(attributes) {
|
|
@@ -24,8 +24,8 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
DefaultHead: ()=>DefaultHead,
|
|
28
|
+
Head: ()=>Head
|
|
29
29
|
});
|
|
30
30
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
31
31
|
const external_react_namespaceObject = require("react");
|
|
@@ -33,8 +33,8 @@ var __webpack_require__ = {};
|
|
|
33
33
|
var __webpack_exports__ = {};
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
documentPlugin: ()=>documentPlugin,
|
|
37
36
|
default: ()=>cli,
|
|
37
|
+
documentPlugin: ()=>documentPlugin,
|
|
38
38
|
getDocumentByEntryName: ()=>getDocumentByEntryName
|
|
39
39
|
});
|
|
40
40
|
const external_module_namespaceObject = require("module");
|
|
@@ -24,29 +24,29 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
TOP_PARTICALS_SEPARATOR: ()=>TOP_PARTICALS_SEPARATOR,
|
|
31
|
-
DOC_EXT: ()=>DOC_EXT,
|
|
27
|
+
BODY_PARTICALS_SEPARATOR: ()=>BODY_PARTICALS_SEPARATOR,
|
|
28
|
+
DOCUMENT_CHUNKSMAP_PLACEHOLDER: ()=>DOCUMENT_CHUNKSMAP_PLACEHOLDER,
|
|
29
|
+
DOCUMENT_COMMENT_PLACEHOLDER_END: ()=>DOCUMENT_COMMENT_PLACEHOLDER_END,
|
|
32
30
|
DOCUMENT_COMMENT_PLACEHOLDER_START: ()=>DOCUMENT_COMMENT_PLACEHOLDER_START,
|
|
33
|
-
|
|
34
|
-
DOCUMENT_TITLE_PLACEHOLDER: ()=>DOCUMENT_TITLE_PLACEHOLDER,
|
|
31
|
+
DOCUMENT_FILE_NAME: ()=>DOCUMENT_FILE_NAME,
|
|
35
32
|
DOCUMENT_LINKS_PLACEHOLDER: ()=>DOCUMENT_LINKS_PLACEHOLDER,
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
DOCUMENT_META_PLACEHOLDER: ()=>DOCUMENT_META_PLACEHOLDER,
|
|
34
|
+
DOCUMENT_SCRIPTS_PLACEHOLDER: ()=>DOCUMENT_SCRIPTS_PLACEHOLDER,
|
|
35
|
+
DOCUMENT_SCRIPT_ATTRIBUTES_END: ()=>DOCUMENT_SCRIPT_ATTRIBUTES_END,
|
|
38
36
|
DOCUMENT_SCRIPT_ATTRIBUTES_START: ()=>DOCUMENT_SCRIPT_ATTRIBUTES_START,
|
|
39
|
-
|
|
37
|
+
DOCUMENT_SCRIPT_PLACEHOLDER_END: ()=>DOCUMENT_SCRIPT_PLACEHOLDER_END,
|
|
40
38
|
DOCUMENT_SCRIPT_PLACEHOLDER_START: ()=>DOCUMENT_SCRIPT_PLACEHOLDER_START,
|
|
41
|
-
HEAD_PARTICALS_SEPARATOR: ()=>HEAD_PARTICALS_SEPARATOR,
|
|
42
|
-
BODY_PARTICALS_SEPARATOR: ()=>BODY_PARTICALS_SEPARATOR,
|
|
43
|
-
DOCUMENT_COMMENT_PLACEHOLDER_END: ()=>DOCUMENT_COMMENT_PLACEHOLDER_END,
|
|
44
39
|
DOCUMENT_SSRDATASCRIPT_PLACEHOLDER: ()=>DOCUMENT_SSRDATASCRIPT_PLACEHOLDER,
|
|
40
|
+
DOCUMENT_SSR_PLACEHOLDER: ()=>DOCUMENT_SSR_PLACEHOLDER,
|
|
41
|
+
DOCUMENT_STYLE_PLACEHOLDER_END: ()=>DOCUMENT_STYLE_PLACEHOLDER_END,
|
|
45
42
|
DOCUMENT_STYLE_PLACEHOLDER_START: ()=>DOCUMENT_STYLE_PLACEHOLDER_START,
|
|
46
|
-
|
|
43
|
+
DOCUMENT_TITLE_PLACEHOLDER: ()=>DOCUMENT_TITLE_PLACEHOLDER,
|
|
44
|
+
DOC_EXT: ()=>DOC_EXT,
|
|
45
|
+
HEAD_PARTICALS_SEPARATOR: ()=>HEAD_PARTICALS_SEPARATOR,
|
|
47
46
|
HTML_SEPARATOR: ()=>HTML_SEPARATOR,
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
HTML_SSRDATASCRIPT_SEPARATOR: ()=>HTML_SSRDATASCRIPT_SEPARATOR,
|
|
48
|
+
PLACEHOLDER_REPLACER_MAP: ()=>PLACEHOLDER_REPLACER_MAP,
|
|
49
|
+
TOP_PARTICALS_SEPARATOR: ()=>TOP_PARTICALS_SEPARATOR
|
|
50
50
|
});
|
|
51
51
|
const constants_namespaceObject = require("@modern-js/utils/universal/constants");
|
|
52
52
|
const DOC_EXT = [
|
package/dist/cjs/index.js
CHANGED
|
@@ -24,15 +24,15 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
isBrowser: ()=>external_common_js_namespaceObject.isBrowser,
|
|
28
|
-
setHeaders: ()=>response_index_js_namespaceObject.setHeaders,
|
|
29
|
-
getMonitors: ()=>index_js_namespaceObject.getMonitors,
|
|
30
27
|
RuntimeContext: ()=>external_core_index_js_namespaceObject.RuntimeContext,
|
|
31
|
-
|
|
28
|
+
defineRuntimeConfig: ()=>external_core_index_js_namespaceObject.defineRuntimeConfig,
|
|
29
|
+
getMonitors: ()=>index_js_namespaceObject.getMonitors,
|
|
30
|
+
getRequest: ()=>request_index_js_namespaceObject.getRequest,
|
|
31
|
+
isBrowser: ()=>external_common_js_namespaceObject.isBrowser,
|
|
32
32
|
redirect: ()=>response_index_js_namespaceObject.redirect,
|
|
33
|
+
setHeaders: ()=>response_index_js_namespaceObject.setHeaders,
|
|
33
34
|
setStatus: ()=>response_index_js_namespaceObject.setStatus,
|
|
34
|
-
|
|
35
|
-
getRequest: ()=>request_index_js_namespaceObject.getRequest
|
|
35
|
+
useRuntimeContext: ()=>external_core_index_js_namespaceObject.useRuntimeContext
|
|
36
36
|
});
|
|
37
37
|
const external_common_js_namespaceObject = require("./common.js");
|
|
38
38
|
const index_js_namespaceObject = require("./core/context/monitors/index.js");
|
package/dist/cjs/react-server.js
CHANGED
|
@@ -25,10 +25,10 @@ var __webpack_exports__ = {};
|
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
getMonitors: ()=>monitors_index_js_namespaceObject.getMonitors,
|
|
28
|
+
getRequest: ()=>index_js_namespaceObject.getRequest,
|
|
28
29
|
redirect: ()=>response_index_js_namespaceObject.redirect,
|
|
29
|
-
setStatus: ()=>response_index_js_namespaceObject.setStatus,
|
|
30
30
|
setHeaders: ()=>response_index_js_namespaceObject.setHeaders,
|
|
31
|
-
|
|
31
|
+
setStatus: ()=>response_index_js_namespaceObject.setStatus
|
|
32
32
|
});
|
|
33
33
|
const index_js_namespaceObject = require("./core/context/request/index.js");
|
|
34
34
|
const monitors_index_js_namespaceObject = require("./core/context/monitors/index.js");
|
|
@@ -33,8 +33,8 @@ var __webpack_require__ = {};
|
|
|
33
33
|
var __webpack_exports__ = {};
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
generateRoutesForEntry: ()=>generateRoutesForEntry,
|
|
37
36
|
generateCode: ()=>generateCode,
|
|
37
|
+
generateRoutesForEntry: ()=>generateRoutesForEntry,
|
|
38
38
|
generatorRegisterCode: ()=>generatorRegisterCode,
|
|
39
39
|
generatorServerRegisterCode: ()=>generatorServerRegisterCode
|
|
40
40
|
});
|
|
@@ -24,8 +24,8 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
optimizeRoute: ()=>optimizeRoute,
|
|
28
27
|
getRouteId: ()=>getRouteId,
|
|
28
|
+
optimizeRoute: ()=>optimizeRoute,
|
|
29
29
|
walk: ()=>walk
|
|
30
30
|
});
|
|
31
31
|
const external_path_namespaceObject = require("path");
|
|
@@ -33,10 +33,10 @@ var __webpack_require__ = {};
|
|
|
33
33
|
var __webpack_exports__ = {};
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
|
|
37
|
-
runtimeGlobalContext: ()=>runtimeGlobalContext,
|
|
36
|
+
fileSystemRoutes: ()=>fileSystemRoutes,
|
|
38
37
|
routesForServer: ()=>routesForServer,
|
|
39
|
-
|
|
38
|
+
runtimeGlobalContext: ()=>runtimeGlobalContext,
|
|
39
|
+
ssrLoaderCombinedModule: ()=>ssrLoaderCombinedModule
|
|
40
40
|
});
|
|
41
41
|
const promises_namespaceObject = require("node:fs/promises");
|
|
42
42
|
const external_path_namespaceObject = require("path");
|
|
@@ -33,15 +33,15 @@ var __webpack_require__ = {};
|
|
|
33
33
|
var __webpack_exports__ = {};
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
parseModule: ()=>parseModule,
|
|
37
|
-
getServerCombinedModuleFile: ()=>getServerCombinedModuleFile,
|
|
38
|
-
hasLoader: ()=>hasLoader,
|
|
39
36
|
getPathWithoutExt: ()=>getPathWithoutExt,
|
|
40
|
-
|
|
37
|
+
getServerCombinedModuleFile: ()=>getServerCombinedModuleFile,
|
|
41
38
|
getServerLoadersFile: ()=>getServerLoadersFile,
|
|
42
|
-
walkDirectory: ()=>walkDirectory,
|
|
43
39
|
hasAction: ()=>hasAction,
|
|
44
|
-
|
|
40
|
+
hasLoader: ()=>hasLoader,
|
|
41
|
+
isPageComponentFile: ()=>isPageComponentFile,
|
|
42
|
+
parseModule: ()=>parseModule,
|
|
43
|
+
replaceWithAlias: ()=>replaceWithAlias,
|
|
44
|
+
walkDirectory: ()=>walkDirectory
|
|
45
45
|
});
|
|
46
46
|
const external_fs_namespaceObject = require("fs");
|
|
47
47
|
var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
|
|
@@ -33,11 +33,11 @@ var __webpack_require__ = {};
|
|
|
33
33
|
var __webpack_exports__ = {};
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
handleFileChange: ()=>external_handler_js_namespaceObject.handleFileChange,
|
|
37
36
|
default: ()=>cli,
|
|
38
|
-
|
|
37
|
+
handleFileChange: ()=>external_handler_js_namespaceObject.handleFileChange,
|
|
38
|
+
handleModifyEntrypoints: ()=>external_handler_js_namespaceObject.handleModifyEntrypoints,
|
|
39
39
|
isRouteEntry: ()=>external_entry_js_namespaceObject.isRouteEntry,
|
|
40
|
-
|
|
40
|
+
routerPlugin: ()=>routerPlugin
|
|
41
41
|
});
|
|
42
42
|
const external_node_path_namespaceObject = require("node:path");
|
|
43
43
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
@@ -34,8 +34,8 @@ var __webpack_require__ = {};
|
|
|
34
34
|
var __webpack_exports__ = {};
|
|
35
35
|
__webpack_require__.r(__webpack_exports__);
|
|
36
36
|
__webpack_require__.d(__webpack_exports__, {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
Link: ()=>PrefetchLink_Link,
|
|
38
|
+
NavLink: ()=>NavLink
|
|
39
39
|
});
|
|
40
40
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
41
41
|
const router_namespaceObject = require("@modern-js/runtime-utils/router");
|
|
@@ -24,14 +24,14 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
runWindowFnStr: ()=>runWindowFnStr,
|
|
28
|
-
setupFnStr: ()=>setupFnStr,
|
|
29
|
-
runRouterDataFnStr: ()=>runRouterDataFnStr,
|
|
30
27
|
initRouterDataAttrs: ()=>initRouterDataAttrs,
|
|
31
28
|
mergeLoaderDataStr: ()=>mergeLoaderDataStr,
|
|
29
|
+
modernInline: ()=>modernInline,
|
|
32
30
|
preResolvedFnStr: ()=>preResolvedFnStr,
|
|
33
31
|
resolveFnStr: ()=>resolveFnStr,
|
|
34
|
-
|
|
32
|
+
runRouterDataFnStr: ()=>runRouterDataFnStr,
|
|
33
|
+
runWindowFnStr: ()=>runWindowFnStr,
|
|
34
|
+
setupFnStr: ()=>setupFnStr
|
|
35
35
|
});
|
|
36
36
|
const constants_js_namespaceObject = require("../../core/constants.js");
|
|
37
37
|
const setupFnStr = "function s(r,e){_ROUTER_DATA.r=_ROUTER_DATA.r||{},_ROUTER_DATA.r[r]=_ROUTER_DATA.r[r]||{};return new Promise((function(A,R){_ROUTER_DATA.r[r][e]={resolve:A,reject:R}}))};";
|
|
@@ -24,8 +24,8 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
modifyRoutes: ()=>external_plugin_js_namespaceObject.modifyRoutes,
|
|
28
27
|
default: ()=>internal,
|
|
28
|
+
modifyRoutes: ()=>external_plugin_js_namespaceObject.modifyRoutes,
|
|
29
29
|
renderRoutes: ()=>external_utils_js_namespaceObject.renderRoutes,
|
|
30
30
|
routerPlugin: ()=>external_plugin_js_namespaceObject.routerPlugin
|
|
31
31
|
});
|
|
@@ -24,10 +24,10 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
28
|
-
routerPlugin: ()=>routerPlugin,
|
|
27
|
+
beforeCreateRouter: ()=>beforeCreateRouter,
|
|
29
28
|
finalRouteConfig: ()=>finalRouteConfig,
|
|
30
|
-
|
|
29
|
+
modifyRoutes: ()=>modifyRoutes,
|
|
30
|
+
routerPlugin: ()=>routerPlugin
|
|
31
31
|
});
|
|
32
32
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
33
33
|
const merge_namespaceObject = require("@modern-js/runtime-utils/merge");
|
|
@@ -50,7 +50,7 @@ var external_DeferredDataScripts_node_js_default = /*#__PURE__*/ __webpack_requi
|
|
|
50
50
|
const external_hooks_js_namespaceObject = require("./hooks.js");
|
|
51
51
|
const external_rsc_router_js_namespaceObject = require("./rsc-router.js");
|
|
52
52
|
const external_utils_js_namespaceObject = require("./utils.js");
|
|
53
|
-
function
|
|
53
|
+
function createRemixRequest(request) {
|
|
54
54
|
const method = 'GET';
|
|
55
55
|
const { headers } = request;
|
|
56
56
|
const controller = new AbortController();
|
|
@@ -98,7 +98,7 @@ const routerPlugin = (userConfig = {})=>({
|
|
|
98
98
|
const { query } = (0, router_namespaceObject.createStaticHandler)(routes, {
|
|
99
99
|
basename: _basename
|
|
100
100
|
});
|
|
101
|
-
const remixRequest =
|
|
101
|
+
const remixRequest = createRemixRequest(context.ssrContext.request.raw);
|
|
102
102
|
const end = (0, time_namespaceObject.time)();
|
|
103
103
|
const routerContext = await query(remixRequest, {
|
|
104
104
|
requestContext
|
|
@@ -33,11 +33,11 @@ var __webpack_require__ = {};
|
|
|
33
33
|
var __webpack_exports__ = {};
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
RSCStaticRouter: ()=>RSCStaticRouter,
|
|
36
37
|
createClientRouterFromPayload: ()=>createClientRouterFromPayload,
|
|
37
38
|
createServerPayload: ()=>createServerPayload,
|
|
38
39
|
handleRSCRedirect: ()=>handleRSCRedirect,
|
|
39
|
-
prepareRSCRoutes: ()=>prepareRSCRoutes
|
|
40
|
-
RSCStaticRouter: ()=>RSCStaticRouter
|
|
40
|
+
prepareRSCRoutes: ()=>prepareRSCRoutes
|
|
41
41
|
});
|
|
42
42
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
43
43
|
const client_namespaceObject = require("@modern-js/render/client");
|
|
@@ -34,14 +34,14 @@ var __webpack_exports__ = {};
|
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
36
|
createRouteObjectsFromConfig: ()=>createRouteObjectsFromConfig,
|
|
37
|
-
renderRoutes: ()=>renderRoutes,
|
|
38
|
-
getRouteComponents: ()=>getRouteComponents,
|
|
39
37
|
deserializeErrors: ()=>deserializeErrors,
|
|
38
|
+
getLocation: ()=>getLocation,
|
|
39
|
+
getRouteComponents: ()=>getRouteComponents,
|
|
40
40
|
getRouteObjects: ()=>getRouteObjects,
|
|
41
|
-
|
|
42
|
-
urlJoin: ()=>urlJoin,
|
|
41
|
+
renderRoutes: ()=>renderRoutes,
|
|
43
42
|
serializeErrors: ()=>serializeErrors,
|
|
44
|
-
|
|
43
|
+
standardSlash: ()=>standardSlash,
|
|
44
|
+
urlJoin: ()=>urlJoin
|
|
45
45
|
});
|
|
46
46
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
47
47
|
const browser_namespaceObject = require("@modern-js/runtime-utils/browser");
|
package/dist/esm/cli/code.mjs
CHANGED
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import { fs } from "@modern-js/utils";
|
|
2
|
+
import { formatImportPath, fs } from "@modern-js/utils";
|
|
3
3
|
import { ENTRY_BOOTSTRAP_FILE_NAME, ENTRY_POINT_FILE_NAME, ENTRY_POINT_REGISTER_FILE_NAME, ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME, ENTRY_POINT_RUNTIME_REGISTER_FILE_NAME, ENTRY_SERVER_BOOTSTRAP_FILE_NAME, INDEX_FILE_NAME, SERVER_ENTRY_POINT_FILE_NAME } from "./constants.mjs";
|
|
4
4
|
import { resolveSSRMode } from "./ssr/mode.mjs";
|
|
5
5
|
import * as __rspack_external__template_mjs_d6ab8956 from "./template.mjs";
|
|
6
6
|
import * as __rspack_external__template_server_mjs_38d6edb1 from "./template.server.mjs";
|
|
7
|
+
const normalizePreEntry = (preEntry)=>{
|
|
8
|
+
if (!preEntry) return [];
|
|
9
|
+
if (Array.isArray(preEntry)) return preEntry.filter((v)=>'string' == typeof v && v.length > 0);
|
|
10
|
+
if ('string' == typeof preEntry) return preEntry ? [
|
|
11
|
+
preEntry
|
|
12
|
+
] : [];
|
|
13
|
+
return [];
|
|
14
|
+
};
|
|
15
|
+
const resolvePreEntryImportPath = ({ preEntry, appDirectory, srcDirectory, internalSrcAlias })=>{
|
|
16
|
+
const absPath = path.isAbsolute(preEntry) ? preEntry : path.resolve(appDirectory, preEntry);
|
|
17
|
+
if (absPath.startsWith(srcDirectory)) return formatImportPath(absPath.replace(srcDirectory, internalSrcAlias));
|
|
18
|
+
return formatImportPath(absPath);
|
|
19
|
+
};
|
|
7
20
|
const generateCode = async (entrypoints, appContext, config, hooks)=>{
|
|
8
21
|
const { mountId } = config.html;
|
|
9
|
-
const { enableAsyncEntry } = config.source;
|
|
10
|
-
const
|
|
22
|
+
const { enableAsyncEntry, enableAsyncPreEntry, preEntry } = config.source;
|
|
23
|
+
const shouldInjectAsyncPreEntry = !!enableAsyncEntry && !!enableAsyncPreEntry;
|
|
24
|
+
const { appDirectory, runtimeConfigFile, internalDirectory, internalSrcAlias, metaName, srcDirectory, serverRoutes } = appContext;
|
|
11
25
|
await Promise.all(entrypoints.map(async (entrypoint)=>{
|
|
12
26
|
const { entryName, isAutoMount, entry, customEntry, customServerEntry, nestedRoutesEntry } = entrypoint;
|
|
13
27
|
const { plugins: runtimePlugins } = await hooks._internalRuntimePlugins.call({
|
|
@@ -38,6 +52,21 @@ const generateCode = async (entrypoints, appContext, config, hooks)=>{
|
|
|
38
52
|
urlPath: serverRoutes.find((route)=>route.entryName === entryName)?.urlPath,
|
|
39
53
|
isNestedRouter: entrypoint.nestedRoutesEntry
|
|
40
54
|
});
|
|
55
|
+
if (shouldInjectAsyncPreEntry) {
|
|
56
|
+
const preEntries = normalizePreEntry(preEntry);
|
|
57
|
+
if (preEntries.length > 0) {
|
|
58
|
+
const injected = preEntries.map((item)=>{
|
|
59
|
+
const importPath = resolvePreEntryImportPath({
|
|
60
|
+
preEntry: item,
|
|
61
|
+
appDirectory,
|
|
62
|
+
srcDirectory,
|
|
63
|
+
internalSrcAlias
|
|
64
|
+
});
|
|
65
|
+
return `import '${importPath}';`;
|
|
66
|
+
}).join('\n');
|
|
67
|
+
indexCode = `${injected}\n${indexCode}`;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
41
70
|
const indexFile = path.resolve(internalDirectory, `./${entryName}/${ENTRY_POINT_FILE_NAME}`);
|
|
42
71
|
await fs.outputFile(indexFile, indexCode, 'utf8');
|
|
43
72
|
if (enableAsyncEntry) {
|
|
@@ -71,7 +71,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
|
|
|
71
71
|
} else this.push(chunk);
|
|
72
72
|
callback();
|
|
73
73
|
} catch (e) {
|
|
74
|
-
e instanceof Error ? callback(e) : callback(new Error('Received
|
|
74
|
+
e instanceof Error ? callback(e) : callback(new Error('Received unknown error when streaming'));
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
});
|
|
@@ -11,7 +11,7 @@ import DeferredDataScripts_node from "./DeferredDataScripts.node.mjs";
|
|
|
11
11
|
import { modifyRoutes, onBeforeCreateRoutes } from "./hooks.mjs";
|
|
12
12
|
import { RSCStaticRouter, createServerPayload, handleRSCRedirect, prepareRSCRoutes } from "./rsc-router.mjs";
|
|
13
13
|
import { createRouteObjectsFromConfig, renderRoutes, urlJoin } from "./utils.mjs";
|
|
14
|
-
function
|
|
14
|
+
function createRemixRequest(request) {
|
|
15
15
|
const method = 'GET';
|
|
16
16
|
const { headers } = request;
|
|
17
17
|
const controller = new AbortController();
|
|
@@ -59,7 +59,7 @@ const routerPlugin = (userConfig = {})=>({
|
|
|
59
59
|
const { query } = createStaticHandler(routes, {
|
|
60
60
|
basename: _basename
|
|
61
61
|
});
|
|
62
|
-
const remixRequest =
|
|
62
|
+
const remixRequest = createRemixRequest(context.ssrContext.request.raw);
|
|
63
63
|
const end = time();
|
|
64
64
|
const routerContext = await query(remixRequest, {
|
|
65
65
|
requestContext
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import { fs } from "@modern-js/utils";
|
|
3
|
+
import { formatImportPath, fs } from "@modern-js/utils";
|
|
4
4
|
import { ENTRY_BOOTSTRAP_FILE_NAME, ENTRY_POINT_FILE_NAME, ENTRY_POINT_REGISTER_FILE_NAME, ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME, ENTRY_POINT_RUNTIME_REGISTER_FILE_NAME, ENTRY_SERVER_BOOTSTRAP_FILE_NAME, INDEX_FILE_NAME, SERVER_ENTRY_POINT_FILE_NAME } from "./constants.mjs";
|
|
5
5
|
import { resolveSSRMode } from "./ssr/mode.mjs";
|
|
6
6
|
import * as __rspack_external__template_mjs_d6ab8956 from "./template.mjs";
|
|
7
7
|
import * as __rspack_external__template_server_mjs_38d6edb1 from "./template.server.mjs";
|
|
8
|
+
const normalizePreEntry = (preEntry)=>{
|
|
9
|
+
if (!preEntry) return [];
|
|
10
|
+
if (Array.isArray(preEntry)) return preEntry.filter((v)=>'string' == typeof v && v.length > 0);
|
|
11
|
+
if ('string' == typeof preEntry) return preEntry ? [
|
|
12
|
+
preEntry
|
|
13
|
+
] : [];
|
|
14
|
+
return [];
|
|
15
|
+
};
|
|
16
|
+
const resolvePreEntryImportPath = ({ preEntry, appDirectory, srcDirectory, internalSrcAlias })=>{
|
|
17
|
+
const absPath = path.isAbsolute(preEntry) ? preEntry : path.resolve(appDirectory, preEntry);
|
|
18
|
+
if (absPath.startsWith(srcDirectory)) return formatImportPath(absPath.replace(srcDirectory, internalSrcAlias));
|
|
19
|
+
return formatImportPath(absPath);
|
|
20
|
+
};
|
|
8
21
|
const generateCode = async (entrypoints, appContext, config, hooks)=>{
|
|
9
22
|
const { mountId } = config.html;
|
|
10
|
-
const { enableAsyncEntry } = config.source;
|
|
11
|
-
const
|
|
23
|
+
const { enableAsyncEntry, enableAsyncPreEntry, preEntry } = config.source;
|
|
24
|
+
const shouldInjectAsyncPreEntry = !!enableAsyncEntry && !!enableAsyncPreEntry;
|
|
25
|
+
const { appDirectory, runtimeConfigFile, internalDirectory, internalSrcAlias, metaName, srcDirectory, serverRoutes } = appContext;
|
|
12
26
|
await Promise.all(entrypoints.map(async (entrypoint)=>{
|
|
13
27
|
const { entryName, isAutoMount, entry, customEntry, customServerEntry, nestedRoutesEntry } = entrypoint;
|
|
14
28
|
const { plugins: runtimePlugins } = await hooks._internalRuntimePlugins.call({
|
|
@@ -39,6 +53,21 @@ const generateCode = async (entrypoints, appContext, config, hooks)=>{
|
|
|
39
53
|
urlPath: serverRoutes.find((route)=>route.entryName === entryName)?.urlPath,
|
|
40
54
|
isNestedRouter: entrypoint.nestedRoutesEntry
|
|
41
55
|
});
|
|
56
|
+
if (shouldInjectAsyncPreEntry) {
|
|
57
|
+
const preEntries = normalizePreEntry(preEntry);
|
|
58
|
+
if (preEntries.length > 0) {
|
|
59
|
+
const injected = preEntries.map((item)=>{
|
|
60
|
+
const importPath = resolvePreEntryImportPath({
|
|
61
|
+
preEntry: item,
|
|
62
|
+
appDirectory,
|
|
63
|
+
srcDirectory,
|
|
64
|
+
internalSrcAlias
|
|
65
|
+
});
|
|
66
|
+
return `import '${importPath}';`;
|
|
67
|
+
}).join('\n');
|
|
68
|
+
indexCode = `${injected}\n${indexCode}`;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
42
71
|
const indexFile = path.resolve(internalDirectory, `./${entryName}/${ENTRY_POINT_FILE_NAME}`);
|
|
43
72
|
await fs.outputFile(indexFile, indexCode, 'utf8');
|
|
44
73
|
if (enableAsyncEntry) {
|
|
@@ -72,7 +72,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
|
|
|
72
72
|
} else this.push(chunk);
|
|
73
73
|
callback();
|
|
74
74
|
} catch (e) {
|
|
75
|
-
e instanceof Error ? callback(e) : callback(new Error('Received
|
|
75
|
+
e instanceof Error ? callback(e) : callback(new Error('Received unknown error when streaming'));
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
});
|
|
@@ -12,7 +12,7 @@ import DeferredDataScripts_node from "./DeferredDataScripts.node.mjs";
|
|
|
12
12
|
import { modifyRoutes, onBeforeCreateRoutes } from "./hooks.mjs";
|
|
13
13
|
import { RSCStaticRouter, createServerPayload, handleRSCRedirect, prepareRSCRoutes } from "./rsc-router.mjs";
|
|
14
14
|
import { createRouteObjectsFromConfig, renderRoutes, urlJoin } from "./utils.mjs";
|
|
15
|
-
function
|
|
15
|
+
function createRemixRequest(request) {
|
|
16
16
|
const method = 'GET';
|
|
17
17
|
const { headers } = request;
|
|
18
18
|
const controller = new AbortController();
|
|
@@ -60,7 +60,7 @@ const routerPlugin = (userConfig = {})=>({
|
|
|
60
60
|
const { query } = createStaticHandler(routes, {
|
|
61
61
|
basename: _basename
|
|
62
62
|
});
|
|
63
|
-
const remixRequest =
|
|
63
|
+
const remixRequest = createRemixRequest(context.ssrContext.request.raw);
|
|
64
64
|
const end = time();
|
|
65
65
|
const routerContext = await query(remixRequest, {
|
|
66
66
|
requestContext
|
|
@@ -30,7 +30,7 @@ export declare const resolveFnStr = "function r(e,r,o,A){A?_ROUTER_DATA.r[e][r].
|
|
|
30
30
|
/**
|
|
31
31
|
* update data for pre resolved promises
|
|
32
32
|
* original function:
|
|
33
|
-
* function
|
|
33
|
+
* function preResolvedDeferredPromise(data, error) {
|
|
34
34
|
if(typeof error !== 'undefined'){
|
|
35
35
|
return Promise.reject(new Error(error.message));
|
|
36
36
|
}else{
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "3.
|
|
18
|
+
"version": "3.2.0",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=20"
|
|
21
21
|
},
|
|
@@ -204,8 +204,8 @@
|
|
|
204
204
|
"@loadable/component": "5.16.7",
|
|
205
205
|
"@loadable/server": "5.16.7",
|
|
206
206
|
"@swc/helpers": "^0.5.17",
|
|
207
|
-
"@swc/core": "1.15.
|
|
208
|
-
"@swc/plugin-loadable-components": "^11.
|
|
207
|
+
"@swc/core": "1.15.33",
|
|
208
|
+
"@swc/plugin-loadable-components": "^11.9.0",
|
|
209
209
|
"@types/loadable__component": "^5.13.10",
|
|
210
210
|
"@types/react-helmet": "^6.1.11",
|
|
211
211
|
"cookie": "0.7.2",
|
|
@@ -215,12 +215,12 @@
|
|
|
215
215
|
"isbot": "3.8.0",
|
|
216
216
|
"react-helmet": "^6.1.0",
|
|
217
217
|
"react-is": "^18.3.1",
|
|
218
|
-
"@modern-js/
|
|
219
|
-
"@modern-js/plugin": "3.
|
|
220
|
-
"@modern-js/
|
|
221
|
-
"@modern-js/runtime-utils": "3.
|
|
222
|
-
"@modern-js/types": "3.
|
|
223
|
-
"@modern-js/utils": "3.
|
|
218
|
+
"@modern-js/plugin": "3.2.0",
|
|
219
|
+
"@modern-js/plugin-data-loader": "3.2.0",
|
|
220
|
+
"@modern-js/render": "3.2.0",
|
|
221
|
+
"@modern-js/runtime-utils": "3.2.0",
|
|
222
|
+
"@modern-js/types": "3.2.0",
|
|
223
|
+
"@modern-js/utils": "3.2.0"
|
|
224
224
|
},
|
|
225
225
|
"peerDependencies": {
|
|
226
226
|
"react": ">=17.0.2",
|
|
@@ -229,20 +229,20 @@
|
|
|
229
229
|
"devDependencies": {
|
|
230
230
|
"@remix-run/web-fetch": "^4.1.3",
|
|
231
231
|
"@rsbuild/core": "2.0.0",
|
|
232
|
-
"@rslib/core": "0.21.
|
|
232
|
+
"@rslib/core": "0.21.4",
|
|
233
233
|
"@testing-library/dom": "^10.4.1",
|
|
234
234
|
"@testing-library/react": "^16.3.2",
|
|
235
235
|
"@types/cookie": "0.6.0",
|
|
236
236
|
"@types/invariant": "^2.2.37",
|
|
237
237
|
"@types/loadable__server": "5.12.11",
|
|
238
238
|
"@types/node": "^20",
|
|
239
|
-
"react": "^19.2.
|
|
240
|
-
"react-dom": "^19.2.
|
|
239
|
+
"react": "^19.2.6",
|
|
240
|
+
"react-dom": "^19.2.6",
|
|
241
241
|
"ts-node": "^10.9.2",
|
|
242
242
|
"typescript": "^5",
|
|
243
|
+
"@modern-js/app-tools": "3.2.0",
|
|
243
244
|
"@modern-js/rslib": "2.68.10",
|
|
244
|
-
"@scripts/rstest-config": "2.66.0"
|
|
245
|
-
"@modern-js/app-tools": "3.1.5"
|
|
245
|
+
"@scripts/rstest-config": "2.66.0"
|
|
246
246
|
},
|
|
247
247
|
"sideEffects": false,
|
|
248
248
|
"publishConfig": {
|