-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
❗ Improve encapsulation of ThemeVars #1088
Comments
Hey @tjosepo! Does this currently block your team? I doubt it’s a good idea to load multiple versions of Orbit even in a micro-frontends application. The host application should be in charge of loading the design system and the modules should use whichever version is available. To bump the version, update the host application and it will replicates everywhere. The downside thought is that Orbit will have to minimize breaking changes or at least offer temporary backward support to prevent the modules from breaking. The upside is that the application won’t load Orbit bundles many times and by forcing every module to be in the same version it ensure the UI stay consistent. What use cases do you have in mind? |
It's not a blocker, but having to synchronize dependencies and releases between micro-frontend is definitely a pain point. React already supports multiple versions on a single page, and I think a similar thing happening to Orbit could solve some of our challenges.
I agree that it's not ideal, but I think we could benefit from being able to do so when dealing with breaking changes. The nice thing about Module Federation is that it's smart enough to reuse the same dependencies if they match versions, and load them separately if they mismatch versions. In the majority of cases, Orbit would be the same version across micro-frontends, and would only be downloaded once.
100% agree.
Recently, there were breaking changes to some tokens. Micro-frontend apps had to be backward compatible, otherwise, some tokens and background would be invalid. 😔 Not updating the micro-frontend first prevented others from updating the version of Orbit on the host. |
Thanks for your reply!
I don't think I understand what you mean here. From my experience, having 2 distinct versions of React on the same page will result in the following error:
I used to think that Module Federation is smart enough to reuse the same dependency if they match versions, but I don't think anymore that it can do that. I might be wrong thought. I think that to reuse the same dependencies, the dependency has to be explicitly specified as a shared singleton dependency. Let me explain how I think it's working: At build time
At runtime
|
Hey @tjosepo I was thinking about this issue and 2 questions comes to my mind, maybe you also thought about those and have solutions?
|
I'm wondering if we could drop it in the One problem I can already think of with this approach is that I think some component (i.e. modals) are wrapped inside their own
Scoping CSS would be useful if we wanted to load multiple versions of Orbit on the same page, but most CSS rules can already be scoped inside a Web Component ShadowRoot. One of the few things that can traverse a ShadowRoot boundary is CSS variables. Using ShadowRoot definitely has its downsides. React doesn't really support them. You need to manually create a new React root inside the ShadowRoot. This means that providers need to be redeclared and all providers that don't rely on an external store and don't use |
Thanks for sharing your thought. createThemeVarsMoving the creation of the vars into the I agree thought that it's an interesting option to consider to support multiple version of the DS in a federated apps. ShadowRootLet me know if you find something interesting with this lead. Pretty sure I read somewhere that React is working on Web Component support. |
Description
Currently, the
createThemeVars()
function appends CSS variables directly in the document'shead
.If multiple version of Orbit are loaded on the same page and call
createThemeVars()
, the variables can be overriden.Ideally, each
<ThemeProvider />
should be able to have its own set of CSS variables that cannot be overriden by another theme provider.Otherwise, having more than one version of Orbit on a page can be brittle, which limits what can be done with micro-frontends.
The text was updated successfully, but these errors were encountered: