@modern-js/main-doc 2.66.0 → 2.66.1-alpha.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 (51) hide show
  1. package/docs/en/apis/app/hooks/src/app.mdx +20 -34
  2. package/docs/en/apis/app/hooks/src/modern.runtime.mdx +9 -0
  3. package/docs/en/apis/app/runtime/app/define-config.mdx +6 -0
  4. package/docs/en/components/enable-micro-frontend.mdx +20 -3
  5. package/docs/en/components/micro-runtime-config.mdx +12 -13
  6. package/docs/en/components/reduck-notify.mdx +27 -0
  7. package/docs/en/configure/app/runtime/0-intro.mdx +63 -91
  8. package/docs/en/configure/app/usage.mdx +93 -69
  9. package/docs/en/guides/basic-features/render/_meta.json +1 -1
  10. package/docs/en/guides/basic-features/render/before-render.mdx +115 -0
  11. package/docs/en/guides/basic-features/routes.mdx +0 -95
  12. package/docs/en/guides/topic-detail/micro-frontend/c02-development.mdx +3 -5
  13. package/docs/en/guides/topic-detail/micro-frontend/c03-main-app.mdx +4 -2
  14. package/docs/en/guides/topic-detail/model/auto-actions.mdx +0 -4
  15. package/docs/en/guides/topic-detail/model/computed-state.mdx +0 -5
  16. package/docs/en/guides/topic-detail/model/define-model.mdx +0 -4
  17. package/docs/en/guides/topic-detail/model/faq.mdx +0 -5
  18. package/docs/en/guides/topic-detail/model/manage-effects.mdx +0 -5
  19. package/docs/en/guides/topic-detail/model/model-communicate.mdx +0 -5
  20. package/docs/en/guides/topic-detail/model/performance.mdx +0 -4
  21. package/docs/en/guides/topic-detail/model/quick-start.mdx +5 -7
  22. package/docs/en/guides/topic-detail/model/redux-integration.mdx +0 -4
  23. package/docs/en/guides/topic-detail/model/typescript-best-practice.mdx +0 -4
  24. package/docs/en/guides/topic-detail/model/use-model.mdx +0 -5
  25. package/docs/en/guides/topic-detail/model/use-out-of-modernjs.mdx +0 -4
  26. package/docs/zh/apis/app/hooks/src/app.mdx +18 -26
  27. package/docs/zh/apis/app/hooks/src/modern.runtime.mdx +9 -0
  28. package/docs/zh/apis/app/runtime/app/define-config.mdx +5 -0
  29. package/docs/zh/components/enable-micro-frontend.mdx +19 -12
  30. package/docs/zh/components/micro-runtime-config.mdx +3 -3
  31. package/docs/zh/components/reduck-notify.mdx +27 -0
  32. package/docs/zh/configure/app/runtime/0-intro.mdx +67 -86
  33. package/docs/zh/configure/app/usage.mdx +44 -21
  34. package/docs/zh/guides/basic-features/render/_meta.json +1 -1
  35. package/docs/zh/guides/basic-features/render/before-render.mdx +115 -0
  36. package/docs/zh/guides/basic-features/routes.mdx +0 -95
  37. package/docs/zh/guides/topic-detail/micro-frontend/c02-development.mdx +3 -5
  38. package/docs/zh/guides/topic-detail/micro-frontend/c03-main-app.mdx +4 -2
  39. package/docs/zh/guides/topic-detail/model/auto-actions.mdx +0 -4
  40. package/docs/zh/guides/topic-detail/model/computed-state.mdx +0 -4
  41. package/docs/zh/guides/topic-detail/model/define-model.mdx +1 -4
  42. package/docs/zh/guides/topic-detail/model/faq.mdx +0 -5
  43. package/docs/zh/guides/topic-detail/model/manage-effects.mdx +0 -4
  44. package/docs/zh/guides/topic-detail/model/model-communicate.mdx +1 -4
  45. package/docs/zh/guides/topic-detail/model/performance.mdx +0 -4
  46. package/docs/zh/guides/topic-detail/model/quick-start.mdx +7 -8
  47. package/docs/zh/guides/topic-detail/model/redux-integration.mdx +0 -4
  48. package/docs/zh/guides/topic-detail/model/typescript-best-practice.mdx +0 -4
  49. package/docs/zh/guides/topic-detail/model/use-model.mdx +0 -5
  50. package/docs/zh/guides/topic-detail/model/use-out-of-modernjs.mdx +0 -4
  51. package/package.json +1 -1
@@ -1,13 +1,12 @@
1
- ---
2
- sidebar_position: 1
3
- title: Quick Start
4
- ---
1
+ # Quick Start
5
2
 
6
3
  :::caution
7
4
  New projects are no longer recommended to use Reduck. You can use state management tools from the community, such as [Jotai](https://jotai.org/), [zustand](https://zustand.docs.pmnd.rs/getting-started/introduction), [valtio](https://valtio.dev/docs/introduction/getting-started), etc.
8
5
  :::
9
6
 
10
- # Quick Start
7
+ import ReduckNotify from '@site-docs-en/components/reduck-notify';
8
+
9
+ <ReduckNotify />
11
10
 
12
11
  import ReduckMigration from "@site-docs-en/components/reduck-migration"
13
12
 
@@ -22,8 +21,7 @@ In the MVC pattern, Reduck plays the role of M(Model), React UI Component corres
22
21
  The state management solution of Modern.js is implemented through built-in Reduck. Using Reduck in Modern.js not only eliminates the manual integration process, but also allows all Reduck APIs to be imported and used directly from the Modern.js Runtime package, providing a better consistency experience.
23
22
 
24
23
  :::info
25
- 1. To use Reduck APIs in Modern.js, you need to set [runtime.state](/configure/app/runtime/state) to enable the state management plugin.
26
- 2. Reduck can also be used separately as a state management library [outside of Modern.js](/guides/topic-detail/model/use-out-of-modernjs).
24
+ Reduck can also be used separately as a state management library [outside of Modern.js](/guides/topic-detail/model/use-out-of-modernjs).
27
25
 
28
26
  :::
29
27
 
@@ -1,7 +1,3 @@
1
- ---
2
- sidebar_position: 11
3
- title: Ecosystem Integration
4
- ---
5
1
  # Redux Ecosystem Integration
6
2
 
7
3
  Reduck is based on Redux, so you can use libraries from the [Redux ecosystem](https://redux.js.org/introduction/ecosystem) to enhance its functionality. APIs like [`Provider`](/apis/app/runtime/model/Provider), [`createApp`](/apis/app/runtime/model/create-app), and [`createStore`](/apis/app/runtime/model/create-store) allow you to configure the use of [middlewares](https://redux.js.org/understanding/thinking-in-redux/glossary#middleware) and [store enhancers](https://redux.js.org/understanding/thinking-in-redux/glossary#store-enhancer); and using [`createStore`](/apis/app/runtime/model/create-store), you can take complete control over the process of creating the store.
@@ -1,7 +1,3 @@
1
- ---
2
- sidebar_position: 10
3
- title: TS Best Practices
4
- ---
5
1
  # TS Best Practices
6
2
 
7
3
  Reduck provides excellent support for TypeScript, and in most cases, you can get API type prompts directly without any extra work. In this section, we will provide additional information on other usage scenarios.
@@ -1,8 +1,3 @@
1
- ---
2
- sidebar_position: 3
3
- title: Use Models
4
- ---
5
-
6
1
  # Use Models
7
2
 
8
3
  ## Using Models in Components
@@ -1,7 +1,3 @@
1
- ---
2
- sidebar_position: 12
3
- title: Using Reduck Separately
4
- ---
5
1
  # Using Reduck Separately
6
2
 
7
3
  When integrating Reduck separately from Modern.js, the following modifications need to be made:
@@ -2,6 +2,7 @@
2
2
  title: App.[tj]sx
3
3
  sidebar_position: 1
4
4
  ---
5
+
5
6
  # App.[tj]sx
6
7
 
7
8
  应用使用[自控路由](/guides/concept/entries.html#自控式路由)时的入口标识符。
@@ -9,35 +10,26 @@ sidebar_position: 1
9
10
  `App.[tj]sx` 并不是实际的应用入口,Modern.js 会自动生成真正的构建打包的入口文件, 内容大致如下:
10
11
 
11
12
  ```js
12
- import React from 'react';
13
- import ReactDOM from 'react-dom/client';
14
- import { createApp, bootstrap } from '@modern-js/runtime';
15
- // App.[jt]sx
13
+ // runtime-global-context
14
+ import { setGlobalContext } from '@modern-js/runtime/context';
16
15
  import App from '@_modern_js_src/App';
17
- // runtime plugin
18
- import { router } from '@modern-js/runtime/plugins';
19
-
20
- const IS_BROWSER = typeof window !== 'undefined' && window.name !== 'nodejs';
21
- const MOUNT_ID = 'root';
22
-
23
- let AppWrapper = null;
24
-
25
- function render() {
26
- AppWrapper = createApp({
27
- plugins: [
28
- router({...{"serverBase":["/"]}, ...App.config?.router}),
29
- ]
30
- })(App)
31
- if (IS_BROWSER) {
32
- bootstrap(AppWrapper, MOUNT_ID, null, ReactDOM);
33
- }
34
- return AppWrapper
35
- }
36
-
37
- AppWrapper = render();
38
- export default AppWrapper;
16
+
17
+ setGlobalContext({
18
+ App,
19
+ });
20
+
21
+ // index.tsx
22
+ import './runtime-global-context';
23
+ import { createRoot } from '@modern-js/runtime/react';
24
+ import { render } from '@modern-js/runtime/browser';
25
+
26
+ const ModernRoot = createRoot();
27
+
28
+ render(<ModernRoot />, 'root');
39
29
  ```
40
30
 
31
+ `createRoot` 执行时,会去获取注册的 Globa App,生成真实的 React 组件。
32
+
41
33
  :::note
42
34
  在多入口的场景下,每个入口都可以拥有独立的 `App.[jt]sx`,详见[入口](/guides/concept/entries)。
43
35
 
@@ -0,0 +1,9 @@
1
+ ---
2
+ title: modern.runtime.[tj]s
3
+ sidebar_position: 4
4
+ ---
5
+ # modern.runtime.[tj]s
6
+
7
+ Modern.js Runtime 配置文件, 通过该文件可以对当前项目的 Runtime 能力进行个性化配置。
8
+
9
+ 了解配置的具体用法,请参考 [Runtime 配置](/configure/app/runtime/0-intro.html)。
@@ -4,6 +4,11 @@ title: defineConfig
4
4
  ---
5
5
  # defineConfig
6
6
 
7
+ :::warning
8
+
9
+ 该 API 即将废弃,推荐使用 `src/modern.runtime.ts` 定义 Runtime 配置,同时支持静态配置和动态配置,使用姿势插件[Runtime 配置](/configure/app/runtime/0-intro.html)
10
+ :::
11
+
7
12
  用于动态配置应用。
8
13
 
9
14
  ## 使用姿势
@@ -1,23 +1,30 @@
1
- ```js title="modern.config.ts"
1
+ ```ts title="modern.config.ts"
2
2
  import { appTools, defineConfig } from '@modern-js/app-tools';
3
3
  import { garfishPlugin } from '@modern-js/plugin-garfish';
4
4
 
5
5
  export default defineConfig({
6
6
  runtime: {
7
7
  router: true,
8
- masterApp: {
9
- apps: [{
10
- name: 'Table',
11
- entry: 'http://localhost:8081',
12
- // activeWhen: '/table'
13
- }, {
14
- name: 'Dashboard',
15
- entry: 'http://localhost:8082'
16
- // activeWhen: '/dashboard'
17
- }]
18
- },
19
8
  },
20
9
  plugins: [appTools(), garfishPlugin()],
21
10
  });
22
11
 
23
12
  ```
13
+
14
+ ```ts title="src/modern.runtime.ts"
15
+ import { defineRuntimeConfig } from '@modern-js/runtime';
16
+
17
+ export default defineRuntimeConfig({
18
+ masterApp: {
19
+ apps: [{
20
+ name: 'Table',
21
+ entry: 'http://localhost:8081',
22
+ // activeWhen: '/table'
23
+ }, {
24
+ name: 'Dashboard',
25
+ entry: 'http://localhost:8082'
26
+ // activeWhen: '/dashboard'
27
+ }]
28
+ },
29
+ });
30
+ ```
@@ -1,7 +1,7 @@
1
- ```js title="src/App.tsx"
2
- import { defineConfig } from '@modern-js/runtime';
1
+ ```ts title="src/modern.runtime.ts"
2
+ import { defineRuntimeConfig } from '@modern-js/runtime';
3
3
 
4
- defineConfig(App, {
4
+ export default defineRuntimeConfig({
5
5
  masterApp: {
6
6
  apps: [{
7
7
  name: 'Table',
@@ -0,0 +1,27 @@
1
+ :::warning
2
+ 从 `MAJOR_VERSION.67.0` 起,Modern.js 不再默认提供 Reduck 状态管理能力。如果需要使用 Reduck,您需要安装并注册 state 插件。
3
+
4
+ **安装步骤**
5
+
6
+ 1. 安装 `@modern-js/plugin-state` 依赖:
7
+
8
+ ```bash
9
+ pnpm add @modern-js/plugin-state
10
+ ```
11
+
12
+ 2. 注册 state 插件:
13
+
14
+ ```ts title="modern.config.ts"
15
+ import { defineConfig } from '@modern-js/app-tools';
16
+ import { statePlugin } from '@modern-js/plugin-state';
17
+
18
+ export default defineConfig({
19
+ ...,
20
+ plugins: [
21
+ ...,
22
+ statePlugin(),
23
+ ],
24
+ });
25
+ ```
26
+
27
+ :::
@@ -1,120 +1,101 @@
1
- ---
2
- title: 总览
3
- sidebar_position: 1
4
- ---
1
+ # 介绍
5
2
 
6
- # 总览
3
+ Modern.js 的运行时(Runtime)配置需集中在 `src/modern.runtime.ts` 文件中声明。
7
4
 
8
- 此节将介绍 Runtime 插件的配置。
9
-
10
- ## 配置方式
11
-
12
- ### runtime
13
-
14
- - **类型:** `Object`
5
+ :::info
6
+ 如果项目中还没有此文件,请执行以下命令创建:
15
7
 
16
- runtime 配置方式如下:
8
+ ```bash
9
+ touch src/modern.runtime.ts
10
+ ```
17
11
 
18
- #### 基本用法
12
+ :::
19
13
 
20
- `modern.config.ts` 中配置
14
+ ## 基本配置
21
15
 
22
- ```ts title="modern.config.ts"
23
- import { defineConfig } from '@modern-js/app-tools';
16
+ ```tsx
17
+ import { defineRuntimeConfig } from '@modern-js/runtime';
24
18
 
25
- export default defineConfig({
26
- runtime: {
27
- state: true,
28
- router: true,
19
+ export default defineRuntimeConfig({
20
+ router: {
21
+ // 路由配置
22
+ },
23
+ state: {
24
+ // 状态管理配置
29
25
  },
26
+ // 其他运行时模块...
30
27
  });
31
28
  ```
32
29
 
33
- #### 运行时配置
34
-
35
- 通过 [`defineConfig`](/apis/app/runtime/app/define-config) API 配置:
36
-
37
- :::info
38
- 当 runtime 配置中存在函数时,只能使用该方式进行配置。
39
-
40
- :::
30
+ ## 多入口配置
41
31
 
42
- import { Tabs, Tab as TabItem } from "@theme";
32
+ 对于多入口应用,`defineRuntimeConfig` 函数可以根据入口名称返回特定的配置:
43
33
 
44
- <Tabs>
45
- <TabItem value="layout" label="约定式路由" default>
34
+ ```tsx
35
+ import { defineRuntimeConfig } from '@modern-js/runtime';
46
36
 
47
- ```tsx title="src/routes/layout.tsx"
48
- import type { AppConfig } from '@modern-js/runtime';
49
-
50
- export const config = (): AppConfig => {
51
- return {
52
- router: {
53
- supportHtml5History: false
54
- }
37
+ export default defineRuntimeConfig(entryName => {
38
+ if (entryName === 'main') {
39
+ return {
40
+ router: {
41
+ // "main" 入口的路由配置
42
+ },
43
+ state: {
44
+ // "main" 入口的状态管理配置
45
+ },
46
+ };
55
47
  }
56
- };
57
- ```
58
-
59
- </TabItem>
60
-
61
- <TabItem value="app" label="自控路由">
62
48
 
63
- ```ts title="src/App.tsx"
64
- import { defineConfig } from '@modern-js/runtime';
65
-
66
- const App = () => {
67
- /** */
68
- };
69
-
70
- defineConfig(App, {
71
- router: {
72
- supportHtml5History: false,
73
- },
49
+ // 其他入口的配置
50
+ return {
51
+ masterApp: {
52
+ // 微前端配置示例
53
+ },
54
+ };
74
55
  });
75
-
76
- export default App;
77
56
  ```
78
57
 
79
- </TabItem>
80
- </Tabs>
81
-
82
- :::info
83
- 使用运行时配置,可以解决 Runtime 插件配置需要在运行时才能获取到具体内容问题。
84
-
85
- Runtime 插件运行时配置和直接在 `modern.config.ts` 中的配置默认会进行合并,且运行时配置优先级更高。
86
-
58
+ :::tip
59
+ 使用 `src/modern.runtime.ts` 配置方式不支持导出异步函数,这与 Modern.js 的渲染方式有关。如果需要添加异步逻辑,请使用 **[Runtime 插件 (Runtime Plugin)](/plugin/introduction.html#runtime-插件)**。
87
60
  :::
88
61
 
89
62
  :::warning
90
- defineConfig 中只能定义 Runtime 插件的具体配置内容,确认是否开启插件还需要通过 `modern.config.ts` 中的配置决定。
91
-
63
+ 使用 `src/modern.runtime.ts` 配置方式需要 Modern.js 版本 **MAJOR_VERSION.66.0** 或更高版本。
92
64
  :::
93
65
 
94
- ### runtimeByEntries
66
+ ## 配置方式演进
95
67
 
96
- - **类型:** `Object`
97
- - **默认值:**无
68
+ MAJOR_VERSION.66.0 之前,运行时配置分散在多个位置:
98
69
 
99
- #### 说明
70
+ 1. `modern.config.ts` 中的 `runtime` 和 `runtimeByEntries` 字段
71
+ 2. 各入口的 `App.config` 或 `layout` 文件导出的 `config` 函数
100
72
 
101
- 按入口添加 runtime 配置,选项属性同 runtime 一致,指定值会和 runtime 属性内容做替换合并操作。
73
+ 为提升可维护性,Modern.js 引入了统一的 `src/modern.runtime.ts` 配置入口。
102
74
 
103
- ```ts title="modern.config.ts"
104
- import { defineConfig } from '@modern-js/app-tools';
75
+ ### 旧配置方式(兼容但不推荐)
105
76
 
106
- export default defineConfig({
77
+ ```ts
78
+ // modern.config.ts
79
+ export default {
107
80
  runtime: {
108
- state: false,
81
+ /* ... */
109
82
  },
110
83
  runtimeByEntries: {
111
- entry1: {
112
- state: true, // { state: true }
113
- },
114
- entry2: {
115
- // { state: false, router: true }
116
- router: true,
117
- },
84
+ /* ... */
118
85
  },
119
- });
86
+ };
87
+
88
+ // App.config
89
+ App.config = {
90
+ /* ... */
91
+ };
92
+
93
+ // layout 文件
94
+ export const config = () => {
95
+ /* 动态配置逻辑 */
96
+ };
120
97
  ```
98
+
99
+ ### 迁移建议
100
+
101
+ 强烈建议将所有运行时配置迁移至 `src/modern.runtime.ts`。虽然旧配置方式目前仍兼容,但计划在未来版本中逐步废弃。统一配置入口可避免配置分散,显著提高项目可维护性。
@@ -1,12 +1,8 @@
1
- ---
2
- sidebar_position: 0
3
- ---
4
-
5
1
  # 配置使用
6
2
 
7
- Modern.js 中有两种配置,分别是编译时配置和服务端运行时配置。
3
+ Modern.js 中有三种配置,分别是编译时配置、运行时配置和服务端运行时配置。
8
4
 
9
- 编译时配置可以在两个位置进行配置:
5
+ **编译时配置**可以在两个位置进行配置:
10
6
 
11
7
  - 根路径下的 `modern.config.(ts|js|mjs)` 文件
12
8
  - `package.json` 文件
@@ -15,9 +11,14 @@ Modern.js 中有两种配置,分别是编译时配置和服务端运行时配
15
11
  Modern.js 不支持同时在 `package.json` 中和 `modern.config.ts` 中配置同一个配置项,推荐在 `modern.config.ts` 中进行配置。如果 Modern.js 检测到重复配置导致的冲突,将会抛出警告。
16
12
  :::
17
13
 
18
- 服务端运行时配置可以在根路径下的 `modern.server-runtime.config.(ts|js|mjs)` 中进行配置。
14
+ **运行时配置**可以在 `src/modern.runtime.(ts|js|mjs)` 文件中配置。
15
+
16
+ {/* TODO server 配置文件更新 */}
17
+ **服务端运行时配置**可以在根路径下的 `modern.server-runtime.config.(ts|js|mjs)` 中进行配置。
19
18
 
20
- ## 在配置文件中配置
19
+ ## 编译时配置
20
+
21
+ ### 在配置文件中配置
21
22
 
22
23
  Modern.js 的配置文件定义在项目的根目录下,支持 `.ts`, `.js` 和 `.mjs` 格式:
23
24
 
@@ -25,7 +26,7 @@ Modern.js 的配置文件定义在项目的根目录下,支持 `.ts`, `.js`
25
26
  - `modern.config.js`
26
27
  - `modern.config.mjs`
27
28
 
28
- ### modern.config.ts(推荐)
29
+ #### modern.config.ts(推荐)
29
30
 
30
31
  我们推荐使用 `.ts` 格式的配置文件,它提供了友好的 TypeScript 类型提示,从而帮助你避免配置中的错误。
31
32
 
@@ -52,7 +53,7 @@ export default defineConfig({
52
53
  });
53
54
  ```
54
55
 
55
- ### modern.config.js
56
+ #### modern.config.js
56
57
 
57
58
  如果你在开发一个非 TypeScript 项目,可以使用 `.js` 格式的配置文件:
58
59
 
@@ -76,7 +77,7 @@ export default {
76
77
  };
77
78
  ```
78
79
 
79
- ### 导出配置函数
80
+ #### 导出配置函数
80
81
 
81
82
  Modern.js 支持在配置文件中导出一个函数,你可以在函数中动态计算配置,并返回给 Modern.js。
82
83
 
@@ -99,7 +100,7 @@ export default defineConfig(({ env, command }) => ({
99
100
  - 当运行 `modern build` 或 `modern serve` 时,`env` 的值为 `production`。
100
101
  - `command`:对应当前运行的命令,如 `dev`、`start`、`build`、`serve`。
101
102
 
102
- ### 导出异步函数
103
+ #### 导出异步函数
103
104
 
104
105
  Modern.js 也支持在配置文件中导出一个异步函数,你可以在函数中进行一些异步操作:
105
106
 
@@ -117,7 +118,7 @@ export default defineConfig(async ({ env, command }) => {
117
118
  });
118
119
  ```
119
120
 
120
- ### 指定配置文件
121
+ #### 指定配置文件
121
122
 
122
123
  Modern.js 命令行支持通过 `--config` 选项来指定配置文件的名称。
123
124
 
@@ -138,7 +139,7 @@ Modern.js 命令行支持通过 `--config` 选项来指定配置文件的名称
138
139
  $ modern build -c modern.prod.config.js
139
140
  ```
140
141
 
141
- ## 在 package.json 中配置(不推荐)
142
+ ### 在 package.json 中配置(不推荐)
142
143
 
143
144
  除了配置文件外,你也可以在 `package.json` 中的 `modernConfig` 字段下设置配置项,如:
144
145
 
@@ -156,16 +157,16 @@ $ modern build -c modern.prod.config.js
156
157
 
157
158
  由于 JSON 文件格式的限制,`package.json` 中只能定义数字、字符串、布尔值、数组等简单类型的值,当我们需要设置函数类型的值时,建议在 Modern.js 配置文件中进行设置。
158
159
 
159
- ### 注意事项
160
+ #### 注意事项
160
161
 
161
162
  - 不建议同时使用 `package.json` 和 `modern.config.js` 进行配置。如果同时使用了两者并出现配置冲突,Modern.js 会在命令行进行提示错误。
162
163
  - `@modern-js/runtime` 导出了同名的 [defineConfig](/apis/app/runtime/app/define-config) API,请注意区分。
163
164
 
164
- ## 本地调试配置
165
+ ### 本地调试配置
165
166
 
166
167
  为了便于本地调试配置,Modern.js 支持在项目根目录下创建 `modern.config.local.(ts|js|mjs)` 文件,用于覆盖 `modern.config.(ts|js|mjs)` 中的配置选项。
167
168
 
168
- ### 示例
169
+ #### 示例
169
170
 
170
171
  比如,项目的 `modern.config.ts` 中配置了端口号为 `3000`:
171
172
 
@@ -193,7 +194,7 @@ export default defineConfig({
193
194
 
194
195
  `modern.config.local.ts` 文件中的配置会与 `modern.config.ts` 中的配置进行深层合并,并覆盖 `modern.config.ts` 中的配置选项,因此 `server.port` 会被覆盖为 `3001`。
195
196
 
196
- ### 注意事项
197
+ #### 注意事项
197
198
 
198
199
  在使用 `modern.config.local.ts` 时,请注意以下事项:
199
200
 
@@ -205,13 +206,13 @@ export default defineConfig({
205
206
  modern.config.local.*
206
207
  ```
207
208
 
208
- ## 合并多份配置
209
+ ### 合并多份配置
209
210
 
210
211
  在某些情况下,你可能需要将多份配置合并为一份配置,此时你可以使用 `mergeConfig` 工具函数来合并多个配置。
211
212
 
212
213
  `mergeConfig` 函数接受一个数组作为参数,数组中的每一项都是一个配置对象,`mergeConfig` 会将数组中的每一项配置对象进行深层合并,自动将多个函数项合并为数组,最终返回一个合并后的配置对象。
213
214
 
214
- ### 示例
215
+ #### 示例
215
216
 
216
217
  ```ts title="modern.config.ts"
217
218
  import { mergeConfig } from '@modern-js/app-tools';
@@ -249,7 +250,7 @@ const mergedConfig = {
249
250
  };
250
251
  ```
251
252
 
252
- ## 配置类型定义
253
+ ### 配置类型定义
253
254
 
254
255
  Modern.js 导出了 `AppUserConfig` 类型,对应 Modern.js 配置对象的类型:
255
256
 
@@ -274,3 +275,25 @@ const config: AppUserConfig<'rspack'> = {
274
275
  },
275
276
  };
276
277
  ```
278
+
279
+ ## 运行时配置
280
+
281
+ 运行时配置的详细信息可以参考 [Runtime 配置介绍](/configure/app/runtime/0-intro.html)。
282
+
283
+ :::tip
284
+ 如果当前的 Runtime 配置需要在编译时和运行时同时使用,请将相关配置参数添加到插件注册的位置。
285
+
286
+ ```ts title="modern.config.ts"
287
+ import { defineConfig } from '@modern-js/app-tools';
288
+ import { statePlugin } from '@modern-js/plugin-state';
289
+
290
+ export default defineConfig({
291
+ plugins: [
292
+ statePlugin({
293
+ /** 在此处添加参数 */
294
+ }),
295
+ ],
296
+ });
297
+ ```
298
+
299
+ :::
@@ -1 +1 @@
1
- ["ssr", "streaming-ssr", "ssr-cache", "ssg"]
1
+ ["ssr", "streaming-ssr", "ssr-cache", "ssg", "before-render"]