vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
609 stars 167 forks source link

Request new annotation @UsesAll that makes explicit @Uses annotations unnecessary #19961

Closed archiecobbs closed 1 week ago

archiecobbs commented 1 week ago

Describe your motivation

In some situations it's required for a developer to manually hunt down all of the Vaadin widgets used in an application and add an explicit @Uses annotation for each one (See #13332 for an example of my earlier frustration with this annotation).

This is not only an annoying requirement, but even when you're done you're not really done. This is because the @Uses annotation itself is brittle - your application can easily break mysteriously after a developer tweak the application during the course of normal development, e.g., by replacing a TextField with a TextArea.

Describe the solution you'd like

I would like a new @UsesAll annotation which would simply disable the optimization in the Vaadin Maven plugin that elides unused Vaadin widgets from the build. Instead, if a @UsesAll annotation is present, all of them would always be included.

This would allow the developer to completely avoid the headache and brittleness of @Uses in exchange for having this optimization disabled.

Describe alternatives you've considered

None.

Additional context

It seems like this would be an easy change to implement and it would solve an acute pain point in Vaadin.

Legioth commented 1 week ago

Isn't that what optimizeBundle = false does. https://vaadin.com/docs/latest/flow/production/production-build#plugin-goals-goal-parameters

It has the additional benefit of also including any add-ons from the classpath rather than relying on a list of 1st party components to include.

archiecobbs commented 1 week ago

Oops, yes - I forgot about that build option.

Still, it might be nice to be able to disabled this from the Java code instead of the pom.xml, e.g., if you are building a JAR file to supply to someone else to include in their build.

But I agree there's a lot less of a need for that given the optimizeBundle option. Closing this request.