-
Notifications
You must be signed in to change notification settings - Fork 4
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
Support importing components from the react-components package #199
Comments
Just to clarify: the goal of this issue is to research whether we can add tree-shaking support to React components. The idea behind it is to try moving Prototype: vaadin/web-components#7048 The outcome of this using Bundling side-effect free componentecho "import { Button } from '@vaadin/button/theme/lumo/vaadin-button-component.js';" | npx esbuild --loader=js --bundle --outfile=out.js
out.js 15b Bundling component marked as side effectecho "import { Button } from '@vaadin/button/theme/lumo/vaadin-button-component.js'; Button.register()" | npx esbuild --loader=js --bundle --outfile=out.js
out.js 298.4kb React integrationThe next thing to prototype is how to make this work with React. In case of At the same time, in order to render an upgraded |
Alternative solution that we discussed is to make React wrappers use dynamic imports, so that the web component is only imported once the Created a branch in WC repo with a quick prototype using JS. Seems to work fine: in production, only imported components are included to the bundle (in case of this example, |
Created a WIP branch to test the dynamic import approach by passing the mock object with property names instead of the real custom element class to
As far as I understand, this is related to how Vite pre-bundling dependencies work. When I remove UPD: reproduced export class MyElement extends LitElement {
render() {
return html`
<vaadin-button>Button</vaadin-button>
<vaadin-menu-bar></vaadin-menu-bar>
`;
}
async firstUpdated() {
await Promise.all([
import('@vaadin/menu-bar/vaadin-menu-bar.js'),
import('@vaadin/button/vaadin-button.js'),
]);
}
} The actual issue is in |
The issues go away if the components are imported from "theme" ( |
Thanks, confirmed it helps (probably because theme folders don't re-export stuff). Updated the branch.
Also, there are some components that are missing the
|
After I bumped WC to 24.4.0-alpha2, some components in kitchen sink again have theme issue:
This seems to be a bug in |
No description provided.
The text was updated successfully, but these errors were encountered: