Skip to content

Commit 544c2ba

Browse files
authored
docs: fix note format (#3823)
1 parent b6efa44 commit 544c2ba

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

apps/website-new/docs/en/guide/framework/modernjs.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,13 @@ In CSR applications, the loader function executes in the browser, meaning they a
251251
In SSR applications, the loader function only executes on the server, meaning they are all Server Loaders by default. In SSR, Module Federation directly calls the corresponding loader function on the server. When switching routes in the browser, Module Federation sends an HTTP request to the SSR service, which also triggers the loader function on the server.
252252

253253
:::note NOTE
254+
254255
Having the loader function for SSR applications execute only on the server offers the following benefits:
255256

256257
- Simplified usage: Ensures that data fetching in SSR applications is isomorphic, so developers don't need to differentiate loader function execution code based on the environment.
257258
- Reduced browser bundle size: Moves logic code and its dependencies from the browser to the server.
258259
- Improved maintainability: Moves logic code to the server, reducing the direct impact of data logic on the frontend UI. Additionally, it prevents accidental inclusion of server-side dependencies in the browser bundle or browser-side dependencies in the server bundle.
260+
259261
:::
260262

261263
#### Using Client Loader in SSR Applications
@@ -280,6 +282,7 @@ export async function loader({ params }) {
280282
}
281283
}
282284
```
285+
283286
:::warning WARNING
284287
To use a Client Loader, there must be a corresponding Server Loader, and the Server Loader must be defined using the `.data` file convention, not the `.loader` file convention.
285288
:::

apps/website-new/docs/zh/guide/framework/modernjs.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,13 @@ loader 函数可能会在服务端或浏览器端执行。在服务端执行的
252252
在 SSR 应用中,loader 函数只会在服务端执行,即默认都是 Server Loader。在 SSR Module Federation 会直接在服务端调用对应的 loader 函数。在浏览器端切换路由时,Module Federation 会发送一个 http 请求到 SSR 服务,同样在服务端触发 loader 函数。
253253

254254
:::note NOTE
255+
255256
SSR 应用的 loader 函数只在服务端执行可以带来以下好处:
256257

257258
简化使用方式:保证 SSR 应用获取数据的方式是同构的,开发者无需根据环境区分 loader 函数执行的代码。
258259
减少浏览器端 bundle 体积:将逻辑代码及其依赖,从浏览器端移动到了服务端。
259260
提高可维护性:将逻辑代码移动到服务端,减少了数据逻辑对前端 UI 的直接影响。此外,也避免了浏览器端 bundle 中误引入服务端依赖,或服务端 bundle 中误引入浏览器端依赖的问题。
261+
260262
:::
261263

262264
#### 在 SSR 应用中使用 Client Loader
@@ -282,7 +284,9 @@ export async function loader({ params }) {
282284
}
283285
```
284286
:::warning WARNING
287+
285288
要使用 Client Loader,必须有对应的 Server Loader,且 Server Loader 必须是 .data 文件约定,不能是 .loader 文件约定。
289+
286290
:::
287291

288292
### FAQ

0 commit comments

Comments
 (0)