Closed XavierLeTohic closed 1 week ago
output.assetPrefix
is for production build, can you try the dev.assetPrefix
config?
Note that when you use moduleFederation.options
, Rsbuild will set the default value of Rspack's output.publicPath configuration to 'auto', this is recommended by MF team.
dev.assetPrefix
helped me discover that the reason why it's not working it's that it does not find assets using rsbuild dev
and with module federation no matter the prefix I use, I updated the Codesandbox to reproduce, any idea?
Note that output.publicPath
does not exists according to the types in 0.7.1 even tho it's mentioned in the documentation.
output.publicPath
is a config of Rspack, you can use Rsbuild's tools.rspack
to configure it.
Is public path set to auto?
Was fixed in dev by setting config.output.publicPath = '/'
since config.output.publicPath = 'auto'
still break the injection of assets when more than one sub path is used and the page is reloaded.
Updated the codesandbox to demo when it fails with auto
-> https://codesandbox.io/p/github/XavierLeTohic/rsbuild-mf-asset-path/main
I tried to change publicPath to / but it is not working for the host app.
I tried to change publicPath to / but it is not working for the host app.
Did you setup MF via appendPlugins
like below?
tools: {
rspack: (config, { appendPlugins }) => {
config.output.publicPath = "/";
appendPlugins([
new ModuleFederationPlugin({ // ...my options })
]);
},
},
I tried to change publicPath to / but it is not working for the host app.
Did you setup MF via
appendPlugins
like below?tools: { rspack: (config, { appendPlugins }) => { config.output.publicPath = "/"; appendPlugins([ new ModuleFederationPlugin({ // ...my options }) ]); }, },
I'm using the v1 moduleFederation.options .
No certain but I think you can find the plugin of the 1.5 from @rspack/core
's container
maybe related to #2747 ?
To resolve this issue, upgrade to the latest version of Module Federation.
@imzisy this issue also happen with the built-in module federation of rsbuild, not only using the external plugin @module-federation/enhanced/rspack
After upgrading to ^1.0.0-alpha.6
it fixed the issue using tools.rspack
but the issue remain with the built-in moduleFederation.options
this doesn't seem like an issue anymore. should be safe to close it?
Fixed on the latest versions
Version
Details
When setting
moduleFederation.options
and reloading with more than one sub path (.i.e/sub/path
) Rsbuild inject assets without the prefix/
even settingoutput.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:
npm install
oryarn install
npm run dev
oryarn dev
http://localhost:5050/example
everything will work as expected if you reloadhttp://localhost:5050/example/sub/path
and reload it will be brokenrsbuild.config.ts
and try to reload it'll work