Skip to content

Commit 8036a96

Browse files
committed
docs(mf): polish docs
1 parent 90339f9 commit 8036a96

File tree

10 files changed

+249
-112
lines changed

10 files changed

+249
-112
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ jobs:
158158
cache: 'pnpm'
159159

160160
- name: Install Dependencies
161-
run: pnpm install && cd ./tests && npx playwright install chromium
161+
run: pnpm install && cd ./tests && pnpm playwright install chromium
162162

163163
# only run benchmark in Ubuntu
164164
- name: Benchmarks (Vitest)
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# @examples/module-federation
2+
3+
Check out [Module Federation Documentation](https://module-federation.io/) for the glossary of `consumer`, `producer`, `remote`, and `host`.
4+
5+
## Packages
6+
7+
In this example directory, there are three projects included, which are:
8+
9+
### [mf-react-component](./mf-react-component/)
10+
11+
**Role**:
12+
13+
- Rslib project: producer
14+
- Storybook: consumer
15+
16+
A React component built with Rslib in the Module Federation format. It includes a Storybook configuration that demonstrates how to develop MF in Storybook.
17+
18+
### [mf-remote](./mf-remote/)
19+
20+
**Role**: producer
21+
22+
A Module Federation remote module built with Rsbuild. It is consumed by [mf-react-component](./mf-react-component/) to show how a Rslib MF module could be consumed by another Rslib app while consuming other remote modules at the same time.
23+
24+
Extra remote module is **optional**, it is used to demonstrate a complex Module Federation set up here.
25+
26+
### [mf-host](./mf-host/)
27+
28+
**Role**: consumer
29+
30+
An Rsbuild app that consumes Module Federation remote module.
31+
32+
## Development MF
33+
34+
### With host app
35+
36+
1. Start the remote module
37+
38+
```bash
39+
pnpm dev:remote
40+
```
41+
42+
2. Start the Rslib MF module
43+
44+
```bash
45+
pnpm dev:rslib
46+
```
47+
48+
3. Start the host app
49+
50+
```bash
51+
pnpm dev:host
52+
```
53+
54+
Then access the host app at http://localhost:3000.
55+
56+
### With Storybook
57+
58+
1. Start the remote module
59+
60+
```bash
61+
pnpm dev:remote
62+
```
63+
64+
2. Start the Rslib MF module
65+
66+
```bash
67+
pnpm dev:rslib
68+
```
69+
70+
2. Start the host app
71+
72+
```bash
73+
pnpm dev:storybook
74+
```
75+
76+
Then access the host app at http://localhost:6006.

examples/module-federation/mf-host/README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
# Rsbuild Project
1+
# @examples/mf-host
22

3-
Module Federation Host Example
3+
> [!NOTE]
4+
> Check out [README](../README.md) to see how to develop a Rslib MF project in a host app or Storybook.
45
5-
## Setup
6+
An Rsbuild app that consumes Module Federation remote module.
67

7-
Install the dependencies:
8+
## Usage
89

9-
```bash
10-
pnpm install
11-
```
12-
13-
## Get Started
10+
### Development
1411

1512
Start the dev server:
1613

1714
```bash
1815
pnpm dev
1916
```
2017

18+
### Build
19+
2120
Build the app for production:
2221

2322
```bash
2423
pnpm build
2524
```
2625

26+
### Preview
27+
2728
Preview the production build locally:
2829

2930
```bash
Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,28 @@
11
# @examples/mf-react-component
22

3-
This example demonstrates how to use Rslib to build a simple Module Federation React component.
3+
> [!NOTE]
4+
> Check out [README](../README.md) to see how to develop a Rslib MF project in a host app or Storybook.
45
5-
### Usage
6+
A React component built with Rslib in the Module Federation format. It includes a Storybook configuration that demonstrates how to develop MF in Storybook.
67

7-
Dev MF module
8+
## Usage
89

9-
1. Start remote module which is loaded by Rslib module.
10+
### Develop MF module
1011

11-
```
12-
nx run @examples/mf-remote:dev
13-
```
14-
15-
2. Start MF dev mode.
16-
17-
```
18-
nx run @examples/mf-react-component:dev
12+
```bash
13+
pnpm run dev
1914
```
2015

21-
3. Use Storybook to development component.
16+
### Build and serve the dist in production mode
2217

23-
```
24-
nx run @examples/mf-react-component:storybook
25-
```
26-
27-
Build
18+
Build the project
2819

29-
```
30-
nx run @examples/mf-react-component:build
20+
```bash
21+
pnpm run build
3122
```
3223

33-
Build and Serve dist
24+
Serve the dist
3425

35-
```
36-
nx run @examples/mf-react-component:serve
26+
```bash
27+
pnpm run serve
3728
```

examples/module-federation/mf-remote/README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
# Rsbuild Project
1+
# @examples/mf-remote
22

3-
Module Federation Remote Example
3+
> [!NOTE]
4+
> Check out [README](../README.md) to see how to develop a Rslib MF project in a host app or Storybook.
45
5-
## Setup
6+
A Module Federation remote module built with Rsbuild. It is consumed by [mf-react-component](./mf-react-component/) to show how a Rslib MF module could be consumed by another Rslib app while consuming other remote modules at the same time.
67

7-
Install the dependencies:
8-
9-
```bash
10-
pnpm install
11-
```
8+
Extra remote module is **optional**, it is used to demonstrate a complex Module Federation set up here.
129

1310
## Get Started
1411

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
{
2-
"name": "@examples/mf",
2+
"name": "@examples/module-federation",
33
"private": true,
44
"scripts": {
5-
"dev:all": "pnpm dev:host & pnpm serve:lib & pnpm dev:remote",
5+
"build:lib": "pnpm --filter mf-react-component run build",
6+
"dev:all:host": "pnpm dev:host & pnpm dev:mf & pnpm dev:remote",
7+
"dev:all:storybook": "pnpm dev:mf & pnpm dev:storybook & pnpm dev:remote",
68
"dev:host": "pnpm --filter mf-host dev",
9+
"dev:mf": "pnpm --filter mf-react-component dev",
710
"dev:remote": "pnpm --filter mf-remote dev",
11+
"dev:storybook": "pnpm --filter mf-react-component storybook",
812
"serve:lib": "pnpm --filter mf-react-component run serve"
913
}
1014
}

0 commit comments

Comments
 (0)