Skip to content

Commit 13d83d3

Browse files
cix: update app and e2e
1 parent d0799cc commit 13d83d3

File tree

1 file changed

+45
-16
lines changed

1 file changed

+45
-16
lines changed
Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,64 @@
11
# Controlled Vendor Sharing
22

3-
Dynamic Vendor Sharing is an application that implements a control panel in the runtime plugin for module federation 1.5 in rspack or `@module-federation/enhanced`. The control panel allows you to deterministically manage and modify the rules for shared modules, as well as upgrade or downgrade applications based on the inputs from the React form.
3+
This example demonstrates a runtime plugin implementation for Module Federation that provides dynamic control over shared module versions. It allows you to deterministically manage and modify shared module versions across federated applications using a control panel interface and localStorage persistence.
44

55
## Features
66

7-
- Runtime plugin that implements rules for module sharing.
8-
- React form for modifying the rules.
9-
- Ability to upgrade or downgrade applications.
10-
- `app1` and `app2` exposing different button components.
7+
- Runtime plugin for dynamic version control of shared modules
8+
- Control panel UI for managing shared module versions
9+
- Persistent version settings using localStorage (`formDataVMSC` key)
10+
- Support for upgrading/downgrading shared module versions
11+
- E2E tests to verify version control functionality
1112

1213
## Main Components
1314

14-
### `./app1/control-share.ts`
15+
### `control-share.ts`
1516

16-
This is the runtime plugin that implements the rules for module federation.
17+
A runtime plugin that implements version control for Module Federation. Key features:
18+
- Implements the `FederationRuntimePlugin` interface
19+
- Uses localStorage to persist version preferences
20+
- Handles version resolution and module sharing between applications
21+
- Manages share scope mapping and instance tracking
1722

18-
### `./app1/src/ControlPanel.js`
23+
### E2E Tests (`checkAutomaticVendorApps.cy.ts`)
1924

20-
This is a React form that allows for the modification of rules implemented in `control-share.ts`.
25+
Comprehensive E2E tests that verify:
26+
- Initial shared module versions
27+
- Version override functionality through localStorage
28+
- UI updates reflecting version changes
29+
- Button component rendering with correct version information
2130

22-
# Running Demo
31+
## Running Demo
2332

2433
Run `pnpm run start`. This will build and serve both `app1` and `app2` on ports 3001 and 3002 respectively.
2534

26-
- [localhost:3001](http://localhost:3001/)
27-
- [localhost:3002](http://localhost:3002/)
35+
- [localhost:3001](http://localhost:3001/) - Host application with control panel
36+
- [localhost:3002](http://localhost:3002/) - Remote application
2837

29-
# Running Cypress E2E Tests
38+
## Running Cypress E2E Tests
3039

31-
To run tests in interactive mode, run `npm run cypress:debug` from the root directory of the project. It will open Cypress Test Runner and allow to run tests in interactive mode. [More info about "How to run tests"](../../cypress/README.md#how-to-run-tests)
40+
To run tests in interactive mode:
41+
```bash
42+
npm run cypress:debug
43+
```
3244

33-
To build app and run test in headless mode, run `yarn e2e:ci`. It will build app and run tests for this workspace in headless mode. If tets failed cypress will create `cypress` directory in sample root folder with screenshots and videos.
45+
To run tests in headless mode:
46+
```bash
47+
yarn e2e:ci
48+
```
3449

35-
["Best Practices, Rules amd more interesting information here](../../cypress/README.md)
50+
For failed tests, screenshots and videos will be saved in the `cypress` directory.
51+
52+
## Implementation Details
53+
54+
The control panel allows you to:
55+
- View current versions of shared modules (react, react-dom, lodash)
56+
- Override versions for specific applications
57+
- Save settings to localStorage
58+
- Clear settings and reload to default versions
59+
60+
The runtime plugin (`control-share.ts`) handles:
61+
- Version resolution based on localStorage settings
62+
- Share scope management
63+
- Instance tracking and updates
64+
- Cross-application module sharing rules

0 commit comments

Comments
 (0)