Skip to content

Commit

Permalink
feat: runtime plugin to mount multi react version app (#3818)
Browse files Browse the repository at this point in the history
* feat: runtime plugin to mound multi react version app

* feat: runtime plugin to mound multi react version app

* update factory

* update factory

* sync with m

* sync main

* fix tests

* improve doc

* improve doc

* improve doc

* locks

* add tests

---------

Co-authored-by: ScriptedAlchemy <zackaryjackson@bytedance.com>
  • Loading branch information
ScriptedAlchemy and ScriptedAlchemy committed May 15, 2024
1 parent 68fa25c commit e9aed1e
Show file tree
Hide file tree
Showing 42 changed files with 42,300 additions and 45,989 deletions.
1 change: 1 addition & 0 deletions .cursorignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/dist/**
3 changes: 3 additions & 0 deletions different-react-versions-16-17-typescript/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
> For an example implementation of using different React versions together with Module Federation, check out the runtime plugin folder [runtime-plugins/multiple-react-versions](https://github.com/module-federation/module-federation-examples/tree/master/runtime-plugins/multiple-react-versions).

# Mixed React Versions and Compatibility levels

This example demos the ability to load two separate versions of react.
Expand Down
19 changes: 2 additions & 17 deletions different-react-versions-16-17/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
# Mixed React Versions and Compatibility levels
# Example has moved

This example demos the ability to load two separate versions of react.
For an example implementation of using different React versions together with Module Federation, check out the runtime plugin folder [runtime-plugins/multiple-react-versions](https://github.com/module-federation/module-federation-examples/tree/master/runtime-plugins/multiple-react-versions).

Module Federation allows us to create an adapter which attaches a hooks-friendly version to render a section of thr app using modern versions.

- `app1` uses and older version of react, not compatible with react Hooks
- `app2` uses a modern react version and its components are hooks based

The adapter consumes both versions of react to "translate" the props into a fresh render. This could be presented as a HOC or federated components could have a legacy export containing the adapter build in.

# Running Demo

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

- [localhost:3001](http://localhost:3001/) (HOST)
- [localhost:3002](http://localhost:3002/) (STANDALONE REMOTE)

<img src="https://ssl.google-analytics.com/collect?v=1&t=event&ec=email&ea=open&t=event&tid=UA-120967034-1&z=1589682154&cid=ae045149-9d17-0367-bbb0-11c41d92b411&dt=ModuleFederationExamples&dp=/email/DifferentReactVersions">
57 changes: 0 additions & 57 deletions different-react-versions-16-17/app1/src/components/App.js

This file was deleted.

This file was deleted.

This file was deleted.

16 changes: 0 additions & 16 deletions different-react-versions-16-17/package.json

This file was deleted.

2 changes: 2 additions & 0 deletions different-react-versions-16-18/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
> For an example implementation of using different React versions together with Module Federation, check out the runtime plugin folder [runtime-plugins/multiple-react-versions](https://github.com/module-federation/module-federation-examples/tree/master/runtime-plugins/multiple-react-versions).
# Mixed React Versions and Compatibility levels

This example demos the ability to load two separate versions of react.
Expand Down
2 changes: 2 additions & 0 deletions different-react-versions-isolated/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
> For an example implementation of using different React versions together with Module Federation, check out the runtime plugin folder [runtime-plugins/multiple-react-versions](https://github.com/module-federation/module-federation-examples/tree/master/runtime-plugins/multiple-react-versions).
# Different React Versions in Isolation

This example demos host and remote applications running in isolation with two different React versions and no shared libraries
Expand Down
2 changes: 2 additions & 0 deletions different-react-versions-typescript/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
> For an example implementation of using different React versions together with Module Federation, check out the runtime plugin folder [runtime-plugins/multiple-react-versions](https://github.com/module-federation/module-federation-examples/tree/master/runtime-plugins/multiple-react-versions).
# Mixed React Versions and Compatibility levels

This example demos the ability to load two separate versions of react (v16.6.3 and v18.2.0).
Expand Down
4 changes: 4 additions & 0 deletions different-react-versions/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
> For an example implementation of using different React versions together with Module Federation, check out the runtime plugin folder [runtime-plugins/multiple-react-versions](https://github.com/module-federation/module-federation-examples/tree/master/runtime-plugins/multiple-react-versions).


# Mixed React Versions and Compatibility levels

This example demos the ability to load two separate versions of react (v16.6.3 and v16.13.1).
Expand Down
Loading

0 comments on commit e9aed1e

Please sign in to comment.