You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// set `react-router-dom/` to reference react-router-dom v5 which shoule be find in node_modules/react-router-dom, otherwise it will cause app.tsx fail to work which in react-router-dom v5 mode.
Copy file name to clipboardExpand all lines: apps/website-new/docs/en/practice/bridge/index.mdx
+47-22Lines changed: 47 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,27 +2,50 @@
2
2
3
3
## Introduction
4
4
5
-
The `MF bridge` is a utility function provided by `Module Federation` to help users load application-level modules through `Module Federation`. It automatically provides the necessary application lifecycle functions `render` and `destroy` required by the `provider` function and ensures compatibility with different framework versions. Additionally, it allows proper routing collaboration between applications.
5
+
`Bridge` is a utility function provided by `Module Federation` for loading application-level modules.
6
+
"Application-level modules" are modules that can run like applications, with framework rendering capabilities and routing abilities.
7
+
With `Bridge`, you can render your application in different frameworks and ensure that routing between applications works collaboratively. This is particularly useful for micro-frontend applications.
6
8
7
9
:::tip
8
-
Before reading this chapter, it's assumed you are already familiar with:
10
+
Before reading this chapter, it's assumed you're familiar with:
9
11
10
12
-[How to consume and export modules](../../guide/start/quick-start.mdx)
-[Features and capabilities of the Module Federation Runtime](../../guide/basic/runtime.mdx)
14
+
-[Characteristics and capabilities of Module Federation Runtime](../../guide/basic/runtime.mdx)
13
15
14
16
:::
15
17
16
18
## Toolkits
17
19
18
20
### @module-federation/bridge-react
19
21
20
-
The `@module-federation/bridge-react` toolkit is a `bridge` utility function package provided by MF for React v18 applications. The exported `createBridgeComponent` can be used for exporting modules in React v18 applications. Usage examples of `@module-federation/bridge-react` can be found in the [Host demo](https://github.com/module-federation/core/tree/main/apps/router-demo/router-host-2000) and [Remote demo](https://github.com/module-federation/core/tree/main/apps/router-demo/router-remote2-2002).
22
+
`@module-federation/bridge-react` is suitable for React framework types, currently supporting React v16, v17, and v18 versions.
23
+
24
+
This toolkit provides two APIs:
25
+
26
+
- createBridgeComponent
27
+
28
+
> Used to create React application-type module exports. If your application is React-based and you want it to be loaded as an application-type module by another MF application, you should use this to create standard-compliant exports for your application.
29
+
30
+
- createRemoteComponent
31
+
32
+
> Used to load application-type modules in a React application. The loaded module must be wrapped by `createBridgeComponent`. `createRemoteComponent` will automatically create a rendering context in your application to ensure the module works properly.
33
+
34
+
For usage of `@module-federation/bridge-react`, see [Host demo](https://github.com/module-federation/core/tree/main/apps/router-demo/router-host-2000) and [Remote demo](https://github.com/module-federation/core/tree/main/apps/router-demo/router-remote2-2002).
21
35
22
36
### @module-federation/bridge-vue3
23
37
24
-
The `@module-federation/bridge-vue3` toolkit is a `bridge` utility function package provided by MF for Vue v3 applications. The exported `createBridgeComponent` can be used for exporting modules in Vue v3 sub-applications. Usage examples of `@module-federation/bridge-vue3` can be found in the [Host demo](https://github.com/module-federation/core/tree/main/apps/router-demo/router-host-2100) and [Remote demo](https://github.com/module-federation/core/tree/main/apps/router-demo/router-remote3-2003).
38
+
`@module-federation/bridge-vue3` is suitable for Vue framework types, currently supporting Vue v3 version.
39
+
40
+
This toolkit provides two APIs:
25
41
42
+
- createBridgeComponent
43
+
44
+
> Used to create Vue application-type module exports. If your application is Vue v3-based and you want it to be loaded as an application-type module by another MF application, you should use this to create standard-compliant exports for your application.
45
+
46
+
- createRemoteComponent
47
+
48
+
> Used to load application-type modules in a Vue application. The loaded module must be wrapped by `createBridgeComponent`. `createRemoteComponent` will automatically create a rendering context in your application to ensure the module works properly.
26
49
27
50
## FAQ
28
51
@@ -31,17 +54,17 @@ The `@module-federation/bridge-vue3` toolkit is a `bridge` utility function pack
31
54
Bridge is mainly used to solve two problems:
32
55
33
56
* Cross-application framework (React, Vue) loading and rendering
34
-
* Support for loading modules with routes (routes can work together properly)
57
+
* Support for loading modules with routing (routes can work well together)
35
58
36
-
These two problems are important features in the "micro-frontend framework".
59
+
These two issues are important features in "micro-frontend frameworks"
37
60
38
-
### How to solve it if the corresponding framework bridge is not provided?
61
+
### How to solve if there's no bridge provided for a specific framework?
39
62
40
-
Currently, `Module Federation` provides official bridge toolkits. If you need bridge toolkits for other frameworks, you can provide feedback via [issue](https://github.com/module-federation/core/issues) or refer to the existing [`Bridge`](https://github.com/module-federation/core/blob/34ba220bcee3d032e4083aae37f802d1ed20d61b/packages/bridge/bridge-react)to implement it yourself.
63
+
Currently, `Module Federation` provides official bridge toolkits. If you need bridge toolkits for other frameworks, you can provide feedback through [issues](https://github.com/module-federation/core/issues), or refer to the existing [`Bridge`](https://github.com/module-federation/core/blob/34ba220bcee3d032e4083aae37f802d1ed20d61b/packages/bridge/bridge-react)implementation.
41
64
42
-
The implementation of `Bridge` is very simple. The core is based on `DOM` rendering. Here is the pseudocode:
65
+
The implementation of `Bridge` is very simple, with the core based on `DOM` rendering. Here's some pseudocode:
0 commit comments