@modern-js/main-doc 2.6.0 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +17 -0
- package/README.md +2 -2
- package/en/apis/app/commands.mdx +2 -0
- package/en/apis/app/hooks/config/upload.mdx +10 -0
- package/en/apis/app/runtime/model/connect.mdx +1 -1
- package/en/apis/app/runtime/model/model_.mdx +1 -1
- package/en/apis/app/runtime/model/use-model.mdx +1 -1
- package/en/apis/app/runtime/web-server/hook.mdx +2 -2
- package/en/apis/app/runtime/web-server/middleware.mdx +33 -9
- package/en/components/enable-bff.mdx +4 -4
- package/en/components/init-rspack-app.mdx +7 -0
- package/en/configure/app/bff/enable-handle-web.mdx +24 -0
- package/en/configure/app/server/enable-framework-ext.mdx +1 -1
- package/en/configure/app/server/ssr.mdx +18 -0
- package/en/guides/advanced-features/bff/_category_.json +1 -1
- package/en/guides/advanced-features/eslint.mdx +30 -32
- package/en/guides/advanced-features/low-level.mdx +1 -1
- package/en/guides/advanced-features/rspack-start.mdx +13 -17
- package/en/guides/advanced-features/ssr.mdx +210 -5
- package/en/guides/advanced-features/web-server.mdx +87 -20
- package/en/guides/{css/tailwindcss.mdx → basic-features/css.mdx} +60 -3
- package/en/guides/basic-features/env-vars.mdx +4 -0
- package/en/guides/concept/builder.mdx +1 -1
- package/en/guides/topic-detail/framework-plugin/extend.mdx +20 -19
- package/en/guides/topic-detail/framework-plugin/hook-list.mdx +156 -155
- package/en/guides/topic-detail/framework-plugin/hook.mdx +58 -43
- package/en/guides/topic-detail/framework-plugin/implement.mdx +47 -49
- package/en/guides/topic-detail/framework-plugin/introduction.mdx +22 -23
- package/en/guides/topic-detail/framework-plugin/plugin-api.mdx +13 -13
- package/en/guides/topic-detail/framework-plugin/relationship.mdx +30 -30
- package/en/guides/topic-detail/generator/plugin/develop.mdx +1 -1
- package/en/guides/topic-detail/micro-frontend/c01-introduction.mdx +17 -17
- package/en/guides/topic-detail/micro-frontend/c02-development.mdx +76 -78
- package/en/guides/topic-detail/micro-frontend/c03-main-app.mdx +57 -51
- package/en/guides/topic-detail/micro-frontend/c04-communicate.mdx +11 -11
- package/en/guides/topic-detail/micro-frontend/c05-mixed-stack.mdx +13 -13
- package/en/guides/topic-detail/model/auto-actions.mdx +18 -21
- package/en/guides/topic-detail/model/computed-state.mdx +27 -25
- package/en/guides/topic-detail/model/define-model.mdx +14 -14
- package/en/guides/topic-detail/model/faq.mdx +12 -13
- package/en/guides/topic-detail/model/manage-effects.mdx +43 -52
- package/en/guides/topic-detail/model/model-communicate.mdx +47 -45
- package/en/guides/topic-detail/model/performance.mdx +22 -23
- package/en/guides/topic-detail/model/quick-start.mdx +29 -28
- package/en/guides/topic-detail/model/redux-integration.mdx +7 -7
- package/en/guides/topic-detail/model/test-model.mdx +11 -11
- package/en/guides/topic-detail/model/typescript-best-practice.mdx +16 -15
- package/en/guides/topic-detail/model/use-model.mdx +40 -45
- package/en/guides/topic-detail/model/use-out-of-modernjs.mdx +16 -16
- package/en/guides/troubleshooting/cli.mdx +2 -2
- package/en/tutorials/first-app/c03-css.mdx +1 -1
- package/package.json +5 -5
- package/zh/apis/app/commands.mdx +2 -0
- package/zh/apis/app/hooks/config/upload.mdx +12 -2
- package/zh/apis/app/runtime/model/connect.mdx +1 -1
- package/zh/apis/app/runtime/model/model_.mdx +1 -1
- package/zh/apis/app/runtime/model/use-model.mdx +1 -1
- package/zh/apis/app/runtime/web-server/hook.mdx +2 -4
- package/zh/apis/app/runtime/web-server/middleware.mdx +30 -10
- package/zh/apis/monorepo/commands/gen-release-note.mdx +3 -3
- package/zh/components/enable-bff.mdx +4 -4
- package/zh/components/init-rspack-app.mdx +7 -0
- package/zh/components/release-note.mdx +1 -1
- package/zh/configure/app/bff/enable-handle-web.mdx +24 -0
- package/zh/configure/app/server/enable-framework-ext.mdx +1 -1
- package/zh/configure/app/server/ssr.mdx +19 -1
- package/zh/guides/advanced-features/bff/_category_.json +1 -1
- package/zh/guides/advanced-features/rspack-start.mdx +13 -17
- package/zh/guides/advanced-features/ssr.mdx +210 -4
- package/zh/guides/advanced-features/web-server.mdx +81 -16
- package/zh/guides/{css/tailwindcss.mdx → basic-features/css.mdx} +60 -3
- package/zh/guides/basic-features/env-vars.mdx +4 -0
- package/zh/guides/concept/builder.mdx +1 -1
- package/zh/guides/topic-detail/changesets/github.mdx +2 -2
- package/zh/guides/topic-detail/changesets/release-note.mdx +1 -1
- package/zh/guides/topic-detail/framework-plugin/plugin-api.mdx +2 -2
- package/zh/guides/topic-detail/generator/plugin/develop.mdx +1 -1
- package/zh/guides/topic-detail/model/faq.mdx +1 -1
- package/zh/guides/topic-detail/model/manage-effects.mdx +1 -1
- package/zh/guides/topic-detail/model/model-communicate.mdx +1 -1
- package/zh/guides/topic-detail/model/performance.mdx +1 -1
- package/zh/guides/topic-detail/model/quick-start.mdx +2 -2
- package/zh/guides/topic-detail/model/use-model.mdx +3 -3
- package/zh/tutorials/first-app/c03-css.mdx +1 -1
- package/en/guides/css/_category_.json +0 -5
- package/en/guides/css/css-in-js.mdx +0 -40
- package/en/guides/css/css-modules.mdx +0 -87
- package/en/guides/css/less-sass.mdx +0 -17
- package/en/guides/css/postcss.mdx +0 -79
- package/zh/guides/css/_category_.json +0 -5
- package/zh/guides/css/css-in-js.mdx +0 -40
- package/zh/guides/css/css-modules.mdx +0 -87
- package/zh/guides/css/less-sass.mdx +0 -17
- package/zh/guides/css/postcss.mdx +0 -80
@@ -1,29 +1,29 @@
|
|
1
1
|
---
|
2
|
-
title:
|
2
|
+
title: Relationship
|
3
3
|
sidebar_position: 4
|
4
4
|
---
|
5
|
-
#
|
5
|
+
# Relationship between Plugins
|
6
6
|
|
7
|
-
Modern.js
|
7
|
+
The plugin configuration object in Modern.js provides a series of fields to control plugin order, mutual exclusion, and other capabilities. The available fields are as follows:
|
8
8
|
|
9
|
-
- `name`: `string
|
10
|
-
- `pre`: `string[]
|
11
|
-
- `post`: `string[]
|
12
|
-
- `rivals`: `string[]
|
13
|
-
- `required`: `string[]
|
14
|
-
- `usePlugin`: `CliPlugin[]
|
9
|
+
- `name`: `string`, sets the name of the current plugin.
|
10
|
+
- `pre`: `string[]`, these plugins will be adjusted to be executed before the current plugin.
|
11
|
+
- `post`: `string[]`, these plugins will be adjusted to be executed after the current plugin.
|
12
|
+
- `rivals`: `string[]`, mutually exclusive plugins, an error will be thrown when encountering these plugins.
|
13
|
+
- `required`: `string[]`, required plugins, an error will be thrown when the corresponding plugin is not found in the plugin list.
|
14
|
+
- `usePlugin`: `CliPlugin[]`, registers other plugins.
|
15
15
|
|
16
|
-
|
16
|
+
The above parameters can be used to achieve plugin front, back, mutual exclusion, and mandatory logic.
|
17
17
|
|
18
|
-
##
|
18
|
+
## Plugin Sorting
|
19
19
|
|
20
|
-
Modern.js
|
20
|
+
Modern.js plugins achieve plugin sorting functionality through the `pre` and `post` parameters.
|
21
21
|
|
22
|
-
###
|
22
|
+
### Pre
|
23
23
|
|
24
|
-
|
24
|
+
By default, plugins are executed in the order they are added. You can declare preceding plugins to be executed by using the `pre` field.
|
25
25
|
|
26
|
-
|
26
|
+
For example, there are the following two plugins:
|
27
27
|
|
28
28
|
```ts title=foo.ts
|
29
29
|
const foo = {
|
@@ -38,11 +38,11 @@ const bar = {
|
|
38
38
|
};
|
39
39
|
```
|
40
40
|
|
41
|
-
`bar`
|
41
|
+
The `bar` plugin configures the `foo` plugin in the `pre` field, so the'foo' plugin must be executed before the `bar` plugin.
|
42
42
|
|
43
|
-
###
|
43
|
+
### Post
|
44
44
|
|
45
|
-
|
45
|
+
Declare succeeding plugins to be executed by using the `post` field.
|
46
46
|
|
47
47
|
```ts title=foo.ts
|
48
48
|
const foo = {
|
@@ -57,13 +57,13 @@ const bar = {
|
|
57
57
|
};
|
58
58
|
```
|
59
59
|
|
60
|
-
`
|
60
|
+
If you use the `post` parameter in the `bar` plugin's configuration and set it to `['foo']`, then the `foo` plugin will be executed after the `bar` plugin.
|
61
61
|
|
62
|
-
##
|
62
|
+
## rivals
|
63
63
|
|
64
|
-
|
64
|
+
The rivals field can be used to declare a mutual exclusion relationship between plugins.
|
65
65
|
|
66
|
-
|
66
|
+
there are two plugin:
|
67
67
|
|
68
68
|
```ts title=foo.ts
|
69
69
|
const foo = {
|
@@ -78,13 +78,13 @@ const bar = {
|
|
78
78
|
};
|
79
79
|
```
|
80
80
|
|
81
|
-
`bar`
|
81
|
+
The `bar` plugin has been configured with the `foo` plugin in the `rivals` field, therefore an error will be thrown if both the `foo` and `bar` plugins are added simultaneously.
|
82
82
|
|
83
|
-
##
|
83
|
+
## required
|
84
84
|
|
85
|
-
|
85
|
+
The `required` field can be used to declare a dependency relationship between plugins.
|
86
86
|
|
87
|
-
|
87
|
+
there are two plugin:
|
88
88
|
|
89
89
|
```ts title=foo.ts
|
90
90
|
const foo = {
|
@@ -99,11 +99,11 @@ const bar = {
|
|
99
99
|
};
|
100
100
|
```
|
101
101
|
|
102
|
-
`bar`
|
102
|
+
The `bar` plugin has been configured with the `foo` plugin in the `required` field. Therefore, an error will be thrown when using the `bar` plugin if the `foo` plugin is not configured.
|
103
103
|
|
104
|
-
##
|
104
|
+
## Register Plugin
|
105
105
|
|
106
|
-
|
106
|
+
When there is a dependency relationship between plugins, we can also actively register another plugin in a plugin by using `usePlugin`.
|
107
107
|
|
108
108
|
```ts title=foo.ts
|
109
109
|
const foo = () => ({
|
@@ -116,4 +116,4 @@ const bar = () => ({
|
|
116
116
|
});
|
117
117
|
```
|
118
118
|
|
119
|
-
|
119
|
+
When the user configures the `bar` plugin, the foo plugin will also be automatically registered and activated. The user does not need to register the `foo` plugin separately.
|
@@ -41,7 +41,7 @@ Different plugin types will ask different questions. You can choose the plugin t
|
|
41
41
|
After the execution of the create project command is completed, a project for developing the generator plugin will be generated accordingly, and the `meta` information will also be generated according to your selection in the `package.json`.
|
42
42
|
|
43
43
|
:::info
|
44
|
-
For generator plugin development, please refer to `@modern-js/generator-plugin-plugin`. [Source Code](https://github.com/
|
44
|
+
For generator plugin development, please refer to `@modern-js/generator-plugin-plugin`. [Source Code](https://github.com/web-infra-dev/modern.js/tree/main/packages/generator/plugins/generator-plugin)
|
45
45
|
|
46
46
|
:::
|
47
47
|
|
@@ -1,29 +1,29 @@
|
|
1
1
|
---
|
2
2
|
sidebar_position: 1
|
3
|
-
title:
|
3
|
+
title: Introduction
|
4
4
|
---
|
5
|
-
#
|
5
|
+
# Introduction
|
6
6
|
|
7
|
-
|
7
|
+
Micro frontend is an architecture similar to microservices. It is an architectural style composed of multiple front-end applications delivered independently. It decomposes the front-end application into some smaller and simpler applications that can be independently developed, tested and deployed., while still a cohesive single product in the eyes of users.
|
8
8
|
|
9
|
-
|
9
|
+
It mainly solves two problems:
|
10
10
|
|
11
|
-
-
|
12
|
-
-
|
11
|
+
- As the iterative application of the project becomes larger and more difficult to maintain.
|
12
|
+
- Collaborative development of projects across teams or departments leads to inefficiencies.
|
13
13
|
|
14
|
-
##
|
14
|
+
## Keyword
|
15
15
|
|
16
|
-
|
16
|
+
In the micro frontend, applications are divided into **main application**, and **sub-applications**.
|
17
17
|
|
18
|
-
-
|
19
|
-
-
|
18
|
+
- Main application: The base project of the micro frontend project, all sub-applications will be loaded by it.
|
19
|
+
- Sub-application: An application developed and deployed independently will eventually be loaded by the main application.
|
20
20
|
|
21
|
-
##
|
21
|
+
## Features
|
22
22
|
|
23
|
-
-
|
24
|
-
-
|
25
|
-
-
|
26
|
-
-
|
27
|
-
-
|
23
|
+
- Base on [Garfish](https://www.garfishjs.org/guide)
|
24
|
+
- Generator supports
|
25
|
+
- Support React component-based reference micro-front-end sub-application
|
26
|
+
- Support loading
|
27
|
+
- Support main application online and sub-application offline debugging mode
|
28
28
|
|
29
|
-
|
29
|
+
You can learn how to develop a micro frontend master app in the section [Experience micro frontend](/guides/topic-detail/micro-frontend/c02-development).
|
@@ -1,56 +1,56 @@
|
|
1
1
|
---
|
2
2
|
sidebar_position: 2
|
3
|
-
title:
|
3
|
+
title: development
|
4
4
|
---
|
5
|
-
# 体验微前端
|
6
5
|
|
7
|
-
|
6
|
+
# Experience Micro Frontend
|
8
7
|
|
9
|
-
|
10
|
-
- 微前端项目开发的基本流程。
|
8
|
+
Through this chapter you can learn:
|
11
9
|
|
12
|
-
|
13
|
-
|
14
|
-
- 自控式路由
|
15
|
-
- 约定式路由
|
10
|
+
- How to create the main application and sub-application of the micro frontend project.
|
11
|
+
- Basic process of micro frontend project development.
|
16
12
|
|
17
|
-
|
13
|
+
## Create an app
|
18
14
|
|
19
|
-
|
15
|
+
Currently supports two routing modes
|
16
|
+
- Self-controlled routing
|
17
|
+
- Conventional routing
|
20
18
|
|
21
|
-
|
19
|
+
First, clarify the routing mode of the main application [create a conventional routing main application](#创建约定式路由主应用) or [create a self-controlled routing main application](#创建自控式路由主应用)
|
22
20
|
|
23
|
-
|
21
|
+
In this experience we will create two sub-applications Table and Dashboard for the main application (Table is reduced routing, Dashboard is self-controlled routing)
|
22
|
+
|
23
|
+
|
24
|
+
### File-based Routing Main App
|
25
|
+
|
26
|
+
Initialize the project with a command line:
|
24
27
|
|
25
28
|
```bash
|
26
29
|
mkdir masterApp && cd masterApp
|
27
30
|
npx @modern-js/create
|
28
31
|
```
|
29
32
|
|
30
|
-
|
31
|
-
|
32
|
-
<DefaultMWAGenerate />
|
33
|
-
|
34
|
-
完成项目创建后我们可以通过 `pnpm run new` 来开启 `微前端` 功能:
|
33
|
+
After the project is created, we can enable the `micro frontend` through `pnpm run new`:
|
35
34
|
|
36
35
|
```bash
|
37
|
-
?
|
38
|
-
?
|
36
|
+
? Action Enable features
|
37
|
+
? Enable features Enable Micro Front-end Feature
|
39
38
|
```
|
40
39
|
|
41
|
-
|
40
|
+
Next, let's register the micro frontend plugin and add the main micro frontend app and add the list of sub-apps:
|
42
41
|
|
43
42
|
import EnableMicroFrontend from "@site-docs/components/enable-micro-frontend";
|
44
43
|
|
45
44
|
<EnableMicroFrontend />
|
46
45
|
|
47
|
-
|
48
|
-
- table (
|
49
|
-
- dashboard (
|
46
|
+
Then we create two new directories in the routes folder
|
47
|
+
- table (for loading conventional routing sub-applications)
|
48
|
+
- dashboard (for loading self-controlled routing sub-applications)
|
50
49
|
|
51
|
-
|
50
|
+
In these two directories, we need to create a `$.tsx` file as the entry of the main application convention route ($represents fuzzy match, that is, `/table` and `/table/test` will match this `$.tsx` as the entry file of the route, which will ensure that the sub-application route is loaded correctly in the micro frontend scenario)
|
51
|
+
|
52
|
+
#### Load file-base routing sub-app
|
52
53
|
|
53
|
-
#### 加载约定式路由子应用
|
54
54
|
```js title="src/routes/table/$.tsx"
|
55
55
|
import { useModuleApps } from '@modern-js/plugin-garfish/runtime';
|
56
56
|
|
@@ -67,7 +67,8 @@ const Index = () => {
|
|
67
67
|
export default Index;
|
68
68
|
```
|
69
69
|
|
70
|
-
####
|
70
|
+
#### Load self-controlled routing sub-app
|
71
|
+
|
71
72
|
```js title="src/routes/dashboard/$.tsx"
|
72
73
|
import { useModuleApps } from '@modern-js/plugin-garfish/runtime';
|
73
74
|
|
@@ -83,16 +84,18 @@ const Index = () => {
|
|
83
84
|
|
84
85
|
export default Index;
|
85
86
|
```
|
86
|
-
####
|
87
|
-
|
87
|
+
#### route link
|
88
|
+
|
89
|
+
At this time, the main application configuration has been completed, and the sub-application can be loaded through the route, and the `layout.tsx` of the main application can be modified to jump to the route:
|
90
|
+
|
88
91
|
```js title="src/route/layout.tsx"
|
89
92
|
import { Outlet, Link } from '@modern-js/runtime/router';
|
90
93
|
|
91
94
|
const Layout = () => (
|
92
95
|
<div>
|
93
|
-
<div><Link to={'/table'}
|
94
|
-
<div><Link to={'/dashboard'}
|
95
|
-
<div><Link to={'/'}
|
96
|
+
<div><Link to={'/table'}>Load file-base routing sub-app</Link></div>
|
97
|
+
<div><Link to={'/dashboard'}>Load self-controlled routing sub-app</Link></div>
|
98
|
+
<div><Link to={'/'}>unmount sub-app</Link></div>
|
96
99
|
<Outlet />
|
97
100
|
</div>
|
98
101
|
);
|
@@ -100,55 +103,51 @@ const Layout = () => (
|
|
100
103
|
export default Layout;
|
101
104
|
```
|
102
105
|
|
103
|
-
###
|
106
|
+
### Self-Controlled Main App
|
104
107
|
|
105
|
-
|
108
|
+
Initialize the project with a command line:
|
106
109
|
|
107
110
|
```bash
|
108
111
|
mkdir masterApp && cd masterApp
|
109
112
|
npx @modern-js/create
|
110
113
|
```
|
111
114
|
|
112
|
-
|
113
|
-
|
114
|
-
完成项目创建后我们可以通过 `pnpm run new` 来开启 `微前端` 功能:
|
115
|
+
After the project is created, we can enable the `micro frontend` function through `pnpm run new`:
|
115
116
|
|
116
117
|
```bash
|
117
|
-
?
|
118
|
-
?
|
118
|
+
? Action Enable features
|
119
|
+
? Enable features Enable Micro Front-end Feature
|
119
120
|
```
|
120
121
|
|
121
|
-
|
122
|
+
Next, let's register the micro frontend plugin and add the main micro frontend app and add the list of sub-apps:
|
122
123
|
|
123
124
|
<EnableMicroFrontend />
|
124
125
|
|
125
|
-
|
126
|
-
|
126
|
+
Since it is a self-controlled route, we delete the `routes/` folder and add the `App.tsx` file in the `src/` directory. If you use a `non-MApp` component here, you need to use the `createBrowserRouter` API of '=React Router v6 to create routes.
|
127
|
+
|
128
|
+
#### Load sub-app
|
129
|
+
|
127
130
|
import CustomRouterMicroFrontend from "@site-docs/components/custom-router-micro-frontend";
|
128
131
|
|
129
132
|
<CustomRouterMicroFrontend />
|
130
133
|
|
131
|
-
###
|
134
|
+
### File-based sub-app
|
132
135
|
|
133
|
-
|
136
|
+
Initialize the project with a command line:
|
134
137
|
|
135
138
|
```bash
|
136
139
|
mkdir table && cd table
|
137
140
|
npx @modern-js/create
|
138
141
|
```
|
139
142
|
|
140
|
-
|
141
|
-
|
142
|
-
<DefaultMWAGenerate/>
|
143
|
-
|
144
|
-
我们执行 `pnpm run new` 来开启 `微前端` 功能:
|
143
|
+
After create sub-app. We execute `pnpm run new` to enable the `micro frontend` function:
|
145
144
|
|
146
145
|
```bash
|
147
|
-
?
|
148
|
-
?
|
146
|
+
? Action Enable features
|
147
|
+
? Enable features Enable Micro Front-end Feature
|
149
148
|
```
|
150
149
|
|
151
|
-
|
150
|
+
Next, let's register the micro frontend plugin and modify `modern.config.ts` to add the configuration of the micro frontend sub-app `deploy.microFrontend`:
|
152
151
|
|
153
152
|
```js title="modern.config.ts"
|
154
153
|
import appTools, { defineConfig } from '@modern-js/app-tools';
|
@@ -169,38 +168,35 @@ export default defineConfig({
|
|
169
168
|
});
|
170
169
|
```
|
171
170
|
|
172
|
-
|
171
|
+
add `src/routes/page.tsx`:
|
172
|
+
|
173
173
|
```js title="src/routes/page.tsx"
|
174
174
|
const Index = () => {
|
175
175
|
return (
|
176
|
-
<div className="container-box">subApp
|
176
|
+
<div className="container-box">subApp</div>
|
177
177
|
)
|
178
178
|
}
|
179
179
|
|
180
180
|
export default Index;
|
181
181
|
```
|
182
182
|
|
183
|
-
###
|
183
|
+
### Self-controlled sub-app
|
184
184
|
|
185
|
-
|
185
|
+
Initialize the project with a command line:
|
186
186
|
|
187
187
|
```bash
|
188
|
-
mkdir
|
188
|
+
mkdir table && cd table
|
189
189
|
npx @modern-js/create
|
190
190
|
```
|
191
191
|
|
192
|
-
|
193
|
-
|
194
|
-
<DefaultMWAGenerate/>
|
195
|
-
|
196
|
-
我们执行 `pnpm run new` 来开启 `微前端`:
|
192
|
+
After create sub-app. We execute `pnpm run new` to enable the `micro frontend` function:
|
197
193
|
|
198
194
|
```bash
|
199
|
-
?
|
200
|
-
?
|
195
|
+
? Action Enable features
|
196
|
+
? Enable features Enable Micro Front-end Feature
|
201
197
|
```
|
202
198
|
|
203
|
-
|
199
|
+
Next, let's register the micro frontend plugin and modify `modern.config.ts` to add the configuration of the micro frontend sub-app `deploy.microFrontend`:
|
204
200
|
|
205
201
|
```js title="modern.config.ts"
|
206
202
|
import appTools, { defineConfig } from '@modern-js/app-tools';
|
@@ -220,9 +216,10 @@ export default defineConfig({
|
|
220
216
|
plugins: [appTools(), garfishPlugin()],
|
221
217
|
});
|
222
218
|
```
|
223
|
-
自控式路由需要删除掉 `routes` 文件夹并在 `src` 目录下新建 `App.tsx`
|
224
219
|
|
225
|
-
|
220
|
+
Self-controlled routing needs to delete the `routes/` folder and create a new `App.tsx` in the `src/` directory.
|
221
|
+
|
222
|
+
And add code in `src/App.tsx`, note that you need to parse from `props` and pass `basename` to `BrowserRouter`.
|
226
223
|
|
227
224
|
```js title="src/App.tsx"
|
228
225
|
import { BrowserRouter, Route, Routes } from '@modern-js/runtime/router';
|
@@ -233,24 +230,25 @@ export default (props: {basename: string}) => {
|
|
233
230
|
return (
|
234
231
|
<BrowserRouter basename={basename}>
|
235
232
|
<Routes>
|
236
|
-
<Route index element={<div
|
237
|
-
<Route path={'path'} element={<div
|
233
|
+
<Route index element={<div>Self-controlled route root</div>} />
|
234
|
+
<Route path={'path'} element={<div>Self-controlled sub route</div>} />
|
238
235
|
</Routes>
|
239
236
|
</BrowserRouter>
|
240
237
|
);
|
241
238
|
};
|
242
239
|
```
|
243
240
|
|
244
|
-
##
|
245
|
-
|
246
|
-
|
247
|
-
-
|
248
|
-
-
|
241
|
+
## Debug
|
242
|
+
|
243
|
+
Start the application by executing the `pnpm run dev` command in the directory in sequence:
|
244
|
+
- masterApp `http://localhost:8080`
|
245
|
+
- table subapplication (conventional routing) `http://localhost:8081`
|
246
|
+
- dashboard subapplication (self-controlled routing) `http://localhost:8082`
|
249
247
|
|
250
|
-
|
248
|
+
Access the main application address `http://localhost:8080`
|
251
249
|
|
252
|
-
|
250
|
+
After completing the experience of the overall development process of micro frontend, you can learn more about how to [develop the main application](/guides/topic-detail/micro-frontend/c03-main-app).
|
253
251
|
|
254
|
-
##
|
252
|
+
## FAQ
|
255
253
|
|
256
|
-
|
254
|
+
Garfish issue: https://www.garfishjs.org/issues/
|