@modern-js/main-doc 2.65.5 → 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.
- package/docs/en/apis/app/hooks/src/app.mdx +20 -34
- package/docs/en/apis/app/hooks/src/modern.runtime.mdx +9 -0
- package/docs/en/apis/app/runtime/app/define-config.mdx +6 -0
- package/docs/en/community/blog/v2-release-note.mdx +1 -1
- package/docs/en/components/enable-micro-frontend.mdx +20 -3
- package/docs/en/components/micro-runtime-config.mdx +12 -13
- package/docs/en/components/reduck-notify.mdx +27 -0
- package/docs/en/configure/app/plugins.mdx +2 -2
- package/docs/en/configure/app/runtime/0-intro.mdx +63 -91
- package/docs/en/configure/app/tools/esbuild.mdx +1 -1
- package/docs/en/configure/app/tools/swc.mdx +1 -1
- package/docs/en/configure/app/usage.mdx +93 -69
- package/docs/en/guides/basic-features/render/_meta.json +1 -1
- package/docs/en/guides/basic-features/render/before-render.mdx +115 -0
- package/docs/en/guides/basic-features/routes.mdx +0 -95
- package/docs/en/guides/topic-detail/micro-frontend/c02-development.mdx +3 -5
- package/docs/en/guides/topic-detail/micro-frontend/c03-main-app.mdx +4 -2
- package/docs/en/guides/topic-detail/model/auto-actions.mdx +0 -4
- package/docs/en/guides/topic-detail/model/computed-state.mdx +0 -5
- package/docs/en/guides/topic-detail/model/define-model.mdx +0 -4
- package/docs/en/guides/topic-detail/model/faq.mdx +0 -5
- package/docs/en/guides/topic-detail/model/manage-effects.mdx +0 -5
- package/docs/en/guides/topic-detail/model/model-communicate.mdx +0 -5
- package/docs/en/guides/topic-detail/model/performance.mdx +0 -4
- package/docs/en/guides/topic-detail/model/quick-start.mdx +5 -7
- package/docs/en/guides/topic-detail/model/redux-integration.mdx +0 -4
- package/docs/en/guides/topic-detail/model/typescript-best-practice.mdx +0 -4
- package/docs/en/guides/topic-detail/model/use-model.mdx +0 -5
- package/docs/en/guides/topic-detail/model/use-out-of-modernjs.mdx +0 -4
- package/docs/en/plugin/_meta.json +8 -7
- package/docs/en/plugin/cli-plugins/_meta.json +1 -1
- package/docs/en/plugin/cli-plugins/api.mdx +617 -0
- package/docs/en/plugin/cli-plugins/life-cycle.mdx +139 -0
- package/docs/en/plugin/cli-plugins/migration.mdx +98 -0
- package/docs/en/plugin/introduction.mdx +119 -47
- package/docs/en/plugin/official/_meta.json +12 -0
- package/docs/en/plugin/official/cli-plugins/_meta.json +1 -0
- package/docs/en/plugin/official/cli-plugins.mdx +6 -0
- package/docs/en/plugin/official/rsbuild-plugins.mdx +3 -0
- package/docs/en/plugin/plugin-system.mdx +237 -0
- package/docs/en/plugin/runtime-plugins/_meta.json +1 -0
- package/docs/en/plugin/runtime-plugins/api.mdx +165 -0
- package/docs/en/plugin/runtime-plugins/life-cycle.mdx +29 -0
- package/docs/en/plugin/runtime-plugins/migration.mdx +101 -0
- package/docs/en/plugin/server-plugins/api.mdx +3 -0
- package/docs/en/plugin/server-plugins/life-cycle.mdx +3 -0
- package/docs/zh/apis/app/hooks/src/app.mdx +18 -26
- package/docs/zh/apis/app/hooks/src/modern.runtime.mdx +9 -0
- package/docs/zh/apis/app/runtime/app/define-config.mdx +5 -0
- package/docs/zh/community/blog/v2-release-note.mdx +1 -1
- package/docs/zh/components/enable-micro-frontend.mdx +19 -12
- package/docs/zh/components/micro-runtime-config.mdx +3 -3
- package/docs/zh/components/reduck-notify.mdx +27 -0
- package/docs/zh/configure/app/plugins.mdx +2 -2
- package/docs/zh/configure/app/runtime/0-intro.mdx +67 -86
- package/docs/zh/configure/app/tools/esbuild.mdx +1 -1
- package/docs/zh/configure/app/tools/swc.mdx +1 -1
- package/docs/zh/configure/app/usage.mdx +44 -21
- package/docs/zh/guides/basic-features/render/_meta.json +1 -1
- package/docs/zh/guides/basic-features/render/before-render.mdx +115 -0
- package/docs/zh/guides/basic-features/routes.mdx +0 -95
- package/docs/zh/guides/topic-detail/micro-frontend/c02-development.mdx +3 -5
- package/docs/zh/guides/topic-detail/micro-frontend/c03-main-app.mdx +4 -2
- package/docs/zh/guides/topic-detail/model/auto-actions.mdx +0 -4
- package/docs/zh/guides/topic-detail/model/computed-state.mdx +0 -4
- package/docs/zh/guides/topic-detail/model/define-model.mdx +1 -4
- package/docs/zh/guides/topic-detail/model/faq.mdx +0 -5
- package/docs/zh/guides/topic-detail/model/manage-effects.mdx +0 -4
- package/docs/zh/guides/topic-detail/model/model-communicate.mdx +1 -4
- package/docs/zh/guides/topic-detail/model/performance.mdx +0 -4
- package/docs/zh/guides/topic-detail/model/quick-start.mdx +7 -8
- package/docs/zh/guides/topic-detail/model/redux-integration.mdx +0 -4
- package/docs/zh/guides/topic-detail/model/typescript-best-practice.mdx +0 -4
- package/docs/zh/guides/topic-detail/model/use-model.mdx +0 -5
- package/docs/zh/guides/topic-detail/model/use-out-of-modernjs.mdx +0 -4
- package/docs/zh/plugin/_meta.json +8 -7
- package/docs/zh/plugin/cli-plugins/_meta.json +1 -1
- package/docs/zh/plugin/cli-plugins/api.mdx +617 -0
- package/docs/zh/plugin/cli-plugins/life-cycle.mdx +139 -0
- package/docs/zh/plugin/cli-plugins/migration.mdx +98 -0
- package/docs/zh/plugin/introduction.mdx +92 -20
- package/docs/zh/plugin/official/_meta.json +12 -0
- package/docs/zh/plugin/official/cli-plugins/_meta.json +1 -0
- package/docs/zh/plugin/official/cli-plugins.mdx +6 -0
- package/docs/zh/plugin/official/rsbuild-plugins.mdx +3 -0
- package/docs/zh/plugin/plugin-system.mdx +239 -0
- package/docs/zh/plugin/runtime-plugins/_meta.json +1 -0
- package/docs/zh/plugin/runtime-plugins/api.mdx +166 -0
- package/docs/zh/plugin/runtime-plugins/life-cycle.mdx +29 -0
- package/docs/zh/plugin/runtime-plugins/migration.mdx +101 -0
- package/docs/zh/plugin/server-plugins/api.mdx +3 -0
- package/docs/zh/plugin/server-plugins/life-cycle.mdx +3 -0
- package/i18n.json +4 -0
- package/package.json +3 -2
- package/src/components/Footer/index.tsx +1 -1
- package/src/components/Mermaid/index.tsx +60 -0
- package/src/components/Mermaid/style.scss +221 -0
- package/docs/en/plugin/cli-plugins.mdx +0 -6
- package/docs/en/plugin/plugin-system/_meta.json +0 -10
- package/docs/en/plugin/plugin-system/extend.mdx +0 -163
- package/docs/en/plugin/plugin-system/hook-list.mdx +0 -711
- package/docs/en/plugin/plugin-system/hook.mdx +0 -188
- package/docs/en/plugin/plugin-system/implement.mdx +0 -243
- package/docs/en/plugin/plugin-system/introduction.mdx +0 -95
- package/docs/en/plugin/plugin-system/lifecycle.mdx +0 -16
- package/docs/en/plugin/plugin-system/plugin-api.mdx +0 -138
- package/docs/en/plugin/plugin-system/relationship.mdx +0 -119
- package/docs/en/plugin/rsbuild-plugins.mdx +0 -3
- package/docs/zh/plugin/cli-plugins.mdx +0 -6
- package/docs/zh/plugin/plugin-system/_meta.json +0 -10
- package/docs/zh/plugin/plugin-system/extend.mdx +0 -163
- package/docs/zh/plugin/plugin-system/hook-list.mdx +0 -715
- package/docs/zh/plugin/plugin-system/hook.mdx +0 -173
- package/docs/zh/plugin/plugin-system/implement.mdx +0 -250
- package/docs/zh/plugin/plugin-system/introduction.mdx +0 -94
- package/docs/zh/plugin/plugin-system/lifecycle.mdx +0 -16
- package/docs/zh/plugin/plugin-system/plugin-api.mdx +0 -138
- package/docs/zh/plugin/plugin-system/relationship.mdx +0 -119
- package/docs/zh/plugin/rsbuild-plugins.mdx +0 -4
- /package/docs/en/plugin/{cli-plugins → official/cli-plugins}/plugin-bff.mdx +0 -0
- /package/docs/en/plugin/{cli-plugins → official/cli-plugins}/plugin-ssg.mdx +0 -0
- /package/docs/en/plugin/{cli-plugins → official/cli-plugins}/plugin-swc.mdx +0 -0
- /package/docs/en/plugin/{cli-plugins → official/cli-plugins}/plugin-tailwind.mdx +0 -0
- /package/docs/en/plugin/{rsbuild-plugins → official/rsbuild-plugins}/_meta.json +0 -0
- /package/docs/en/plugin/{rsbuild-plugins → official/rsbuild-plugins}/plugin-esbuild.mdx +0 -0
- /package/docs/zh/plugin/{cli-plugins → official/cli-plugins}/plugin-bff.mdx +0 -0
- /package/docs/zh/plugin/{cli-plugins → official/cli-plugins}/plugin-ssg.mdx +0 -0
- /package/docs/zh/plugin/{cli-plugins → official/cli-plugins}/plugin-swc.mdx +0 -0
- /package/docs/zh/plugin/{cli-plugins → official/cli-plugins}/plugin-tailwind.mdx +0 -0
- /package/docs/zh/plugin/{rsbuild-plugins → official/rsbuild-plugins}/_meta.json +0 -0
- /package/docs/zh/plugin/{rsbuild-plugins → official/rsbuild-plugins}/plugin-esbuild.mdx +0 -0
@@ -1,44 +1,30 @@
|
|
1
|
-
---
|
2
|
-
title: App.[tj]sx
|
3
|
-
sidebar_position: 1
|
4
|
-
---
|
5
1
|
# App.[tj]sx
|
6
2
|
|
7
|
-
The
|
3
|
+
The entry identifier when using [Self-controlled Routing](/guides/concept/entries.html#self-controlled-routing) in the application.
|
8
4
|
|
9
|
-
`App.[tj]sx` is not the actual entry
|
5
|
+
`App.[tj]sx` is not the actual application entry; Modern.js will automatically generate the real entry file, which is roughly as follows:
|
10
6
|
|
11
7
|
```js
|
12
|
-
|
13
|
-
import
|
14
|
-
import { createApp, bootstrap } from '@modern-js/runtime';
|
15
|
-
// App.[jt]sx
|
8
|
+
// runtime-global-context
|
9
|
+
import { setGlobalContext } from '@modern-js/runtime/context';
|
16
10
|
import App from '@_modern_js_src/App';
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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;
|
11
|
+
|
12
|
+
setGlobalContext({
|
13
|
+
App,
|
14
|
+
});
|
15
|
+
|
16
|
+
// index.tsx
|
17
|
+
import './runtime-global-context';
|
18
|
+
import { createRoot } from '@modern-js/runtime/react';
|
19
|
+
import { render } from '@modern-js/runtime/browser';
|
20
|
+
|
21
|
+
const ModernRoot = createRoot();
|
22
|
+
|
23
|
+
render(<ModernRoot />, 'root');
|
39
24
|
```
|
40
25
|
|
41
|
-
|
42
|
-
In the multi-entry scenario, each entry can have its own `App.[jt]sx`. See [Entries](/guides/concept/entries) for details.
|
26
|
+
When `createRoot` is executed, it will retrieve the registered Global App and generate the actual React component.
|
43
27
|
|
28
|
+
:::note
|
29
|
+
In scenarios with multiple entry points, each entry can have its own independent `App.[jt]sx`. For more details, see [Entry Points](/guides/concept/entries).
|
44
30
|
:::
|
@@ -0,0 +1,9 @@
|
|
1
|
+
---
|
2
|
+
title: modern.runtime.[tj]s
|
3
|
+
sidebar_position: 4
|
4
|
+
---
|
5
|
+
# modern.runtime.[tj]s
|
6
|
+
|
7
|
+
The Modern.js Runtime configuration file allows for personalized configuration of the Runtime capabilities for the current project.
|
8
|
+
|
9
|
+
For specific usage of the configuration, please refer to [Runtime Configuration](/configure/app/runtime/0-intro.html).
|
@@ -3,8 +3,14 @@ title: defineConfig
|
|
3
3
|
---
|
4
4
|
# defineConfig
|
5
5
|
|
6
|
+
:::warning
|
7
|
+
|
8
|
+
Soon to be deprecated. It is recommended to use `src/modern.runtime.ts` to define Runtime configurations, which supports both static and dynamic configurations. Please refer to the plugin [Runtime Configuration](/configure/app/runtime/0-intro.html).
|
9
|
+
|
6
10
|
For dynamically configuring applications runtime features.
|
7
11
|
|
12
|
+
:::
|
13
|
+
|
8
14
|
## Usage
|
9
15
|
|
10
16
|
```ts
|
@@ -132,7 +132,7 @@ Modern.js 可以划分为三个核心部分:**CLI 工具、服务端和运行
|
|
132
132
|
|
133
133
|
在字节跳动内部,我们借助这些插件 API,结合公司内的基建和平台,封装出内部的企业级框架。如果你需要对 Modern.js 框架进行深度定制,也可以借助这些插件 API 来完成。
|
134
134
|
|
135
|
-
> 如果你对 Modern.js 的插件系统感兴趣,请阅读 [「Modern.js - 自定义插件」](https://modernjs.dev/plugin/plugin-system
|
135
|
+
> 如果你对 Modern.js 的插件系统感兴趣,请阅读 [「Modern.js - 自定义插件」](https://modernjs.dev/plugin/plugin-system.html)文档。
|
136
136
|
|
137
137
|
### 嵌套路由
|
138
138
|
|
@@ -1,13 +1,30 @@
|
|
1
|
-
```
|
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
|
-
state: true,
|
9
|
-
masterApp: true,
|
10
8
|
},
|
11
9
|
plugins: [appTools(), garfishPlugin()],
|
12
10
|
});
|
11
|
+
|
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
|
+
});
|
13
30
|
```
|
@@ -1,18 +1,17 @@
|
|
1
|
-
```
|
2
|
-
import {
|
1
|
+
```ts title="src/modern.runtime.ts"
|
2
|
+
import { defineRuntimeConfig } from '@modern-js/runtime';
|
3
3
|
|
4
|
-
|
4
|
+
export default defineRuntimeConfig({
|
5
5
|
masterApp: {
|
6
|
-
apps: [
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
],
|
6
|
+
apps: [{
|
7
|
+
name: 'Table',
|
8
|
+
entry: 'http://localhost:8081',
|
9
|
+
// activeWhen: '/table'
|
10
|
+
}, {
|
11
|
+
name: 'Dashboard',
|
12
|
+
entry: 'http://localhost:8082'
|
13
|
+
// activeWhen: '/dashboard'
|
14
|
+
}]
|
16
15
|
},
|
17
16
|
});
|
18
17
|
```
|
@@ -0,0 +1,27 @@
|
|
1
|
+
:::warning
|
2
|
+
Starting from `MAJOR_VERSION.67.0`, Modern.js no longer provides Reduck state management capabilities by default. If you need to use Reduck, you must install and register the state plugin.
|
3
|
+
|
4
|
+
**Installation Steps**
|
5
|
+
|
6
|
+
1. Install the `@modern-js/plugin-state` dependency:
|
7
|
+
|
8
|
+
```bash
|
9
|
+
pnpm add @modern-js/plugin-state
|
10
|
+
```
|
11
|
+
|
12
|
+
2. Register the state plugin:
|
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
|
+
:::
|
@@ -9,7 +9,7 @@ sidebar_position: 9
|
|
9
9
|
|
10
10
|
Used to configure custom Modern.js framework plugins.
|
11
11
|
|
12
|
-
Refer to [How to Develop Plugins](/plugin/plugin-system
|
12
|
+
Refer to [How to Develop Plugins](/plugin/plugin-system) for how to write custom plugins.
|
13
13
|
|
14
14
|
## Note
|
15
15
|
|
@@ -33,7 +33,7 @@ Currently, Modern.js has opened up the ability to customize CLI plugins, and Ser
|
|
33
33
|
|
34
34
|
By default, custom plugins are executed in the order of the `plugins` array, and the execution time of built-in Modern.js plugins is earlier than that of custom plugins.
|
35
35
|
|
36
|
-
When the plugin sets options that control the order, such as `pre` and `post`, the execution order will be adjusted based on the declared fields. Refer to [
|
36
|
+
When the plugin sets options that control the order, such as `pre` and `post`, the execution order will be adjusted based on the declared fields. Refer to [Plugins Structure](/plugin/plugin-system) for more information.
|
37
37
|
|
38
38
|
## Example
|
39
39
|
|
@@ -1,119 +1,91 @@
|
|
1
|
-
|
2
|
-
title: Overview
|
3
|
-
sidebar_position: 1
|
4
|
-
---
|
1
|
+
# Introduce
|
5
2
|
|
6
|
-
|
3
|
+
Modern.js runtime configuration should be centralized in the `src/modern.runtime.ts` file.
|
7
4
|
|
8
|
-
|
9
|
-
|
10
|
-
## Configuration
|
11
|
-
|
12
|
-
### runtime
|
13
|
-
|
14
|
-
- **Type:** `Object`
|
15
|
-
|
16
|
-
The runtime is configured as follows:
|
5
|
+
:::info
|
6
|
+
If this file doesn't exist in your project yet, create it with the following command:
|
17
7
|
|
18
|
-
|
8
|
+
```bash
|
9
|
+
touch src/modern.runtime.ts
|
10
|
+
```
|
11
|
+
:::
|
19
12
|
|
20
|
-
|
13
|
+
## Basic Configuration
|
21
14
|
|
22
|
-
```
|
23
|
-
import {
|
15
|
+
```tsx
|
16
|
+
import { defineRuntimeConfig } from '@modern-js/runtime';
|
24
17
|
|
25
|
-
export default
|
26
|
-
|
27
|
-
|
28
|
-
|
18
|
+
export default defineRuntimeConfig({
|
19
|
+
router: {
|
20
|
+
// Router configuration
|
21
|
+
},
|
22
|
+
state: {
|
23
|
+
// State management configuration
|
29
24
|
},
|
25
|
+
// Other runtime modules...
|
30
26
|
});
|
31
27
|
```
|
32
28
|
|
33
|
-
|
34
|
-
|
35
|
-
Configure using [`defineConfig`](/apis/app/runtime/app/define-config) API:
|
36
|
-
|
37
|
-
:::info
|
38
|
-
When there is a function in the runtime configuration, it can only be configured this way.
|
39
|
-
|
40
|
-
:::
|
29
|
+
## Multi-Entry Configuration
|
41
30
|
|
42
|
-
|
31
|
+
For multi-entry applications, `defineRuntimeConfig` can accept a function that returns specific configurations based on the entry name:
|
43
32
|
|
44
|
-
|
45
|
-
|
33
|
+
```tsx
|
34
|
+
import { defineRuntimeConfig } from '@modern-js/runtime';
|
46
35
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
36
|
+
export default defineRuntimeConfig((entryName) => {
|
37
|
+
if (entryName === 'main') {
|
38
|
+
return {
|
39
|
+
router: {
|
40
|
+
// Router configuration for "main" entry
|
41
|
+
},
|
42
|
+
state: {
|
43
|
+
// State management configuration for "main" entry
|
44
|
+
},
|
45
|
+
};
|
55
46
|
}
|
56
|
-
};
|
57
|
-
```
|
58
|
-
|
59
|
-
</TabItem>
|
60
|
-
|
61
|
-
<TabItem value="app" label="Self-controlled Routing">
|
62
|
-
|
63
|
-
```ts title="src/App.tsx"
|
64
|
-
import { defineConfig } from '@modern-js/runtime';
|
65
|
-
|
66
|
-
const App = () => {
|
67
|
-
/** */
|
68
|
-
};
|
69
47
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
48
|
+
// Configuration for other entries
|
49
|
+
return {
|
50
|
+
masterApp: {
|
51
|
+
// Micro-frontend configuration example
|
52
|
+
},
|
53
|
+
};
|
74
54
|
});
|
75
|
-
|
76
|
-
export default App;
|
77
55
|
```
|
78
|
-
|
79
|
-
|
80
|
-
</Tabs>
|
81
|
-
|
82
|
-
:::info
|
83
|
-
Using runtime configuration, you can solve the problem that runtime plugin configuration needs to be at runtime to get specific content.
|
84
|
-
|
85
|
-
Runtime plugin runtime configuration and configuration directly in `modern.config.ts` are merged by default, and runtime configuration takes precedence.
|
86
|
-
|
56
|
+
:::tip
|
57
|
+
Using the `src/modern.runtime.ts` configuration approach does not support exporting asynchronous functions, which is related to the rendering method of Modern.js. If you need to add asynchronous logic, please use the **[Runtime Plugin](/plugin/introduction.html#runtime-plugin)**.
|
87
58
|
:::
|
88
59
|
|
89
60
|
:::warning
|
90
|
-
|
91
|
-
|
61
|
+
Using the `src/modern.runtime.ts` configuration approach requires Modern.js version **MAJOR_VERSION.66.0** or higher.
|
92
62
|
:::
|
93
63
|
|
94
|
-
|
64
|
+
## Configuration Evolution
|
95
65
|
|
96
|
-
|
66
|
+
Before MAJOR_VERSION.66.0, runtime configurations were scattered across multiple locations:
|
97
67
|
|
98
|
-
|
68
|
+
1. The `runtime` and `runtimeByEntries` fields in `modern.config.ts`
|
69
|
+
2. The `App.config` or the `config` function exported from `layout` files for each entry
|
99
70
|
|
100
|
-
|
71
|
+
To improve maintainability, Modern.js introduced the unified `src/modern.runtime.ts` configuration entry.
|
101
72
|
|
102
|
-
|
103
|
-
import { defineConfig } from '@modern-js/app-tools';
|
73
|
+
### Legacy Configuration (Compatible but Not Recommended)
|
104
74
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
},
|
109
|
-
runtimeByEntries: {
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
},
|
118
|
-
});
|
75
|
+
```ts
|
76
|
+
// modern.config.ts
|
77
|
+
export default {
|
78
|
+
runtime: { /* ... */ },
|
79
|
+
runtimeByEntries: { /* ... */ },
|
80
|
+
};
|
81
|
+
|
82
|
+
// App.config
|
83
|
+
App.config = {/* ... */}
|
84
|
+
|
85
|
+
// layout file
|
86
|
+
export const config = () => { /* Dynamic configuration logic */ };
|
119
87
|
```
|
88
|
+
|
89
|
+
### Migration Recommendation
|
90
|
+
|
91
|
+
We strongly recommend migrating all runtime configurations to `src/modern.runtime.ts`. Although the legacy configuration approach is still compatible, it is planned to be gradually deprecated in future versions. A unified configuration entry prevents scattered configurations and significantly improves project maintainability.
|
@@ -41,4 +41,4 @@ export default defineConfig({
|
|
41
41
|
});
|
42
42
|
```
|
43
43
|
|
44
|
-
For config details, please refer to [Esbuild Plugin Configuration](/plugin/rsbuild-plugins/plugin-esbuild.html#config).
|
44
|
+
For config details, please refer to [Esbuild Plugin Configuration](/plugin/official/rsbuild-plugins/plugin-esbuild.html#config).
|
@@ -108,4 +108,4 @@ export default defineConfig({
|
|
108
108
|
});
|
109
109
|
```
|
110
110
|
|
111
|
-
For config details, please refer to [SWC Plugin Configuration](/plugin/cli-plugins/plugin-swc.html#config).
|
111
|
+
For config details, please refer to [SWC Plugin Configuration](/plugin/official/cli-plugins/plugin-swc.html#config).
|