Bundle dependency problem

We are having an issue with component shadow DOMs not being loaded. When this happens, the component tag appears in the page HTML, but it isn’t styled properly and doesn’t function.

The setup to the problem is a bit complex, so bear with me as I try to explain.

We have a “core” application, which is packaged as a WAR file using the standard Vaadin Maven build process. The application contains multiple pages with @Routes, but let’s focus on two, call them A and B. Page A is the page that users land on after logging in. Page B is some other page, but the important distinction from A is that B uses the Details component, while A does not.

Page A
Page B → Details

We also have some add-on features packaged as JAR files. These add-ons also have multiple pages, and we define the Routes to them using the API instead of the @Route annotation. Let’s focus on one add-on page, call it Z, also with a dependency on the Details component.

Page Z → Details

Here’s the problem. If I log in to page A and then immediately navigate to page Z, the Details component won’t work. If, however, I log in to page A, visit page B, and then navigate to page Z, then the Details component works fine (on both B and Z).

A → Z = Details broken
A → B → A → Z = Details works
also
A → Z (Details broken) → A → B (Details works) → A → Z (Details works)

This issue only occurs in a production deployment. In our development environment everything works fine. Note also that this isn’t specific to the Details component, I’ve just chosen it as an example.

I’m guessing that there’s some sort of lazy loading of the resource bundle that isn’t working properly for pages that weren’t part of the original frontend compilation process?

Sounds similar to the question you asked some weeks ago. Does the problem goes away when configuring maven with optimizeBundle = false?

I can try that at the next build, but isn’t it false by default? (that’s what the documentation says)

Sounds like a documentation bug, it’s true by default for production mode flow/flow-plugins/flow-maven-plugin/src/main/java/com/vaadin/flow/plugin/maven/BuildFrontendMojo.java at b3728570471a294a49c3032cc8943044e698d771 · vaadin/flow · GitHub

I would combine it with forceProductionBuild = true to make sure it’s really used and no previously created/committed bundle is used

Actually documentation says default is true

optimizeBundle (default: true)
Whether to include only frontend resources used from application entry points (the default) or to include all resources found on the classpath. This should normally be left to the default, but a value of false can be useful for faster production builds or debugging discrepancies between development and production builds

If you have seen the opposite on a different page, please link it in this thread or create an issue in the documentation repository

2 Likes

Based on a quick test, that seems to have solved the problem. Will this have any negative consequences other than perhaps a slower initial page load time?

that’s the only downside

Here’s the fix for the documentation fix: fix default value of optimizeBundle setting by mcollovati · Pull Request #4473 · vaadin/docs · GitHub
Other pages correctly reported true as the default value.

@kklein @knoobie Thanks for noticing!

1 Like