rsbuild: [Bug]: MF breaks the asset path when more than one sub path
Version
System:
OS: macOS 14.4.1
CPU: (8) arm64 Apple M1
Memory: 41.70 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Browsers:
Chrome: 125.0.6422.141
Safari: 17.4.1
npmPackages:
@rsbuild/core: ^0.7.1 => 0.7.1
@rsbuild/plugin-react: ^0.7.1 => 0.7.1
Details
When setting moduleFederation.options and reloading with more than one sub path (.i.e /sub/path) Rsbuild inject assets without the prefix / even setting output.assetPrefix: "/" resulting in a white page.
Commenting or removing the whole moduleFederation from rsbuild config and everything works well.
See the attached Codesandbox and repository to reproduce.
Reproduce link
https://codesandbox.io/p/github/XavierLeTohic/rsbuild-mf-asset-path/main
Reproduce Steps
The repo of the codesandbox is here:
https://github.com/XavierLeTohic/rsbuild-mf-asset-path
To reproduce:
- Clone
npm installoryarn installnpm run devoryarn dev- On
http://localhost:5050/exampleeverything will work as expected if you reload - Go to
http://localhost:5050/example/sub/pathand reload it will be broken - Comment the whole module federation in
rsbuild.config.tsand try to reload it’ll work
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 30 (6 by maintainers)
After upgrading to
^1.0.0-alpha.6it fixed the issue usingtools.rspackbut the issue remain with the built-inmoduleFederation.options@XavierLeTohic @petrosD93 Thanks a lot guys for your help, I made it easier, I just passed publicPath: ‘auto’ only for remote project,
Everything seems to work, locally dev/prod, as well as on amazon, I want to put my setup rsbuild+eslint+prettier+tailwind+mf in a separate monorepo, maybe it will help someone, as I will write here:))
@VictorPulzz have a look at this https://github.com/module-federation/core/issues/3343
I ended up using the base meta tag
I will have a look tomorrow, also why are you spreading the default rsbuild config everywhere? It’s not gonna erase the whole config at the end but apply some kind of patch
https://module-federation.io/guide/basic/rsbuild.html
this doesn’t seem like an issue anymore. should be safe to close it?
@imzisy this issue also happen with the built-in module federation of rsbuild, not only using the external plugin
@module-federation/enhanced/rspackNo certain but I think you can find the plugin of the 1.5 from
@rspack/core’scontainer