@modern-js/main-doc 2.66.1-alpha.2 → 2.67.1
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/docs/en/apis/app/hooks/src/entry.server.mdx +2 -2
- package/docs/en/components/nodeVersion.mdx +15 -9
- package/docs/en/components/prerequisites.mdx +1 -1
- package/docs/en/configure/app/source/enable-custom-entry.mdx +2 -2
- package/docs/en/guides/basic-features/data/data-cache.mdx +4 -0
- package/docs/zh/apis/app/hooks/src/entry.server.mdx +2 -2
- package/docs/zh/components/nodeVersion.mdx +14 -10
- package/docs/zh/components/prerequisites.mdx +1 -1
- package/docs/zh/configure/app/source/enable-custom-entry.mdx +2 -2
- package/docs/zh/guides/basic-features/data/data-cache.mdx +4 -0
- package/package.json +4 -4
@@ -35,8 +35,8 @@ export default createRequestHandler(handleRequest);
|
|
35
35
|
Users need to customize the Server-Side Rendering entry points, they can customize the server entry in `src/entry.server.ts` or `src/{entryName}/entry.server.ts`.
|
36
36
|
|
37
37
|
```tsx title="src/entry.server.tsx"
|
38
|
-
import { renderString, createRequestHandler } from '@
|
39
|
-
import type { HandleRequest } from '@
|
38
|
+
import { renderString, createRequestHandler } from '@modern-js/runtime/ssr/server';
|
39
|
+
import type { HandleRequest } from '@modern-js/runtime/ssr/server';
|
40
40
|
|
41
41
|
const handleRequest: HandleRequest = async (request, ServerRoot, options) => {
|
42
42
|
// do something before rendering
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Before getting started, you will need to install [Node.js](https://nodejs.org/), and ensure that your Node.js version is higher than
|
1
|
+
Before getting started, you will need to install [Node.js](https://nodejs.org/), and ensure that your Node.js version is higher than 18.20.8. **We recommend using the LTS version of Node.js 22.**
|
2
2
|
|
3
3
|
You can check the currently used Node.js version with the following command:
|
4
4
|
|
@@ -6,21 +6,27 @@ You can check the currently used Node.js version with the following command:
|
|
6
6
|
node -v
|
7
7
|
```
|
8
8
|
|
9
|
-
If you do not have Node.js installed in your current environment, or the installed version is lower than
|
9
|
+
If you do not have Node.js installed in your current environment, or the installed version is lower than 18.20.8, you can use [nvm](https://github.com/nvm-sh/nvm) or [fnm](https://github.com/Schniz/fnm) to install the required version.
|
10
10
|
|
11
|
-
Here is an example of how to install the Node.js
|
11
|
+
Here is an example of how to install the Node.js 22 LTS version via nvm:
|
12
12
|
|
13
13
|
```bash
|
14
|
-
# Install the long-term support version of Node.js
|
15
|
-
nvm install
|
14
|
+
# Install the long-term support version of Node.js 22
|
15
|
+
nvm install 22 --lts
|
16
16
|
|
17
|
-
# Make the newly installed Node.js
|
18
|
-
nvm alias default
|
17
|
+
# Make the newly installed Node.js 22 as the default version
|
18
|
+
nvm alias default 22
|
19
19
|
|
20
|
-
# Switch to the newly installed Node.js
|
21
|
-
nvm use
|
20
|
+
# Switch to the newly installed Node.js 22
|
21
|
+
nvm use 22
|
22
22
|
```
|
23
23
|
|
24
24
|
:::tip nvm and fnm
|
25
25
|
Both nvm and fnm are Node.js version management tools. Relatively speaking, nvm is more mature and stable, while fnm is implemented using Rust, which provides better performance than nvm.
|
26
26
|
:::
|
27
|
+
|
28
|
+
Additionally, after installing nvm or fnm, when there is a `.nvmrc` file containing `lts/jod` in the repository's root directory, the system will automatically install or switch to the correct Node.js version upon entering the repository.
|
29
|
+
|
30
|
+
:::warning
|
31
|
+
Modern.js currently still supports Node 16, but will officially terminate support for Node.js 16 in June 2025. To ensure a smooth transition for your project, please complete the Node.js version upgrade before June 2025.
|
32
|
+
:::
|
@@ -46,8 +46,8 @@ For more browser entry details, refer to [Entries](/guides/concept/entries.html)
|
|
46
46
|
create `src/entry.server.tsx` file,add custom behavior for rendering responses:
|
47
47
|
|
48
48
|
```tsx
|
49
|
-
import { renderString, createRequestHandler } from '@
|
50
|
-
import type { HandleRequest } from '@
|
49
|
+
import { renderString, createRequestHandler } from '@modern-js/runtime/ssr/server';
|
50
|
+
import type { HandleRequest } from '@modern-js/runtime/ssr/server';
|
51
51
|
|
52
52
|
const handleRequest: HandleRequest = async (request, ServerRoot, options) => {
|
53
53
|
// do something before rendering
|
@@ -35,8 +35,8 @@ export default createRequestHandler(handleRequest);
|
|
35
35
|
如果用户需自定义 Server-Side Rendering 入口,可以在 `src/entry.server.ts`、`src/{entryName}/entry.server.ts` 中自定义 server 入口。
|
36
36
|
|
37
37
|
```tsx title="src/entry.server.tsx"
|
38
|
-
import { renderString, createRequestHandler } from '@
|
39
|
-
import type { HandleRequest } from '@
|
38
|
+
import { renderString, createRequestHandler } from '@modern-js/runtime/ssr/server';
|
39
|
+
import type { HandleRequest } from '@modern-js/runtime/ssr/server';
|
40
40
|
|
41
41
|
const handleRequest: HandleRequest = async (request, ServerRoot, options) => {
|
42
42
|
// do something before rendering
|
@@ -1,4 +1,4 @@
|
|
1
|
-
在开始使用前,你需要安装 [Node.js](https://nodejs.org/),并保证 Node.js 版本不低于
|
1
|
+
在开始使用前,你需要安装 [Node.js](https://nodejs.org/),并保证 Node.js 版本不低于 18.20.8,**我们推荐使用 Node.js 22 的 LTS 版本**。
|
2
2
|
|
3
3
|
你可以通过以下命令检查当前使用的 Node.js 版本:
|
4
4
|
|
@@ -6,23 +6,27 @@
|
|
6
6
|
node -v
|
7
7
|
```
|
8
8
|
|
9
|
-
如果你当前的环境中尚未安装 Node.js,或是安装的版本低于
|
9
|
+
如果你当前的环境中尚未安装 Node.js,或是安装的版本低于 18,可以通过 [nvm](https://github.com/nvm-sh/nvm) 或 [fnm](https://github.com/Schniz/fnm) 安装需要的版本。
|
10
10
|
|
11
|
-
下面是通过 nvm 安装 Node.js
|
11
|
+
下面是通过 nvm 安装 Node.js 22 LTS 版本的例子:
|
12
12
|
|
13
13
|
```bash
|
14
|
-
# 安装 Node.js
|
15
|
-
nvm install
|
14
|
+
# 安装 Node.js 22 的长期支持版本
|
15
|
+
nvm install 22 --lts
|
16
16
|
|
17
|
-
# 将刚安装的 Node.js
|
18
|
-
nvm alias default
|
17
|
+
# 将刚安装的 Node.js 22 设置为默认版本
|
18
|
+
nvm alias default 22
|
19
19
|
|
20
|
-
# 切换到刚安装的 Node.js
|
21
|
-
nvm use
|
20
|
+
# 切换到刚安装的 Node.js 22
|
21
|
+
nvm use 22
|
22
22
|
```
|
23
23
|
|
24
24
|
:::tip nvm 和 fnm
|
25
25
|
nvm 和 fnm 都是 Node.js 版本管理工具。相对来说,nvm 较为成熟和稳定,而 fnm 是使用 Rust 实现的,比 nvm 提供了更好的性能。
|
26
26
|
:::
|
27
27
|
|
28
|
-
此外,在安装 nvm 或 fnm 后,然后只要仓库根目录下有内容为 `lts/
|
28
|
+
此外,在安装 nvm 或 fnm 后,然后只要仓库根目录下有内容为 `lts/jod` 的 `.nvmrc` 文件,进入这个仓库时就会自动安装或切换到正确的 Node.js 版本。
|
29
|
+
|
30
|
+
:::warning
|
31
|
+
Modern.js 目前仍支持 Node 16,但会在 2025 年 6 月正式终止对 Node.js 16 的支持,为确保您的项目顺利过渡,请在 2025 年 6 月前完成 Node.js 版本升级。
|
32
|
+
:::
|
@@ -45,8 +45,8 @@ beforeRender().then(() => {
|
|
45
45
|
创建 `src/entry.server.tsx` 文件,为渲染响应添加自定义行为:
|
46
46
|
|
47
47
|
```tsx
|
48
|
-
import { renderString, createRequestHandler } from '@
|
49
|
-
import type { HandleRequest } from '@
|
48
|
+
import { renderString, createRequestHandler } from '@modern-js/runtime/ssr/server';
|
49
|
+
import type { HandleRequest } from '@modern-js/runtime/ssr/server';
|
50
50
|
|
51
51
|
const handleRequest: HandleRequest = async (request, ServerRoot, options) => {
|
52
52
|
// do something before rendering
|
package/package.json
CHANGED
@@ -15,17 +15,17 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.
|
18
|
+
"version": "2.67.1",
|
19
19
|
"publishConfig": {
|
20
20
|
"registry": "https://registry.npmjs.org/",
|
21
21
|
"access": "public"
|
22
22
|
},
|
23
23
|
"dependencies": {
|
24
24
|
"mermaid": "^11.4.1",
|
25
|
-
"@modern-js/sandpack-react": "2.
|
25
|
+
"@modern-js/sandpack-react": "2.67.1"
|
26
26
|
},
|
27
27
|
"devDependencies": {
|
28
|
-
"@rspress/shared": "1.
|
28
|
+
"@rspress/shared": "1.43.10",
|
29
29
|
"@types/fs-extra": "9.0.13",
|
30
30
|
"@types/node": "^16",
|
31
31
|
"classnames": "^2",
|
@@ -33,7 +33,7 @@
|
|
33
33
|
"fs-extra": "^10",
|
34
34
|
"react": "^18.3.1",
|
35
35
|
"react-dom": "^18.3.1",
|
36
|
-
"rspress": "1.
|
36
|
+
"rspress": "1.43.10",
|
37
37
|
"ts-node": "^10.9.1",
|
38
38
|
"typescript": "^5"
|
39
39
|
},
|