@modern-js/server-core 3.0.0-alpha.1 → 3.0.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.
Files changed (102) hide show
  1. package/dist/cjs/adapters/node/plugins/resource.js +7 -7
  2. package/dist/cjs/index.js +18 -10
  3. package/dist/esm/adapters/node/helper/index.mjs +5 -5
  4. package/dist/esm/adapters/node/hono.mjs +1 -1
  5. package/dist/esm/adapters/node/index.mjs +4 -4
  6. package/dist/esm/adapters/node/node.mjs +1 -1
  7. package/dist/esm/adapters/node/plugins/index.mjs +3 -3
  8. package/dist/esm/adapters/node/plugins/resource.mjs +8 -8
  9. package/dist/esm/adapters/node/plugins/static.mjs +2 -2
  10. package/dist/esm/context.mjs +1 -1
  11. package/dist/esm/index.mjs +12 -12
  12. package/dist/esm/plugins/compat/index.mjs +1 -1
  13. package/dist/esm/plugins/default.mjs +6 -6
  14. package/dist/esm/plugins/index.mjs +8 -8
  15. package/dist/esm/plugins/log.mjs +1 -1
  16. package/dist/esm/plugins/monitors.mjs +1 -1
  17. package/dist/esm/plugins/render/csrRscRender.mjs +1 -1
  18. package/dist/esm/plugins/render/index.mjs +4 -4
  19. package/dist/esm/plugins/render/inject.mjs +1 -1
  20. package/dist/esm/plugins/render/render.mjs +7 -7
  21. package/dist/esm/plugins/render/renderRscHandler.mjs +1 -1
  22. package/dist/esm/plugins/render/ssrCache.mjs +2 -2
  23. package/dist/esm/plugins/render/ssrRender.mjs +4 -4
  24. package/dist/esm/plugins/route.mjs +1 -1
  25. package/dist/esm/serverBase.mjs +3 -3
  26. package/dist/esm/types/config/index.mjs +6 -6
  27. package/dist/esm/types/index.mjs +4 -4
  28. package/dist/esm/types/plugins/index.mjs +1 -1
  29. package/dist/esm/utils/error.mjs +1 -1
  30. package/dist/esm/utils/index.mjs +9 -9
  31. package/dist/esm-node/adapters/node/helper/index.mjs +1 -0
  32. package/dist/esm-node/adapters/node/helper/loadCache.mjs +1 -0
  33. package/dist/esm-node/adapters/node/helper/loadConfig.mjs +1 -0
  34. package/dist/esm-node/adapters/node/helper/loadEnv.mjs +1 -0
  35. package/dist/esm-node/adapters/node/helper/loadPlugin.mjs +1 -0
  36. package/dist/esm-node/adapters/node/helper/utils.mjs +1 -0
  37. package/dist/esm-node/adapters/node/hono.mjs +1 -0
  38. package/dist/esm-node/adapters/node/index.mjs +1 -0
  39. package/dist/esm-node/adapters/node/node.mjs +1 -0
  40. package/dist/esm-node/adapters/node/plugins/index.mjs +1 -0
  41. package/dist/esm-node/adapters/node/plugins/nodeServer.mjs +1 -0
  42. package/dist/esm-node/adapters/node/plugins/resource.mjs +8 -7
  43. package/dist/esm-node/adapters/node/plugins/static.mjs +1 -0
  44. package/dist/esm-node/constants.mjs +1 -0
  45. package/dist/esm-node/context.mjs +1 -0
  46. package/dist/esm-node/helper.mjs +1 -0
  47. package/dist/esm-node/hono.mjs +1 -0
  48. package/dist/esm-node/index.mjs +3 -2
  49. package/dist/esm-node/plugins/compat/hooks.mjs +1 -0
  50. package/dist/esm-node/plugins/compat/index.mjs +1 -0
  51. package/dist/esm-node/plugins/default.mjs +1 -0
  52. package/dist/esm-node/plugins/favicon.mjs +1 -0
  53. package/dist/esm-node/plugins/index.mjs +1 -0
  54. package/dist/esm-node/plugins/log.mjs +1 -0
  55. package/dist/esm-node/plugins/middlewares.mjs +1 -0
  56. package/dist/esm-node/plugins/monitors.mjs +1 -0
  57. package/dist/esm-node/plugins/processedBy.mjs +1 -0
  58. package/dist/esm-node/plugins/render/csrRscRender.mjs +1 -0
  59. package/dist/esm-node/plugins/render/dataHandler.mjs +1 -0
  60. package/dist/esm-node/plugins/render/index.mjs +1 -0
  61. package/dist/esm-node/plugins/render/inject.mjs +1 -0
  62. package/dist/esm-node/plugins/render/render.mjs +1 -0
  63. package/dist/esm-node/plugins/render/renderRscHandler.mjs +1 -0
  64. package/dist/esm-node/plugins/render/serverActionHandler.mjs +1 -0
  65. package/dist/esm-node/plugins/render/ssrCache.mjs +1 -0
  66. package/dist/esm-node/plugins/render/ssrRender.mjs +1 -0
  67. package/dist/esm-node/plugins/render/utils.mjs +1 -0
  68. package/dist/esm-node/plugins/route.mjs +1 -0
  69. package/dist/esm-node/serverBase.mjs +1 -0
  70. package/dist/esm-node/types/config/bff.mjs +1 -0
  71. package/dist/esm-node/types/config/dev.mjs +1 -0
  72. package/dist/esm-node/types/config/html.mjs +1 -0
  73. package/dist/esm-node/types/config/index.mjs +1 -0
  74. package/dist/esm-node/types/config/output.mjs +1 -0
  75. package/dist/esm-node/types/config/security.mjs +1 -0
  76. package/dist/esm-node/types/config/server.mjs +1 -0
  77. package/dist/esm-node/types/config/share.mjs +1 -0
  78. package/dist/esm-node/types/config/source.mjs +1 -0
  79. package/dist/esm-node/types/config/tools.mjs +1 -0
  80. package/dist/esm-node/types/index.mjs +1 -0
  81. package/dist/esm-node/types/plugins/base.mjs +1 -0
  82. package/dist/esm-node/types/plugins/index.mjs +1 -0
  83. package/dist/esm-node/types/plugins/plugin.mjs +1 -0
  84. package/dist/esm-node/types/render.mjs +1 -0
  85. package/dist/esm-node/types/requestHandler.mjs +1 -0
  86. package/dist/esm-node/types/server.mjs +1 -0
  87. package/dist/esm-node/utils/entry.mjs +1 -0
  88. package/dist/esm-node/utils/env.mjs +1 -0
  89. package/dist/esm-node/utils/error.mjs +1 -0
  90. package/dist/esm-node/utils/index.mjs +1 -0
  91. package/dist/esm-node/utils/middlewareCollector.mjs +1 -0
  92. package/dist/esm-node/utils/publicDir.mjs +1 -0
  93. package/dist/esm-node/utils/request.mjs +1 -0
  94. package/dist/esm-node/utils/serverConfig.mjs +1 -0
  95. package/dist/esm-node/utils/storage.mjs +1 -0
  96. package/dist/esm-node/utils/transformStream.mjs +1 -0
  97. package/dist/esm-node/utils/warmup.mjs +1 -0
  98. package/dist/types/adapters/node/plugins/resource.d.ts +2 -2
  99. package/dist/types/index.d.ts +1 -1
  100. package/dist/types/types/config/server.d.ts +1 -1
  101. package/dist/types/types/config/tools.d.ts +1 -7
  102. package/package.json +23 -14
@@ -73,25 +73,25 @@ function injectTemplates(pwd, routes, htmlTemplatePromise) {
73
73
  await next();
74
74
  };
75
75
  }
76
- const loadBundle = async (filepath, logger)=>{
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
- logger.error(`Load ${filepath} bundle failed, error = %s`, e instanceof Error ? e.stack || e.message : e);
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, logger) {
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, logger);
94
- const loaderBundle = await loadBundle(loaderBundlePath, logger);
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 logger = c.get('logger');
116
- const serverManifest = await (manifestPromise || getServerManifest(pwd, routes, logger));
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();
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', {
@@ -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,4 +1,4 @@
1
- import { isResFinalized } from "./helper";
1
+ import { isResFinalized } from "./helper/index.mjs";
2
2
  const httpCallBack2HonoMid = (handler)=>async (context, next)=>{
3
3
  const { req, res } = context.env.node;
4
4
  const onPipe = ()=>{
@@ -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, logger)=>{
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
- logger.error(`Load ${filepath} bundle failed, error = %s`, e instanceof Error ? e.stack || e.message : e);
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, logger) {
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, logger);
48
- const loaderBundle = await loadBundle(loaderBundlePath, logger);
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 logger = c.get('logger');
70
- const serverManifest = await (manifestPromise || getServerManifest(pwd, routes, logger));
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();
@@ -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) {
@@ -1,3 +1,3 @@
1
- import { createStorage } from "./utils/storage";
1
+ import { createStorage } from "./utils/storage.mjs";
2
2
  const { run, useHonoContext } = createStorage();
3
3
  export { run, useHonoContext };
@@ -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 };
@@ -1,4 +1,4 @@
1
- import { getPathname } from "../utils";
1
+ import { getPathname } from "../utils/index.mjs";
2
2
  const humanize = (times)=>{
3
3
  const [delimiter, separator] = [
4
4
  ',',
@@ -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,4 +1,4 @@
1
- import { createRender } from "./render";
1
+ import { createRender } from "./render.mjs";
2
2
  const injectRenderHandlerPlugin = ({ staticGenerate, cacheConfig })=>({
3
3
  name: '@modern-js/plugin-inject-render',
4
4
  setup (api) {
@@ -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;
@@ -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);
@@ -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";
@@ -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";
@@ -1,4 +1,4 @@
1
- import { parseHeaders } from "./request";
1
+ import { parseHeaders } from "./request.mjs";
2
2
  const ERROR_PAGE_TEXT = {
3
3
  404: 'This page could not be found.',
4
4
  500: 'Internal Server Error.'
@@ -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,4 @@
1
+ import "node:module";
1
2
  import { loadServerEnv } from "./loadEnv.mjs";
2
3
  import { loadServerPlugins } from "./loadPlugin.mjs";
3
4
  import { loadServerCliConfig, loadServerRuntimeConfig } from "./loadConfig.mjs";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import path from "path";
2
3
  import { SERVER_DIR, requireExistModule } from "@modern-js/utils";
3
4
  const CACHE_FILENAME = 'cache';
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import path_0 from "path";
2
3
  import { OUTPUT_CONFIG_FILE, ensureAbsolutePath, fs as utils_fs, lodash, requireExistModule } from "@modern-js/utils";
3
4
  import { parse } from "flatted";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import path from "path";
2
3
  import { dotenv, dotenvExpand, fs } from "@modern-js/utils";
3
4
  async function loadServerEnv(options) {
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { compatibleRequire, tryResolve } from "@modern-js/utils";
2
3
  async function resolveServerPlugin(plugin, appDirectory) {
3
4
  const { name, options } = plugin;
@@ -1,2 +1,3 @@
1
+ import "node:module";
1
2
  const isResFinalized = (res)=>res.headersSent || res._modernBodyPiped || res.writableEnded || res.finished || !res.socket?.writable;
2
3
  export { isResFinalized };
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { isResFinalized } from "./helper/index.mjs";
2
3
  const httpCallBack2HonoMid = (handler)=>async (context, next)=>{
3
4
  const { req, res } = context.env.node;
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { connectMid2HonoMid, connectMockMid2HonoMid, httpCallBack2HonoMid } from "./hono.mjs";
2
3
  import { createNodeServer, createWebRequest, sendResponse } from "./node.mjs";
3
4
  import { getHtmlTemplates, getServerManifest, injectNodeSeverPlugin, injectResourcePlugin, injectRscManifestPlugin, serverStaticPlugin } from "./plugins/index.mjs";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { ServerResponse } from "node:http";
2
3
  import { Readable, Writable } from "node:stream";
3
4
  import cloneable_readable from "cloneable-readable";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  export * from "./static.mjs";
2
3
  export * from "./resource.mjs";
3
4
  export * from "./nodeServer.mjs";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  const injectNodeSeverPlugin = ({ nodeServer })=>({
2
3
  name: '@modern-js/plugin-inject-node-server',
3
4
  setup (api) {
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import path from "path";
2
3
  import { fileReader } from "@modern-js/runtime-utils/fileReader";
3
4
  import { LOADABLE_STATS_FILE, MAIN_ENTRY_NAME, NESTED_ROUTE_SPEC_FILE, ROUTE_MANIFEST_FILE, SERVER_BUNDLE_DIRECTORY, compatibleRequire, fs, isProd } from "@modern-js/utils";
@@ -27,25 +28,25 @@ function injectTemplates(pwd, routes, htmlTemplatePromise) {
27
28
  await next();
28
29
  };
29
30
  }
30
- const loadBundle = async (filepath, logger)=>{
31
+ const loadBundle = async (filepath, monitors)=>{
31
32
  if (!await fs.pathExists(filepath)) return;
32
33
  try {
33
34
  const module = await compatibleRequire(filepath, false);
34
35
  return module;
35
36
  } catch (e) {
36
- logger.error(`Load ${filepath} bundle failed, error = %s`, e instanceof Error ? e.stack || e.message : e);
37
+ monitors.error(`Load ${filepath} bundle failed, error = %s`, e instanceof Error ? e.stack || e.message : e);
37
38
  return;
38
39
  }
39
40
  };
40
- async function getServerManifest(pwd, routes, logger) {
41
+ async function getServerManifest(pwd, routes, monitors) {
41
42
  const loaderBundles = {};
42
43
  const renderBundles = {};
43
44
  await Promise.all(routes.filter((route)=>Boolean(route.bundle)).map(async (route)=>{
44
45
  const entryName = route.entryName || MAIN_ENTRY_NAME;
45
46
  const renderBundlePath = path.join(pwd, route.bundle || '');
46
47
  const loaderBundlePath = path.join(pwd, SERVER_BUNDLE_DIRECTORY, `${entryName}-server-loaders.js`);
47
- const renderBundle = await loadBundle(renderBundlePath, logger);
48
- const loaderBundle = await loadBundle(loaderBundlePath, logger);
48
+ const renderBundle = await loadBundle(renderBundlePath, monitors);
49
+ const loaderBundle = await loadBundle(loaderBundlePath, monitors);
49
50
  renderBundle && (renderBundles[entryName] = renderBundle);
50
51
  loaderBundle && (loaderBundles[entryName] = loaderBundle?.loadModules ? await loaderBundle?.loadModules() : loaderBundle);
51
52
  }));
@@ -66,8 +67,8 @@ async function getServerManifest(pwd, routes, logger) {
66
67
  function injectServerManifest(pwd, routes, manifestPromise) {
67
68
  return async (c, next)=>{
68
69
  if (routes && !c.get('serverManifest')) {
69
- const logger = c.get('logger');
70
- const serverManifest = await (manifestPromise || getServerManifest(pwd, routes, logger));
70
+ const monitors = c.get('monitors');
71
+ const serverManifest = await (manifestPromise || getServerManifest(pwd, routes, monitors));
71
72
  c.set('serverManifest', serverManifest);
72
73
  }
73
74
  await next();
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import path from "path";
2
3
  import { fileReader } from "@modern-js/runtime-utils/fileReader";
3
4
  import { fs } from "@modern-js/utils";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  const AGGRED_DIR = {
2
3
  mock: 'config/mock',
3
4
  server: 'server',
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { createStorage } from "./utils/storage.mjs";
2
3
  const { run, useHonoContext } = createStorage();
3
4
  export { run, useHonoContext };
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  const LOADER_CONTEXT = 'loaderContext';
2
3
  function getLoaderCtx(c) {
3
4
  const loaderContext = c.get(LOADER_CONTEXT);
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { deleteCookie, getCookie, setCookie } from "hono/cookie";
2
3
  import { languageDetector } from "hono/language";
3
4
  export { deleteCookie, getCookie, languageDetector, setCookie };
@@ -1,8 +1,9 @@
1
+ import "node:module";
1
2
  import { ErrorDigest, createErrorHtml, onError } from "./utils/index.mjs";
2
3
  import { getPublicDirConfig, getPublicDirPatterns, getPublicDirRoutePrefixes, normalizePublicDir, normalizePublicDirPath, resolvePublicDirPaths } from "./utils/publicDir.mjs";
3
4
  import { AGGRED_DIR } from "./constants.mjs";
4
5
  import { createServerBase } from "./serverBase.mjs";
5
- import { useHonoContext } from "./context.mjs";
6
+ import { run, useHonoContext } from "./context.mjs";
6
7
  import { Hono } from "hono";
7
8
  import { getLoaderCtx } from "./helper.mjs";
8
9
  export * from "./plugins/index.mjs";
@@ -10,4 +11,4 @@ export * from "./types/plugins/index.mjs";
10
11
  export * from "./types/render.mjs";
11
12
  export * from "./types/config/index.mjs";
12
13
  export * from "./types/requestHandler.mjs";
13
- export { AGGRED_DIR, ErrorDigest, Hono, createErrorHtml, createServerBase, getLoaderCtx, getPublicDirConfig, getPublicDirPatterns, getPublicDirRoutePrefixes, normalizePublicDir, normalizePublicDirPath, onError, resolvePublicDirPaths, useHonoContext };
14
+ export { AGGRED_DIR, ErrorDigest, Hono, createErrorHtml, createServerBase, getLoaderCtx, getPublicDirConfig, getPublicDirPatterns, getPublicDirRoutePrefixes, normalizePublicDir, normalizePublicDirPath, onError, resolvePublicDirPaths, run, useHonoContext };
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  function getHookRunners(context) {
2
3
  const { hooks } = context;
3
4
  return {
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { createAsyncHook, createAsyncPipelineHook } from "@modern-js/plugin";
2
3
  import { getHookRunners, handleSetupResult } from "./hooks.mjs";
3
4
  const compatPlugin = ()=>({
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { compatPlugin } from "./compat/index.mjs";
2
3
  import { logPlugin } from "./log.mjs";
3
4
  import { initMonitorsPlugin, injectServerTiming, injectloggerPlugin } from "./monitors.mjs";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  const faviconPlugin = ()=>({
2
3
  name: '@modern-js/plugin-favicon',
3
4
  setup (api) {
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { getRenderHandler, injectRenderHandlerPlugin, renderPlugin } from "./render/index.mjs";
2
3
  import { faviconPlugin } from "./favicon.mjs";
3
4
  import { injectServerTiming, injectloggerPlugin } from "./monitors.mjs";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { getPathname } from "../utils/index.mjs";
2
3
  const humanize = (times)=>{
3
4
  const [delimiter, separator] = [
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  const injectConfigMiddlewarePlugin = (configMiddlewares = [], configRenderMiddlewares = [])=>({
2
3
  name: '@modern-js/plugin-inject-config-middleware',
3
4
  setup (api) {
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { time } from "@modern-js/runtime-utils/time";
2
3
  import { SERVER_TIMING, ServerTimings } from "../constants.mjs";
3
4
  function createMonitors() {
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  const processedByPlugin = ()=>({
2
3
  name: '@modern-js/plugin-processed',
3
4
  setup (api) {
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { MAIN_ENTRY_NAME } from "@modern-js/utils/universal/constants";
2
3
  import { createRequestHandlerConfig } from "./utils.mjs";
3
4
  const csrRscRender = async (req, options)=>{
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { MAIN_ENTRY_NAME } from "@modern-js/utils/universal/constants";
2
3
  const dataHandler = async (request, { routeInfo, serverRoutes, monitors, onError, onTiming, serverManifest, loaderContext })=>{
3
4
  const serverLoaderModule = serverManifest?.loaderBundles?.[routeInfo.entryName || MAIN_ENTRY_NAME];
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { getLoaderCtx } from "../../helper.mjs";
2
3
  import { sortRoutes } from "../../utils/index.mjs";
3
4
  import { requestLatencyMiddleware } from "../monitors.mjs";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { createRender } from "./render.mjs";
2
3
  const injectRenderHandlerPlugin = ({ staticGenerate, cacheConfig })=>({
3
4
  name: '@modern-js/plugin-inject-render',
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import * as __rspack_external__modern_js_runtime_utils_router_2aa8d96f from "@modern-js/runtime-utils/router";
2
3
  import { cutNameByHyphen } from "@modern-js/utils/universal";
3
4
  import { TrieRouter } from "hono/router/trie-router";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { MAIN_ENTRY_NAME } from "@modern-js/utils/universal/constants";
2
3
  import { createRequestHandlerConfig } from "./utils.mjs";
3
4
  const renderRscHandler = async (req, options)=>{
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { MAIN_ENTRY_NAME } from "@modern-js/utils/universal/constants";
2
3
  const serverActionHandler = async (req, { serverManifest, routeInfo, rscClientManifest })=>{
3
4
  const serverBundle = serverManifest?.renderBundles?.[routeInfo.entryName || MAIN_ENTRY_NAME];
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { createMemoryStorage } from "@modern-js/runtime-utils/storer";
2
3
  import { X_RENDER_CACHE } from "../../constants.mjs";
3
4
  import { createTransformStream, getPathname } from "../../utils/index.mjs";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { MAIN_ENTRY_NAME } from "@modern-js/utils/universal/constants";
2
3
  import { X_MODERNJS_RENDER } from "../../constants.mjs";
3
4
  import { getPathname, parseHeaders } from "../../utils/index.mjs";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  function createRequestHandlerConfig(userConfig) {
2
3
  const { output, server, security, html, source } = userConfig;
3
4
  return {
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { MAIN_ENTRY_NAME } from "@modern-js/utils/universal/constants";
2
3
  import { sortRoutes } from "../utils/index.mjs";
3
4
  function injectRoute(route) {
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { server as server_server } from "@modern-js/plugin/server";
2
3
  import { Hono } from "hono";
3
4
  import { run } from "./context.mjs";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  export * from "./bff.mjs";
2
3
  export * from "./html.mjs";
3
4
  export * from "./output.mjs";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  export * from "./config/index.mjs";
2
3
  export * from "./plugins/index.mjs";
3
4
  export * from "./render.mjs";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -1 +1,2 @@
1
+ import "node:module";
1
2
  export * from "./plugin.mjs";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  const sortRoutes = (route1, route2)=>route2.urlPath.length - route1.urlPath.length;
2
3
  const uniqueKeyByRoute = (route)=>`${route.entryName}-${route.urlPath}`;
3
4
  export { sortRoutes, uniqueKeyByRoute };
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  const getRuntimeEnv = ()=>{
2
3
  if (globalThis?.process?.release?.name === 'node') return 'node';
3
4
  return 'other';
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { parseHeaders } from "./request.mjs";
2
3
  const ERROR_PAGE_TEXT = {
3
4
  404: 'This page could not be found.',
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  export * from "./env.mjs";
2
3
  export * from "./transformStream.mjs";
3
4
  export * from "./middlewareCollector.mjs";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  const mergeExtension = (users)=>{
2
3
  const output = [];
3
4
  return {
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import path from "path";
2
3
  function normalizePublicDir(publicDir) {
3
4
  if (!publicDir) return [];
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  function parseQuery(req) {
2
3
  const query = {};
3
4
  const { url } = req;
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { merge } from "ts-deepmerge";
2
3
  const loadConfig = ({ cliConfig, serverConfig })=>{
3
4
  const config = merge({
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { AsyncLocalStorage } from "async_hooks";
2
3
  const createStorage = ()=>{
3
4
  let storage;
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  function createTransformStream(fn) {
2
3
  const decoder = new TextDecoder();
3
4
  const encoder = new TextEncoder();
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  function warmup(bundles) {
2
3
  bundles.forEach((bundle)=>{
3
4
  bundle && import(bundle).catch((_)=>{});
@@ -1,8 +1,8 @@
1
- import type { Logger, ServerRoute } from '@modern-js/types';
1
+ import type { Monitors, ServerRoute } from '@modern-js/types';
2
2
  import type { Middleware, ServerEnv, ServerManifest, ServerPlugin } from '../../../types';
3
3
  export declare function getHtmlTemplates(pwd: string, routes: ServerRoute[]): Promise<Record<string, string>>;
4
4
  export declare function injectTemplates(pwd: string, routes?: ServerRoute[], htmlTemplatePromise?: ReturnType<typeof getHtmlTemplates>): Middleware<ServerEnv>;
5
- export declare function getServerManifest(pwd: string, routes: ServerRoute[], logger: Logger): Promise<ServerManifest>;
5
+ export declare function getServerManifest(pwd: string, routes: ServerRoute[], monitors: Monitors): Promise<ServerManifest>;
6
6
  export declare function injectServerManifest(pwd: string, routes?: ServerRoute[], manifestPromise?: Promise<ServerManifest>): Middleware<ServerEnv>;
7
7
  export declare function getRscServerManifest(pwd: string): Promise<any>;
8
8
  export declare function getClientManifest(pwd: string): Promise<any>;
@@ -3,7 +3,7 @@ export { normalizePublicDir, normalizePublicDirPath, getPublicDirRoutePrefixes,
3
3
  export { AGGRED_DIR } from './constants';
4
4
  export type { ServerBase, ServerBaseOptions } from './serverBase';
5
5
  export { createServerBase } from './serverBase';
6
- export { useHonoContext } from './context';
6
+ export { run, useHonoContext } from './context';
7
7
  export { Hono } from 'hono';
8
8
  export type { Middleware, MiddlewareHandler, Context, Next, HonoRequest as InternalRequest, ServerEnv, ServerManifest, ServerLoaderBundle, } from './types';
9
9
  export { getLoaderCtx } from './helper';
@@ -28,7 +28,7 @@ export interface ServerUserConfig {
28
28
  baseUrl?: string | string[];
29
29
  port?: number;
30
30
  watchOptions?: WatchOptions;
31
- compiler?: 'babel' | 'typescript';
31
+ compiler?: 'typescript';
32
32
  /**
33
33
  * @description use json script tag instead of inline script
34
34
  * @default false
@@ -1,8 +1,2 @@
1
- import type { BabelTransformOptions } from '@modern-js/types/common';
2
- import type { ConfigChain } from './share';
3
- type ToolsBabelConfig = ConfigChain<BabelTransformOptions, any>;
4
- export interface ToolsUserConfig {
5
- babel?: ToolsBabelConfig;
6
- }
1
+ export type ToolsUserConfig = Record<string, never>;
7
2
  export type ToolsNormalizedConfig = ToolsUserConfig;
8
- export {};
package/package.json CHANGED
@@ -15,25 +15,34 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "3.0.0-alpha.1",
19
- "jsnext:source": "./src/index.ts",
18
+ "version": "3.0.0",
20
19
  "types": "./dist/types/index.d.ts",
21
20
  "main": "./dist/cjs/index.js",
22
- "module": "./dist/esm-node/index.mjs",
23
21
  "exports": {
24
22
  ".": {
25
23
  "types": "./dist/types/index.d.ts",
26
- "import": "./dist/esm-node/index.mjs",
24
+ "modern:source": "./src/index.ts",
25
+ "node": {
26
+ "import": "./dist/esm-node/index.mjs",
27
+ "require": "./dist/cjs/index.js"
28
+ },
27
29
  "default": "./dist/cjs/index.js"
28
30
  },
29
31
  "./node": {
30
32
  "types": "./dist/types/adapters/node/index.d.ts",
31
- "import": "./dist/esm-node/adapters/node/index.mjs",
33
+ "modern:source": "./src/adapters/node/index.ts",
34
+ "node": {
35
+ "import": "./dist/esm-node/adapters/node/index.mjs",
36
+ "require": "./dist/cjs/adapters/node/index.js"
37
+ },
32
38
  "default": "./dist/cjs/adapters/node/index.js"
33
39
  },
34
40
  "./hono": {
35
41
  "types": "./dist/types/hono.d.ts",
36
- "import": "./dist/esm-node/hono.mjs",
42
+ "node": {
43
+ "import": "./dist/esm-node/hono.mjs",
44
+ "require": "./dist/cjs/hono.js"
45
+ },
37
46
  "default": "./dist/cjs/hono.js"
38
47
  }
39
48
  },
@@ -60,22 +69,22 @@
60
69
  "@web-std/stream": "^1.0.3",
61
70
  "cloneable-readable": "^3.0.0",
62
71
  "flatted": "^3.3.3",
63
- "hono": "^4.10.4",
72
+ "hono": "^4.11.7",
64
73
  "ts-deepmerge": "7.0.3",
65
- "@modern-js/plugin": "3.0.0-alpha.1",
66
- "@modern-js/runtime-utils": "3.0.0-alpha.1",
67
- "@modern-js/utils": "3.0.0-alpha.1"
74
+ "@modern-js/plugin": "3.0.0",
75
+ "@modern-js/utils": "3.0.0",
76
+ "@modern-js/runtime-utils": "3.0.0"
68
77
  },
69
78
  "devDependencies": {
70
- "@rslib/core": "0.19.1",
79
+ "@rslib/core": "0.19.4",
71
80
  "@types/cloneable-readable": "^2.0.3",
72
81
  "@types/merge-deep": "^3.0.3",
73
82
  "@types/node": "^20",
74
83
  "http-proxy-middleware": "^2.0.9",
75
84
  "typescript": "^5",
76
- "@modern-js/types": "3.0.0-alpha.1",
77
- "@scripts/rstest-config": "2.66.0",
78
- "@modern-js/rslib": "2.68.10"
85
+ "@modern-js/rslib": "2.68.10",
86
+ "@modern-js/types": "3.0.0",
87
+ "@scripts/rstest-config": "2.66.0"
79
88
  },
80
89
  "sideEffects": false,
81
90
  "publishConfig": {