Is Module Federation Right for You?

Rate this content
Bookmark

Discover Micro Frontends with Module Federation. Learn about the benefits and pitfalls so you can decide whether Micro Frontends are a good fit for your organization.

This workshop has been presented at JSNation 2022, check out the latest edition of this JavaScript Conference.

FAQ

Micro-frontends are a design approach in which a front-end app is decomposed into individual, semi-independent 'microapps' working loosely together. They promote agile practices, allow for better scalability, and enable teams to deploy features independently, thus improving development speed and testing capabilities.

Module Federation is a feature from Webpack that allows a JavaScript application to dynamically load code from another application at runtime. This facilitates the development of micro-frontends by allowing different teams to build and deploy features independently which can then be combined seamlessly into a single product.

Module Federation allows for decoupling of deployments, enabling teams to update individual micro-frontends without redeploying the entire application. This results in faster updates, reduced risks, and the ability to rollback features independently if issues arise.

Best practices include organizing deployed code into version subfolders to manage different versions efficiently, using semantic versioning, and deploying each micro-frontend independently to a CDN for optimal performance and scalability.

While it's technically possible to use different JavaScript frameworks within micro-frontends, it is generally recommended to avoid this as it can complicate the architecture and lead to performance issues. Instead, ensuring a consistent technology stack across micro-frontends is advisable unless there's a compelling reason for diversity, such as gradual migration from one framework to another.

Organizations can handle versioning by deploying each micro-frontend as a separate entity with unique version numbers, and maintain a history of deployments. Rollbacks are facilitated by simply switching the version of the micro-frontend being served, without impacting other components of the application.

Effective strategies include using an event bus for decoupled communication, shared state management tools like Redux for state synchronization, or leveraging the browser's built-in capabilities such as LocalStorage or URLs for lighter communication needs.

Grgur Grisogono
Grgur Grisogono
191 min
04 Jul, 2022

Comments

Sign in or register to post your comment.

Video Summary and Transcription

This workshop on micro-frontends covers topics like dependencies, communication between federated modules, team organizations, and code sharing. It emphasizes the benefits of module federation and micro-frontends in enabling continuous operation and collaboration. The workshop provides practical examples and discusses the challenges of managing breaking changes and handling conflicts. It also explores the use of React as a view rendering library and the importance of sharing data and controlling communication between feature apps.

1. Introduction to Micro-Frontends

Short description:

Thank you all for joining our workshop. We'll start with a primer on micro-frontends and their benefits. Then we'll work through examples and discuss potential system-level architectures. I've worked with Module Federation and Microfurence extensively, delivering them to numerous countries and millions of users. During this workshop, we'll cover topics like dependencies, communication between federated modules, modulation in hybrid apps, team organizations, and code sharing. We'll also have a Q&A session. My goal is for you to leave this workshop feeling knowledgeable and prepared to implement micro-frontends in your projects.

Thank you all for for joining our workshop today. We have about 2 1⁄2 hours to talk about module federation, but we really cannot talk about module federation without talking about micro-frontends. So we're going to do a little primer on what micro-frontends are and why they're helpful, why we are here. And then we're going to work through examples.

When we are done with the examples, if you're still on board with module federation, I'm going to also show you a few slides on potential architectures, the system-level architectures that you can choose. And I'm also going to show you some slides that I've learned to work well when presenting micro-frontends to bosses, businesses, clients, and so on. Things that they like to hear, because usually they don't speak the language of engineers, and I kind of want to share some of that. So you have it. The slideshow is going to be in in the github repository, and I'm going to share with you in just a minute.

But before we do, again, I'm going to take a second to introduce myself. My name is, well, Gregor is the easy way to pronounce it, the official way would be Gergoor, which I know is terrible, lots of rolling R's. But I've been working with Module Federation and Microfurence for a while, and I'm not the inventor of any of this. So if you know people like Zack Jackson, who I think he's the mastermind behind Microfurence and Toby Carver from Webpack, those guys are incredibly smart. I did spend a lot of time with those two in late 2020 when Madoff Federation was out, because we used that extensively with some, I'm not going to mention names, but some of the big companies out there, big in communications, in auto industry, in pharmaceuticals. You're going to see their logos at the end, but I'm not going to mention them. So I've been working with micro-finance for a long time and delivered them to about 200 countries, and I think lots of millions, users are already, have already accessed some of those stuff, some of those micro-finance that I help architect to create. And today, I only want to share that experience with you. I want to share, you know, we've been through a lot of amazing discoveries and difficult times, difficult problems to have. Because these are highly scalable systems. Scalable in terms of infrastructure, scalable in terms of scalable teams, multinational. So if you work with any of those, you know, this is hopefully going to be of use to you.

So during this workshop, we're going to be talking about, again, what microfrontends are and why your business or your client's business should care. We're going to create a very, very simple Module Federation app cluster. It's going to be super simple because this is an intra-level workshop. And there's going to be plenty of stuff to show, plenty of problems and solutions to show through that very small cluster. We're going to show how to deal with some of the most common issues like working with dependencies, how to deal with problems that you get when you work with dependencies, types of dependencies, and strategies for dealing with different types of dependencies. Then one of the most common questions is how we communicate between federated modules. And I think communication is where you make it or break it. I am going to briefly mention or briefly talk about modulation in hybrid apps. So it doesn't have to be web only. It can be hybrid. It can be completely universal whether it's web, PWA, desktop, or mobile. There are some very interesting implications there. Again, we're going to talk about team organizations, a team organization, working with your repositories, code shares. So we're going to blend a lot of that in. Finally, I'm going to set aside some time for questions and answers. One thing that I want you to get out of this is I want you to sound smart when you get back to your jobs, your peers, whoever you talk to, meetups. I want you to sound smart.

2. Sharing Experiences and Simplifying Concepts

Short description:

Interesting thing happened to me today, this morning, I was working with one of those car manufacturers, a team that I'm helping there. We had certain issues with service site rendering of federated modular federation. But that's only issues that happen with huge, huge sites. I created a PR and inside the PR I just added a few flags that I needed to add to this headless Chrome. I'm going to share a few things, hope you get them back to your job. I'm going to try not to use difficult words. So if you have experience, please try to listen. If you have no experience, if you're not technical, I hope that you're going to be able to digest what we're talking about.

Interesting thing happened to me today, this morning, I was working with one of those car manufacturers, a team that I'm helping there, they said, so we had certain issues with service site rendering of federated modular federation. But that's only issues that happen with huge, huge sites, when you have to run a service rendered tenths of thousands of pages at the same time. And I didn't know how to solve the problem. So I said, you know, I'm going to Google it up. I'm going to find it and I'm going to, you know, put it in. So I created a PR. And inside the PR I just added a few flags that I needed to add to this headless Chrome. And they said, oh, I don't know how we get to be so smart. How did you find all those flags? And I said, I'm going to Google it up. So I wasn't smart. I just Googled it up. So this is our time of sharing, you know, it's not googling, but I'm going to share a few things, hope you get them back to your job. Also, I'm going to try not to use difficult words. So you're not going to get smart in a way you're going to use like isomorphic apps, something like that kind of verbiage, I'm going to try to be simple. So if you have experience, like I know some of you have with model iteration, please try to listen. If you have no experience, if you're not technical, I hope that you're going to be able to, this is why I hope you're going to be able to digest what we're talking about.

QnA

Watch more workshops on topic

Micro Frontends with Module Federation and React
JSNation Live 2021JSNation Live 2021
113 min
Micro Frontends with Module Federation and React
Workshop
Alex Lobera
Alex Lobera
Did you ever work in a monolithic Next.js app? I did and scaling a large React app so that many teams can work simultaneously is not easy. With micro frontends you can break up a frontend monolith into smaller pieces so that each team can build and deploy independently. In this workshop you'll learn how to build large React apps that scale using micro frontends.
Micro-Frontends with Module Federation and Angular
JSNation Live 2021JSNation Live 2021
113 min
Micro-Frontends with Module Federation and Angular
Workshop
Manfred Steyer
Manfred Steyer
Ever more companies are choosing Micro-Frontends. However, they are anything but easy to implement. Fortunately, Module Federation introduced with webpack 5 has initiated a crucial change of direction.
In this interactive workshop, you will learn from Manfred Steyer -- Angular GDE and Trusted Collaborator in the Angular team -- how to plan and implement Micro-Frontend architectures with Angular and the brand new webpack Module Federation. We talk about sharing libraries and advanced concepts like dealing with version mismatches, dynamic Module Federation, and integration into monorepos.
After the individual exercises, you will have a case study you can use as a template for your projects. This workshop helps you evaluate the individual options for your projects.
Prerequisites:You should have some experience with Angular.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Scaling Up with Remix and Micro Frontends
Remix Conf Europe 2022Remix Conf Europe 2022
23 min
Scaling Up with Remix and Micro Frontends
Top Content
This talk discusses the usage of Microfrontends in Remix and introduces the Tiny Frontend library. Kazoo, a used car buying platform, follows a domain-driven design approach and encountered issues with granular slicing. Tiny Frontend aims to solve the slicing problem and promotes type safety and compatibility of shared dependencies. The speaker demonstrates how Tiny Frontend works with server-side rendering and how Remix can consume and update components without redeploying the app. The talk also explores the usage of micro frontends and the future support for Webpack Module Federation in Remix.
Monolith to Micro-Frontends
React Advanced Conference 2022React Advanced Conference 2022
22 min
Monolith to Micro-Frontends
Top Content
Microfrontends are considered as a solution to the problems of exponential growth, code duplication, and unclear ownership in older applications. Transitioning from a monolith to microfrontends involves decoupling the system and exploring options like a modular monolith. Microfrontends enable independent deployments and runtime composition, but there is a discussion about the alternative of keeping an integrated application composed at runtime. Choosing a composition model and a router are crucial decisions in the technical plan. The Strangler pattern and the reverse Strangler pattern are used to gradually replace parts of the monolith with the new application.
Micro-Frontends With React & Vite Module Federation
React Advanced Conference 2023React Advanced Conference 2023
20 min
Micro-Frontends With React & Vite Module Federation
Top Content
Watch video: Micro-Frontends With React & Vite Module Federation
Microfrontends is an architecture used by big companies to split monolithic frontend applications into manageable parts. Maintaining a consistent look and feel across different microfrontends is a challenge. Sharing styles can be done through Vanilla CSS, CSS modules, or CSS in JS. JavaScript variables can be used in styles, but readability and runtime overhead are considerations. Sharing state in microfrontends can be achieved through custom events, broadcast channels, shared state managers, or custom PubSub implementations. Module federation with Vite allows for client composition and sharing dependencies. Configuration is similar to Webpack, and future work includes working on the QUIC framework.
Federated Microfrontends at Scale
React Summit 2023React Summit 2023
31 min
Federated Microfrontends at Scale
Top Content
Watch video: Federated Microfrontends at Scale
This Talk discusses the transition from a PHP monolith to a federated micro-frontend setup at Personio. They implemented orchestration and federation using Next.js as a module host and router. The use of federated modules and the integration library allowed for a single runtime while building and deploying independently. The Talk also highlights the importance of early adopters and the challenges of building an internal open source system.
“Microfrontends” for Mobile in React Native
React Advanced Conference 2023React Advanced Conference 2023
24 min
“Microfrontends” for Mobile in React Native
Top Content
Watch video: “Microfrontends” for Mobile in React Native
Micro frontends are an architectural style where independent deliverable frontend applications compose a greater application. They allow for independent development and deployment, breaking down teams into feature verticals. React Native's architecture enables updating the JavaScript layer without going through the app store. Code Push can be used to deploy separate JavaScript bundles for each micro frontend. However, there are challenges with managing native code and dependencies in a micro frontend ecosystem for mobile apps.
Sharing is Caring: (How) Should Micro Frontends Share State?
React Summit 2022React Summit 2022
23 min
Sharing is Caring: (How) Should Micro Frontends Share State?
Top Content
Micro-frontends allow development teams to work autonomously and with less friction and limitations. Organizing teams around business concerns, in alignment with subdomains, rather than technical concerns, can lead to software that is split nicely and user stories falling under the responsibility of a single team. Having a logical backup or reference point is important for implementing microfrontends without breaking their isolation. Microfrontends can communicate with each other using the window object and custom events. Microfrontends should be kept isolated while maintaining communication through various approaches.