vaadin / vaadin-gradle-plugin

Gradle plugin for Vaadin 14 applications. Takes care of front-end build, helps to configure repositories and to create various project and file templates.
Apache License 2.0
31 stars 9 forks source link

Problem with 'optimizeBundle' in multi-module customer project. #126

Closed enver-haase closed 2 years ago

enver-haase commented 2 years ago

Desktop (please complete the following information):

Describe the bug A clear and concise description of what the bug is.

I have a customer project that shows the following behaviour:

Add a tile, its styling is not loaded. Add another type of tile, both tiles' styling are loaded and applied. Meaning: the first component's @CssImport is ignored only in production mode.

You can see this in the Chrome tools Network tab: the style of the first tile is included in the bundle that is only loaded when the second tile is added to the view.

To Reproduce Steps to reproduce the behavior:

  1. Setup project 'web-components-skill'. I cannot share this project publicly, but I am happy to work on it together with the assignee.

  2. Run Gradle task 'gradle -x javadoc build'.

  3. Deploy artifact build/libs/web-components-skill-1.0-SNAPSHOT.war to apache-tomee-webprofile-8.0.8/webapps

  4. Start TomEE if not done so already

  5. Open localhost:8080/web-components-skill-1.0-SNAPSHOT.war

  6. Add a tile of the lowermost kind, size 1 -- see the styling problem

  7. Add a tile of the middle kind, size 1 -- see how the problem goes away.

Expected behavior When loading the second/third/fourth CSS/JS bundle, this should happen already with a first loaded tile of the lowermost kind; the @CssImport it has is proven to be correct (e.g. works in development mode). Also, when we add a fake @Route("foo") to the component (SkillKennzahl.java) then the component scanner adds it to the initially loaded bundle and the behaviour is correct.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context When I add

vaadin {
    optimizeBundle = false
}

to the build.gradle file, then all the styles are in the bundle loaded initially -- which gives a somewhat slower startup time but correct behaviour.

Please get in touch with me. It is highly possible that this bug is lurking in the Maven plugin's bytecode scanner too. --Enver

enver-haase commented 2 years ago

https://vaadin.slack.com/archives/C6X43FE8M/p1638791067003700

enver-haase commented 2 years ago

https://stackoverflow.com/questions/70248918/is-vaadins-cssimport-annotation-broken

may be related -- in which case downgrading to 14.5.5 could be an option.

mvysny commented 2 years ago

Could you please attach an example project which reproduces the issue? I know it's hard (given the set of stack used), but believe me - it's even harder for me :)

enver-haase commented 2 years ago

When debugging this yesterday, @mstahv and me found that the customer project, while attributing @CssImport to one component, never actually add the component with that attribute to the component tree. Please can you, therefore, close the bug as INVALID.

mvysny commented 2 years ago

Thank you for letting me know, good to know :+1: