@modern-js/main-doc 2.0.0-canary.1 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/_category_.json +1 -1
  3. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/use-module-apps.md +62 -31
  4. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/router/router.md +174 -375
  5. package/en/docusaurus-plugin-content-docs/current/components/enable-micro-frontend.md +13 -0
  6. package/en/docusaurus-plugin-content-docs/current/components/micro-master-manifest-config.md +15 -0
  7. package/en/docusaurus-plugin-content-docs/current/components/micro-runtime-config.md +18 -0
  8. package/en/docusaurus-plugin-content-docs/current/components/router-legacy-tip.md +1 -0
  9. package/en/docusaurus-plugin-content-docs/current/configure/app/auto-load-plugin.md +62 -0
  10. package/en/docusaurus-plugin-content-docs/current/configure/app/deploy/microFrontend.md +54 -0
  11. package/en/docusaurus-plugin-content-docs/current/configure/app/output/ssg.md +226 -0
  12. package/en/docusaurus-plugin-content-docs/current/configure/app/runtime/master-app.md +20 -39
  13. package/en/docusaurus-plugin-content-docs/current/configure/app/runtime/router.md +17 -4
  14. package/en/docusaurus-plugin-content-docs/current/configure/app/runtime/state.md +17 -4
  15. package/en/docusaurus-plugin-content-docs/current/configure/app/server/enable-framework-ext.md +47 -0
  16. package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/bff/function.md +2 -2
  17. package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/ssg.md +6 -2
  18. package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/_category_.json +4 -0
  19. package/en/docusaurus-plugin-content-docs/current/guides/basic-features/data-fetch.md +1 -1
  20. package/en/docusaurus-plugin-content-docs/current/guides/basic-features/routes.md +0 -2
  21. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/_category_.json +5 -0
  22. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/extend.md +162 -0
  23. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/hook-list.md +803 -0
  24. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/hook.md +169 -0
  25. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/implement.md +247 -0
  26. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/introduction.md +49 -0
  27. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/plugin-api.md +116 -0
  28. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/relationship.md +118 -0
  29. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/config/common.md +1 -1
  30. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/config/module.md +3 -1
  31. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/config/mwa.md +1 -9
  32. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/project.md +2 -2
  33. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/micro-frontend/_category_.json +4 -0
  34. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/micro-frontend/c01-introduction.md +29 -0
  35. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/micro-frontend/c02-development.md +191 -0
  36. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/micro-frontend/c03-main-app.md +246 -0
  37. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/micro-frontend/c04-communicate.md +54 -0
  38. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/micro-frontend/c05-mixed-stack.md +24 -0
  39. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/_category_.json +4 -0
  40. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/auto-actions.md +90 -0
  41. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/computed-state.md +151 -0
  42. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/define-model.md +66 -0
  43. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/faq.md +43 -0
  44. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/manage-effects.md +259 -0
  45. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/model-communicate.md +219 -0
  46. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/performance.md +173 -0
  47. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/quick-start.md +116 -0
  48. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/redux-integration.md +21 -0
  49. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/test-model.md +43 -0
  50. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/typescript-best-practice.md +71 -0
  51. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/use-model.md +244 -0
  52. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/use-out-of-modernjs.md +51 -0
  53. package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/_category_.json +5 -0
  54. package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c01-start.md +99 -0
  55. package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c02-component.md +56 -0
  56. package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c03-css.md +324 -0
  57. package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c04-routes.md +169 -0
  58. package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c05-loader.md +82 -0
  59. package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c06-model.md +260 -0
  60. package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c07-container.md +283 -0
  61. package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c08-entries.md +137 -0
  62. package/en/docusaurus-plugin-content-docs/current/tutorials/foundations/_category_.json +1 -1
  63. package/en/docusaurus-plugin-content-docs/current/tutorials/foundations/introduction.md +5 -3
  64. package/package.json +4 -4
  65. package/zh/apis/app/runtime/core/use-module-apps.md +2 -0
  66. package/zh/apis/app/runtime/router/router.md +169 -371
  67. package/zh/components/micro-master-manifest-config.md +15 -0
  68. package/zh/components/router-legacy-tip.md +1 -0
  69. package/zh/configure/app/auto-load-plugin.md +62 -0
  70. package/zh/configure/app/deploy/microFrontend.md +0 -10
  71. package/zh/configure/app/output/ssg.md +1 -5
  72. package/zh/configure/app/runtime/master-app.md +4 -18
  73. package/zh/configure/app/runtime/router.md +19 -4
  74. package/zh/configure/app/runtime/state.md +7 -7
  75. package/zh/configure/app/server/enable-framework-ext.md +47 -0
  76. package/zh/configure/app/server/port.md +1 -1
  77. package/zh/configure/app/tools/_category_.json +1 -1
  78. package/zh/guides/advanced-features/eslint.md +2 -1
  79. package/zh/guides/advanced-features/ssg.md +4 -0
  80. package/zh/guides/basic-features/data-fetch.md +1 -1
  81. package/zh/guides/basic-features/env-vars.md +1 -1
  82. package/zh/guides/basic-features/routes.md +0 -3
  83. package/zh/guides/topic-detail/generator/config/module.md +3 -1
  84. package/zh/guides/topic-detail/generator/config/mwa.md +1 -9
  85. package/zh/guides/topic-detail/model/quick-start.md +1 -1
  86. package/zh/tutorials/first-app/c06-model.md +5 -1
  87. package/zh/tutorials/first-app/c08-entries.md +1 -1
  88. package/zh/tutorials/foundations/introduction.md +5 -3
  89. package/en/docusaurus-plugin-content-docs/current/apis/app/overview.md +0 -12
  90. package/en/docusaurus-plugin-content-docs/current/configure/app/bff/fetcher.md +0 -28
  91. package/en/docusaurus-plugin-content-docs/current/configure/app/dev/with-master-app.md +0 -31
  92. package/en/docusaurus-plugin-content-docs/current/guides/overview.md +0 -11
  93. package/en/docusaurus-plugin-content-docs/current/tutorials/foundations/basic.md +0 -8
  94. package/zh/apis/app/overview.md +0 -11
  95. package/zh/apis/monorepo/overview.md +0 -11
  96. package/zh/configure/app/bff/fetcher.md +0 -31
  97. package/zh/configure/app/dev/with-master-app.md +0 -32
  98. package/zh/guides/overview.md +0 -11
  99. package/zh/tutorials/foundations/basic.md +0 -8
@@ -1,4 +1,4 @@
1
1
 
2
- > @modern-js/main-doc@2.0.0-beta.6 build /Users/bytedance/Desktop/workspace/modern.js/packages/toolkit/main-doc
2
+ > @modern-js/main-doc@2.0.1 build /github/workspace/packages/toolkit/main-doc
3
3
  > npx ts-node ./scripts/sync.ts
4
4
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "label": "运行时",
2
+ "label": "runtime",
3
3
  "position": 3,
4
4
  "collapsed": false,
5
5
  "link": {
@@ -10,16 +10,6 @@ Returns the React components of all micro-front-end sub-applications for freely
10
10
  import { useModuleApps } from '@modern-js/plugin-garfish/runtime';
11
11
  ```
12
12
 
13
- :::info Turn on
14
- This API is used in the main application of micro frontend, please execute `pnpm run new` to turn on the micro frontend function first.
15
-
16
- ```bash
17
- pnpm run new
18
- ? 请选择你想要的操作 启用可选功能
19
- ? 启用可选功能 启用「微前端」模式
20
- ```
21
- :::
22
-
23
13
  ## Function Signature
24
14
 
25
15
  `function useModuleApps(): Record<string, React.FC<any>>`
@@ -30,30 +20,13 @@ Returns the React components wrapped around each subapp.
30
20
 
31
21
  You need to configure the micro-front-end sub-application information first.
32
22
 
33
- ```ts title=modern.config.js
34
- module.exports = {
35
- runtime: {
36
- features:{
37
- masterApp: {
38
- apps: [
39
- {
40
- name: 'Home',
41
- entry: 'http://www.home.com'
42
- },
43
- {
44
- name: 'Contact',
45
- entry: 'http://www.contact.com'
46
- },
47
- ]
48
- }
49
- }
50
- }
51
- }
52
- ```
23
+ import EnableMicroFrontend from '@site-docs-en/components/enable-micro-frontend.md';
24
+
25
+ <EnableMicroFrontend />
53
26
 
54
27
  ```tsx title=App.tsx
55
28
  function App() {
56
- const { Components: { Home, Contact } } = useModuleApps();
29
+ const { Home, Contact } = useModuleApps();
57
30
 
58
31
  return <div>
59
32
  Master APP
@@ -65,11 +38,69 @@ function App() {
65
38
  </Route>
66
39
  </div>;
67
40
  }
41
+
42
+ defineConfig(App, {
43
+ masterApp: {
44
+ apps: [
45
+ {
46
+ // name 区分大小写,name 提供的是什么 useModuleApps 返回的就是什么
47
+ name: "Home",
48
+ entry: "http://127.0.0.1:8081/"
49
+ },
50
+ {
51
+ name: "Contact",
52
+ entry: "http://localhost:8082"
53
+ }
54
+ ]
55
+ }
56
+ })
68
57
  ```
69
58
 
70
59
  Get the `Home` and `Contact` sub-application components(the same as name in the config) through `useModuleApps()`. After that, you can load the child application just like a normal React component.
71
60
 
72
61
 
62
+ ### Centralized Routing
63
+
64
+ **Centralized Routing** is a way to centrally configure the activation routes of sub-applications. 我add `activeWhen` config to enable **Centralized Routing**。
65
+
66
+ import MicroRuntimeConfig from '@site-docs-en/components/micro-runtime-config.md';
67
+
68
+ <MicroRuntimeConfig />
69
+
70
+ Then use the `useModuleApp` method to get the `MApp` component in the main application, and render the `MApp` in the main application.
71
+
72
+ ```tsx title=main: App.tsx
73
+ import { useModuleApp } from '@modern-js/plugin-runtime';
74
+
75
+ function App() {
76
+ const { MApp } = useModuleApps();
77
+
78
+ return <div>
79
+ <MApp />
80
+ </div>
81
+ }
82
+
83
+ defineConfig(App, {
84
+ masterApp: {
85
+ apps: [
86
+ {
87
+ // name is case sensitive, what name provides is what useModuleApps returns
88
+ name: "Dashboard",
89
+ activeWhen: '/dashboard',
90
+ entry: "http://127.0.0.1:8081/"
91
+ },
92
+ {
93
+ name: "TableList",
94
+ activeWhen: '/table',
95
+ entry: "http://localhost:8082"
96
+ }
97
+ ]
98
+ }
99
+ })
100
+ ```
101
+
102
+ After starting the application in this way, accessing the `/dashboard` route will render the `Dashboard`, and accessing the `/table` route will render the `TableList`.
103
+
73
104
  ## Load Animation
74
105
 
75
106
  The transition animation of the component loading process can be customized in the following ways.