-
Notifications
You must be signed in to change notification settings - Fork 33
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
Host preloading script loads assets from incorrect remote when base
not explicit for cross domain remotes
#242
Comments
I am trying to debug it. vitejs/vite#5214 might be a similar issue.
Weirdly, this one has both a |
OK, I got it to work by explicitly adding I guess this makes sense - I don't think we had to specify a In the provided examples:
I am using native ESM, although I don't think it makes a difference; I tried using commonjs and had the same issue. Either way, not sure if this is a bug, perhaps either a chance for an update to the documentation? Will leave this one open in case it helps someone else! |
base
not explicit for cross domain remotes
Hi @lmiller1990 thanks for looking into that, I'm glad you solved the issue. |
hi @gioboa I encountered the same issue with vite + vue and module federation with manifest configuration. the issue is that the loadEsmEntry function
is using "entry" to load the federated module, but in mf-manifest.json generated you can see that entry is only
and in vite.config I have the federation configured as
Although giving a getPublicPath function and/or providing base can fix partially the issue, in my case it was increasing the problems as I had different places where the federated module could be hosted with different paths. I've solved the issue implementing a plugin which attaches to loadEntry
but I'm not sure about few things like why in remoteInfo.version there's the mf-manifest url ... |
Hi @dvelluto thanks for sharing your steps. |
I am trying to migrate from webpack to vite. It's mostly working, except one issue, when the host and remote are deployed on separate domains.
Minimal reproduction: https://github.com/lmiller1990/vite-module-federation-bug
There is a bug where, for production builds (not
vite dev
) the host will preload assets from its own domain. The remote IS able to load exposed assets from the host, though. Weird!You can reproduce this by running
./reproduction.sh
:This will do a non minified, production build, and serve both apps using the
serve
static server.Visiting the remote,
http://localhost:4000
, is fine. It loads a remote module exposed from the host,http://localhost:3000
, which logs a greeting (see the console).Visitng the host,
http://localhost:3000
, however, shows the issue. Thepreload-helper
tries to load the remote asset, such asplace.js
, fromhttp://localhost:3000/assets/place-DpMnJR6N.js
- it should be fromhttp://localhost:4000/assets/place-DpMnJR6N.js
.The problem is more clear when you look at the
preload
code:All assets are preloaded from
/
.This does NOT happen with
vite dev
. If the domains are the same, it works as expected:The text was updated successfully, but these errors were encountered: