-
-
Notifications
You must be signed in to change notification settings - Fork 257
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
Issue with dynamic route when reloading application with RSBuild and MF v2 #3343
Comments
@ScriptedAlchemy The above occurs when we have publicpath set to auto. If we have publicpath set to '/' the application works but the host breaks! Any suggestion for this? |
Update: Issue is with children routes and not the dynamic route... If we have all routes on the same level everything is fine... if not when refreshing a child route, the browser tries to resolve the static files with: where |
Use getPublicPath instead. |
Or set base meta tag in your head |
This seems to work and I can dynamically set my base ref in my
However, shouldn't this be handled by Also, we can now see two entries in network.. One going to http://localhost:3001/some/static/js/vendors-node_modules_rspack_plugin-react-refresh_client_reactRefreshEntry_js-_module-federati-74bf07.js and the other one going to http://localhost:3001/static/js/vendors-node_modules_rspack_plugin-react-refresh_client_reactRefreshEntry_js-_module-federati-74bf07.js Is this the expected behavior? |
no it shouldnt, compiler is not a framework. setting base can cause issues. alternatively, use getPublicPath option or hard code them |
I agree with the statement that compiler is not a framework but it feels like that I am missing something. In the example of 2 react apps (one host and one remote), setting One would expect that this configuration will keep working even if a nested route is introduced on the remote. What am I missing here with the nested route? Why do we have different behavior between the scenarios of just having single routes vs nested routes? Is it something with the devServer? In our previous configurations with Webpack5, setting I do want to explore the Where should the getPublicPath be configured? On the remote mf config or the host? And what does it actually do? I tried to configure
on the remote mf confing and also leaving rspack Apologies for the long question, I am just trying to understand how I can correctly configure this setup. I do know that this might not be the correct place to post such questions so feel free to direct me to the correct channels or people where we can join knowledge to address this and finally come up with an example repo for react and nested routes for module federation. |
play around with it and see. https://module-federation.io/configure/getpublicpath.html most likely would be on the remote side since they are the ones using auto to figure out base paths |
Describe the bug
I have created a POC to test out the configuration of RSBuild and Module Federation v2. Everything was working fine and I managed to expose the remote so it can be consumed by another app.
This was achieved by the following RSBuild configuration:
Now everything was working fine, until I introduced a dynamic route to my React Router.
The issue is that when my browser is at localhost:3001/something/route2 and I hit refresh, the application breaks with the following error and a white page is displayed:
If my browser is at localhost:3001/something and I hit refresh, everything works fine.
I do believe that this has to do with the rsbuild configuration and the
publicPath: 'auto'
, however this is required in order to expose the application and consume it by the host.Is there a way to bypass the above issue?
Also maybe it would be a good idea to include a working example of Module Federated apps with React and React Router using dynamic routes as this is a very common setup
Reproduction
https://github.com/petrosD93/rspack-remote.git
Used Package Manager
npm
System Info
Validations
The text was updated successfully, but these errors were encountered: