You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a developer using Module federation enhanced runtime I want to use module federations that render into Shadom DOM instances from web components so that CSS can be isolated.
Suggested solution
In the loadRemote function we could provide a separate root, loadRemote(moduleId, shadowRoot). This would allow the user to declare where the CSS should be linked.
This would allow using federated modules inside of web components using shadow roots:
In order for this to work, module federation can no longer assume "if it was loaded once, we're loaded and done!" it has to treat attachment as something that happens per root, which is not just about loading but how the browser indicates scoping for styles made available to shadow dom.
I've provided a PR here #3740 but it isn't complete because the preload cache assumes a single CSS attachment phase due to a global cache. I'm not sure the best path forward from here.
Alternative
I considered the idea of returning a different root via a runtime plugin, however, this suffers the same "it isn't a single attach phase anymore" problem and it doesn't naturally support the reality of multiple instances of a web component on a page, each component needed it's css attached.
Clear and concise description of the problem
As a developer using Module federation enhanced runtime I want to use module federations that render into Shadom DOM instances from web components so that CSS can be isolated.
Suggested solution
In the
loadRemote
function we could provide a separate root,loadRemote(moduleId, shadowRoot)
. This would allow the user to declare where the CSS should be linked.This would allow using federated modules inside of web components using shadow roots:
Since this element can be rendered multiple times, the CSS would need to be linked for each different root:
And if the the user doesn't provide a root, it should load it in the document.head using the behavior we have today:
In order for this to work, module federation can no longer assume "if it was loaded once, we're loaded and done!" it has to treat attachment as something that happens per root, which is not just about loading but how the browser indicates scoping for styles made available to shadow dom.
I've provided a PR here #3740 but it isn't complete because the preload cache assumes a single CSS attachment phase due to a global cache. I'm not sure the best path forward from here.
Alternative
I considered the idea of returning a different root via a runtime plugin, however, this suffers the same "it isn't a single attach phase anymore" problem and it doesn't naturally support the reality of multiple instances of a web component on a page, each component needed it's css attached.
Additional context
Encapsulation from CSS Shadow DOM
Validations
The text was updated successfully, but these errors were encountered: