My current project utilizes React 18 and webpack 5 with the module federation plugin. I am exploring the possibility of integrating Next JS with module federation, but I am encountering an issue where the host project is not able to fetch styles from the remote project properly. This inconsistency in styling is causing a visually unappealing result, with some styles loading correctly while others fail to upload.
In my setup:
- baseguicomponent -> host project
- droninfocomponent -> remote project
The main problem lies in the rendering of styles across the projects.
Below is the configuration provided in my next.config.js file for the host project:
[...]
This piece of code showcases how the modules are configured within the project, along with the shared dependencies between them.
For the host index.js file:
[...]
And the corresponding package.json for the host project:
[...]
Similarly, for the remote project, here is the next.config.js configuration:
[...]
With this setup, the remote index.js file looks like this:
[...]
Followed by the package.json for the remote project:
[...]
However, despite setting up the configurations as illustrated above, I am facing difficulties sharing the _app.js file for the remote project. The loss of proper styling integration on the host project is puzzling because the standalone remote module appears unaffected. I have struggled to find adequate examples or resources related to module federation implementations in Next JS, leading to difficulty in resolving the styling discrepancies.