-
-
Notifications
You must be signed in to change notification settings - Fork 237
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
Module Federation requests to wrong url to load remotes. #3070
Comments
UPDATE In order to make it work, I had to re-configure publicPath for rspack: // rsbuild.config.js (shell)
...
tools: {
rspack: {
output: {
uniqueName: "shell",
publicPath: "/",
},
},
},
... // rsbuild.config.js (remote)
...
tools: {
rspack: {
output: {
uniqueName: "remote",
publicPath: "auto",
},
},
},
... |
yep, setting public path resolves it. |
@chenjiahan we should make "auto" the default when MF is detected. |
The @nyqykk can you help to check this issue? |
This still doesn't explain why we have to set it to "/" on shell apps. Can you help me to understand that behaviour? |
If you provide a repo we can take a look |
can you provide a repo? |
My apologies folks, But remotes still should explicitly set publicPath to "auto" in order to work. Since setting it to "auto" also for shell doesn't cause any issues, plugin can ensure publicPath is set to "auto" no matter what. I think this is not the case rn. |
We are improving the default value of publicPath / assetPrefix for Rsbuild MF apps, see web-infra-dev/rsbuild#3757 |
@ScriptedAlchemy Hey, is there a way to configure the publicPath to be anything other than 'auto'. It seems like a hard restriction that module federation files from remote can only be exposed from the root. Codebase in my company for example has a base framework that controls entry & output fields & hence the output ends up becoming: "output": {
"filename": "[name]/page.js",
"publicPath": "/webpack/"
}, What this means is, if I have a new ModuleFederationPlugin({
name: "devportal",
filename: "remoteEntry.js",
remotes: {},
exposes: {
'./Simple': './src/components/Simple.jsx',
}, This generates files like this:
I'm looking to see if there is a possibility to configure:
What I tried?I tried the latter - by editing:
Although this worked in terms of code being injected has the right path, but unfortunately it didn't work when integrating it within the host. Looking for a cleaner way to achieve this, as it's sort of a blocker for us to adopt microfrontends via module federation. Appreciate any help / workaround. |
Describe the bug
I have this rsbuild.config.js for my shell app which is migrated from Vite to use MF 2.0
and result of requesting to http://localhost:3000/mf-manifest.json (shell app requests to the correct url and gets the correct response which I do when I request via browser):
We expect shell app to request for "http://localhost:3000/static/js/async/src_App_tsx.js" but instead it requests for "http://localhost:5173/static/js/async/src_App_tsx.js" and this results in the index.html content for shell app which is not a js. And http://localhost:3000/static/js/async/src_App_tsx.js correctly returns the remote component.
This is thrown as error on console:
Uncaught (in promise) Error: [ Federation Runtime ]:
Unable to use the muhaberat's '/static/js/remote.js' URL with remote's globalName to get remoteEntry exports.
Possible reasons could be:
while loading "./RemoteApp" from webpack/container/reference/remote
Notes:
Remote Component is rendered under a dynamic route handled by react-router-dom:
{BASE_URL}/:id/remote
Reproduction
.
Used Package Manager
pnpm
System Info
Validations
The text was updated successfully, but these errors were encountered: