Microservices bringen zahlreiche Vorteile für die Backend-Entwicklung mit sich. Könnte man die Vorteile nicht auch im Frontend nutzen? Dazu prägt sich aktuell die Idee des MicroFrontend, für deren Umsetzung beispielsweise WebComponents eingesetzt werden können. Im Vortrag wird beispielhaft eine Web-Komponente auf Basis von Standard-APIs erstellt und daran gezeigt, was hier bereits mit jedem aktuellen Browser möglich ist. Ebenso bietet das allseits beliebte Angular Framework mit Angular-Elements eine Möglichkeit für die Implementierung von WebComponents.
In einer Demo werden diese beiden Welten zusammengeführt, und wir schauen uns Alternativen an, die von anderen Frameworks wie beispielsweise React oder Polymer angeboten werden. Außerdem wird aus mehr als einem Jahr Praxis bei der Umsetzung mit MicroFrontends berichtet.
Speaker:
Thomas Bröll arbeitet als Principal Consultant für Trivadis am Standort Stuttgart. Er ist seit mehr als 2 Jahrzenten als Software Entwickler, Berater und Architekt im Bereich Java. Sein Fokus ist dabei die Konzeption und Implementierung von Web-Applikationen und Business-Anwendungen auf Basis von Java-, Web- und Cloud-Technologien.
Er ist darüber hinaus für die Trivadis als Referent und Trainer im Bereich Java und Java Enterprise tätig.
Marius Hilleke hat bei der Trivadis erfolgreich das Java-Trainee-Programm absolviert und ist derzeit als Berater und Entwickler tätig. Dabei beschäftigt er sich mit unterschiedlichen Technologien für Cloud-basierte Anwendungen, wie beispielsweise dem Spring- und dem Angular-Framework. Darüber hinaus ist er besonders an Cloud-Technologien, wie Docker und Kubernetes interessiert
3. Was sind MicroFrontends?
Definitionsversuche
– The idea behind Micro Frontends is to think about a website or web app as a composition of
features which are owned by independent teams. Each team has a distinct area of
business or mission it cares about and specialises in. A team is cross functional and develops its
features end-to-end, from database to user interface. – [1]
– In this approach, a web application is broken up by its pages and features, with each feature being
owned end-to-end by a single team. Multiple techniques exist to bring the application features—some
old and some new—together as a cohesive user experience, but the goal remains to allow each feature
to be developed, tested and deployed independently from others. – [2]
[1] Michael Geers: https://micro-frontends.org/
[2] ThoughtWorks: https://www.thoughtworks.com/radar/techniques/micro-frontends
Unabhängigkeit End-To-Endfeature-basierte Modularisierung
4. MicroFrontends – MicroServices im Browser
• MicroServices Paradigma
• Ein Feature End-to-End
• Eigene Teams
• Vorteile mitnehmen
• Wiederverwendbarkeit von Komponente
• Integration „fremder“ fachlicher Features
• Nachteile umgehen
• Nur für wiederverwendbare Komponenten
• Nur an sinnvollen Grenzen aufteilen
5. Angular?
• „Angular is ideal for building complete applications,
and our tooling, documentation and infrastructure
are primarily aimed at this case.“
• Rob Wormald, Angular Team
6. Angular?
• „[…] but is quite challenging to use in scenarios that
don‘t fit that specific Single Page application model.“
• Rob Wormald, Angular Team
8. Welche Möglichkeiten zur technischen Umsetzung von
MicroFrontends gibt es?
[1] https://martinfowler.com/articles/micro-frontends.html
Server-seitige
Komposition via
Templates
Integration zum
Build-Zeitpunkt
via iframes
via JavaScript
via Web Components
Laufzeit-
integration
Kombinationen
der Ansätze
14. Web components are a set of web platform APIs that allow you to create
new custom, reusable, encapsulated HTML tags to use in web pages and
web apps. Custom components and widgets build on the Web Component
standards, will work across modern browsers, and can be used with any
JavaScript library or framework that works with HTML.
Web components are based on existing web standards. Features to support
web components are currently being added to the HTML and DOM specs,
letting web developers easily extend HTML with new elements with
encapsulated styling and custom behavior. – [1]
[1] webcomponents.org: https://www.webcomponents.org/introduction
Definition
24. Noch einiges mehr ….
• Templates
• Slots
• Binding, verbessertes Rendering mit
• https://lit-html.polymer-project.org/
• Open Web-Components Recommendations + Template https://open-wc.org/
• Browser Support für alte Browser
• WebComponents-Polyfill von webcomponents.org (Teil des Polymer Projekts)
• Babel
• Polyfills für viele einzelne Funktionen
• Typescript - Setup
• Webpack/Babel
• Starter z.B. https://open-wc.org/
26. Angular?
• „[…] but is quite challenging to use in scenarios that
don‘t fit that specific Single Page application model.“
Rob Wormald, Angular Team
27. Wie kann ein MicroFrontend mit AngularElements umgesetzt werden?
[1] https://www.webcomponents.org/introduction