Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Vamos Falar Sobre Micro Frontends

Vamos Falar Sobre Micro Frontends

Talk apresentada no 8° Meet-up do Paraíba JS

Avatar for Nélio Frazão

Nélio Frazão

March 12, 2020
Tweet

More Decks by Nélio Frazão

Other Decks in Technology

Transcript

  1. SOBRE NÉLIO Nélio Frazão, Frontend, com 12 anos de experiência.

    Possui MBA em Marketing Digital, pela Faculdade Estácio/Idez em /João Pessoa/PB. e especialista em Desenvolvimento de Aplicações para WEB pelo UNIPÊ
  2. DESVANTAGENS MONOLITO Baixa Escalabilidade Falta de Flexibilidade Code Base Gigante

    Complexidade Preso a uma única tecnologia. Exige que todo o sistema seja replicado. Quanto maior o sistema, maior é a base de código. Dificuldade nas entregas contínuas.
  3. MICRO FRONT END CHECKOUT FRONT END DB CHECKOUT SERVICE A

    P I G A T W A Y DB CATALOG SERVICE CATALOG FRONT END B A S E A P P
  4. DEFININDO MICRO FRONTEND Um estilo de arquitetura onde podem ser

    feitas entregas independentes de fragmentos de frontend que compõem uma aplicação maior.
  5. O QUE DEVEMOS ESPERAR DE UM MICRO FRONTEND? AGNÓSTICO DE

    TECNOLOGIA ISOLAR CÓDIGO DA EQUIPE DEPLOY INDEPENDENTE CONVENÇÕES DE TRABALHO
  6. BUILD-TIME INTEGRATION { "name": "@ecommerce/container" , "version": "1.0.0", "description": "some

    ecommerce app" , "dependencies": { "@ecommerce/checkout": "^1.2.3", "@ecommerce/catalog": "^4.5.6", } }
  7. SERVER-SIDE TEMPLATE COMPOSITION USER'S BROWSER SERVICE 2 N G I

    N X CONTAINER APP SERVER SERVICE 1 <esi:include src="include/service1" />
  8. SERVER-SIDE TEMPLATE COMPOSITION <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title>Feed

    me</title> </head> <body> <h1> Feed me</h1> <esi:include src="/order" /> </body> </html> server { listen 8080; server_name localhost; root /usr/share/nginx/html; index index.html; ssi on; rewrite ^/$ http:/ /localhost:8080/browse redirect; location /browse { set $PAGE 'browse'; } location /order { set $PAGE 'order'; } location /profile { set $PAGE 'profile' } error_page 404 /index.html; } variável $PAGE guarda a URL que está sendo solicitado:
  9. <h1>Welcome to Feed me!</h1> <script src="https:/ /browse.example.com/bundle.js"></script> <script src="https:/ /order.example.com/bundle.js"></script>

    <script src="https:/ /profile.example.com/bundle.js"></script> <div id="micro-frontend-root"></div> <script type="text/javascript"> const webComponentsByRoute = { '/': 'micro-frontend-browse-restaurants', '/order-food': 'micro-frontend-order-food', '/user-profile': 'micro-frontend-user-profile', }; const webComponentType = webComponentsByRoute[window.location.pathname]; const root = document.getElementById('micro-frontend-root'); const webComponent = document.createElement(webComponentType); root.appendChild(webComponent); </script> EXEMPLO