Web component not loading in production builds

We have a custom web component that works fine in development mode, but not in production. The Shadow DOM is not loaded. We fixed it by explicitly requiring it in the bundle with the @Uses annotation. I would appreciate some insight into why this was needed. It is my understanding that @Uses is necessary if we instantiate a component class with reflection; which we do not, in this case.

How are you instantiating it? Is the package different from your application entry point?

new MyComponent()

@quirky-zebra

And the route where it’s used is reachable? You aren’t adding routes dynamically? Or other black magic?

The route is added by annotation. Though, the class is instantiated with a custom instantiator that uses Guice. However, this should not matter, as the view code instantiates MyComponent with new.

Your first sentence makes me wondering: how are you creating and adding routes?

The bytecode scanner only scans component that it can reach from within your routes - so if it can’t find your routes, it doesn’t matter what you do in them

It finds the route

And the package is also within range / no add-on / module with another package name?

Yes

Now I have ruled out all normal problems :grimacing: do you have an example online where it’s broken?

Sorry cannot reproduce in a small project and cannot share company code

Thank you for helping though!

This might be related https://github.com/vaadin/flow/issues/17346 , so fixed in 24.1.7

@sanguine-whale Thanks but the problem was with 24.1.7

Please make an issue in Flow, this should work identical in dev and prod mode.

Will do. Unfortunately, I couldn’t reproduce in a minimal reproducible example

https://github.com/vaadin/flow/issues/17592

Your sentence “we do instantiate the view with Guice”… makes me wondering: what exactly are you doing? Not that this is the problem