Selectively define custom elements and their dependencies


With a bundle compiled with the dist-custom-elements-bundle output target, it is possible to import components as a module.
We can then either define all custom elements with the defineCustomElements helper, which is not ideal in term of bundle size, or define them one by one.
It’s all very well explained here: Bundling Custom Elements with Stencil - Stencil.

When a component has dependencies, it also necessary to explicitly define them all.
In the context of a public design system, it may not be a very intuitive usage. It means being aware of the component’s dependencies and manually define them all. For very complex components, it can be very cumbersome.

Would there be away to automatically detect the dependencies and consequently define all needed custom Elements?
The ideal usage would then look like something like this:


Thanks for the help!