@modern-js/server-core 3.0.0-alpha.0 → 3.0.0-alpha.2
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/adapters/node/plugins/resource.js +9 -10
- package/dist/cjs/index.js +18 -10
- package/dist/cjs/plugins/render/render.js +1 -1
- package/dist/esm/adapters/node/helper/index.mjs +5 -5
- package/dist/esm/adapters/node/hono.mjs +1 -1
- package/dist/esm/adapters/node/index.mjs +4 -4
- package/dist/esm/adapters/node/node.mjs +1 -1
- package/dist/esm/adapters/node/plugins/index.mjs +3 -3
- package/dist/esm/adapters/node/plugins/resource.mjs +10 -11
- package/dist/esm/adapters/node/plugins/static.mjs +2 -2
- package/dist/esm/context.mjs +1 -1
- package/dist/esm/index.mjs +12 -12
- package/dist/esm/plugins/compat/index.mjs +1 -1
- package/dist/esm/plugins/default.mjs +6 -6
- package/dist/esm/plugins/index.mjs +8 -8
- package/dist/esm/plugins/log.mjs +1 -1
- package/dist/esm/plugins/monitors.mjs +1 -1
- package/dist/esm/plugins/render/csrRscRender.mjs +1 -1
- package/dist/esm/plugins/render/index.mjs +4 -4
- package/dist/esm/plugins/render/inject.mjs +1 -1
- package/dist/esm/plugins/render/render.mjs +8 -8
- package/dist/esm/plugins/render/renderRscHandler.mjs +1 -1
- package/dist/esm/plugins/render/ssrCache.mjs +2 -2
- package/dist/esm/plugins/render/ssrRender.mjs +4 -4
- package/dist/esm/plugins/route.mjs +1 -1
- package/dist/esm/serverBase.mjs +3 -3
- package/dist/esm/types/config/index.mjs +6 -6
- package/dist/esm/types/index.mjs +4 -4
- package/dist/esm/types/plugins/index.mjs +1 -1
- package/dist/esm/utils/error.mjs +1 -1
- package/dist/esm/utils/index.mjs +9 -9
- package/dist/esm-node/adapters/node/helper/index.mjs +2 -0
- package/dist/esm-node/adapters/node/helper/loadCache.mjs +2 -0
- package/dist/esm-node/adapters/node/helper/loadConfig.mjs +2 -0
- package/dist/esm-node/adapters/node/helper/loadEnv.mjs +2 -0
- package/dist/esm-node/adapters/node/helper/loadPlugin.mjs +2 -0
- package/dist/esm-node/adapters/node/helper/utils.mjs +2 -0
- package/dist/esm-node/adapters/node/hono.mjs +2 -0
- package/dist/esm-node/adapters/node/index.mjs +2 -0
- package/dist/esm-node/adapters/node/node.mjs +2 -0
- package/dist/esm-node/adapters/node/plugins/index.mjs +2 -0
- package/dist/esm-node/adapters/node/plugins/nodeServer.mjs +2 -0
- package/dist/esm-node/adapters/node/plugins/resource.mjs +11 -10
- package/dist/esm-node/adapters/node/plugins/static.mjs +2 -0
- package/dist/esm-node/constants.mjs +2 -0
- package/dist/esm-node/context.mjs +2 -0
- package/dist/esm-node/helper.mjs +2 -0
- package/dist/esm-node/hono.mjs +2 -0
- package/dist/esm-node/index.mjs +4 -2
- package/dist/esm-node/plugins/compat/hooks.mjs +2 -0
- package/dist/esm-node/plugins/compat/index.mjs +2 -0
- package/dist/esm-node/plugins/default.mjs +2 -0
- package/dist/esm-node/plugins/favicon.mjs +2 -0
- package/dist/esm-node/plugins/index.mjs +2 -0
- package/dist/esm-node/plugins/log.mjs +2 -0
- package/dist/esm-node/plugins/middlewares.mjs +2 -0
- package/dist/esm-node/plugins/monitors.mjs +2 -0
- package/dist/esm-node/plugins/processedBy.mjs +2 -0
- package/dist/esm-node/plugins/render/csrRscRender.mjs +2 -0
- package/dist/esm-node/plugins/render/dataHandler.mjs +2 -0
- package/dist/esm-node/plugins/render/index.mjs +2 -0
- package/dist/esm-node/plugins/render/inject.mjs +2 -0
- package/dist/esm-node/plugins/render/render.mjs +3 -1
- package/dist/esm-node/plugins/render/renderRscHandler.mjs +2 -0
- package/dist/esm-node/plugins/render/serverActionHandler.mjs +2 -0
- package/dist/esm-node/plugins/render/ssrCache.mjs +2 -0
- package/dist/esm-node/plugins/render/ssrRender.mjs +2 -0
- package/dist/esm-node/plugins/render/utils.mjs +2 -0
- package/dist/esm-node/plugins/route.mjs +2 -0
- package/dist/esm-node/serverBase.mjs +2 -0
- package/dist/esm-node/types/config/bff.mjs +2 -0
- package/dist/esm-node/types/config/dev.mjs +2 -0
- package/dist/esm-node/types/config/html.mjs +2 -0
- package/dist/esm-node/types/config/index.mjs +2 -0
- package/dist/esm-node/types/config/output.mjs +2 -0
- package/dist/esm-node/types/config/security.mjs +2 -0
- package/dist/esm-node/types/config/server.mjs +2 -0
- package/dist/esm-node/types/config/share.mjs +2 -0
- package/dist/esm-node/types/config/source.mjs +2 -0
- package/dist/esm-node/types/config/tools.mjs +2 -0
- package/dist/esm-node/types/index.mjs +2 -0
- package/dist/esm-node/types/plugins/base.mjs +2 -0
- package/dist/esm-node/types/plugins/index.mjs +2 -0
- package/dist/esm-node/types/plugins/plugin.mjs +2 -0
- package/dist/esm-node/types/render.mjs +2 -0
- package/dist/esm-node/types/requestHandler.mjs +2 -0
- package/dist/esm-node/types/server.mjs +2 -0
- package/dist/esm-node/utils/entry.mjs +2 -0
- package/dist/esm-node/utils/env.mjs +2 -0
- package/dist/esm-node/utils/error.mjs +2 -0
- package/dist/esm-node/utils/index.mjs +2 -0
- package/dist/esm-node/utils/middlewareCollector.mjs +2 -0
- package/dist/esm-node/utils/publicDir.mjs +2 -0
- package/dist/esm-node/utils/request.mjs +2 -0
- package/dist/esm-node/utils/serverConfig.mjs +2 -0
- package/dist/esm-node/utils/storage.mjs +2 -0
- package/dist/esm-node/utils/transformStream.mjs +2 -0
- package/dist/esm-node/utils/warmup.mjs +2 -0
- package/dist/types/adapters/node/plugins/resource.d.ts +3 -3
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types/config/server.d.ts +1 -1
- package/dist/types/types/config/tools.d.ts +1 -7
- package/package.json +22 -13
|
@@ -73,25 +73,25 @@ function injectTemplates(pwd, routes, htmlTemplatePromise) {
|
|
|
73
73
|
await next();
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
const loadBundle = async (filepath,
|
|
76
|
+
const loadBundle = async (filepath, monitors)=>{
|
|
77
77
|
if (!await utils_namespaceObject.fs.pathExists(filepath)) return;
|
|
78
78
|
try {
|
|
79
79
|
const module = await (0, utils_namespaceObject.compatibleRequire)(filepath, false);
|
|
80
80
|
return module;
|
|
81
81
|
} catch (e) {
|
|
82
|
-
|
|
82
|
+
monitors.error(`Load ${filepath} bundle failed, error = %s`, e instanceof Error ? e.stack || e.message : e);
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
|
-
async function getServerManifest(pwd, routes,
|
|
86
|
+
async function getServerManifest(pwd, routes, monitors) {
|
|
87
87
|
const loaderBundles = {};
|
|
88
88
|
const renderBundles = {};
|
|
89
89
|
await Promise.all(routes.filter((route)=>Boolean(route.bundle)).map(async (route)=>{
|
|
90
90
|
const entryName = route.entryName || utils_namespaceObject.MAIN_ENTRY_NAME;
|
|
91
91
|
const renderBundlePath = external_path_default().join(pwd, route.bundle || '');
|
|
92
92
|
const loaderBundlePath = external_path_default().join(pwd, utils_namespaceObject.SERVER_BUNDLE_DIRECTORY, `${entryName}-server-loaders.js`);
|
|
93
|
-
const renderBundle = await loadBundle(renderBundlePath,
|
|
94
|
-
const loaderBundle = await loadBundle(loaderBundlePath,
|
|
93
|
+
const renderBundle = await loadBundle(renderBundlePath, monitors);
|
|
94
|
+
const loaderBundle = await loadBundle(loaderBundlePath, monitors);
|
|
95
95
|
renderBundle && (renderBundles[entryName] = renderBundle);
|
|
96
96
|
loaderBundle && (loaderBundles[entryName] = loaderBundle?.loadModules ? await loaderBundle?.loadModules() : loaderBundle);
|
|
97
97
|
}));
|
|
@@ -112,8 +112,8 @@ async function getServerManifest(pwd, routes, logger) {
|
|
|
112
112
|
function injectServerManifest(pwd, routes, manifestPromise) {
|
|
113
113
|
return async (c, next)=>{
|
|
114
114
|
if (routes && !c.get('serverManifest')) {
|
|
115
|
-
const
|
|
116
|
-
const serverManifest = await (manifestPromise || getServerManifest(pwd, routes,
|
|
115
|
+
const monitors = c.get('monitors');
|
|
116
|
+
const serverManifest = await (manifestPromise || getServerManifest(pwd, routes, monitors));
|
|
117
117
|
c.set('serverManifest', serverManifest);
|
|
118
118
|
}
|
|
119
119
|
await next();
|
|
@@ -131,13 +131,12 @@ async function getRscSSRManifest(pwd) {
|
|
|
131
131
|
const rscSSRManifest = await (0, utils_namespaceObject.compatibleRequire)(external_path_default().join(pwd, 'react-ssr-manifest.json')).catch((_)=>void 0);
|
|
132
132
|
return rscSSRManifest;
|
|
133
133
|
}
|
|
134
|
-
const injectRscManifestPlugin = ()=>({
|
|
134
|
+
const injectRscManifestPlugin = (enableRsc)=>({
|
|
135
135
|
name: '@modern-js/plugin-inject-rsc-manifest',
|
|
136
136
|
setup (api) {
|
|
137
137
|
api.onPrepare(()=>{
|
|
138
138
|
const { middlewares, distDirectory: pwd } = api.getServerContext();
|
|
139
|
-
|
|
140
|
-
if (!config.server?.rsc) return;
|
|
139
|
+
if (!enableRsc) return;
|
|
141
140
|
middlewares.push({
|
|
142
141
|
name: 'inject-rsc-manifest',
|
|
143
142
|
handler: async (c, next)=>{
|
package/dist/cjs/index.js
CHANGED
|
@@ -94,6 +94,7 @@ var __webpack_exports__ = {};
|
|
|
94
94
|
normalizePublicDirPath: ()=>_utils_publicDir__rspack_import_1.normalizePublicDirPath,
|
|
95
95
|
onError: ()=>_utils__rspack_import_0.onError,
|
|
96
96
|
resolvePublicDirPaths: ()=>_utils_publicDir__rspack_import_1.resolvePublicDirPaths,
|
|
97
|
+
run: ()=>_context__rspack_import_4.run,
|
|
97
98
|
useHonoContext: ()=>_context__rspack_import_4.useHonoContext
|
|
98
99
|
});
|
|
99
100
|
var _utils__rspack_import_0 = __webpack_require__("./utils");
|
|
@@ -116,10 +117,11 @@ var __webpack_exports__ = {};
|
|
|
116
117
|
"normalizePublicDirPath",
|
|
117
118
|
"onError",
|
|
118
119
|
"ErrorDigest",
|
|
119
|
-
"getLoaderCtx",
|
|
120
|
-
"getPublicDirRoutePrefixes",
|
|
121
120
|
"getPublicDirPatterns",
|
|
121
|
+
"getPublicDirRoutePrefixes",
|
|
122
122
|
"getPublicDirConfig",
|
|
123
|
+
"getLoaderCtx",
|
|
124
|
+
"run",
|
|
123
125
|
"AGGRED_DIR"
|
|
124
126
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_plugins__rspack_import_7[__rspack_import_key];
|
|
125
127
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
@@ -136,10 +138,11 @@ var __webpack_exports__ = {};
|
|
|
136
138
|
"normalizePublicDirPath",
|
|
137
139
|
"onError",
|
|
138
140
|
"ErrorDigest",
|
|
139
|
-
"getLoaderCtx",
|
|
140
|
-
"getPublicDirRoutePrefixes",
|
|
141
141
|
"getPublicDirPatterns",
|
|
142
|
+
"getPublicDirRoutePrefixes",
|
|
142
143
|
"getPublicDirConfig",
|
|
144
|
+
"getLoaderCtx",
|
|
145
|
+
"run",
|
|
143
146
|
"AGGRED_DIR"
|
|
144
147
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_types_plugins__rspack_import_8[__rspack_import_key];
|
|
145
148
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
@@ -156,10 +159,11 @@ var __webpack_exports__ = {};
|
|
|
156
159
|
"normalizePublicDirPath",
|
|
157
160
|
"onError",
|
|
158
161
|
"ErrorDigest",
|
|
159
|
-
"getLoaderCtx",
|
|
160
|
-
"getPublicDirRoutePrefixes",
|
|
161
162
|
"getPublicDirPatterns",
|
|
163
|
+
"getPublicDirRoutePrefixes",
|
|
162
164
|
"getPublicDirConfig",
|
|
165
|
+
"getLoaderCtx",
|
|
166
|
+
"run",
|
|
163
167
|
"AGGRED_DIR"
|
|
164
168
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_types_render__rspack_import_9[__rspack_import_key];
|
|
165
169
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
@@ -176,10 +180,11 @@ var __webpack_exports__ = {};
|
|
|
176
180
|
"normalizePublicDirPath",
|
|
177
181
|
"onError",
|
|
178
182
|
"ErrorDigest",
|
|
179
|
-
"getLoaderCtx",
|
|
180
|
-
"getPublicDirRoutePrefixes",
|
|
181
183
|
"getPublicDirPatterns",
|
|
184
|
+
"getPublicDirRoutePrefixes",
|
|
182
185
|
"getPublicDirConfig",
|
|
186
|
+
"getLoaderCtx",
|
|
187
|
+
"run",
|
|
183
188
|
"AGGRED_DIR"
|
|
184
189
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_types_config__rspack_import_10[__rspack_import_key];
|
|
185
190
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
@@ -196,10 +201,11 @@ var __webpack_exports__ = {};
|
|
|
196
201
|
"normalizePublicDirPath",
|
|
197
202
|
"onError",
|
|
198
203
|
"ErrorDigest",
|
|
199
|
-
"getLoaderCtx",
|
|
200
|
-
"getPublicDirRoutePrefixes",
|
|
201
204
|
"getPublicDirPatterns",
|
|
205
|
+
"getPublicDirRoutePrefixes",
|
|
202
206
|
"getPublicDirConfig",
|
|
207
|
+
"getLoaderCtx",
|
|
208
|
+
"run",
|
|
203
209
|
"AGGRED_DIR"
|
|
204
210
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_types_requestHandler__rspack_import_11[__rspack_import_key];
|
|
205
211
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
@@ -217,6 +223,7 @@ exports.normalizePublicDir = __webpack_exports__.normalizePublicDir;
|
|
|
217
223
|
exports.normalizePublicDirPath = __webpack_exports__.normalizePublicDirPath;
|
|
218
224
|
exports.onError = __webpack_exports__.onError;
|
|
219
225
|
exports.resolvePublicDirPaths = __webpack_exports__.resolvePublicDirPaths;
|
|
226
|
+
exports.run = __webpack_exports__.run;
|
|
220
227
|
exports.useHonoContext = __webpack_exports__.useHonoContext;
|
|
221
228
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
222
229
|
"AGGRED_DIR",
|
|
@@ -232,6 +239,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
232
239
|
"normalizePublicDirPath",
|
|
233
240
|
"onError",
|
|
234
241
|
"resolvePublicDirPaths",
|
|
242
|
+
"run",
|
|
235
243
|
"useHonoContext"
|
|
236
244
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
237
245
|
Object.defineProperty(exports, '__esModule', {
|
|
@@ -241,7 +241,7 @@ var __webpack_exports__ = {};
|
|
|
241
241
|
}
|
|
242
242
|
async function csrRender(request, options) {
|
|
243
243
|
const { html, rscClientManifest } = options;
|
|
244
|
-
if (!rscClientManifest || process.env.MODERN_DISABLE_INJECT_RSC_DATA) return new Response(html, {
|
|
244
|
+
if (!rscClientManifest || process.env.MODERN_DISABLE_INJECT_RSC_DATA || !options.routeInfo.isRSC) return new Response(html, {
|
|
245
245
|
status: 200,
|
|
246
246
|
headers: new Headers({
|
|
247
247
|
'content-type': 'text/html; charset=UTF-8',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { loadServerEnv } from "./loadEnv";
|
|
2
|
-
import { loadServerPlugins } from "./loadPlugin";
|
|
3
|
-
import { loadServerCliConfig, loadServerRuntimeConfig } from "./loadConfig";
|
|
4
|
-
import { loadCacheConfig } from "./loadCache";
|
|
5
|
-
import { isResFinalized } from "./utils";
|
|
1
|
+
import { loadServerEnv } from "./loadEnv.mjs";
|
|
2
|
+
import { loadServerPlugins } from "./loadPlugin.mjs";
|
|
3
|
+
import { loadServerCliConfig, loadServerRuntimeConfig } from "./loadConfig.mjs";
|
|
4
|
+
import { loadCacheConfig } from "./loadCache.mjs";
|
|
5
|
+
import { isResFinalized } from "./utils.mjs";
|
|
6
6
|
export { isResFinalized, loadCacheConfig, loadServerCliConfig, loadServerEnv, loadServerPlugins, loadServerRuntimeConfig };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { connectMid2HonoMid, connectMockMid2HonoMid, httpCallBack2HonoMid } from "./hono";
|
|
2
|
-
import { createNodeServer, createWebRequest, sendResponse } from "./node";
|
|
3
|
-
import { getHtmlTemplates, getServerManifest, injectNodeSeverPlugin, injectResourcePlugin, injectRscManifestPlugin, serverStaticPlugin } from "./plugins";
|
|
4
|
-
import { loadCacheConfig, loadServerCliConfig, loadServerEnv, loadServerPlugins, loadServerRuntimeConfig } from "./helper";
|
|
1
|
+
import { connectMid2HonoMid, connectMockMid2HonoMid, httpCallBack2HonoMid } from "./hono.mjs";
|
|
2
|
+
import { createNodeServer, createWebRequest, sendResponse } from "./node.mjs";
|
|
3
|
+
import { getHtmlTemplates, getServerManifest, injectNodeSeverPlugin, injectResourcePlugin, injectRscManifestPlugin, serverStaticPlugin } from "./plugins/index.mjs";
|
|
4
|
+
import { loadCacheConfig, loadServerCliConfig, loadServerEnv, loadServerPlugins, loadServerRuntimeConfig } from "./helper/index.mjs";
|
|
5
5
|
export { connectMid2HonoMid, connectMockMid2HonoMid, createNodeServer, createWebRequest, getHtmlTemplates, getServerManifest, httpCallBack2HonoMid, injectNodeSeverPlugin, injectResourcePlugin, injectRscManifestPlugin, loadCacheConfig, loadServerCliConfig, loadServerEnv, loadServerPlugins, loadServerRuntimeConfig, sendResponse, serverStaticPlugin };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ServerResponse } from "node:http";
|
|
2
2
|
import { Readable, Writable } from "node:stream";
|
|
3
3
|
import cloneable_readable from "cloneable-readable";
|
|
4
|
-
import { isResFinalized } from "./helper";
|
|
4
|
+
import { isResFinalized } from "./helper/index.mjs";
|
|
5
5
|
const createWebRequest = (req, res, body)=>{
|
|
6
6
|
const headerRecord = [];
|
|
7
7
|
for (const [key, value] of Object.entries(req.headers))if (!key.startsWith(':')) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./static";
|
|
2
|
-
export * from "./resource";
|
|
3
|
-
export * from "./nodeServer";
|
|
1
|
+
export * from "./static.mjs";
|
|
2
|
+
export * from "./resource.mjs";
|
|
3
|
+
export * from "./nodeServer.mjs";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { fileReader } from "@modern-js/runtime-utils/fileReader";
|
|
3
3
|
import { LOADABLE_STATS_FILE, MAIN_ENTRY_NAME, NESTED_ROUTE_SPEC_FILE, ROUTE_MANIFEST_FILE, SERVER_BUNDLE_DIRECTORY, compatibleRequire, fs, isProd } from "@modern-js/utils";
|
|
4
|
-
import { uniqueKeyByRoute } from "../../../utils";
|
|
4
|
+
import { uniqueKeyByRoute } from "../../../utils/index.mjs";
|
|
5
5
|
async function getHtmlTemplates(pwd, routes) {
|
|
6
6
|
const htmlRoutes = routes.filter((route)=>route.entryName);
|
|
7
7
|
const htmls = await Promise.all(htmlRoutes.map(async (route)=>{
|
|
@@ -27,25 +27,25 @@ function injectTemplates(pwd, routes, htmlTemplatePromise) {
|
|
|
27
27
|
await next();
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
const loadBundle = async (filepath,
|
|
30
|
+
const loadBundle = async (filepath, monitors)=>{
|
|
31
31
|
if (!await fs.pathExists(filepath)) return;
|
|
32
32
|
try {
|
|
33
33
|
const module = await compatibleRequire(filepath, false);
|
|
34
34
|
return module;
|
|
35
35
|
} catch (e) {
|
|
36
|
-
|
|
36
|
+
monitors.error(`Load ${filepath} bundle failed, error = %s`, e instanceof Error ? e.stack || e.message : e);
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
-
async function getServerManifest(pwd, routes,
|
|
40
|
+
async function getServerManifest(pwd, routes, monitors) {
|
|
41
41
|
const loaderBundles = {};
|
|
42
42
|
const renderBundles = {};
|
|
43
43
|
await Promise.all(routes.filter((route)=>Boolean(route.bundle)).map(async (route)=>{
|
|
44
44
|
const entryName = route.entryName || MAIN_ENTRY_NAME;
|
|
45
45
|
const renderBundlePath = path.join(pwd, route.bundle || '');
|
|
46
46
|
const loaderBundlePath = path.join(pwd, SERVER_BUNDLE_DIRECTORY, `${entryName}-server-loaders.js`);
|
|
47
|
-
const renderBundle = await loadBundle(renderBundlePath,
|
|
48
|
-
const loaderBundle = await loadBundle(loaderBundlePath,
|
|
47
|
+
const renderBundle = await loadBundle(renderBundlePath, monitors);
|
|
48
|
+
const loaderBundle = await loadBundle(loaderBundlePath, monitors);
|
|
49
49
|
renderBundle && (renderBundles[entryName] = renderBundle);
|
|
50
50
|
loaderBundle && (loaderBundles[entryName] = loaderBundle?.loadModules ? await loaderBundle?.loadModules() : loaderBundle);
|
|
51
51
|
}));
|
|
@@ -66,8 +66,8 @@ async function getServerManifest(pwd, routes, logger) {
|
|
|
66
66
|
function injectServerManifest(pwd, routes, manifestPromise) {
|
|
67
67
|
return async (c, next)=>{
|
|
68
68
|
if (routes && !c.get('serverManifest')) {
|
|
69
|
-
const
|
|
70
|
-
const serverManifest = await (manifestPromise || getServerManifest(pwd, routes,
|
|
69
|
+
const monitors = c.get('monitors');
|
|
70
|
+
const serverManifest = await (manifestPromise || getServerManifest(pwd, routes, monitors));
|
|
71
71
|
c.set('serverManifest', serverManifest);
|
|
72
72
|
}
|
|
73
73
|
await next();
|
|
@@ -85,13 +85,12 @@ async function getRscSSRManifest(pwd) {
|
|
|
85
85
|
const rscSSRManifest = await compatibleRequire(path.join(pwd, 'react-ssr-manifest.json')).catch((_)=>void 0);
|
|
86
86
|
return rscSSRManifest;
|
|
87
87
|
}
|
|
88
|
-
const injectRscManifestPlugin = ()=>({
|
|
88
|
+
const injectRscManifestPlugin = (enableRsc)=>({
|
|
89
89
|
name: '@modern-js/plugin-inject-rsc-manifest',
|
|
90
90
|
setup (api) {
|
|
91
91
|
api.onPrepare(()=>{
|
|
92
92
|
const { middlewares, distDirectory: pwd } = api.getServerContext();
|
|
93
|
-
|
|
94
|
-
if (!config.server?.rsc) return;
|
|
93
|
+
if (!enableRsc) return;
|
|
95
94
|
middlewares.push({
|
|
96
95
|
name: 'inject-rsc-manifest',
|
|
97
96
|
handler: async (c, next)=>{
|
|
@@ -2,8 +2,8 @@ import path from "path";
|
|
|
2
2
|
import { fileReader } from "@modern-js/runtime-utils/fileReader";
|
|
3
3
|
import { fs } from "@modern-js/utils";
|
|
4
4
|
import { getMimeType } from "hono/utils/mime";
|
|
5
|
-
import { sortRoutes } from "../../../utils";
|
|
6
|
-
import { getPublicDirPatterns } from "../../../utils/publicDir";
|
|
5
|
+
import { sortRoutes } from "../../../utils/index.mjs";
|
|
6
|
+
import { getPublicDirPatterns } from "../../../utils/publicDir.mjs";
|
|
7
7
|
const serverStaticPlugin = ()=>({
|
|
8
8
|
name: '@modern-js/plugin-server-static',
|
|
9
9
|
setup (api) {
|
package/dist/esm/context.mjs
CHANGED
package/dist/esm/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ErrorDigest, createErrorHtml, onError } from "./utils";
|
|
2
|
-
import { getPublicDirConfig, getPublicDirPatterns, getPublicDirRoutePrefixes, normalizePublicDir, normalizePublicDirPath, resolvePublicDirPaths } from "./utils/publicDir";
|
|
3
|
-
import { AGGRED_DIR } from "./constants";
|
|
4
|
-
import { createServerBase } from "./serverBase";
|
|
5
|
-
import { useHonoContext } from "./context";
|
|
1
|
+
import { ErrorDigest, createErrorHtml, onError } from "./utils/index.mjs";
|
|
2
|
+
import { getPublicDirConfig, getPublicDirPatterns, getPublicDirRoutePrefixes, normalizePublicDir, normalizePublicDirPath, resolvePublicDirPaths } from "./utils/publicDir.mjs";
|
|
3
|
+
import { AGGRED_DIR } from "./constants.mjs";
|
|
4
|
+
import { createServerBase } from "./serverBase.mjs";
|
|
5
|
+
import { run, useHonoContext } from "./context.mjs";
|
|
6
6
|
import { Hono } from "hono";
|
|
7
|
-
import { getLoaderCtx } from "./helper";
|
|
8
|
-
export * from "./plugins";
|
|
9
|
-
export * from "./types/plugins";
|
|
10
|
-
export * from "./types/render";
|
|
11
|
-
export * from "./types/config";
|
|
12
|
-
export * from "./types/requestHandler";
|
|
13
|
-
export { AGGRED_DIR, ErrorDigest, Hono, createErrorHtml, createServerBase, getLoaderCtx, getPublicDirConfig, getPublicDirPatterns, getPublicDirRoutePrefixes, normalizePublicDir, normalizePublicDirPath, onError, resolvePublicDirPaths, useHonoContext };
|
|
7
|
+
import { getLoaderCtx } from "./helper.mjs";
|
|
8
|
+
export * from "./plugins/index.mjs";
|
|
9
|
+
export * from "./types/plugins/index.mjs";
|
|
10
|
+
export * from "./types/render.mjs";
|
|
11
|
+
export * from "./types/config/index.mjs";
|
|
12
|
+
export * from "./types/requestHandler.mjs";
|
|
13
|
+
export { AGGRED_DIR, ErrorDigest, Hono, createErrorHtml, createServerBase, getLoaderCtx, getPublicDirConfig, getPublicDirPatterns, getPublicDirRoutePrefixes, normalizePublicDir, normalizePublicDirPath, onError, resolvePublicDirPaths, run, useHonoContext };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createAsyncHook, createAsyncPipelineHook } from "@modern-js/plugin";
|
|
2
|
-
import { getHookRunners, handleSetupResult } from "./hooks";
|
|
2
|
+
import { getHookRunners, handleSetupResult } from "./hooks.mjs";
|
|
3
3
|
const compatPlugin = ()=>({
|
|
4
4
|
name: '@modern-js/server-compat',
|
|
5
5
|
registryHooks: {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { compatPlugin } from "./compat";
|
|
2
|
-
import { logPlugin } from "./log";
|
|
3
|
-
import { initMonitorsPlugin, injectServerTiming, injectloggerPlugin } from "./monitors";
|
|
4
|
-
import { processedByPlugin } from "./processedBy";
|
|
5
|
-
import { injectRenderHandlerPlugin } from "./render";
|
|
6
|
-
import { injectRoutePlugin } from "./route";
|
|
1
|
+
import { compatPlugin } from "./compat/index.mjs";
|
|
2
|
+
import { logPlugin } from "./log.mjs";
|
|
3
|
+
import { initMonitorsPlugin, injectServerTiming, injectloggerPlugin } from "./monitors.mjs";
|
|
4
|
+
import { processedByPlugin } from "./processedBy.mjs";
|
|
5
|
+
import { injectRenderHandlerPlugin } from "./render/index.mjs";
|
|
6
|
+
import { injectRoutePlugin } from "./route.mjs";
|
|
7
7
|
function createSilenceLogger() {
|
|
8
8
|
return new Proxy({}, {
|
|
9
9
|
get: ()=>()=>{}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getRenderHandler, injectRenderHandlerPlugin, renderPlugin } from "./render";
|
|
2
|
-
import { faviconPlugin } from "./favicon";
|
|
3
|
-
import { injectServerTiming, injectloggerPlugin } from "./monitors";
|
|
4
|
-
import { processedByPlugin } from "./processedBy";
|
|
5
|
-
import { logPlugin } from "./log";
|
|
6
|
-
import { createDefaultPlugins } from "./default";
|
|
7
|
-
import { compatPlugin, handleSetupResult } from "./compat";
|
|
8
|
-
import { injectConfigMiddlewarePlugin } from "./middlewares";
|
|
1
|
+
import { getRenderHandler, injectRenderHandlerPlugin, renderPlugin } from "./render/index.mjs";
|
|
2
|
+
import { faviconPlugin } from "./favicon.mjs";
|
|
3
|
+
import { injectServerTiming, injectloggerPlugin } from "./monitors.mjs";
|
|
4
|
+
import { processedByPlugin } from "./processedBy.mjs";
|
|
5
|
+
import { logPlugin } from "./log.mjs";
|
|
6
|
+
import { createDefaultPlugins } from "./default.mjs";
|
|
7
|
+
import { compatPlugin, handleSetupResult } from "./compat/index.mjs";
|
|
8
|
+
import { injectConfigMiddlewarePlugin } from "./middlewares.mjs";
|
|
9
9
|
export { compatPlugin, createDefaultPlugins, faviconPlugin, getRenderHandler, handleSetupResult, injectConfigMiddlewarePlugin, injectRenderHandlerPlugin, injectServerTiming, injectloggerPlugin, logPlugin, processedByPlugin, renderPlugin };
|
package/dist/esm/plugins/log.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { time } from "@modern-js/runtime-utils/time";
|
|
2
|
-
import { SERVER_TIMING, ServerTimings } from "../constants";
|
|
2
|
+
import { SERVER_TIMING, ServerTimings } from "../constants.mjs";
|
|
3
3
|
function createMonitors() {
|
|
4
4
|
const coreMonitors = [];
|
|
5
5
|
const log = (level, message, args)=>{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MAIN_ENTRY_NAME } from "@modern-js/utils/universal/constants";
|
|
2
|
-
import { createRequestHandlerConfig } from "./utils";
|
|
2
|
+
import { createRequestHandlerConfig } from "./utils.mjs";
|
|
3
3
|
const csrRscRender = async (req, options)=>{
|
|
4
4
|
const { routeInfo, serverManifest, rscSSRManifest, rscClientManifest, rscServerManifest, locals, params, loaderContext, reporter, monitors, onError, onTiming, staticGenerate, html } = options;
|
|
5
5
|
const serverBundle = serverManifest?.renderBundles?.[routeInfo.entryName || MAIN_ENTRY_NAME];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getLoaderCtx } from "../../helper";
|
|
2
|
-
import { sortRoutes } from "../../utils";
|
|
3
|
-
import { requestLatencyMiddleware } from "../monitors";
|
|
4
|
-
export * from "./inject";
|
|
1
|
+
import { getLoaderCtx } from "../../helper.mjs";
|
|
2
|
+
import { sortRoutes } from "../../utils/index.mjs";
|
|
3
|
+
import { requestLatencyMiddleware } from "../monitors.mjs";
|
|
4
|
+
export * from "./inject.mjs";
|
|
5
5
|
const DYNAMIC_ROUTE_REG = /\/:./;
|
|
6
6
|
function escapeRegexSpecialChars(path) {
|
|
7
7
|
return path.replace(/[()[\]{}*+?.^$|\\]/g, '\\$&');
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as __rspack_external__modern_js_runtime_utils_router_2aa8d96f from "@modern-js/runtime-utils/router";
|
|
2
2
|
import { cutNameByHyphen } from "@modern-js/utils/universal";
|
|
3
3
|
import { TrieRouter } from "hono/router/trie-router";
|
|
4
|
-
import { X_MODERNJS_RENDER } from "../../constants";
|
|
5
|
-
import { ErrorDigest, createErrorHtml, getPathname, getRuntimeEnv, parseHeaders, parseQuery, sortRoutes, uniqueKeyByRoute } from "../../utils";
|
|
6
|
-
import { csrRscRender } from "./csrRscRender";
|
|
7
|
-
import { dataHandler } from "./dataHandler";
|
|
8
|
-
import { renderRscHandler } from "./renderRscHandler";
|
|
9
|
-
import { serverActionHandler } from "./serverActionHandler";
|
|
10
|
-
import { ssrRender } from "./ssrRender";
|
|
4
|
+
import { X_MODERNJS_RENDER } from "../../constants.mjs";
|
|
5
|
+
import { ErrorDigest, createErrorHtml, getPathname, getRuntimeEnv, parseHeaders, parseQuery, sortRoutes, uniqueKeyByRoute } from "../../utils/index.mjs";
|
|
6
|
+
import { csrRscRender } from "./csrRscRender.mjs";
|
|
7
|
+
import { dataHandler } from "./dataHandler.mjs";
|
|
8
|
+
import { renderRscHandler } from "./renderRscHandler.mjs";
|
|
9
|
+
import { serverActionHandler } from "./serverActionHandler.mjs";
|
|
10
|
+
import { ssrRender } from "./ssrRender.mjs";
|
|
11
11
|
var __webpack_modules__ = {
|
|
12
12
|
"@modern-js/runtime-utils/router" (module) {
|
|
13
13
|
module.exports = __rspack_external__modern_js_runtime_utils_router_2aa8d96f;
|
|
@@ -214,7 +214,7 @@ function injectFallbackReasonToHtml({ html, reason, framework }) {
|
|
|
214
214
|
}
|
|
215
215
|
async function csrRender(request, options) {
|
|
216
216
|
const { html, rscClientManifest } = options;
|
|
217
|
-
if (!rscClientManifest || process.env.MODERN_DISABLE_INJECT_RSC_DATA) return new Response(html, {
|
|
217
|
+
if (!rscClientManifest || process.env.MODERN_DISABLE_INJECT_RSC_DATA || !options.routeInfo.isRSC) return new Response(html, {
|
|
218
218
|
status: 200,
|
|
219
219
|
headers: new Headers({
|
|
220
220
|
'content-type': 'text/html; charset=UTF-8',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MAIN_ENTRY_NAME } from "@modern-js/utils/universal/constants";
|
|
2
|
-
import { createRequestHandlerConfig } from "./utils";
|
|
2
|
+
import { createRequestHandlerConfig } from "./utils.mjs";
|
|
3
3
|
const renderRscHandler = async (req, options)=>{
|
|
4
4
|
const { routeInfo, serverManifest, rscSSRManifest, rscClientManifest, rscServerManifest, locals, params, loaderContext, monitors, onError, onTiming, staticGenerate } = options;
|
|
5
5
|
const serverBundle = serverManifest?.renderBundles?.[routeInfo.entryName || MAIN_ENTRY_NAME];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createMemoryStorage } from "@modern-js/runtime-utils/storer";
|
|
2
|
-
import { X_RENDER_CACHE } from "../../constants";
|
|
3
|
-
import { createTransformStream, getPathname } from "../../utils";
|
|
2
|
+
import { X_RENDER_CACHE } from "../../constants.mjs";
|
|
3
|
+
import { createTransformStream, getPathname } from "../../utils/index.mjs";
|
|
4
4
|
const removeTailSlash = (s)=>s.replace(/\/+$/, '');
|
|
5
5
|
const ZERO_RENDER_LEVEL = /"renderLevel":0/;
|
|
6
6
|
const NO_SSR_CACHE = /<meta\s+[^>]*name=["']no-ssr-cache["'][^>]*>/i;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MAIN_ENTRY_NAME } from "@modern-js/utils/universal/constants";
|
|
2
|
-
import { X_MODERNJS_RENDER } from "../../constants";
|
|
3
|
-
import { getPathname, parseHeaders } from "../../utils";
|
|
4
|
-
import { getCacheResult, matchCacheControl, shouldUseCache } from "./ssrCache";
|
|
5
|
-
import { createRequestHandlerConfig } from "./utils";
|
|
2
|
+
import { X_MODERNJS_RENDER } from "../../constants.mjs";
|
|
3
|
+
import { getPathname, parseHeaders } from "../../utils/index.mjs";
|
|
4
|
+
import { getCacheResult, matchCacheControl, shouldUseCache } from "./ssrCache.mjs";
|
|
5
|
+
import { createRequestHandlerConfig } from "./utils.mjs";
|
|
6
6
|
const SERVER_RUNTIME_ENTRY = 'requestHandler';
|
|
7
7
|
async function ssrRender(request, { routeInfo, html, config: userConfig, staticGenerate, nodeReq, serverManifest, rscSSRManifest, rscClientManifest, rscServerManifest, locals, params, loaderContext, monitors, cacheConfig, onError, onTiming, reporter }) {
|
|
8
8
|
const { entryName } = routeInfo;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MAIN_ENTRY_NAME } from "@modern-js/utils/universal/constants";
|
|
2
|
-
import { sortRoutes } from "../utils";
|
|
2
|
+
import { sortRoutes } from "../utils/index.mjs";
|
|
3
3
|
function injectRoute(route) {
|
|
4
4
|
return async (c, next)=>{
|
|
5
5
|
if (route && !c.get('route')) c.set('route', route);
|
package/dist/esm/serverBase.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { server as server_server } from "@modern-js/plugin/server";
|
|
2
2
|
import { Hono } from "hono";
|
|
3
|
-
import { run } from "./context";
|
|
4
|
-
import { handleSetupResult } from "./plugins/compat/hooks";
|
|
5
|
-
import { loadConfig } from "./utils";
|
|
3
|
+
import { run } from "./context.mjs";
|
|
4
|
+
import { handleSetupResult } from "./plugins/compat/hooks.mjs";
|
|
5
|
+
import { loadConfig } from "./utils/index.mjs";
|
|
6
6
|
function _check_private_redeclaration(obj, privateCollection) {
|
|
7
7
|
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
8
8
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from "./bff";
|
|
2
|
-
export * from "./html";
|
|
3
|
-
export * from "./output";
|
|
4
|
-
export * from "./server";
|
|
5
|
-
export * from "./source";
|
|
6
|
-
export * from "./tools";
|
|
1
|
+
export * from "./bff.mjs";
|
|
2
|
+
export * from "./html.mjs";
|
|
3
|
+
export * from "./output.mjs";
|
|
4
|
+
export * from "./server.mjs";
|
|
5
|
+
export * from "./source.mjs";
|
|
6
|
+
export * from "./tools.mjs";
|
package/dist/esm/types/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./config";
|
|
2
|
-
export * from "./plugins";
|
|
3
|
-
export * from "./render";
|
|
4
|
-
export * from "./server";
|
|
1
|
+
export * from "./config/index.mjs";
|
|
2
|
+
export * from "./plugins/index.mjs";
|
|
3
|
+
export * from "./render.mjs";
|
|
4
|
+
export * from "./server.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./plugin";
|
|
1
|
+
export * from "./plugin.mjs";
|
package/dist/esm/utils/error.mjs
CHANGED
package/dist/esm/utils/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from "./env";
|
|
2
|
-
export * from "./transformStream";
|
|
3
|
-
export * from "./middlewareCollector";
|
|
4
|
-
export * from "./error";
|
|
5
|
-
export * from "./warmup";
|
|
6
|
-
export * from "./entry";
|
|
7
|
-
export * from "./request";
|
|
8
|
-
export * from "./serverConfig";
|
|
9
|
-
export * from "./publicDir";
|
|
1
|
+
export * from "./env.mjs";
|
|
2
|
+
export * from "./transformStream.mjs";
|
|
3
|
+
export * from "./middlewareCollector.mjs";
|
|
4
|
+
export * from "./error.mjs";
|
|
5
|
+
export * from "./warmup.mjs";
|
|
6
|
+
export * from "./entry.mjs";
|
|
7
|
+
export * from "./request.mjs";
|
|
8
|
+
export * from "./serverConfig.mjs";
|
|
9
|
+
export * from "./publicDir.mjs";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
/*#__PURE__*/ import.meta.url;
|
|
1
3
|
import { connectMid2HonoMid, connectMockMid2HonoMid, httpCallBack2HonoMid } from "./hono.mjs";
|
|
2
4
|
import { createNodeServer, createWebRequest, sendResponse } from "./node.mjs";
|
|
3
5
|
import { getHtmlTemplates, getServerManifest, injectNodeSeverPlugin, injectResourcePlugin, injectRscManifestPlugin, serverStaticPlugin } from "./plugins/index.mjs";
|