originjs / vite-plugin-federation

Module Federation for vite & rollup
Other
2.29k stars 236 forks source link

All shared dependencies are being fetched multiple times, not working as single instance .. #446

Open AsuraKev opened 1 year ago

AsuraKev commented 1 year ago

Hi All,

I am getting React error as below when I have already listed react, react-dom, react-router as shared in both host and remote Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons: 1. You might have mismatching versions of React and the renderer (such as React DOM) 2. You might be breaking the Rules of Hooks 3. You might have more than one copy of React in the same app See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.

image

christophediprima commented 1 year ago

Having the same issue! Do you have the same use case as this one: #449 ? Do you have modules being both host and remote?

AsuraKev commented 1 year ago

For more information I have the following setup

Remote vite config

image

Remote exposed register function image

In host I just called the register function to mount the remote app. This is different from the example where instead of just importing the remote component, instead I invoke a method to load the remote application

image

AsuraKev commented 1 year ago

Downgraded to version 1.1.14 and its working. Latest version seems to be broken

coolcorexix commented 8 months ago

Downgraded to version 1.1.14 and its working. Latest version seems to be broken

we have a different problem back in 1.1.14, it's the shared does not have checksum at the end which cause the caching error - a big reason why I had to upgrade to 1.3.*

AsuraKev commented 8 months ago

I am switching to rspack soon. A lot of native module federation support going to happen there! This package looks like it’s being abandoned