Lädt...


🔧 Sharing components Micro Frontends


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

Sharing components like common buttons and input fields between microservices can be achieved through several strategies. Here are some effective approaches:

𝟭. 𝗖𝗼𝗺𝗽𝗼𝗻𝗲𝗻𝘁 𝗟𝗶𝗯𝗿𝗮𝗿𝗶𝗲𝘀
Create a shared component library that includes all the reusable components (e.g., buttons, input fields). This library can be published as a package to a package registry (e.g., npm) and then imported into each microservice.

. 𝙎𝙩𝙚𝙥𝙨:
     1. Create a separate repository for the component library.
     2. Develop and test the components.
     3. Publish the library to a package registry.
     4. Install the library in each microservice project.
.𝘼𝙙𝙫𝙖𝙣𝙩𝙖𝙜𝙚𝙨:
     - Centralized management of components.
     - Easy updates and versioning.
.𝗗𝗶𝘀𝗮𝗱𝘃𝗮𝗻𝘁𝗮𝗴𝗲𝘀:
     - Requires proper version management.
     - All microservices need to be updated to use the latest version.

𝟮. 𝗠𝗼𝗻𝗼𝗿𝗲𝗽𝗼 𝘄𝗶𝘁𝗵 𝗧𝗼𝗼𝗹𝘀 𝗹𝗶𝗸𝗲 𝗡𝘅 𝗼𝗿 𝗟𝗲𝗿𝗻𝗮
Use a monorepo setup with tools like Nx or Lerna to manage multiple projects in a single repository. This approach allows you to share code and dependencies easily between microservices.

. 𝙎𝙩𝙚𝙥𝙨:
     1. Set up a monorepo with Nx or Lerna.
     2. Create shared component libraries within the monorepo.
     3. Import and use the shared components in each microservice.
.𝘼𝙙𝙫𝙖𝙣𝙩𝙖𝙜𝙚𝙨:
     - Simplifies code sharing and dependency management.
     - Easier refactoring and consistency across microservices.
.𝗗𝗶𝘀𝗮𝗱𝘃𝗮𝗻𝘁𝗮𝗴𝗲𝘀:
     - Monorepo can become complex to manage as it grows.
     - Requires a robust CI/CD pipeline.

𝟯. 𝗦𝗵𝗮𝗿𝗲𝗱 𝗚𝗶𝘁 𝗦𝘂𝗯𝗺𝗼𝗱𝘂𝗹𝗲
Use Git submodules to include a shared repository (containing the common components) within each microservice repository.

. 𝙎𝙩𝙚𝙥𝙨:
     1. Create a repository for shared components.
     2. Add the shared repository as a submodule to each microservice repository.
     3. Use the shared components in the microservices.
.𝘼𝙙𝙫𝙖𝙣𝙩𝙖𝙜𝙚𝙨:
     - Directly integrates with Git.
     - Updates in the shared repository can be pulled into each microservice.
.𝗗𝗶𝘀𝗮𝗱𝘃𝗮𝗻𝘁𝗮𝗴𝗲𝘀:
     - Managing submodule updates can be cumbersome.
     - Not as seamless as using a package registry.

𝟰. 𝗠𝗶𝗰𝗿𝗼 𝗙𝗿𝗼𝗻𝘁𝗲𝗻𝗱𝘀
In a micro-frontend architecture, each microservice can expose its components which can be used by other microservices through a shared component service or by importing them dynamically.

. 𝙎𝙩𝙚𝙥𝙨:
     1. Create a micro-frontend architecture where each microservice can publish its UI components.
     2. Use module federation (e.g., Webpack 5 Module Federation) to dynamically import components.
.𝘼𝙙𝙫𝙖𝙣𝙩𝙖𝙜𝙚𝙨:
     - Promotes independent deployment.
     - Components can be updated independently.
.𝗗𝗶𝘀𝗮𝗱𝘃𝗮𝗻𝘁𝗮𝗴𝗲𝘀:
     - Requires a more complex setup and configuration.
     - Potential for increased latency and load times.

𝗘𝘅𝗮𝗺𝗽𝗹𝗲 𝘄𝗶𝘁𝗵 𝗮 𝗖𝗼𝗺𝗽𝗼𝗻𝗲𝗻𝘁 𝗟𝗶𝗯𝗿𝗮𝗿𝘆 (𝗻𝗽𝗺)
Here's an example workflow using a component library published to npm:
𝟭. 𝗖𝗿𝗲𝗮𝘁𝗲 𝘁𝗵𝗲 𝗖𝗼𝗺𝗽𝗼𝗻𝗲𝗻𝘁 𝗟𝗶𝗯𝗿𝗮𝗿𝘆:

Image description

𝟮. 𝗗𝗲𝘃𝗲𝗹𝗼𝗽 𝗖𝗼𝗺𝗽𝗼𝗻𝗲𝗻𝘁𝘀:
Create reusable components like Button and Input in the library:

Image description

𝟯. 𝗣𝘂𝗯𝗹𝗶𝘀𝗵 𝘁𝗼 𝗻𝗽𝗺:

Image description

𝟰. 𝗨𝘀𝗲 𝗶𝗻 𝗠𝗶𝗰𝗿𝗼𝘀𝗲𝗿𝘃𝗶𝗰𝗲𝘀:
Install the library in each microservice:

Image description

Import and use the components in a microservice:

Image description

By following this approach, you can maintain a centralized library of reusable components and easily share them across your microservices, ensuring consistency and reducing duplication.

...

🔧 Microservices and Frontends (aka Patterns for Micro Frontends)


📈 44.26 Punkte
🔧 Programmierung

🔧 Sharing components Micro Frontends


📈 43.56 Punkte
🔧 Programmierung

🔧 How to build scalable micro-frontends with Vike and Vite


📈 25.96 Punkte
🔧 Programmierung

🔧 Micro Frontends and Design Systems: How to Achieve Cohesion Across Teams


📈 25.96 Punkte
🔧 Programmierung

🔧 Micro Frontends — Criando aplicativos mais profissionais com o Modular


📈 25.96 Punkte
🔧 Programmierung

🔧 How to build scalable micro-frontends with Vike and Vite


📈 25.96 Punkte
🔧 Programmierung

🔧 Angular Addicts #33: NgRx 19, using the Page Object Model in tests, Micro Frontends using Vite & more


📈 25.96 Punkte
🔧 Programmierung

🔧 Micro Frontends with Native Federation 🍿


📈 25.96 Punkte
🔧 Programmierung

🔧 Entendendo Micro-frontends


📈 25.96 Punkte
🔧 Programmierung

🔧 Web Architecture: Monorepos, Micro-frontends, and Vite


📈 25.96 Punkte
🔧 Programmierung

🔧 Micro Frontends with Vite and Bit


📈 25.96 Punkte
🔧 Programmierung

🔧 Building Micro Frontends with Vite, React, and TypeScript: A Step-by-Step Guide


📈 25.96 Punkte
🔧 Programmierung

🔧 Monorepo and Micro-Frontends Using Module Federation + Vite


📈 25.96 Punkte
🔧 Programmierung

🔧 Micro-frontends Using React: The Complete Guide


📈 25.96 Punkte
🔧 Programmierung

🔧 Micro-Frontends with React: A Comprehensive Guide


📈 25.96 Punkte
🔧 Programmierung

🔧 Micro Frontends Architecture


📈 25.96 Punkte
🔧 Programmierung

🔧 Micro-frontends with Rspack and Modern.js


📈 25.96 Punkte
🔧 Programmierung

🔧 The Case for Build-Time Micro Frontends


📈 25.96 Punkte
🔧 Programmierung

🔧 The Emergence of Micro Frontends: Integrating With Next.js


📈 25.96 Punkte
🔧 Programmierung

🔧 The Rise of Micro Frontends: Why They’re the Future of Web Development


📈 25.96 Punkte
🔧 Programmierung

🔧 Scaling Frontend Development with Single-Spa Micro-Frontends


📈 25.96 Punkte
🔧 Programmierung

🔧 Scaling Micro-Frontends With Orchestrators


📈 25.96 Punkte
🔧 Programmierung

🔧 Mastering Micro-Frontends: Architecting a Modular Frontend Application


📈 25.96 Punkte
🔧 Programmierung

🔧 Mastering Micro Frontends: A Modular Approach to Scalable Web Applications


📈 25.96 Punkte
🔧 Programmierung

🔧 Micro Frontends: DO's, DON'Ts, Tools and Scaling Strategies


📈 25.96 Punkte
🔧 Programmierung

🔧 Microservices and Micro Frontends: A Match Made in Architectural Heaven


📈 25.96 Punkte
🔧 Programmierung

🔧 Episode 12: The Guardian of Codex – Embracing PWAs and Micro-Frontends


📈 25.96 Punkte
🔧 Programmierung

🔧 Micro-frontends and beyond: composable frontend applications


📈 25.96 Punkte
🔧 Programmierung

🔧 Implementing Micro Frontends in Angular: Step-By-Step Guide


📈 25.96 Punkte
🔧 Programmierung

🔧 "Mastering Micro Frontends: The Future of Scalable and Agile Front-End Development"


📈 25.96 Punkte
🔧 Programmierung

🔧 Getting started with micro frontends


📈 25.96 Punkte
🔧 Programmierung

🔧 Micro-Frontends: Breaking Down Monolithic Frontend Architectures


📈 25.96 Punkte
🔧 Programmierung

🔧 Embracing Micro Frontends: Simplifying Large-Scale Projects


📈 25.96 Punkte
🔧 Programmierung

🔧 The next step in ecommerce? Replatform with APIs and micro frontends


📈 25.96 Punkte
🔧 Programmierung

🔧 Module Federation: Building a Micro Frontends Solution in 2024


📈 25.96 Punkte
🔧 Programmierung

matomo