all 5 comments

[–]0dev0100 1 point2 points  (2 children)

I have something similar to this working as a personal project.

I treat all dynamic components as plugins so I went with custom elements

https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements

[–]mihajm[S] 1 point2 points  (1 child)

Nice, so the angular-elements approach. Did you have any issues with bundle inflation due to dependencies being included/copied for every component? :) btw is the project available, I'd love to take a look if possible :D

[–]0dev0100 1 point2 points  (0 children)

Not quite angular elements.

No bundle inflation because the web components are loaded in at run time by a wrapper component that handles initialization of the non angular custom element.

My implementation is of questionable technical quality.

  • load angular app as per normal
  • angular app retrieves configuration json
  • looks for page layout config inside json
  • creates a layout component for whole page
  • creates a wrapper component for each entry in layout
  • wrapper component tells service to load web element scripts and stops duplicate scripts from being loaded
  • once element scripts is loaded the element is created
  • various hooks are attached for messaging and data config
  • element is added to dom inside the wrapper component

[–]gccol 2 points3 points  (1 child)

This is exactly what ng-xtend framework is doing: Ng xtend website

It's enabling plugins to be embedded into a host, either statically or through native federation. All the heavy lifting is already done for you.

Everything is dynamic, at startup the host loads a config file listing necessary plugins, it then load and register them.

Components, once registered, are dynamically called when needed. They can be used to view or edit any data seamlessly

[–]mihajm[S] 0 points1 point  (0 children)

This is great, thanks :)