@modern-js/main-doc 2.0.0-beta.4 → 2.0.0-beta.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/en/docusaurus-plugin-content-docs/current/apis/app/commands/dev.md +8 -3
  3. package/en/docusaurus-plugin-content-docs/current/apis/app/commands/inspect.md +33 -8
  4. package/en/docusaurus-plugin-content-docs/current/apis/app/commands/serve.md +32 -0
  5. package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/src/server.md +31 -0
  6. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/bootstrap.md +4 -3
  7. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/create-app.md +2 -3
  8. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/use-module-apps.md +1 -1
  9. package/en/docusaurus-plugin-content-docs/current/components/init-app.md +1 -1
  10. package/en/docusaurus-plugin-content-docs/current/configure/app/builder-plugins.md +70 -0
  11. package/en/docusaurus-plugin-content-docs/current/configure/app/dev/with-master-app.md +0 -1
  12. package/en/docusaurus-plugin-content-docs/current/configure/app/plugins.md +11 -5
  13. package/en/docusaurus-plugin-content-docs/current/configure/app/source/disable-entry-dirs.md +38 -0
  14. package/en/docusaurus-plugin-content-docs/current/configure/app/source/entries.md +66 -2
  15. package/en/docusaurus-plugin-content-docs/current/configure/app/tools/esbuild.md +1 -1
  16. package/en/docusaurus-plugin-content-docs/current/guides/concept/entries.md +1 -1
  17. package/en/docusaurus-plugin-content-docs/current/guides/get-started/quick-start.md +3 -3
  18. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/_category_.json +4 -0
  19. package/en/docusaurus-plugin-content-docs/current/guides/{concept → topic-detail/framework-plugin}/lifecycle.md +0 -0
  20. package/package.json +3 -3
  21. package/zh/apis/app/commands/dev.md +9 -4
  22. package/zh/apis/app/commands/inspect.md +34 -9
  23. package/zh/apis/app/commands/{start.md → serve.md} +3 -3
  24. package/zh/apis/app/hooks/src/index_.md +1 -1
  25. package/zh/apis/app/hooks/src/server.md +31 -0
  26. package/zh/apis/app/runtime/core/bootstrap.md +3 -4
  27. package/zh/apis/app/runtime/core/create-app.md +1 -18
  28. package/zh/apis/app/runtime/core/use-module-apps.md +64 -33
  29. package/zh/apis/app/runtime/web-server/hook.md +1 -1
  30. package/zh/apis/app/runtime/web-server/middleware.md +1 -0
  31. package/zh/components/default-mwa-generate.md +5 -0
  32. package/zh/components/deploy.md +1 -0
  33. package/zh/components/enable-micro-frontend.md +13 -0
  34. package/zh/components/init-app.md +2 -2
  35. package/zh/components/micro-runtime-config.md +18 -0
  36. package/zh/components/prerequisites.md +2 -2
  37. package/zh/components/release-note.md +1 -0
  38. package/zh/configure/app/builder-plugins.md +72 -0
  39. package/zh/configure/app/deploy/_category_.json +4 -0
  40. package/zh/configure/app/deploy/microFrontend.md +64 -0
  41. package/zh/configure/app/dev/with-master-app.md +0 -2
  42. package/zh/configure/app/plugins.md +10 -4
  43. package/zh/configure/app/runtime/master-app.md +33 -36
  44. package/zh/configure/app/source/disable-entry-dirs.md +37 -0
  45. package/zh/configure/app/source/entries-dir.md +0 -3
  46. package/zh/configure/app/source/entries.md +66 -3
  47. package/zh/guides/advanced-features/compatibility.md +12 -1
  48. package/zh/guides/advanced-features/eslint.md +21 -21
  49. package/zh/guides/advanced-features/ssg.md +14 -3
  50. package/zh/guides/advanced-features/ssr.md +1 -1
  51. package/zh/guides/advanced-features/testing.md +11 -0
  52. package/zh/guides/advanced-features/web-server.md +12 -1
  53. package/zh/guides/basic-features/css/tailwindcss.md +11 -0
  54. package/zh/guides/basic-features/data-fetch.md +398 -5
  55. package/zh/guides/basic-features/routes.md +35 -3
  56. package/zh/guides/concept/entries.md +104 -14
  57. package/zh/guides/get-started/quick-start.md +8 -5
  58. package/zh/guides/get-started/upgrade.md +3 -1
  59. package/zh/guides/{concept → topic-detail/framework-plugin}/lifecycle.md +0 -0
  60. package/zh/guides/topic-detail/micro-frontend/c01-introduction.md +29 -0
  61. package/zh/guides/topic-detail/micro-frontend/c02-development.md +191 -0
  62. package/zh/guides/topic-detail/micro-frontend/c03-main-app.md +246 -0
  63. package/zh/guides/topic-detail/micro-frontend/c04-communicate.md +54 -0
  64. package/zh/guides/topic-detail/micro-frontend/{mixed-stack.md → c05-mixed-stack.md} +3 -3
  65. package/zh/guides/topic-detail/monorepo/create-sub-project.md +2 -2
  66. package/zh/tutorials/first-app/c01-start.md +9 -4
  67. package/zh/tutorials/first-app/c03-css.md +19 -0
  68. package/zh/tutorials/first-app/c04-routes.md +4 -4
  69. package/zh/tutorials/first-app/c05-loader.md +3 -3
  70. package/zh/tutorials/first-app/c06-model.md +19 -19
  71. package/zh/tutorials/first-app/c07-container.md +38 -23
  72. package/zh/tutorials/first-app/c08-entries.md +4 -1
  73. package/en/docusaurus-plugin-content-docs/current/apis/app/commands/start.md +0 -32
  74. package/zh/guides/advanced-features/custom-app.md +0 -70
  75. package/zh/guides/topic-detail/micro-frontend/communicate.md +0 -39
  76. package/zh/guides/topic-detail/micro-frontend/debugging.md +0 -168
  77. package/zh/guides/topic-detail/micro-frontend/introduction.md +0 -13
  78. package/zh/guides/topic-detail/micro-frontend/route-mode.md +0 -110
@@ -1,110 +0,0 @@
1
- ---
2
- sidebar_position: 4
3
- title: 加载子应用
4
- ---
5
-
6
- 在微前端中分为两种加载子应用的方式:
7
-
8
- 1. **子应用组件** 获取到每个子应用的组件,之后就可以像使用普通的 React 组件一样渲染微前端的子应用。
9
- 2. **集中式路由** 通过集中式的路由配置,自动根据当前页面 pathname 激活渲染对应的子应用。
10
-
11
- ## 子应用组件
12
-
13
- 使用 `useModuleApps` API 可以获取到各个子应用的组件。结合 `router`,可以自控式的根据不同的路由渲染不同的子应用。
14
-
15
- 假设我们的子应用列表配置如下:
16
-
17
- ```typescript title="modern.config.ts"
18
- export default defineConfig({
19
- runtime: {
20
- masterApp: {
21
- manifest: {
22
- modules: [
23
- {
24
- name: "Dashboard",
25
- entry: "http://localhost:8081"
26
- },
27
- {
28
- name: "TableList",
29
- entry: "http://localhost:8082"
30
- }
31
- ]
32
- }
33
- }
34
- }
35
- }
36
- ```
37
-
38
- 编辑主应用 `App.tsx` 文件如下:
39
-
40
- ```tsx title=主应用:App.tsx
41
- import { useModuleApps } from '@modern-js/plugin-garfish';
42
- import { Route, Switch } from '@modern-js/runtime/router';
43
-
44
- function App() {
45
- const { Dashboard, TableList } = useModuleApps();
46
-
47
- return <div>
48
- <Switch>
49
- <Route path='/dashboard'>
50
- <Dashboard />
51
- </Route>
52
- <Route path='/tablelist'>
53
- <TableList />
54
- </Route>
55
- </ Switch>
56
- </div>
57
- }
58
- ```
59
-
60
- 这里通过 `Route` 组件自定义了 **DashBoard** 的激活路由为 **/dashboard**, **TableList** 的激活路由为 **/tablelist**。
61
-
62
- ## 集中式路由
63
-
64
- **集中式路由** 是将子应用的激活路由集中配置的方式。我们给子应用列表信息添加 `activeWhen` 字段来启用 **集中式路由**。
65
-
66
- ```typescript title="modern.config.ts"Å {8,13}
67
- export default defineConfig({
68
- runtime: {
69
- masterApp: {
70
- manifest: {
71
- modules: [
72
- {
73
- name: "Dashboard",
74
- activeWhen: '/dashboard',
75
- entry: "http://localhost:8081"
76
- },
77
- {
78
- name: TableList,
79
- activeWhen: '/tablelist',
80
- entry: "http://localhost:8082"
81
- }
82
- ]
83
- }
84
- }
85
- }
86
- }
87
- ```
88
-
89
- 然后在主应用中使用 `useModuleApp` API 来获取 `MApp` 在主应用渲染。
90
-
91
- ```tsx title=主应用:App.tsx
92
- import { useModuleApp } from '@modern-js/runtime';
93
-
94
- function App() {
95
- const MApp = useModuleApp();
96
-
97
- return <div>
98
- <MApp />
99
- </div>
100
- }
101
- ```
102
-
103
- 这样启动应用后,访问 `/dashboard` 路由,会渲染 `Dashboard` 子应用,访问 `/tablelist` 路由,会渲染 `TableList` 子应用。
104
-
105
- ## 两种模式混用
106
-
107
- 当然 **子应用组件** 和 **集中式路由** 是可以混合使用的。
108
-
109
- - 一部分子应用作为 **子应用组件** 激活,另外一部分作为 **集中式路由** 激活。
110
- - 一部分子应用既可以作为 **集中式路由** 激活,也可以作为 **子应用组件** 激活。