-
Notifications
You must be signed in to change notification settings - Fork 101
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
RFC: Bring your own Web Components #1231
Comments
@MarcusNotheis , Option 1
Option 2
Option 3
In conclusion:
|
Hey @codefactor, I've prepared a pull request for Option 2 and can release a snapshot version for testing. |
I think we would want to, but after thinking the coupling between the tree of imports to the consumer is going to get even worse with icons, by a lot in some cases. Can we also generate some kind of helper? Here is some pseudocode for consumer: // substitute "<path>" with the custom bring your own component directory
import { useAnalyticalTableDependencies } from "<path>/AnalyticalTableDependencies";
import { AnalyticalTable } from "<path>/AnalyticalTable";
export function MyComponent() {
useAnalyticalTableDependencies();
return (<AnalyticalTable />);
} Here is some psuedocode for the dependencies file. // AnalyticalTableDependencies.js (autogenerated file)
import useHook from somewhere; // not sure best hook here.
export function useAnalyticalTableDependencies() {
useHook(async () => {
const promises = [];
// embeds a tree of all imports that are required here
if ( tag is not defined ) promises.push(require(pathToTag));
if ( icon is not defined ) promises.push(require(pathToIcon));
});
} Another option -- maybe we have a helper to return a list of tags/icons: import DEPENDENCIES from "<path>/AnalayticalTableDependencies";
import { useDependencies } from "<path>/DependencyHelper";
export function MyComponent() {
useDependencies(DEPENDENCIES);
return (<AnalyticalTable />);
} |
hey @codefactor, we have just merged the corresponding Pull Request and released it with |
As of now, the UI5 Web Component wrappers, e.g. the
<Button />
component is always importing the UI5 Button Web Component:ui5-webcomponents-react/packages/main/src/webComponents/Button/index.tsx
Line 3 in f034aeb
This makes it impossible to "bring your own button", e.g. in a Widget use case.
Option 1: Lazy Load All Web Components in
useIsomorphicLayoutEffect
This option removes the top level import of the Web Component and pushes down the import in an
useIsomorphicLayoutEffect
hook.Example:
This would only load the
Button
Web Component when theui5-button
tag name is not defined and theThemeProvider
didn't prohibit the loading of web components.Pro's
Con's
Option 2: Create Wrapper-only components
This option will create new components that will only contain the
Button
React component, but without the Web Component import. The Wrapper will be re-exported through a file that will import the Web Component as well for keeping backwards compatibility.Example
This approach would allow the end-user to decide whether he want's to use
@ui5/webcomponens-react
together with the UI5 Web Components or only as a wrapper and he/she is taking care of importing the required web components by themselves.Pro's
Con's
AnalyticalTable
orDynamicPage
would need a codemod so that they are offered in two versions as well - with Web Components or withoutAnalyticalTable
? We would have to maintain a list of used components in our documentation, very error prone?Option 3: Webpack 5 Module Federation
Webpack 5 offers the
ModuleFederationPlugin
which allows sharing dependencies over multiple micro front ends and loading shared dependencies in case they are not satisfied yet.Links
Pro's
@ui5/webcomponents-react
requiredCon's
create-react-app
(Issue already open: Webpack 5 support (module federation) facebook/create-react-app#9510)The text was updated successfully, but these errors were encountered: