Open dziedrius opened 1 year ago
Hey, I had the same issue this morning and in my case the issue was caused by the host
using a custom hook from the remote
module. The custom hook (defined in the remote) imports smth from redux-oidc
. I changed the vite.config.js
in both modules to contain redux-oidc
like below which fixed the error for me. Hope that helps for you too.
shared: ['react', 'react-dom', 'react-redux']
facing the same issue
"@originjs/vite-plugin-federation": "^1.2.3", "@vitejs/plugin-react": "^3.1.0", "autoprefixer": "^10.4.13", "compression": "^1.7.4", "cors": "^2.8.5", "express": "^4.18.2", "postcss-import": "^15.1.0", "tailwindcss": "^3.2.7", "vite": "^4.4.2"
@julianps, thanks, suggested workaround worked for me too, probably will use temporary.
But in general it is a ugly workaround, as it couples host and remote and whole module federation purpose is to decouple :) Hopefully there will be proper way to handle this.
@julianps thanks man, works for me too!
We've noticed that after we've used federation plugin, one part of our application started to fail with:
We saw similar complaints as open issues, but I'm not sure if our issue has the same root cause, hence opening as separate one, if we will see that they converge, we might close one of the issues as duplicate.
It seems, that if remote is importing component that is using require, like this:
it works fine using in vite directly, but fails if used through module federation.
To isolate the issue, I took react-vite example from vite-plugin-federation repo master and adjusted a bit to match our situation, added dependency to failing component:
and added that component to the remote button:
So going directly to remote, everything works as expected, going to host it fails to load due react error.
Any ideas if this can by somehow fixed by adjusting configuration or that is a bug/missing feature in vite-plugin-federation, if yes, would it be hard to fix it?
Currently this is a showstopper for us, even if we possibly could rewrite component used in example to avoid the issue, I think the situation is too common and sooner or later we will face situation were it will not make sense to rewrite and we will be forced to switch back to webpack :(
Versions