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

How We Build Mirco Frontend

Avatar for Perry Poon Perry Poon
September 28, 2023
17

How We Build Mirco Frontend

Avatar for Perry Poon

Perry Poon

September 28, 2023
Tweet

Transcript

  1. Achievements Micro Frontend 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. - https://micro-frontends.org
  2. Micro Frontend Lifecycle Bootstrap Mount Unmount function render(content) { document.querySelector('body').innerText

    = content } window.AwesomeApp = { bootstrap: () /> { console.log('bootstraped') return Promise.resolve() }, mount: () /> { render('Aloha') return Promise.resolve() }, unmount: () /> { render('') return Promise.resolve() } }
  3. Micro Frontend Assets Loading Download HTML Collect Scripts & Styles

    Download Scripts & Styles Exec Scripts Insert Styles as inlined
  4. Micro Frontend Assets Loading <!DOCTYPE html> <html lang="en"> <head> <meta

    charset="UTF-8"> <title>Awesome App//title> //head> <body> <script src="https://vendor.11xx.js">//script> <script src="https://main.xx11.js" entry>//script> //body> //html> // on host app importHTML('https://xxx.com') .then(res /> { res.execScripts().then(exports /> { // exports is, as you expected, the exports from the main.js }) })
  5. Q&A