@modern-js/runtime 3.0.5 → 3.1.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/core/browser/index.js +4 -1
- package/dist/cjs/core/server/stream/createReadableStream.js +2 -0
- package/dist/cjs/core/server/string/index.js +4 -1
- package/dist/cjs/router/cli/code/index.js +1 -1
- package/dist/cjs/router/cli/code/utils.js +5 -5
- package/dist/esm/core/browser/index.mjs +4 -1
- package/dist/esm/core/server/stream/createReadableStream.mjs +2 -0
- package/dist/esm/core/server/string/index.mjs +4 -1
- package/dist/esm/router/cli/code/index.mjs +2 -2
- package/dist/esm/router/cli/code/utils.mjs +2 -2
- package/dist/esm-node/core/browser/index.mjs +4 -1
- package/dist/esm-node/core/server/stream/createReadableStream.mjs +2 -0
- package/dist/esm-node/core/server/string/index.mjs +4 -1
- package/dist/esm-node/router/cli/code/index.mjs +2 -2
- package/dist/esm-node/router/cli/code/utils.mjs +2 -2
- package/dist/types/router/cli/code/utils.d.ts +1 -1
- package/package.json +9 -9
|
@@ -39,6 +39,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
39
39
|
renderWithReact18: ()=>renderWithReact18,
|
|
40
40
|
renderWithReact17: ()=>renderWithReact17
|
|
41
41
|
});
|
|
42
|
+
const constants_namespaceObject = require("@modern-js/utils/universal/constants");
|
|
42
43
|
const external_cookie_namespaceObject = require("cookie");
|
|
43
44
|
var external_cookie_default = /*#__PURE__*/ __webpack_require__.n(external_cookie_namespaceObject);
|
|
44
45
|
const index_js_namespaceObject = require("../context/index.js");
|
|
@@ -128,7 +129,9 @@ async function renderWithReact17(App, rootElement) {
|
|
|
128
129
|
}
|
|
129
130
|
async function hydrateWithReact18(App, rootElement) {
|
|
130
131
|
const ReactDOM = await import("react-dom/client");
|
|
131
|
-
const root = ReactDOM.hydrateRoot(rootElement, App
|
|
132
|
+
const root = ReactDOM.hydrateRoot(rootElement, App, {
|
|
133
|
+
identifierPrefix: constants_namespaceObject.SSR_HYDRATION_ID_PREFIX
|
|
134
|
+
});
|
|
132
135
|
return root;
|
|
133
136
|
}
|
|
134
137
|
async function hydrateWithReact17(App, rootElement, callback) {
|
|
@@ -28,6 +28,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
28
28
|
});
|
|
29
29
|
const external_stream_namespaceObject = require("stream");
|
|
30
30
|
const node_namespaceObject = require("@modern-js/runtime-utils/node");
|
|
31
|
+
const constants_namespaceObject = require("@modern-js/utils/universal/constants");
|
|
31
32
|
const external_common_js_namespaceObject = require("../../../common.js");
|
|
32
33
|
const external_constants_js_namespaceObject = require("../../constants.js");
|
|
33
34
|
const index_js_namespaceObject = require("../../context/index.js");
|
|
@@ -65,6 +66,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
|
|
|
65
66
|
return new Promise((resolve)=>{
|
|
66
67
|
const { pipe: reactStreamingPipe } = renderToPipeableStream(processedRootElement, {
|
|
67
68
|
nonce: config.nonce,
|
|
69
|
+
identifierPrefix: constants_namespaceObject.SSR_HYDRATION_ID_PREFIX,
|
|
68
70
|
[onReady] () {
|
|
69
71
|
let styledComponentsStyleTags = '';
|
|
70
72
|
extenders.forEach((extender)=>{
|
|
@@ -36,6 +36,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
36
36
|
renderString: ()=>renderString
|
|
37
37
|
});
|
|
38
38
|
const time_namespaceObject = require("@modern-js/runtime-utils/time");
|
|
39
|
+
const constants_namespaceObject = require("@modern-js/utils/universal/constants");
|
|
39
40
|
const server_namespaceObject = require("react-dom/server");
|
|
40
41
|
var server_default = /*#__PURE__*/ __webpack_require__.n(server_namespaceObject);
|
|
41
42
|
const external_react_helmet_namespaceObject = require("react-helmet");
|
|
@@ -104,7 +105,9 @@ async function generateHtml(App, htmlTemplate, chunkSet, collectors, htmlModifie
|
|
|
104
105
|
const finalApp = collectors.reduce((pre, creator)=>creator.collect?.(pre) || pre, App);
|
|
105
106
|
try {
|
|
106
107
|
const end = (0, time_namespaceObject.time)();
|
|
107
|
-
html = server_default().renderToString(finalApp
|
|
108
|
+
html = server_default().renderToString(finalApp, {
|
|
109
|
+
identifierPrefix: constants_namespaceObject.SSR_HYDRATION_ID_PREFIX
|
|
110
|
+
});
|
|
108
111
|
chunkSet.renderLevel = external_constants_js_namespaceObject.RenderLevel.SERVER_RENDER;
|
|
109
112
|
helmetData = external_react_helmet_default().renderStatic();
|
|
110
113
|
const cost = end();
|
|
@@ -160,7 +160,7 @@ const generateCode = async (appContext, config, entrypoints, api)=>{
|
|
|
160
160
|
}
|
|
161
161
|
const serverLoaderCombined = external_templates_js_namespaceObject.ssrLoaderCombinedModule(entrypoints, entrypoint, config, appContext);
|
|
162
162
|
if (serverLoaderCombined) {
|
|
163
|
-
const serverLoaderFile = (0, external_utils_js_namespaceObject.
|
|
163
|
+
const serverLoaderFile = (0, external_utils_js_namespaceObject.getServerCombinedModuleFile)(internalDirectory, entryName);
|
|
164
164
|
await utils_namespaceObject.fs.outputFile(serverLoaderFile, serverLoaderCombined);
|
|
165
165
|
}
|
|
166
166
|
await utils_namespaceObject.fs.outputFile(external_path_default().resolve(internalDirectory, `./${entryName}/${external_constants_js_namespaceObject.FILE_SYSTEM_ROUTES_FILE_NAME}`), code, 'utf8');
|
|
@@ -34,10 +34,10 @@ var __webpack_exports__ = {};
|
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
36
|
parseModule: ()=>parseModule,
|
|
37
|
+
getServerCombinedModuleFile: ()=>getServerCombinedModuleFile,
|
|
37
38
|
hasLoader: ()=>hasLoader,
|
|
38
|
-
isPageComponentFile: ()=>isPageComponentFile,
|
|
39
39
|
getPathWithoutExt: ()=>getPathWithoutExt,
|
|
40
|
-
|
|
40
|
+
isPageComponentFile: ()=>isPageComponentFile,
|
|
41
41
|
getServerLoadersFile: ()=>getServerLoadersFile,
|
|
42
42
|
walkDirectory: ()=>walkDirectory,
|
|
43
43
|
hasAction: ()=>hasAction,
|
|
@@ -112,13 +112,13 @@ const hasAction = async (filename, source)=>{
|
|
|
112
112
|
return false;
|
|
113
113
|
};
|
|
114
114
|
const getServerLoadersFile = (internalDirectory, entryName)=>external_path_default().join(internalDirectory, entryName, 'route-server-loaders.js');
|
|
115
|
-
const
|
|
115
|
+
const getServerCombinedModuleFile = (internalDirectory, entryName)=>external_path_default().join(internalDirectory, entryName, 'server-loader-combined.js');
|
|
116
116
|
const getPathWithoutExt = (filename)=>{
|
|
117
117
|
const extname = external_path_default().extname(filename);
|
|
118
118
|
return extname ? filename.slice(0, -extname.length) : filename;
|
|
119
119
|
};
|
|
120
120
|
exports.getPathWithoutExt = __webpack_exports__.getPathWithoutExt;
|
|
121
|
-
exports.
|
|
121
|
+
exports.getServerCombinedModuleFile = __webpack_exports__.getServerCombinedModuleFile;
|
|
122
122
|
exports.getServerLoadersFile = __webpack_exports__.getServerLoadersFile;
|
|
123
123
|
exports.hasAction = __webpack_exports__.hasAction;
|
|
124
124
|
exports.hasLoader = __webpack_exports__.hasLoader;
|
|
@@ -128,7 +128,7 @@ exports.replaceWithAlias = __webpack_exports__.replaceWithAlias;
|
|
|
128
128
|
exports.walkDirectory = __webpack_exports__.walkDirectory;
|
|
129
129
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
130
130
|
"getPathWithoutExt",
|
|
131
|
-
"
|
|
131
|
+
"getServerCombinedModuleFile",
|
|
132
132
|
"getServerLoadersFile",
|
|
133
133
|
"hasAction",
|
|
134
134
|
"hasLoader",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SSR_HYDRATION_ID_PREFIX } from "@modern-js/utils/universal/constants";
|
|
1
2
|
import cookie from "cookie";
|
|
2
3
|
import { getGlobalInternalRuntimeContext } from "../context/index.mjs";
|
|
3
4
|
import { getInitialContext } from "../context/runtime.mjs";
|
|
@@ -86,7 +87,9 @@ async function renderWithReact17(App, rootElement) {
|
|
|
86
87
|
}
|
|
87
88
|
async function hydrateWithReact18(App, rootElement) {
|
|
88
89
|
const ReactDOM = await import("react-dom/client");
|
|
89
|
-
const root = ReactDOM.hydrateRoot(rootElement, App
|
|
90
|
+
const root = ReactDOM.hydrateRoot(rootElement, App, {
|
|
91
|
+
identifierPrefix: SSR_HYDRATION_ID_PREFIX
|
|
92
|
+
});
|
|
90
93
|
return root;
|
|
91
94
|
}
|
|
92
95
|
async function hydrateWithReact17(App, rootElement, callback) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PassThrough, Readable, Transform } from "stream";
|
|
2
2
|
import { storage } from "@modern-js/runtime-utils/node";
|
|
3
|
+
import { SSR_HYDRATION_ID_PREFIX } from "@modern-js/utils/universal/constants";
|
|
3
4
|
import { ESCAPED_SHELL_STREAM_END_MARK } from "../../../common.mjs";
|
|
4
5
|
import { RenderLevel } from "../../constants.mjs";
|
|
5
6
|
import { getGlobalInternalRuntimeContext } from "../../context/index.mjs";
|
|
@@ -37,6 +38,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
|
|
|
37
38
|
return new Promise((resolve)=>{
|
|
38
39
|
const { pipe: reactStreamingPipe } = renderToPipeableStream(processedRootElement, {
|
|
39
40
|
nonce: config.nonce,
|
|
41
|
+
identifierPrefix: SSR_HYDRATION_ID_PREFIX,
|
|
40
42
|
[onReady] () {
|
|
41
43
|
let styledComponentsStyleTags = '';
|
|
42
44
|
extenders.forEach((extender)=>{
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { time } from "@modern-js/runtime-utils/time";
|
|
2
|
+
import { SSR_HYDRATION_ID_PREFIX } from "@modern-js/utils/universal/constants";
|
|
2
3
|
import server from "react-dom/server";
|
|
3
4
|
import react_helmet from "react-helmet";
|
|
4
5
|
import { RenderLevel } from "../../constants.mjs";
|
|
@@ -65,7 +66,9 @@ async function generateHtml(App, htmlTemplate, chunkSet, collectors, htmlModifie
|
|
|
65
66
|
const finalApp = collectors.reduce((pre, creator)=>creator.collect?.(pre) || pre, App);
|
|
66
67
|
try {
|
|
67
68
|
const end = time();
|
|
68
|
-
html = server.renderToString(finalApp
|
|
69
|
+
html = server.renderToString(finalApp, {
|
|
70
|
+
identifierPrefix: SSR_HYDRATION_ID_PREFIX
|
|
71
|
+
});
|
|
69
72
|
chunkSet.renderLevel = RenderLevel.SERVER_RENDER;
|
|
70
73
|
helmetData = react_helmet.renderStatic();
|
|
71
74
|
const cost = end();
|
|
@@ -6,7 +6,7 @@ import { resolveSSRMode } from "../../../cli/ssr/mode.mjs";
|
|
|
6
6
|
import { FILE_SYSTEM_ROUTES_FILE_NAME } from "../constants.mjs";
|
|
7
7
|
import { walk } from "./nestedRoutes.mjs";
|
|
8
8
|
import { fileSystemRoutes, routesForServer, ssrLoaderCombinedModule } from "./templates.mjs";
|
|
9
|
-
import {
|
|
9
|
+
import { getServerCombinedModuleFile, getServerLoadersFile } from "./utils.mjs";
|
|
10
10
|
async function generateRoutesForEntry(entrypoint, appContext) {
|
|
11
11
|
const routes = [];
|
|
12
12
|
if (entrypoint.nestedRoutesEntry) {
|
|
@@ -119,7 +119,7 @@ const generateCode = async (appContext, config, entrypoints, api)=>{
|
|
|
119
119
|
}
|
|
120
120
|
const serverLoaderCombined = ssrLoaderCombinedModule(entrypoints, entrypoint, config, appContext);
|
|
121
121
|
if (serverLoaderCombined) {
|
|
122
|
-
const serverLoaderFile =
|
|
122
|
+
const serverLoaderFile = getServerCombinedModuleFile(internalDirectory, entryName);
|
|
123
123
|
await fs.outputFile(serverLoaderFile, serverLoaderCombined);
|
|
124
124
|
}
|
|
125
125
|
await fs.outputFile(path.resolve(internalDirectory, `./${entryName}/${FILE_SYSTEM_ROUTES_FILE_NAME}`), code, 'utf8');
|
|
@@ -65,9 +65,9 @@ const hasAction = async (filename, source)=>{
|
|
|
65
65
|
return false;
|
|
66
66
|
};
|
|
67
67
|
const getServerLoadersFile = (internalDirectory, entryName)=>path.join(internalDirectory, entryName, 'route-server-loaders.js');
|
|
68
|
-
const
|
|
68
|
+
const getServerCombinedModuleFile = (internalDirectory, entryName)=>path.join(internalDirectory, entryName, 'server-loader-combined.js');
|
|
69
69
|
const getPathWithoutExt = (filename)=>{
|
|
70
70
|
const extname = path.extname(filename);
|
|
71
71
|
return extname ? filename.slice(0, -extname.length) : filename;
|
|
72
72
|
};
|
|
73
|
-
export { getPathWithoutExt,
|
|
73
|
+
export { getPathWithoutExt, getServerCombinedModuleFile, getServerLoadersFile, hasAction, hasLoader, isPageComponentFile, parseModule, replaceWithAlias, walkDirectory };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
+
import { SSR_HYDRATION_ID_PREFIX } from "@modern-js/utils/universal/constants";
|
|
2
3
|
import cookie from "cookie";
|
|
3
4
|
import { getGlobalInternalRuntimeContext } from "../context/index.mjs";
|
|
4
5
|
import { getInitialContext } from "../context/runtime.mjs";
|
|
@@ -87,7 +88,9 @@ async function renderWithReact17(App, rootElement) {
|
|
|
87
88
|
}
|
|
88
89
|
async function hydrateWithReact18(App, rootElement) {
|
|
89
90
|
const ReactDOM = await import("react-dom/client");
|
|
90
|
-
const root = ReactDOM.hydrateRoot(rootElement, App
|
|
91
|
+
const root = ReactDOM.hydrateRoot(rootElement, App, {
|
|
92
|
+
identifierPrefix: SSR_HYDRATION_ID_PREFIX
|
|
93
|
+
});
|
|
91
94
|
return root;
|
|
92
95
|
}
|
|
93
96
|
async function hydrateWithReact17(App, rootElement, callback) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { PassThrough, Readable, Transform } from "stream";
|
|
3
3
|
import { storage } from "@modern-js/runtime-utils/node";
|
|
4
|
+
import { SSR_HYDRATION_ID_PREFIX } from "@modern-js/utils/universal/constants";
|
|
4
5
|
import { ESCAPED_SHELL_STREAM_END_MARK } from "../../../common.mjs";
|
|
5
6
|
import { RenderLevel } from "../../constants.mjs";
|
|
6
7
|
import { getGlobalInternalRuntimeContext } from "../../context/index.mjs";
|
|
@@ -38,6 +39,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
|
|
|
38
39
|
return new Promise((resolve)=>{
|
|
39
40
|
const { pipe: reactStreamingPipe } = renderToPipeableStream(processedRootElement, {
|
|
40
41
|
nonce: config.nonce,
|
|
42
|
+
identifierPrefix: SSR_HYDRATION_ID_PREFIX,
|
|
41
43
|
[onReady] () {
|
|
42
44
|
let styledComponentsStyleTags = '';
|
|
43
45
|
extenders.forEach((extender)=>{
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { time } from "@modern-js/runtime-utils/time";
|
|
3
|
+
import { SSR_HYDRATION_ID_PREFIX } from "@modern-js/utils/universal/constants";
|
|
3
4
|
import server from "react-dom/server";
|
|
4
5
|
import react_helmet from "react-helmet";
|
|
5
6
|
import { RenderLevel } from "../../constants.mjs";
|
|
@@ -66,7 +67,9 @@ async function generateHtml(App, htmlTemplate, chunkSet, collectors, htmlModifie
|
|
|
66
67
|
const finalApp = collectors.reduce((pre, creator)=>creator.collect?.(pre) || pre, App);
|
|
67
68
|
try {
|
|
68
69
|
const end = time();
|
|
69
|
-
html = server.renderToString(finalApp
|
|
70
|
+
html = server.renderToString(finalApp, {
|
|
71
|
+
identifierPrefix: SSR_HYDRATION_ID_PREFIX
|
|
72
|
+
});
|
|
70
73
|
chunkSet.renderLevel = RenderLevel.SERVER_RENDER;
|
|
71
74
|
helmetData = react_helmet.renderStatic();
|
|
72
75
|
const cost = end();
|
|
@@ -7,7 +7,7 @@ import { resolveSSRMode } from "../../../cli/ssr/mode.mjs";
|
|
|
7
7
|
import { FILE_SYSTEM_ROUTES_FILE_NAME } from "../constants.mjs";
|
|
8
8
|
import { walk } from "./nestedRoutes.mjs";
|
|
9
9
|
import { fileSystemRoutes, routesForServer, ssrLoaderCombinedModule } from "./templates.mjs";
|
|
10
|
-
import {
|
|
10
|
+
import { getServerCombinedModuleFile, getServerLoadersFile } from "./utils.mjs";
|
|
11
11
|
async function generateRoutesForEntry(entrypoint, appContext) {
|
|
12
12
|
const routes = [];
|
|
13
13
|
if (entrypoint.nestedRoutesEntry) {
|
|
@@ -120,7 +120,7 @@ const generateCode = async (appContext, config, entrypoints, api)=>{
|
|
|
120
120
|
}
|
|
121
121
|
const serverLoaderCombined = ssrLoaderCombinedModule(entrypoints, entrypoint, config, appContext);
|
|
122
122
|
if (serverLoaderCombined) {
|
|
123
|
-
const serverLoaderFile =
|
|
123
|
+
const serverLoaderFile = getServerCombinedModuleFile(internalDirectory, entryName);
|
|
124
124
|
await fs.outputFile(serverLoaderFile, serverLoaderCombined);
|
|
125
125
|
}
|
|
126
126
|
await fs.outputFile(path.resolve(internalDirectory, `./${entryName}/${FILE_SYSTEM_ROUTES_FILE_NAME}`), code, 'utf8');
|
|
@@ -66,9 +66,9 @@ const hasAction = async (filename, source)=>{
|
|
|
66
66
|
return false;
|
|
67
67
|
};
|
|
68
68
|
const getServerLoadersFile = (internalDirectory, entryName)=>path.join(internalDirectory, entryName, 'route-server-loaders.js');
|
|
69
|
-
const
|
|
69
|
+
const getServerCombinedModuleFile = (internalDirectory, entryName)=>path.join(internalDirectory, entryName, 'server-loader-combined.js');
|
|
70
70
|
const getPathWithoutExt = (filename)=>{
|
|
71
71
|
const extname = path.extname(filename);
|
|
72
72
|
return extname ? filename.slice(0, -extname.length) : filename;
|
|
73
73
|
};
|
|
74
|
-
export { getPathWithoutExt,
|
|
74
|
+
export { getPathWithoutExt, getServerCombinedModuleFile, getServerLoadersFile, hasAction, hasLoader, isPageComponentFile, parseModule, replaceWithAlias, walkDirectory };
|
|
@@ -8,5 +8,5 @@ export declare const parseModule: ({ source, filename, }: {
|
|
|
8
8
|
export declare const hasLoader: (filename: string, source?: string) => Promise<boolean>;
|
|
9
9
|
export declare const hasAction: (filename: string, source?: string) => Promise<boolean>;
|
|
10
10
|
export declare const getServerLoadersFile: (internalDirectory: string, entryName: string) => string;
|
|
11
|
-
export declare const
|
|
11
|
+
export declare const getServerCombinedModuleFile: (internalDirectory: string, entryName: string) => string;
|
|
12
12
|
export declare const getPathWithoutExt: (filename: string) => string;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "3.0
|
|
18
|
+
"version": "3.1.0",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=20"
|
|
21
21
|
},
|
|
@@ -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/plugin": "3.0
|
|
219
|
-
"@modern-js/plugin-data-loader": "3.0
|
|
220
|
-
"@modern-js/render": "3.0
|
|
221
|
-
"@modern-js/
|
|
222
|
-
"@modern-js/
|
|
223
|
-
"@modern-js/utils": "3.0
|
|
218
|
+
"@modern-js/plugin": "3.1.0",
|
|
219
|
+
"@modern-js/plugin-data-loader": "3.1.0",
|
|
220
|
+
"@modern-js/render": "3.1.0",
|
|
221
|
+
"@modern-js/runtime-utils": "3.1.0",
|
|
222
|
+
"@modern-js/types": "3.1.0",
|
|
223
|
+
"@modern-js/utils": "3.1.0"
|
|
224
224
|
},
|
|
225
225
|
"peerDependencies": {
|
|
226
226
|
"react": ">=17.0.2",
|
|
@@ -240,9 +240,9 @@
|
|
|
240
240
|
"react-dom": "^19.2.4",
|
|
241
241
|
"ts-node": "^10.9.2",
|
|
242
242
|
"typescript": "^5",
|
|
243
|
-
"@modern-js/app-tools": "3.0.5",
|
|
244
243
|
"@modern-js/rslib": "2.68.10",
|
|
245
|
-
"@scripts/rstest-config": "2.66.0"
|
|
244
|
+
"@scripts/rstest-config": "2.66.0",
|
|
245
|
+
"@modern-js/app-tools": "3.1.0"
|
|
246
246
|
},
|
|
247
247
|
"sideEffects": false,
|
|
248
248
|
"publishConfig": {
|