federation runtime vue 3 remotes with getPublicPath generates double calls (one with wrong public path)
Describe the bug
Hello,
I use federation runtime to dynamically import vue 3 remotes with getPublicPath. some css, vendors assets are called twice:
- once with the proper public path retrieved through the getPublicPath function
- once with the consumer url which returns in my case the root html.
you can see screenshots in the repro project README.
It doesn't always generate an issue as one of the two calls succeeds.
I don't have this behavior if I replace getPublicPath by a static publicPath.
Thank you
Reproduction
https://github.com/WeetA34/mf-double-calls-repro
Used Package Manager
yarn
System Info
System:
OS: macOS 14.5
CPU: (10) arm64 Apple M1 Max
Memory: 128.44 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.15.1 - /usr/local/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn ---> yarn 4.3.1 with nodeLinker node-modules in the project
npm: 9.8.1 - /opt/homebrew/bin/npm
pnpm: 9.4.0 - /opt/homebrew/bin/pnpm
bun: 1.0.21 - ~/.bun/bin/bun
Browsers:
Chrome: 126.0.6478.185
Safari: 17.5
Validations
- [X] Read the docs.
- [X] Read the common issues list.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a Module federation issue and not a framework-specific issue.
- [X] The provided reproduction is a minimal reproducible example of the bug.
Hello, fyi, it's still the same with 0.3.5
Hello, fyi, it's still the same with 0.5.1
Hello, fyi, it's still the same with 0.6.3 :)
+1, seeing the same issue as well (with React, although that doesn't really matter here)
Hello, fyi, it's still the same with 0.6.8 :)
hmm seems like a legit issue. Will check the source code. You can try setting public path to auto?
Hello Zack, i'll test that. thx
Hello Zack, It seems to be ok without getPublicPath and config.output.publicPath set to 'auto' instead. Thank you
Hello again, I moved to @module-federation/rsbuild-plugin. publicPath='auto' by default It works fine
Perfect
Stale issue message
Bump
The wrong css asset is loaded by producer's miniCss runtime . It will use publicPath + assetUrl as final url .
And the producer not set specific publicPath , so it will call twice .
I am having the exact issue as the original poster describes, but when using RsBuild.
I used the workaround mentioned of setting config.output.publicPath, but I am setting it to a specific URL (not 'auto') and it builds the mf-manifest.json with publicPath: '/' which is not what I expect. Does config.output.publicPath not work with RsBuild?
Check docs. Rsbuild sets it a different way than rspack. Assetprefix or something
Thanks @ScriptedAlchemy, I found someone had mentioned assetPrefix in another issue and that does indeed work for rsbuild.
Just an FYI to others using rsbuild that come across this page, when using 'output.assetPrefix' you don't need to use 'getPublicPath', as 'publicPath' in the mf-manifest.json will be populated with the assetPrefix value from what I observed.
I'll look at adding schema validation to rsbuild so people don't get confused
Stale issue message