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.

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.

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.

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.

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