Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple react versions runtime plugin example does not work with loadRemote #4278

Open
p12y opened this issue Sep 30, 2024 · 2 comments
Open

Comments

@p12y
Copy link

p12y commented Sep 30, 2024

Problem

Multiple react version runtime plugin example does not work with loadRemote, only import.

Example

https://github.com/module-federation/module-federation-examples/tree/master/runtime-plugins/multiple-react-versions

To recreate

In app1/App.js, update the lazy imports to use loadRemote instead of import:

+ import { loadRemote } from '@module-federation/enhanced/runtime';

- const ModernComponent = React.lazy(() => import('app2/ModernComponent'));
- const RemoteButton = React.lazy(() => import('app2/Button'));
+ const ModernComponent = React.lazy(() => loadRemote('app2/ModernComponent'));
+ const RemoteButton = React.lazy(() => loadRemote('app2/Button'));

Expected behaviour

The app should continue to work as expected

Actual behaviour

The app crashes with "ERROR Element type is invalid. Received a promise that resolves to: undefined. Lazy element type must resolve to a class or function."

image

Impact

The plugin approach to supporting multiple react versions does not work when using the runtime utils, which are needed when loading modules dynamically.

@ScriptedAlchemy
Copy link
Member

Ill need to check this again, its been a while and we have since created the framework bridge capability.

https://module-federation.io/practice/bridge/index.html

@ScriptedAlchemy
Copy link
Member

You also have to return an object with a default key. So loading remotely may not work without returning an object like {default: value}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants