Wk-notes-03-09-micro-frontend-bootstrapper
Micro-front-end-bootstrapper
html container/anchor structure
<div data-widget-type="WIDGET_TYPE">
<script type="widget">
{
"type": "json",
"generateFrom": "CMS(aem)",
"purpose": "widget-config-for-feature-and-globals",
"scope": "per-widget-container"
}
<script/>
<div/>
<script src="PATH/TO/BUNDLE/app.js"/>bundle/app.js
bundle/app.jsregister = (widgetType: string, widget: Widget) => {
// widgetType as 'flight-search', 'email-subscription'
// where we assume one widget type can be mounted several times on one page
// Load config from html
getConfiguration = (anchorContainer) => {}
// Get the instance from container
getWidgetInstance = (anchorContainer) => {}
// Render widget on html
mountWidget = (anchorContainer) => {
widget = new Widget(id, anchorContainer, configuration);
}
// Update widget on html
updateWidget = (anchorContainer, props) => {}
// Update widget on html
unmountWidget = (anchorContainer) => {}
// render All anchorContainers (potentially multiple)
renderAll = () => {}
document.addEventListener('DOMContentLoaded', renderAll);
document.addEventListener('load', renderAll);
}Thoughts
Last updated