So when you have local routing, you have something like that. Inside the micro-front-end, if you're using React Router, I have an example I will share later, you can do something like that. You just delegate, basically, to handle furniture slash table and I have a customer, for instance, there is an e-commerce here in the UK, that the first micro-front-end they deploy alongside their existing system was the mirror category of their e-commerce. The rest of the e-commerce was monolith. Then slowly but steadily, when they learned some stuff, they had to roll back a couple of times because they screw up some things, but then slowly but steadily, they started to deploy all the different micro-front-ends, one after the other. They augmented this, let's say, mirror one with I don't know, furniture and other stuff, and slowly but steadily, they created and deployed their micro-front-ends. This is a great strategy for selling even to your management that you don't need 18, 24 months of dark development or stealth mode development for building an entire system. You build one micro-front-end, one route, you iterate on that, and you grow with that. In the meantime that you're doing this end-to-end work, you will learn a ton because you are forced to go through all the process from the ideation, building, creating the observability, logging, deployment, and so on. Super important.
But also, when you are building micro-front-ends, it is one part that very often is messed up by people. If you look into the different examples from single SPA, multi-federation, etc., the majority of the time people are writing in the examples all the different micro-front-ends and remotes to load inside the configuration of Webpack or RSPack or whatever. That is a problem. It's not production-ready because everyone here is using a multi-environment approach. When you work with a multi-environment approach, you might have ephemeral environments sometimes if you're lucky and you don't have just three specific configurations. Even if you have three specific configurations, it's painful if you, let's say, write inside the Webpack configuration before you can leverage dynamic routing. What does it mean? Back four years ago, I created a working group. It was myself, it was Zach Jackson, the creator of multi-federation, it was Joel Danning, the creator of single SPA, and then there was Mateo Figues, that is the creator of Open Components. These three frameworks are the most used frameworks worldwide for building micro-front-ends. I said, listen guys, we need to find a solution for solving the problem of deployment and routing because it has to be something agnostic that we can use in every framework. The framework that we have today, but the framework we have also tomorrow. Before we came up with this schema that became available on GitHub publicly. This schema basically is a discovery schema, like we call it, that enables us to have a bunch of information related to the microphone tense. Because it's JSON, it can be generated wherever you want. You can have your CI, CD, the final task that is basically generating this schema or storing in a database, wherever you want. But the cool thing is, an application shell can load this stuff and directly from this schema generate the dynamic routing. So, it may be one user in, let's say, a specific application, maybe one user doesn't need to load the catalog because it doesn't have the permission and another does, but you can easily implement this JSON with a direct router. So, you just take this JSON, you parse it, you retrieve whatever information you need, and then you generate the routes dynamically. The beauty of that, if you're using, in this case, Moji Federation, that what you can do is when you have, let's say, a change of pages, you can lazy load leveraging the Moji Federation advanced API without writing everything inside the configuration for loading common dependencies, as well as loading a specific microphone tend. Very simple.
Comments