@modern-js/main-doc 3.0.0 → 3.0.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.
Files changed (72) hide show
  1. package/docs/en/_nav.json +1 -1
  2. package/docs/en/apis/app/commands.mdx +1 -1
  3. package/docs/en/community/blog/_meta.json +7 -1
  4. package/docs/en/community/blog/v3-release-note.mdx +625 -0
  5. package/docs/en/components/rsbuild.mdx +1 -1
  6. package/docs/en/configure/app/builder-plugins.mdx +1 -1
  7. package/docs/en/configure/app/dev/server.mdx +7 -7
  8. package/docs/en/configure/app/resolve/alias-strategy.mdx +1 -1
  9. package/docs/en/configure/app/resolve/dedupe.mdx +1 -1
  10. package/docs/en/configure/app/security/sri.mdx +1 -1
  11. package/docs/en/configure/app/server/rsc.mdx +2 -2
  12. package/docs/en/configure/app/source/decorators.mdx +1 -1
  13. package/docs/en/configure/app/tools/bundler-chain.mdx +1 -1
  14. package/docs/en/configure/app/tools/dev-server.mdx +1 -1
  15. package/docs/en/configure/app/tools/swc.mdx +2 -2
  16. package/docs/en/guides/advanced-features/compatibility.mdx +1 -1
  17. package/docs/en/guides/advanced-features/page-performance/optimize-bundle.mdx +1 -1
  18. package/docs/en/guides/basic-features/css/css.mdx +4 -4
  19. package/docs/en/guides/basic-features/css/tailwindcss.mdx +2 -2
  20. package/docs/en/guides/basic-features/debug/proxy.mdx +1 -1
  21. package/docs/en/guides/basic-features/render/rsc.mdx +137 -8
  22. package/docs/en/guides/concept/builder.mdx +3 -3
  23. package/docs/en/guides/get-started/tech-stack.mdx +3 -3
  24. package/docs/en/guides/topic-detail/module-federation/application.mdx +6 -6
  25. package/docs/en/guides/topic-detail/module-federation/deploy.mdx +2 -2
  26. package/docs/en/guides/topic-detail/module-federation/i18n.mdx +12 -12
  27. package/docs/en/guides/topic-detail/module-federation/introduce.mdx +1 -1
  28. package/docs/en/guides/topic-detail/module-federation/ssr.mdx +4 -4
  29. package/docs/en/guides/topic-detail/module-federation/usage.mdx +7 -7
  30. package/docs/en/guides/troubleshooting/builder.mdx +4 -4
  31. package/docs/en/guides/upgrade/config.mdx +31 -3
  32. package/docs/en/plugin/cli-plugins/api.mdx +9 -9
  33. package/docs/en/plugin/introduction.mdx +5 -5
  34. package/docs/zh/_nav.json +1 -1
  35. package/docs/zh/apis/app/commands.mdx +1 -1
  36. package/docs/zh/community/blog/_meta.json +7 -1
  37. package/docs/zh/community/blog/v3-release-note.mdx +626 -0
  38. package/docs/zh/components/rsbuild.mdx +1 -1
  39. package/docs/zh/configure/app/builder-plugins.mdx +1 -1
  40. package/docs/zh/configure/app/dev/server.mdx +7 -7
  41. package/docs/zh/configure/app/resolve/alias-strategy.mdx +1 -1
  42. package/docs/zh/configure/app/resolve/dedupe.mdx +1 -1
  43. package/docs/zh/configure/app/security/sri.mdx +1 -1
  44. package/docs/zh/configure/app/server/rsc.mdx +2 -2
  45. package/docs/zh/configure/app/source/decorators.mdx +1 -1
  46. package/docs/zh/configure/app/tools/bundler-chain.mdx +1 -1
  47. package/docs/zh/configure/app/tools/dev-server.mdx +1 -1
  48. package/docs/zh/configure/app/tools/swc.mdx +2 -2
  49. package/docs/zh/guides/advanced-features/compatibility.mdx +1 -1
  50. package/docs/zh/guides/advanced-features/page-performance/optimize-bundle.mdx +1 -1
  51. package/docs/zh/guides/basic-features/css/css.mdx +4 -4
  52. package/docs/zh/guides/basic-features/css/tailwindcss.mdx +2 -2
  53. package/docs/zh/guides/basic-features/debug/proxy.mdx +1 -1
  54. package/docs/zh/guides/basic-features/render/rsc.mdx +222 -8
  55. package/docs/zh/guides/concept/builder.mdx +3 -3
  56. package/docs/zh/guides/get-started/tech-stack.mdx +3 -3
  57. package/docs/zh/guides/topic-detail/module-federation/application.mdx +6 -6
  58. package/docs/zh/guides/topic-detail/module-federation/deploy.mdx +2 -2
  59. package/docs/zh/guides/topic-detail/module-federation/i18n.mdx +12 -12
  60. package/docs/zh/guides/topic-detail/module-federation/introduce.mdx +1 -1
  61. package/docs/zh/guides/topic-detail/module-federation/ssr.mdx +4 -4
  62. package/docs/zh/guides/topic-detail/module-federation/usage.mdx +7 -7
  63. package/docs/zh/guides/troubleshooting/builder.mdx +4 -4
  64. package/docs/zh/guides/upgrade/config.mdx +31 -3
  65. package/docs/zh/plugin/cli-plugins/api.mdx +9 -9
  66. package/docs/zh/plugin/introduction.mdx +5 -5
  67. package/package.json +6 -5
  68. package/rspress.config.ts +1 -2
  69. package/src/components/Mermaid/index.tsx +3 -0
  70. package/src/components/RsbuildLink/index.tsx +1 -1
  71. package/src/index.ts +1 -1
  72. package/src/pages/index.tsx +1 -1
@@ -28,7 +28,7 @@ export default {
28
28
  };
29
29
  ```
30
30
 
31
- For more details, please refer to the [Rsbuild - server.compress](https://rsbuild.rs/config/server/compress) documentation.
31
+ For more details, please refer to the [Rsbuild - server.compress](https://v2.rsbuild.dev/config/server/compress) documentation.
32
32
 
33
33
  ### headers
34
34
 
@@ -49,7 +49,7 @@ export default {
49
49
  };
50
50
  ```
51
51
 
52
- For more details, please refer to the [Rsbuild - server.headers](https://rsbuild.rs/config/server/headers) documentation.
52
+ For more details, please refer to the [Rsbuild - server.headers](https://v2.rsbuild.dev/config/server/headers) documentation.
53
53
 
54
54
  ### historyApiFallback
55
55
 
@@ -68,7 +68,7 @@ export default {
68
68
  };
69
69
  ```
70
70
 
71
- For more configuration options, please refer to the [Rsbuild - server.historyApiFallback](https://rsbuild.rs/config/server/history-api-fallback) documentation.
71
+ For more configuration options, please refer to the [Rsbuild - server.historyApiFallback](https://v2.rsbuild.dev/config/server/history-api-fallback) documentation.
72
72
 
73
73
  ### watch
74
74
 
@@ -77,7 +77,7 @@ For more configuration options, please refer to the [Rsbuild - server.historyApi
77
77
 
78
78
  Whether to watch files change in directories such as `mock/`, `server/`, `api/`.
79
79
 
80
- For more details, please refer to the [Rsbuild - dev.watchFiles](https://rsbuild.rs/config/dev/watch-files) documentation.
80
+ For more details, please refer to the [Rsbuild - dev.watchFiles](https://v2.rsbuild.dev/config/dev/watch-files) documentation.
81
81
 
82
82
  ### cors
83
83
 
@@ -100,7 +100,7 @@ const defaultOptions = {
100
100
  };
101
101
  ```
102
102
 
103
- For more configuration options and detailed usage, please refer to the [Rsbuild - server.cors](https://rsbuild.rs/config/server/cors) documentation.
103
+ For more configuration options and detailed usage, please refer to the [Rsbuild - server.cors](https://v2.rsbuild.dev/config/server/cors) documentation.
104
104
 
105
105
  ### proxy
106
106
 
@@ -116,7 +116,7 @@ export default {
116
116
  proxy: {
117
117
  // http://localhost:8080/api -> https://example.com/api
118
118
  // http://localhost:8080/api/foo -> https://example.com/api/foo
119
- '/api': 'https://example.com/api',
119
+ '/api': 'https://example.com',
120
120
  },
121
121
  },
122
122
  },
@@ -124,5 +124,5 @@ export default {
124
124
  ```
125
125
 
126
126
  :::tip
127
- This option is the same as Rsbuild's `server.proxy` option, see [Rsbuild - server.proxy](https://v2.rsbuild.rs/config/server/proxy) for detailed usage.
127
+ This option is the same as Rsbuild's `server.proxy` option, see [Rsbuild - server.proxy](https://v2.rsbuild.dev/config/server/proxy) for detailed usage.
128
128
  :::
@@ -7,7 +7,7 @@ title: aliasStrategy
7
7
  - **Type:** `'prefer-tsconfig' | 'prefer-alias'`
8
8
  - **Default:** `'prefer-tsconfig'`
9
9
 
10
- Set the strategy for path alias resolution, to control the priority relationship between the paths option in `tsconfig.json` and the [resolve.alias](https://rsbuild.rs/config/resolve/alias) option of Rsbuild.
10
+ Set the strategy for path alias resolution, to control the priority relationship between the paths option in `tsconfig.json` and the [resolve.alias](https://v2.rsbuild.dev/config/resolve/alias) option of Rsbuild.
11
11
 
12
12
  import RsbuildConfig from '@site-docs/components/rsbuild-config-tooltip';
13
13
 
@@ -6,7 +6,7 @@ title: dedupe
6
6
 
7
7
  - **Type:** `string[]`
8
8
 
9
- Force Rsbuild to resolve the specified packages from project root, which is useful for deduplicating packages and reducing the bundle size. same as the [resolve.dedupe](https://rsbuild.rs/config/resolve/dedupe) config of Rsbuild.
9
+ Force Rsbuild to resolve the specified packages from project root, which is useful for deduplicating packages and reducing the bundle size. same as the [resolve.dedupe](https://v2.rsbuild.dev/config/resolve/dedupe) config of Rsbuild.
10
10
 
11
11
  import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
12
12
 
@@ -18,7 +18,7 @@ type SriOptions = {
18
18
  Adding an `integrity` attribute to `<script>` and `<link rel="stylesheet">` tags introduced by HTML allows the browser to verify the integrity of the introduced resource, thus preventing tampering with the downloaded resource.
19
19
 
20
20
  :::info
21
- For a specific introduction to SRI, you can refer to [Rsbuild security.sri](https://rsbuild.rs/zh/config/security/sri).
21
+ For a specific introduction to SRI, you can refer to [Rsbuild security.sri](https://v2.rsbuild.dev/zh/config/security/sri).
22
22
 
23
23
  This configuration type is not completely consistent with Rsbuild and will be automatically converted during the build process.
24
24
  :::
@@ -21,8 +21,8 @@ export default defineConfig({
21
21
 
22
22
  :::tip Prerequisites
23
23
  Before enabling RSC, ensure:
24
- 1. React and React DOM are upgraded to version 19 (recommended 19.2.3 or above)
25
- 2. Install the `react-server-dom-webpack` dependency
24
+ 1. React and React DOM are upgraded to version 19 (recommended 19.2.4 or above)
25
+ 2. Install the `react-server-dom-rspack@0.0.1-beta.0` dependency
26
26
 
27
27
  :::
28
28
 
@@ -23,7 +23,7 @@ const defaultDecorators = {
23
23
  Used to configure the decorators syntax.
24
24
 
25
25
  :::warning
26
- The usage of this configuration item is exactly the same as that of Rsbuild, but the default value is different. For detailed information, please refer to [Rsbuild - source.decorators](https://rsbuild.rs/config/source/decorators).
26
+ The usage of this configuration item is exactly the same as that of Rsbuild, but the default value is different. For detailed information, please refer to [Rsbuild - source.decorators](https://v2.rsbuild.dev/config/source/decorators).
27
27
  :::
28
28
 
29
29
  We found that most projects still use the `legacy` version of the decorator syntax, so the default value is `legacy`.
@@ -27,4 +27,4 @@ Configurations modified via bundler chain will work on Rspack builds.
27
27
 
28
28
  > `tools.bundlerChain` is executed earlier than tools.rspack and thus will be overridden by changes in tools.rspack.
29
29
 
30
- For more information, please refer to [Rsbuild#tools.bundlerChain](https://rsbuild.rs/config/tools/bundler-chain).
30
+ For more information, please refer to [Rsbuild#tools.bundlerChain](https://v2.rsbuild.dev/config/tools/bundler-chain).
@@ -102,7 +102,7 @@ export default {
102
102
  proxy: {
103
103
  // http://localhost:8080/api -> https://example.com/api
104
104
  // http://localhost:8080/api/foo -> https://example.com/api/foo
105
- '/api': 'https://example.com/api',
105
+ '/api': 'https://example.com',
106
106
  },
107
107
  },
108
108
  },
@@ -35,7 +35,7 @@ export default defineConfig({
35
35
  });
36
36
  ```
37
37
 
38
- For more usage, please refer to [Rsbuild - tools.swc](https://rsbuild.rs/config/tools/swc).
38
+ For more usage, please refer to [Rsbuild - tools.swc](https://v2.rsbuild.dev/config/tools/swc).
39
39
 
40
40
  ### Register SWC Plugin
41
41
 
@@ -66,4 +66,4 @@ This means that you must to choose an SWC plugin that matches the current versio
66
66
 
67
67
  If you encounter the above issues, a common solution is to upgrade both the Modern.js and SWC plugins to the latest versions.
68
68
 
69
- For details, please refer to [Rsbuild - SWC Plugin Version](https://rsbuild.rs/guide/basic/configure-swc#swc-plugin-version).
69
+ For details, please refer to [Rsbuild - SWC Plugin Version](https://v2.rsbuild.dev/guide/configuration/swc#swc-plugin-version).
@@ -56,7 +56,7 @@ The `overrideBrowserslist` configuration has a higher priority than the `.browse
56
56
  In most scenarios, it is recommended to prioritize using the `.browserslistrc` file rather than the `overrideBrowserslist` configuration because the `.browserslistrc` file is the officially defined configuration file, has better general applicability, and can be recognized by other libraries in the community.
57
57
 
58
58
  :::tip
59
- Please refer to [Rsbuild - Setting Browser Range](https://rsbuild.rs/zh/guide/advanced/browserslist) for more information.
59
+ Please refer to [Rsbuild - Setting Browser Range](https://v2.rsbuild.dev/zh/guide/advanced/browserslist) for more information.
60
60
  :::
61
61
 
62
62
  import UpgradeBrowserslist from '@site-docs-en/components/upgrade-browserslist';
@@ -98,4 +98,4 @@ See details in [plugin-image-compress](https://github.com/rspack-contrib/rsbuild
98
98
 
99
99
  A great chunk splitting strategy is very important to improve the loading performance of the application. It can make full use of the browser's caching mechanism to reduce the number of requests and improve the loading speed of the application.
100
100
 
101
- A variety of [chunk splitting strategies](https://rsbuild.rs/guide/optimization/split-chunk) are built into Modern.js, which can meet the needs of most applications. You can also customize the chunk splitting config according to your own business scenarios.
101
+ A variety of [chunk splitting strategies](https://v2.rsbuild.dev/guide/optimization/code-splitting) are built into Modern.js, which can meet the needs of most applications. You can also customize the chunk splitting config according to your own business scenarios.
@@ -12,20 +12,20 @@ Modern.js has built-in popular community CSS preprocessors, including Less and S
12
12
 
13
13
  By default, you don't need to configure Less and Sass. If you have custom loader configuration requirements, you can set them up by configuring [tools.less](/configure/app/tools/less) and [tools.sass](/configure/app/tools/sass).
14
14
 
15
- You can also use Stylus in Modern.js by installing the Stylus plugin provided by Rsbuild. For usage, please refer to [Stylus Plugin](https://rsbuild.rs/plugins/list/plugin-stylus).
15
+ You can also use Stylus in Modern.js by installing the Stylus plugin provided by Rsbuild. For usage, please refer to [Stylus Plugin](https://v2.rsbuild.dev/plugins/list/plugin-stylus).
16
16
 
17
17
  ## Using PostCSS
18
18
 
19
19
  Modern.js has built-in [PostCSS](https://postcss.org/) to transform CSS code.
20
20
 
21
- Please refer to [Rsbuild - Using PostCSS](https://rsbuild.rs/guide/styling/css-usage) for detailed usage.
21
+ Please refer to [Rsbuild - Using PostCSS](https://v2.rsbuild.dev/guide/styling/css-usage) for detailed usage.
22
22
 
23
23
  ## Using Lightning CSS
24
24
 
25
25
  Modern.js supports using [Lightning CSS](https://lightningcss.dev/) to convert CSS code. This feature can be turned on by configuring [tools.lightningcssLoader](/configure/app/tools/lightningcss-loader).
26
26
 
27
- Please refer to [Rsbuild - Using Lightning CSS](https://rsbuild.rs/guide/styling/css-usage#lightning-css) for detailed usage.
27
+ Please refer to [Rsbuild - Using Lightning CSS](https://v2.rsbuild.dev/guide/styling/css-usage#lightning-css) for detailed usage.
28
28
 
29
29
  ## Using Uno CSS
30
30
 
31
- Please read the [Rsbuild - Using UnoCSS](https://rsbuild.rs/guide/styling/unocss) for detailed usage.
31
+ Please read the [Rsbuild - Using UnoCSS](https://v2.rsbuild.dev/guide/styling/unocss) for detailed usage.
@@ -6,8 +6,8 @@
6
6
 
7
7
  To use [Tailwind CSS](https://tailwindcss.com/) in Modern.js, you only need to configure it according to the Rsbuild steps. Rsbuild supports Tailwind CSS versions v3 and v4:
8
8
 
9
- - [Tailwind CSS v3](https://rsbuild.rs/guide/styling/tailwindcss-v3#tailwind-css-v3)
10
- - [Tailwind CSS v4](https://rsbuild.rs/guide/styling/tailwindcss)
9
+ - [Tailwind CSS v3](https://v2.rsbuild.dev/guide/styling/tailwindcss-v3#tailwind-css-v3)
10
+ - [Tailwind CSS v4](https://v2.rsbuild.dev/guide/styling/tailwindcss)
11
11
 
12
12
  ## Tailwind CSS Autocomplete
13
13
 
@@ -17,7 +17,7 @@ export default defineConfig({
17
17
  proxy: {
18
18
  // http://localhost:8080/api -> https://example.com/api
19
19
  // http://localhost:8080/api/foo -> https://example.com/api/foo
20
- '/api': 'https://example.com/api',
20
+ '/api': 'https://example.com',
21
21
  },
22
22
  },
23
23
  },
@@ -21,12 +21,12 @@ Before starting, we recommend reading React's official [Server Components docume
21
21
 
22
22
  ## Quick Start
23
23
 
24
- 1. **Ensure React and React DOM are upgraded to version 19** (recommended version 19.2.3 or above)
24
+ 1. **Ensure React and React DOM are upgraded to version 19** (recommended version 19.2.4 or above)
25
25
 
26
- 2. **Install the `react-server-dom-webpack` dependency**
26
+ 2. **Install the `react-server-dom-rspack@0.0.1-beta.0` dependency**
27
27
 
28
28
  ```bash
29
- npm install react-server-dom-webpack
29
+ npm install react-server-dom-rspack@0.0.1-beta.0
30
30
  ```
31
31
 
32
32
  :::warning Notes
@@ -49,8 +49,8 @@ export default defineConfig({
49
49
  ```
50
50
 
51
51
  :::info Migrating from Legacy CSR Projects
52
- If you have a CSR project that uses Modern.js data loaders, after enabling RSC, data loaders will execute on the server by default.
53
- To maintain consistency with the original behavior, you need to change all `.data.ts` files to `.data.client.ts` first.
52
+ If you have a CSR project that uses Modern.js Data Loaders, after enabling RSC, Data Loaders will execute on the server by default.
53
+ For detailed migration guide, please refer to [CSR Project Migration to RSC](#csr-project-migration-guide).
54
54
 
55
55
  :::
56
56
 
@@ -233,11 +233,140 @@ Each level of route components (such as `layout.tsx`, `page.tsx`) can independen
233
233
 
234
234
  For example, if `layout.tsx` is a Client Component (requiring client-side interactivity), you can still set `page.tsx` as a Server Component (for data fetching and rendering). This approach provides great flexibility and allows non-RSC projects to gradually migrate to RSC projects.
235
235
 
236
- ## Notes
236
+ ## Server Component and Data Loader
237
+
238
+ In RSC projects, you have two ways to fetch data: directly in Server Components, or using [Data Loader](/guides/basic-features/data/data-fetch). Both approaches have their advantages, and you can choose flexibly based on your scenario.
239
+
240
+ ### Comparison of Two Data Fetching Approaches
241
+
242
+ | Feature | Fetching in Server Component | Fetching in Data Loader |
243
+ | --- | --- | --- |
244
+ | Avoid Request Waterfall | Requires manual optimization | ✅ Automatically parallel execution |
245
+ | Component Cohesion | ✅ Data and UI in the same place | Data logic separated into separate files |
246
+ | Maintainability | ✅ Easier to understand and maintain | Requires maintaining additional files |
247
+ | Type Safety | ✅ Natural type inference | Requires manual type management |
248
+
249
+ **Generally, we recommend fetching data in Server Components**, because waterfall requests have less performance impact on the server, and this approach makes components more cohesive, with data fetching logic and UI rendering in the same place, making it easier to understand and maintain. However, if your page has multiple independent data sources and you want to completely avoid request waterfall issues, Data Loader's parallel execution feature will be more advantageous.
250
+
251
+ ### Data Loader Execution Environment in RSC Projects
252
+
253
+ In RSC projects, the execution environment of Data Loaders is related to file naming:
254
+
255
+ - **`*.data.ts`**: Executes only on the **server**, and data can be consumed by both Client Components and Server Components
256
+ - **`*.data.client.ts`**: Executes only on the **client**
257
+
258
+ ```bash
259
+ .
260
+ └── routes
261
+ └── user
262
+ ├── page.tsx # Route component (can be Server or Client Component)
263
+ ├── page.data.ts # Executes on server, data can be consumed by any component
264
+ └── page.data.client.ts # Executes on client
265
+ ```
266
+
267
+ In Modern.js RSC projects, Server Components can receive data returned by Data Loaders through the `loaderData` prop:
268
+
269
+ ```tsx title="routes/user/page.tsx"
270
+ // Server Component receives loaderData through props
271
+ export default function UserPage({ loaderData }: { loaderData: { name: string } }) {
272
+ return <div>Welcome, {loaderData.name}</div>;
273
+ }
274
+ ```
275
+
276
+ ```tsx title="routes/user/page.tsx"
277
+ 'use client';
278
+ // Client Component can also receive loaderData through props
279
+ export default function UserPage({ loaderData }: { loaderData: { name: string } }) {
280
+ return <div>Welcome, {loaderData.name}</div>;
281
+ }
282
+ ```
283
+
284
+ ### Data Loader Returning Server Component
285
+
286
+ In Modern.js RSC projects, Data Loaders have a powerful feature: **they can return Server Components**. This is very helpful for gradual migration, allowing you to render server-generated content in Client Components.
287
+
288
+ ```tsx title="routes/user/layout.data.tsx"
289
+ // Server Component defined in data loader file
290
+ function UserProfile() {
291
+ return <div>User Profile (Server Rendered)</div>;
292
+ }
293
+
294
+ export const loader = async () => {
295
+ const userData = await fetchUserData();
296
+
297
+ return {
298
+ user: userData,
299
+ // Return a Server Component as part of the data
300
+ ProfileComponent: <UserProfile />,
301
+ };
302
+ };
303
+ ```
304
+
305
+ ```tsx title="routes/user/layout.tsx"
306
+ 'use client';
307
+ import { Outlet } from '@modern-js/runtime/router';
308
+
309
+ export default function UserLayout({
310
+ loaderData,
311
+ }: {
312
+ loaderData: { user: any; ProfileComponent: React.ReactNode };
313
+ }) {
314
+ const { user, ProfileComponent } = loaderData;
315
+
316
+ return (
317
+ <div>
318
+ {/* Directly render Server Component in Client Component */}
319
+ {ProfileComponent}
320
+ <div>User: {user.name}</div>
321
+ <Outlet />
322
+ </div>
323
+ );
324
+ }
325
+ ```
326
+
327
+ ## CSR Project Migration Guide
328
+
329
+ Modern.js's RSC capability supports both SSR and CSR projects. For existing CSR projects, if you want to gradually migrate to RSC, we recommend following these steps:
330
+
331
+ 1. **Enable RSC Configuration**
332
+
333
+ ```ts title="modern.config.ts"
334
+ import { defineConfig } from '@modern-js/app-tools';
335
+
336
+ export default defineConfig({
337
+ server: {
338
+ rsc: true,
339
+ },
340
+ });
341
+ ```
342
+
343
+ 2. **Mark All Route Components with `'use client'`**
344
+
345
+ This ensures that existing components maintain their behavior and continue to run as Client Components.
346
+
347
+ ```tsx title="routes/page.tsx"
348
+ 'use client';
349
+
350
+ export default function Page() {
351
+ // Existing client-side logic remains unchanged
352
+ }
353
+ ```
354
+
355
+ 3. **Rename All `*.data.ts` to `*.data.client.ts`**
356
+
357
+ Since `*.data.ts` in RSC projects executes on the server by default, to maintain consistency with CSR project behavior (Data Loaders execute on the client), you need to rename the files.
358
+
359
+ ```bash
360
+ # Before renaming
361
+ routes/user/page.data.ts
362
+
363
+ # After renaming
364
+ routes/user/page.data.client.ts
365
+ ```
237
366
 
238
- ### Legacy CSR Projects
367
+ After completing these steps, you can gradually migrate components to Server Components and enjoy the performance benefits of RSC.
239
368
 
240
- If you have a CSR project that uses Modern.js data loaders, after enabling RSC, data loaders will execute on the server by default, which means you need to change all `.data.ts` files to `.data.client.ts` first to maintain consistency with the previous behavior.
369
+ ## Notes
241
370
 
242
371
  ### Projects Using Streaming SSR
243
372
 
@@ -4,7 +4,7 @@ sidebar_position: 2
4
4
 
5
5
  # Build Engine
6
6
 
7
- Modern.js internally encapsulates [Rsbuild](https://rsbuild.rs/), using Rspack as the bundler.
7
+ Modern.js internally encapsulates [Rsbuild](https://v2.rsbuild.dev/), using Rspack as the bundler.
8
8
 
9
9
  ::: tip What is Rsbuild?
10
10
  Rsbuild is a build tool based on Rspack. It is an enhanced Rspack CLI, easy-to-use, and ready-to-use out of the box.
@@ -40,7 +40,7 @@ flowchart TD
40
40
 
41
41
  ## Build Documentation
42
42
 
43
- The documentation address of Rsbuild is: https://rsbuild.rs/
43
+ The documentation address of Rsbuild is: https://v2.rsbuild.dev/
44
44
 
45
45
  In this documentation, you can learn about the detailed introduction of Rsbuild, and you can also find complete usage guides for various building capabilities.
46
46
 
@@ -57,4 +57,4 @@ In Modern.js, you can register Rspack plugins or Rsbuild plugins:
57
57
 
58
58
  Rsbuild provides rich build capabilities, including JavaScript compilation, CSS compilation, static assets processing, code hot update, code compression, TS type checking, and dozens of other capabilities.
59
59
 
60
- We recommend that you read [「Rsbuild - All Features」](https://rsbuild.rs/guide/start/features) to learn about all the features provided by Rsbuild.
60
+ We recommend that you read [「Rsbuild - All Features」](https://v2.rsbuild.dev/guide/start/features) to learn about all the features provided by Rsbuild.
@@ -12,7 +12,7 @@ In this document, you can learn about the main technology stack involved in the
12
12
 
13
13
  Modern.js uses [React 18](https://react.dev/) to build user interfaces and is also compatible with React 17.
14
14
 
15
- Rsbuild supports building Vue applications. If you need to use Vue, you can refer to ["Rsbuild - Vue"](https://rsbuild.rs/guide/framework/vue).
15
+ Rsbuild supports building Vue applications. If you need to use Vue, you can refer to ["Rsbuild - Vue"](https://v2.rsbuild.dev/guide/framework/vue).
16
16
 
17
17
  ## Routing
18
18
 
@@ -34,7 +34,7 @@ Modern.js uses [Rspack](https://rspack.rs/) to bundle your web applications.
34
34
 
35
35
  Modern.js uses [SWC](https://swc.rs/) as JavaScript transpiler to transform TypeScript or JSX into JavaScript code that can run in browsers and perform syntax downgrades.
36
36
 
37
- When using Rspack for building, `babel-loader` is not enabled by default. If you need to add [Babel](https://babeljs.io/) plugins, you can configure them through [`babel plugin`](https://rsbuild.rs/plugins/list/plugin-babel#babel-plugin), which will generate additional compilation overhead and slow down Rspack build speed to some extent.
37
+ When using Rspack for building, `babel-loader` is not enabled by default. If you need to add [Babel](https://babeljs.io/) plugins, you can configure them through [`babel plugin`](https://v2.rsbuild.dev/plugins/list/plugin-babel#babel-plugin), which will generate additional compilation overhead and slow down Rspack build speed to some extent.
38
38
 
39
39
  ## Minimizer
40
40
 
@@ -53,7 +53,7 @@ Modern.js supports enabling ["Tailwind CSS"](/guides/basic-features/css/tailwind
53
53
  Modern.js supports three CSS preprocessors: [Sass](https://sass-lang.com/), [Less](https://lesscss.org/), and [Stylus](https://stylus-lang.com/):
54
54
 
55
55
  - Sass and Less are supported by default and ready to use.
56
- - Stylus is optional and can be used by referring to the ["Stylus Plugin"](https://rsbuild.rs/plugins/list/plugin-stylus).
56
+ - Stylus is optional and can be used by referring to the ["Stylus Plugin"](https://v2.rsbuild.dev/plugins/list/plugin-stylus).
57
57
 
58
58
  ## CSS Modules
59
59
 
@@ -18,7 +18,7 @@ The filename can be arbitrary; Modern.js does not enforce a specific naming conv
18
18
  import '@modern-js/runtime/registry/index'; // This line must be included, it will import micro frontend runtime dependencies by default
19
19
  import { render } from '@modern-js/runtime/browser';
20
20
  import { createRoot } from '@modern-js/runtime/react';
21
- import { createBridgeComponent } from '@module-federation/modern-js/react-v19';
21
+ import { createBridgeComponent } from '@module-federation/modern-js-v3/react-v19';
22
22
 
23
23
  const ModernRoot = createRoot();
24
24
  export const provider = createBridgeComponent({
@@ -32,8 +32,8 @@ export default provider;
32
32
  :::note
33
33
  Please select the corresponding import path based on the React version used in your project:
34
34
 
35
- - **React 19**: Use `@module-federation/modern-js/react-v19`
36
- - **React 18**: Use `@module-federation/modern-js/react-v18`
35
+ - **React 19**: Use `@module-federation/modern-js-v3/react-v19`
36
+ - **React 18**: Use `@module-federation/modern-js-v3/react-v18`
37
37
 
38
38
  You can check the React version in your project's `package.json` file to determine which import path to use.
39
39
  :::
@@ -43,7 +43,7 @@ This file will pass the root component of the `main` entry application to the Br
43
43
  Next, we configure `module-federation.config.ts` to modify the export to `src/export-App.tsx`:
44
44
 
45
45
  ```ts title="module-federation.config.ts"
46
- import { createModuleFederationConfig } from '@module-federation/modern-js';
46
+ import { createModuleFederationConfig } from '@module-federation/modern-js-v3';
47
47
 
48
48
  export default createModuleFederationConfig({
49
49
  name: 'remote',
@@ -76,8 +76,8 @@ If you are not familiar with the capabilities of `$.tsx`, please read [Wildcard
76
76
  :::
77
77
 
78
78
  ```tsx title="src/routes/remote/$.tsx"
79
- import { createRemoteAppComponent } from '@module-federation/modern-js/react';
80
- import { loadRemote } from '@module-federation/modern-js/runtime';
79
+ import { createRemoteAppComponent } from '@module-federation/modern-js-v3/react';
80
+ import { loadRemote } from '@module-federation/modern-js-v3/runtime';
81
81
 
82
82
  const ErrorBoundary = (info?: { error: { message: string } }) => {
83
83
  return (
@@ -14,7 +14,7 @@ For the consumer of Module Federation, its connection with the producer is the r
14
14
  For example, if the producer is deployed under the domain `https://my-remote-module`, the developer needs to modify the consumer's configuration file:
15
15
 
16
16
  ```ts title="module-federation.config.ts"
17
- import { createModuleFederationConfig } from '@module-federation/modern-js';
17
+ import { createModuleFederationConfig } from '@module-federation/modern-js-v3';
18
18
 
19
19
  export default createModuleFederationConfig({
20
20
  name: 'host',
@@ -76,7 +76,7 @@ This configuration will also affect the access path of the producer's `mf-manife
76
76
  At this point, the consumer needs to configure the following address when configuring the remote module:
77
77
 
78
78
  ```ts title="module-federation.config.ts"
79
- import { createModuleFederationConfig } from '@module-federation/modern-js';
79
+ import { createModuleFederationConfig } from '@module-federation/modern-js-v3';
80
80
 
81
81
  export default createModuleFederationConfig({
82
82
  name: 'host',
@@ -38,7 +38,7 @@ Both producers and consumers need to enable i18n capability first.
38
38
  In Module Federation scenarios, you need to install both the i18n plugin and the Module Federation plugin:
39
39
 
40
40
  ```bash
41
- pnpm add i18next react-i18next @modern-js/plugin-i18n @module-federation/modern-js
41
+ pnpm add i18next react-i18next @modern-js/plugin-i18n @module-federation/modern-js-v3
42
42
  ```
43
43
 
44
44
  :::info
@@ -54,7 +54,7 @@ Configure both the i18n plugin and the Module Federation plugin in `modern.confi
54
54
  ```ts title="modern.config.ts"
55
55
  import { appTools, defineConfig } from '@modern-js/app-tools';
56
56
  import { i18nPlugin } from '@modern-js/plugin-i18n';
57
- import { moduleFederationPlugin } from '@module-federation/modern-js';
57
+ import { moduleFederationPlugin } from '@module-federation/modern-js-v3';
58
58
 
59
59
  export default defineConfig({
60
60
  plugins: [appTools(), i18nPlugin(), moduleFederationPlugin()],
@@ -84,7 +84,7 @@ Both producers and consumers need to configure `shared` in `module-federation.co
84
84
  #### Configure Module Federation
85
85
 
86
86
  ```ts title="module-federation.config.ts"
87
- import { createModuleFederationConfig } from '@module-federation/modern-js';
87
+ import { createModuleFederationConfig } from '@module-federation/modern-js-v3';
88
88
 
89
89
  export default createModuleFederationConfig({
90
90
  // The name parameter must be unique and cannot be the same as other applications (including different remotes)
@@ -203,7 +203,7 @@ When using an independent I18n instance, the producer maintains its own language
203
203
  #### Configure Module Federation
204
204
 
205
205
  ```ts title="module-federation.config.ts"
206
- import { createModuleFederationConfig } from '@module-federation/modern-js';
206
+ import { createModuleFederationConfig } from '@module-federation/modern-js-v3';
207
207
 
208
208
  export default createModuleFederationConfig({
209
209
  // The name parameter must be unique and cannot be the same as other applications (including different remotes)
@@ -229,7 +229,7 @@ When consumers need to load remote components, they need to configure accordingl
229
229
  First, configure the remote module in the consumer's `module-federation.config.ts`:
230
230
 
231
231
  ```ts title="module-federation.config.ts"
232
- import { createModuleFederationConfig } from '@module-federation/modern-js';
232
+ import { createModuleFederationConfig } from '@module-federation/modern-js-v3';
233
233
 
234
234
  export default createModuleFederationConfig({
235
235
  // The name parameter must be unique and cannot be the same as other applications (including different remotes)
@@ -258,8 +258,8 @@ If the producer uses a shared I18n instance, the consumer must configure `shared
258
258
  When the producer uses a shared I18n instance, the consumer can directly load the remote component without additional configuration:
259
259
 
260
260
  ```tsx title="src/routes/page.tsx"
261
- import { createLazyComponent } from '@module-federation/modern-js/react';
262
- import { getInstance } from '@module-federation/modern-js/runtime';
261
+ import { createLazyComponent } from '@module-federation/modern-js-v3/react';
262
+ import { getInstance } from '@module-federation/modern-js-v3/runtime';
263
263
 
264
264
  const RemoteComponent = createLazyComponent({
265
265
  instance: getInstance(),
@@ -352,7 +352,7 @@ First, you need to create an entry file to export the application:
352
352
  import '@modern-js/runtime/registry/index';
353
353
  import { render } from '@modern-js/runtime/browser';
354
354
  import { createRoot } from '@modern-js/runtime/react';
355
- import { createBridgeComponent } from '@module-federation/modern-js/react-v19';
355
+ import { createBridgeComponent } from '@module-federation/modern-js-v3/react-v19';
356
356
  import type { ReactElement } from 'react';
357
357
 
358
358
  const ModernRoot = createRoot();
@@ -371,7 +371,7 @@ export default provider;
371
371
  #### Configure Module Federation
372
372
 
373
373
  ```ts title="module-federation.config.ts"
374
- import { createModuleFederationConfig } from '@module-federation/modern-js';
374
+ import { createModuleFederationConfig } from '@module-federation/modern-js-v3';
375
375
 
376
376
  export default createModuleFederationConfig({
377
377
  // The name parameter must be unique and cannot be the same as other applications (including different remotes)
@@ -472,7 +472,7 @@ When consumers need to load remote applications, they need to use the Bridge API
472
472
  First, configure the remote application in the consumer's `module-federation.config.ts`:
473
473
 
474
474
  ```ts title="module-federation.config.ts"
475
- import { createModuleFederationConfig } from '@module-federation/modern-js';
475
+ import { createModuleFederationConfig } from '@module-federation/modern-js-v3';
476
476
 
477
477
  export default createModuleFederationConfig({
478
478
  // The name parameter must be unique and cannot be the same as other applications (including different remotes)
@@ -500,8 +500,8 @@ If the producer uses a shared I18n instance, the consumer must configure `shared
500
500
  Create a component for loading the remote application:
501
501
 
502
502
  ```tsx title="src/components/RemoteApp.tsx"
503
- import { createRemoteAppComponent } from '@module-federation/modern-js/react';
504
- import { loadRemote } from '@module-federation/modern-js/runtime';
503
+ import { createRemoteAppComponent } from '@module-federation/modern-js-v3/react';
504
+ import { loadRemote } from '@module-federation/modern-js-v3/runtime';
505
505
  import React from 'react';
506
506
 
507
507
  const FallbackErrorComp = (info: any) => {
@@ -18,7 +18,7 @@ Refer to [Module Federation 2.0 Announcement](https://module-federation.io/zh/bl
18
18
 
19
19
  ## Modern.js MF Plugin
20
20
 
21
- Based on internal practices at ByteDance, the Module Federation team officially provides the [Modern.js Plugin](https://www.npmjs.com/package/@module-federation/modern-js) to help developers use Module Federation more easily.
21
+ Based on internal practices at ByteDance, the Module Federation team officially provides the [Modern.js Plugin](https://www.npmjs.com/package/@module-federation/modern-js-v3) to help developers use Module Federation more easily.
22
22
 
23
23
  The plugin injects the Module Federation plugin into Modern.js applications and automatically handles build configurations and adds runtime code.
24
24
 
@@ -1,6 +1,6 @@
1
1
  # Server-Side Rendering
2
2
 
3
- `@module-federation/modern-js` offers powerful capabilities, enabling developers to easily combine Module Federation with server-side rendering (SSR) in Modern.js applications.
3
+ `@module-federation/modern-js-v3` offers powerful capabilities, enabling developers to easily combine Module Federation with server-side rendering (SSR) in Modern.js applications.
4
4
 
5
5
  ## Enable SSR
6
6
 
@@ -35,7 +35,7 @@ Module Federation now supports [data fetching](https://module-federation.io/zh/g
35
35
  In Modern.js, data fetching can be used with SSR. Using the example in the previous chapter, create a data fetching file:
36
36
 
37
37
  ```ts title="src/components/Button.data.ts"
38
- import type { DataFetchParams } from '@module-federation/modern-js/react';
38
+ import type { DataFetchParams } from '@module-federation/modern-js-v3/react';
39
39
 
40
40
  export type Data = {
41
41
  data: string;
@@ -74,11 +74,11 @@ Consumers must use [`createLazyComponent`](https://module-federation.io/practice
74
74
 
75
75
  ```tsx title="src/routes/page.tsx"
76
76
  import type { JSX } from 'react';
77
- import { getInstance } from '@module-federation/modern-js/runtime';
77
+ import { getInstance } from '@module-federation/modern-js-v3/runtime';
78
78
  import {
79
79
  ERROR_TYPE,
80
80
  lazyLoadComponentPlugin,
81
- } from '@module-federation/modern-js/react';
81
+ } from '@module-federation/modern-js-v3/react';
82
82
 
83
83
  const instance = getInstance();
84
84
  instance!.registerPlugins([lazyLoadComponentPlugin()]);