Open keyhangholami opened 4 years ago
we don't necessarily need to install the react-app-rewired dependency.
That is correct. This is quoted in the 5 Steps to Turn a Random React Application Into a Micro Front-End:
If you use our improved MicroFrontend.js, you don’t have to use react-app-rewired in step 1, and step 2 can be completely skipped. 5 steps are reduced to 3.5. The details are described in “You Don’t Have to Lose Optimization for Micro-Frontends”.
This saving is captured in the chunkOptimization branch of this repo.
It's fixed on this commit.
For render vs. component, the render needs to be called in this way:
<Route path="/reactMFApp" render={()=><CreateReactApp />} />
<Route path="/vueMFApp" render={() =><CreateVueApp />} />
The hot reload of the MFs "inside" the container is not working.
That is correct. It would be nice, but it is hard to make it work in this dynamic loading way.
Dependency management.
This is a task in my future todos.
Caching the script is not working for the Vue.
Yes, this is a major issue for this solution.
Description
I suggest keeping the conversation on technical part here to be able to format the messages better and reference them easier. I explain everything here, then we can create a task for each or open PR for each part we can take over.
Status on the previous items mentioned on LinkedIn
So, here is an update on those those 5 items I mentioned last time:
It was a question that looks ok-ish and apparently we don't necessarily need to install the react-app-rewired dependency.
It's fixed on this commit.
The hot reload of the MFs "inside" the container is not working (not a big deal. But it'll be nice if we can find a way to have this feature on the container level.) What I mean by that, in case you are working on one MF and you are coding in there, but you wanna test it the integrated version with the container, then you don't need to reload the page to see your changes. (if it's still not clear, run the container, vue and react app. Open the container on your browser, go to the React MF and change something [add a dummy text or change the bg color] save it and go to the browser. You'll see the change is not reflected automatically until you refresh the page). But as I said this is not very major even if we couldn't find a solution to it.
This issue refers to this part of the Vue doc
I think since the container is in React and the DOM manipulation from here to here is done by the Vue app and it's changing the DOM from outside, and it is a bad practice when it comes to React applications. IMO, we should change the
Microfrontend.js
in a way that based on the type of the app, it either returns:For react apps
or
for Vue apps
Remaining Issues
In addition to the unsolved items above, there are a couple of problems that I couldn't deal with so far:
react
,react-dom
,react-dom-router
,lodash
, etc. 3 times. And it's not nice. I know in the main article that you referred to this approach was suggested but I think it's again a bottleneck and we can not update the MF dependencies independently (because they all depend on the main version that is defined in there). In the Frameworks like SingleSPA, they offer an option like this: You can load the common dependencies in the container application. In order to do that we have to:They've also thought about technology updates. Meaning, you can update the dependencies to whatever version you want and then in the container specify for which MF use which version. Something like this:
Caching the script is not working for the Vue. As I explained on LinkedIn, when I change this
if (key === 'main.js')
to thisif (key === 'main.js' || key === '/app.js')
it stops working after switching from one MF to another. Therefore it always downloads the scripts and append them to the head and the problem is in asset-manifest config and chunks. If we could set it up to generate an asset-manifest exactly same as the one React generates, then we could tackle this issue as well. Major issueThe
asset-manifest.json
: 3.1. I couldn't manage to make the output look like whatcreate-react-app
generates. For building the images, the shape of the final object (if you compare the asset-manifest of Vue with React, you see the categorisation is different and for that I had to update the code on Microfrontend.js. If we can config it properly here then we don't need to add extra code to Microfrontend.js file only for Vue cases. 3.2. I couldn't generate the assets' links. You said that you've already fixed it by hardcoding it. But instead of hardcoding we can move the logo to the public folder and use the following code in Home.js