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
I’m using the module-federation-enhanced example from the rspack-examples repository. When I run the application as provided in the example, it works correctly.
However, I encountered an issue during development when I temporarily removed the usage of the remote component ProviderButton in consumer/src/App.tsx. Here’s what happened:
Initial Code (Working):
The App.tsx originally looked like this, and the app worked fine:
import'./App.css';// The remote component provided by federation_providerimportProviderButtonfrom'federation_provider/button';constApp=()=>{return(<divclassName="content"><h1>Rsbuild with React</h1><p>Start building amazing things with Rsbuild.</p><div><ProviderButton/></div></div>);};exportdefaultApp;
Temporary Change (Hot Reload Worked):
I modified the code to remove ProviderButton like this:
import'./App.css';// The remote component provided by federation_providerconstApp=()=>{return(<divclassName="content"><h1>Rsbuild with React</h1><p>Start building amazing things with Rsbuild.</p><div></div></div>);};exportdefaultApp;
When I saved the file, the app hot reloaded, and the button disappeared as expected.
Reverting to the Original Code (Error):
After reverting the code back to its original state (re-adding the ProviderButton import and component usage), I saved the file, but this time I got the following error:
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of `Page`.
It seems like something breaks in the module-federation-enhanced setup when hot reloading after the ProviderButton component is removed and then re-added. Any idea what might cause this issue and how to resolve it?
Both @module-federation/rsbuild-plugin and @module-federation/enhanced/rspack gives same error.
Describe the bug
I’m using the module-federation-enhanced example from the rspack-examples repository. When I run the application as provided in the example, it works correctly.
However, I encountered an issue during development when I temporarily removed the usage of the remote component
ProviderButton
inconsumer/src/App.tsx
. Here’s what happened:Initial Code (Working):
The App.tsx originally looked like this, and the app worked fine:
Temporary Change (Hot Reload Worked):
I modified the code to remove ProviderButton like this:
When I saved the file, the app hot reloaded, and the button disappeared as expected.
Reverting to the Original Code (Error):
After reverting the code back to its original state (re-adding the
ProviderButton
import and component usage), I saved the file, but this time I got the following error:It seems like something breaks in the module-federation-enhanced setup when hot reloading after the ProviderButton component is removed and then re-added. Any idea what might cause this issue and how to resolve it?
Both
@module-federation/rsbuild-plugin
and@module-federation/enhanced/rspack
gives same error.When app crashes
returns empty
m.default
instead of functionReproduction
https://github.com/rspack-contrib/rspack-examples/tree/main/rsbuild/module-federation-enhanced
Used Package Manager
pnpm
System Info
Validations
The text was updated successfully, but these errors were encountered: