Skip to content
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

Use Vite aliases to allow excluding commercial components #240

Open
Legioth opened this issue Mar 19, 2024 · 0 comments
Open

Use Vite aliases to allow excluding commercial components #240

Legioth opened this issue Mar 19, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@Legioth
Copy link
Member

Legioth commented Mar 19, 2024

The current implement is directly referencing all Vaadin components in react-components, regardless of the license of the component. This is problematic for users that are for some reason (e.g. government policy) required to only have open source dependencies in their application (in other words, it's not acceptable to have commercial dependencies even if those are not used). It is not practical to exclude specific components because of the way index.js directly imports all components. Tree shaking during the production build leaves out unused modules but Vite in dev mode will still try to load all the modules.

One way of solving this would be to configure Vite to have an alias for any missing dependency to replace that import with a dummy placeholder that just informs the user that the dependency was missing. We could make Vaadin's default Vite configuration (vite.generated.ts) check for the existence of each commercial web component dependency and include a corresponding alias in the Vite configuration if it's not present.

In addition to this, we also need to make it practical to exclude those dependencies on the npm level. One potential way for this is to have those web components as optional peer dependencies instead of regular dependencies. There has been some reports about version conflict issues in combination with peer dependencies so one alternative might to have a regular dependency in our own code but remove it from package.json when publishing the module to npm. In either case, we also need to have a separate dependency that applications should have in their package.json to explicitly include the optional components along with logic that automatically includes this dependency when com.vaadin:vaadin is on the classpath while not including it if only com.vaadin:vaadin-core is present.

@yuriy-fix yuriy-fix added the enhancement New feature or request label Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants