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
Shared works only for top level imports #564
Comments
Also running into this on a react app. When a top-level component renders a child, i'm seeing errors around |
@peterholcomb what do you mean with your comment? do you have a workaround? i am also running into this |
@judithhartmann I eventually just gave up on this plugin for our react app. I setup webpack on both our host and client apps using the webpack federation plugin and it worked great. I just couldn't get this one to work on our apps unfortunately. |
@peterholcomb I just finished migrating all of my project apps from Webpack to Vite, but when I deployed, I encountered this error. It feels like a waste of time; I wish I had known about this issue beforehand. |
@adirzoari I just ended up add webpack and a webpack config to each of my client apps, then just added an npm script to my package.json called For the host app i did have to switch back from vite to webpack and build it. |
Not sure if it's related - but if you add the |
@peterholcomb |
@danielm2402 Yeah, happy to share these. I will gather them up and try to post them tomorrow. I ended up using webpack on both host/remote and it worked well. |
You can notice the issue in the react example application in this repository as well. React is not shared there, even though it is configured to be |
@peterholcomb |
Versions
Reproduction
https://github.com/originjs/vite-plugin-federation/tree/main/packages/examples/react-vite
Additional Details
The issues seems to be here: https://github.com/originjs/vite-plugin-federation/blob/main/packages/lib/src/prod/remote-production.ts#L261-L263
sharedInfo[0]
isreact
but moduleName is not alwaysreact
. Sometimes it isreact/jsx-runtime
Same issue happens if remote has imports like
import ReactDOM from 'react-dom/client';
Steps to reproduce
What is Expected?
Shared react module should be downloaded only once as http://localhost:5000/assets/__federation_shared_react-2436d585.js
What is actually happening?
First host downloads shared react module from http://localhost:5000/assets/__federation_shared_react-2436d585.js
Then remote downloads shared react module from http://localhost:5001/assets/__federation_shared_react-2436d585.js
The text was updated successfully, but these errors were encountered: