vaadin / flow

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

running vaadin:prepare-frontend using directory dependency works, but jar dependencies filter away resources #19645

Open roeltje25 opened 3 days ago

roeltje25 commented 3 days ago

Description of the bug

While developing in eclipse I use a dependency library I include this project locally. when prepare-runtime runs via maven the files from META-INF/frontend/ are ALL copied to the generated/jar-resources directory. Which is great and correct and all good things. But when a colleague who has not checked out the dependency from github is doing the same thing the files are copied from the jar file. However, for some unknown reason now only css, javascript and typescript are copied along. To me this is absolutely wrong, or at least should be documented clearly somewhere logical. Now, I had to investigate and debug the maven stuff and get all the way to here:

https://github.com/vaadin/flow/blob/main/flow-server/src/main/java/com/vaadin/flow/server/frontend/TaskCopyFrontendFiles.java#L43 which is used here https://github.com/vaadin/flow/blob/main/flow-server/src/main/java/com/vaadin/flow/server/frontend/TaskCopyFrontendFiles.java#L97

The use case is e.g. that I have several iconsets that are defined in svg files which are loaded in an init javascript. these all reside in a dependent library so we can share this among projects

Expected behavior

All files in the META-INF/frontend or otherwise META-INF/resources/frontend directories should be copied to generated/jar-resources on running vaadin:prepare-frontend goal in maven

Minimal reproducible example

Use a starter project add a dependent library with some frontend files which are not javascript, typscript or css, such as a svg file.

Versions

knoobie commented 3 days ago

All files in the META-INF/frontend or otherwise META-INF/resources/frontend directories should be copied to generated/jar-resources on running vaadin:prepare-frontend goal in maven

Note: This might not be true and can result in a potential information leakage if there for example are README.md in the folder for the development team. So this is an assumption that holds not true for every project.

roeltje25 commented 8 hours ago

All files in the META-INF/frontend or otherwise META-INF/resources/frontend directories should be copied to generated/jar-resources on running vaadin:prepare-frontend goal in maven

Note: This might not be true and can result in a potential information leakage if there for example are README.md in the folder for the development team. So this is an assumption that holds not true for every project.

Although, this could be the case, it is against the conventions in e.g. maven which do not normally filter like that. And I might in fact WANT to include README.md in the frontend. If auxiliary files about the frontend directory are needed, we should include them elsewhere or explicitly ignore them in some file.

That should of course be documented, or at least the existing filtering should be documented. Regardless, in our situation we need to include svgs to load as iconsets. We want these bundled, not as regular resources. This is currently not possible....

knoobie commented 7 hours ago

maven which do not normally filter like that

Maven typically is not program that exposes things over the web; Vaadin on the other hand is 😉

A workaround could be to publish your svgs as npm package and include as frontend dependency.

There is also a similar feature request / pull request already open regarding a customizing; so if you are interested to create one for your use-case the team could consider it as well https://github.com/vaadin/flow/pull/19550