module-federation-plugin-example | This examples loads a microfrontend into a shell
kandi X-RAY | module-federation-plugin-example Summary
kandi X-RAY | module-federation-plugin-example Summary
This examples loads a microfrontend into a shell:.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of module-federation-plugin-example
module-federation-plugin-example Key Features
module-federation-plugin-example Examples and Code Snippets
Community Discussions
Trending Discussions on module-federation-plugin-example
QUESTION
We are creating an MFE angular app using Module Federation WebPack 5 and ended up in an issue with the image source path. When we run the MFE alone, the image is loading(localhost:5000/assets/../angular.png
) but when we run the host/shell app, the image is not loading for MFE since MFE is running in a different port(5000) and Shell is running in a different port(4200) and the app is trying to access the image from Shell's asset folder(localhost:4200/assets/../angular.png
) when we run the shell app.
We have two options in hand:
- Move those images to a common folder, outside the MFE and refer
- set the image path dynamically using the basepath from a configuration file
We have used the below sample for my testing but in the below sample the angular.png file is available in both MFE1 and Shell but if we remove it from Shell, it won't work when we load the shell app.
Source Reference Code Sample (thanks to @manfredsteyer)
Any other solution in MFE to resolve this?
...ANSWER
Answered 2021-Sep-16 at 08:37The problem is that the images are imported using relative paths. Because the micro frontends are always loaded inside the shell, these paths will reference the shell's assets. To fix the issue you would need to add the complete URL to the image to load it from the correct micro frontend.
If you want to load an image in the micro frontend it should look like this:
QUESTION
So I have 2 angular apps and I'm using webpack module federation to import one into the other I got it working but I'm encountering some strange behavior. I think the problem is the same or similar to this but there's no answer and it's been some time.
In my remote app I have a div below a table that is only there while I'm getting the data from the database and then it's hidden. When i go to the remote it works fine no problem but when i use the shell the div was not being hidden. I then added a button to toggle the div visibility but what happened was that the div os duplicated when the bool flag turn true and nothing when it turned false. I then used the shell from this github and changed the flight component to be exactly the same as my remote component and imported my component and it happens only on my component. This can be seen in this video.
I believe the problem is in the remote and not in the host.
Host webpack.config.ts:
...ANSWER
Answered 2021-Sep-06 at 13:09So it seams the problem was that i was importing 'BrowserAnimationsModule' on the remote module i was exporting. After i removed it it started working properly.
QUESTION
I'm working on a new project using Angular 11 and Webpack 5. I am basing my work on Manfred Steyer's Module Federation Plugin Example repo, which uses Angular CLI. I can't figure out how to share a singleton service from a shared local Angular library between my two apps.
I'll do my best to explain my setup.. Real sorry about how long this is going to be.
Simplified File Structure ...ANSWER
Answered 2020-Oct-28 at 16:22TL;DR
- Make sure any module dependencies your shared services have are also shared.
- Make sure you've structured your shared config correctly in
webpack.config.ts
I'm going to note that my project is an NX Monorepo using Angular CLI. I'm using (at the moment) Angular 11.0.0-next and Webpack 5, which is only available as an opt-in with ng11 at the time of writing.
If you're using path aliases in your tsconfig, you are used to importing local libraries like "@common/my-lib", but you can't share modules by alias in your webpack config. Furthermore, if you're on NX, your linting will complain if you import from absolute or relative library paths, so there is a disconnect between what Webpack wants, and what nx/tslint wants.
In my project I have some library aliases like the following
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install module-federation-plugin-example
Install packages: yarn (!)*
Start Micro Frontend (remote): ng serve mfe1 -o
Start Shell (host): ng serve shell -o
Make sure mfe1 is started before shell is loaded into the browser
Use the hyperlink flights in the shell to load mfe1
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page