Coder Social home page Coder Social logo

mfe-module-federation's Introduction

Exploring Micro-Frontend using Webpack 5 module federation

At the time This project was developed, the latest Angular version was v11 that doesn't support webpack 5 by default and it's needed to explictily set the webpack version in package.json and to use yarn and not npm.

Table of content


Installation

Install the dependencies using yarn

yarn install

yarn is needed to use the provided webpack version resolutions in package.json

Run the Shell and the micro-frontend

yarn start

Will run the shell on http://localhost:4200/, mfe1 application on http://localhost:5100/, and mfe2 on http://localhost:5200/

Understand the workspace

An Angular workspace that is consists of three angular applications:

shell:

Angular application (host) that has moduler fereation setup and able to import modules or components from other micro frontends that expose features using module feration. In this app we provide UI to import features and component dynamically from MFE1 and MFE2.


mfe1:

Angular Application (remote) that has moduler fereation setup to expose feature modules mfe1 application exposes (feature A, Feature B).



mfe2:

Angular Application (remote) that has moduler fereation setup to expose feature modules mfe2 application exposes Header component and widgets.

Module Fedration

What is module fedration?

  • Module federation is a new feature in Webpack 5 which allows the loading of separately compiled program parts that are not yet known at compile time. In addition, the individual program parts can share libraries with each other so that the individual bundles do not contain any duplicates and the bundle file will remain small.

  • before webpack 5, webpack assumes everything is compiled through compile-time and you cann't lazy load any feature from a remote URL. we had several workarounds but it's the first official solution to make it possible and make micro-frontend easier than ever.

  • The application which exposing the code parts called remote and the one that use this parts called host

    A host: a Webpack build that is initialized first during a page load (when the onLoad event is triggered).

    A remote: another Webpack build, where part of it is being consumed by a β€œhost”

mfe-module-federation's People

Contributors

abanoubsameh avatar

Stargazers

Yogan Rameg avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.