gioboa / react-microfrontend-demo

React+Vite with Module Federation is now possible
23 stars 6 forks source link

Error installing dependencies #4

Closed carlflor closed 1 year ago

carlflor commented 1 year ago

Hi! Thanks for sharing this. However, when trying to run install:deps, I get some error:

> react-microfrontend-demo@1.0.0 install:deps
> npm --prefix ./host install && npm --prefix ./remote install

npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@module-federation/vite/-/vite-module-federation-0.2.6.tgz - Not found
npm ERR! 404
npm ERR! 404  '@module-federation/vite@https://registry.npmjs.org/@module-federation/vite/-/vite-module-federation-0.2.6.tgz' is not in this registry.
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

Is there something I'm missing?

gioboa commented 1 year ago

Hi, the package in there https://www.npmjs.com/package/@module-federation/vite?activeTab=versions Can you try again please?

carlflor commented 1 year ago

Did I need to change anything? Still not working. I found this though: https://github.com/module-federation/module-federation-examples/tree/master/vite-react-microfrontends

I managed to install this and run locally. I'm assuming these two repos are similar

gioboa commented 1 year ago

It's the same example, because I moved the code under the module-federation organisation. is that project working for you?

carlflor commented 1 year ago

yup, that was working

gioboa commented 1 year ago

it's the same code 🤔 😂

carlflor commented 1 year ago

I wasn't able to resolve it, but I think I can work with the one from module-federation-examples. Thank you! :D

carlflor commented 1 year ago

Just to share with you what I have so far, I have followed your sample with a new monorepo: https://github.com/carlflor/vite-react-mfe

One thing I noticed though is the shared dependencies are being cached into each app's (host/remote) node_modules. For example, I have a shared React component library. I have to compile it into JS so it can be a federated module.

That compiled module is cached in my host/remote. Because of this, any changes in that shared library (even after recompiling) won't reflect in my apps unless I delete the cache manually or remove them from my shared dependencies (via skip). I posted this question in this repo:

https://github.com/angular-architects/module-federation-plugin/issues/305