You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Grid Helper Dense Mode does not work with productive build #171
Hi @timomeinen ! Dense mode seems to be working on our demo application that is actually deployed in production mode.
Can you try creating a new small sample application, integrate the add-on, copy the demos and then run it in production mode? .. if it works, compare it to your application to spot significant differences, if it doesn't attach the sample project here so we can take a look.
Thanks!
I have just added a checkbox of the DENSE mode to the start.vaadin.com demo application.
I remember I had a similar issue with a different plugin and solved it by manually referencing the JS via Annotation to force it being packed into the prod.bundle. Here also the vaadin:build-frontend does not pickup the dependency and says, no bundle is needed:
[INFO] --- vaadin:25.0.7:build-frontend (default-cli) @ app ---
[INFO] Reflections took 725 ms to scan 118 urls, producing 5125 keys and 20651 values
[INFO] Scanning classes to find frontend configurations and dependencies...
[INFO] Visited 1255 classes. Took 1006 ms.
[INFO] Checking if a production mode bundle build is needed
[INFO] A production mode bundle build is not needed
The problem is that GridHelper is not recognized as Vaadin Component by the vaadin-maven-plugin and thus it does not recognize the @CssImport(value = "./fcGridHelper/vaadin-menu-bar.css", themeFor = "vaadin-menu-bar"). The result is that the CSS is missing in the bundle:
I tried to use com.vaadin.flow.component.dependency.Uses to give Vaadin a hint to include Grid-Helpers StyleSheets and JavaScript dependencies, but as GridHelper is not a com.vaadin.flow.component.Component it does not work:
@Uses(GridHelper.class) // Compile error as GridHelper is not instanceof Component
Instead, when we force bundling by disabling the byte-code scanner with <optimizeBundle>false</optimizeBundle>, it works:
The vaadin-maven-plugin production bundle scanner is reachability-based: it seeds from known entry points and follows bytecode references to discover @CssImport / @JsModule dependencies.
When a view calls a GridHelper method, javac emits an instruction naming GridHelper as the owner class. The FrontendClassVisitor adds it to the reachability set, then the scanner visits GridHelper, and its @CssImport annotations are picked up. This is why our demo application works correctly in production (the demo for the dense theme feature is compiled with other demos that cause GridHelper to be reachable).
In your sample project, only the DENSE_THEME constant is used. Javac inlines the constant and emits no field-access instruction at all
(it's the same as if you had written grid.addThemeName("fcGh-dense")). Therefore GridHelper never appears in any executable instruction, the scanner never reaches it, and its annotations are not processed.
The fix from commit 9ade7ea works, but I've created an alternative approach in #175 that I think is cleaner.
Instead of the VaadinServiceInitListener anchor class, it adds setDenseTheme(Grid, boolean) and isDenseTheme(Grid) methods. This solves the production bundle problem the same way (a method call creates a bytecode reference to GridHelper, so the scanner finds its @CssImport annotations), but it's also more consistent with the rest of the GridHelper API where every feature follows the GridHelper.setSomething(grid, value) / GridHelper.isSomething(grid) pattern — the dense theme was the only one that required direct theme name manipulation.
Is it possible to release a patch version of the existing solution (GridHelperServiceInitListener) as we depend on this feature and I would like to get rid of my local hack?
Activity
mlopezFC commentedon Mar 19, 2026
Hi @timomeinen !
Dense mode seems to be working on our demo application that is actually deployed in production mode.
Can you try creating a new small sample application, integrate the add-on, copy the demos and then run it in production mode? .. if it works, compare it to your application to spot significant differences, if it doesn't attach the sample project here so we can take a look.
Thanks!
Showcase dense mode in production mode not working
timomeinen commentedon Mar 19, 2026
Hi @mlopezFC,
please find a small example of the problem here: https://github.com/timomeinen/grid-helpers-issue-171
I have just added a checkbox of the DENSE mode to the start.vaadin.com demo application.
I remember I had a similar issue with a different plugin and solved it by manually referencing the JS via Annotation to force it being packed into the prod.bundle. Here also the vaadin:build-frontend does not pickup the dependency and says, no bundle is needed:
A production mode bundle build is not needed
timomeinen commentedon Mar 23, 2026
The problem is that
GridHelperis not recognized as Vaadin Component by thevaadin-maven-pluginand thus it does not recognize the@CssImport(value = "./fcGridHelper/vaadin-menu-bar.css", themeFor = "vaadin-menu-bar"). The result is that the CSS is missing in the bundle:❯ grep "fcGridHelper/vaadin-menu-bar.css" target/classes/META-INF/VAADIN/config/stats.jsonIn contrast the dev mode bundle has the required file:
I tried to use
com.vaadin.flow.component.dependency.Usesto give Vaadin a hint to include Grid-Helpers StyleSheets and JavaScript dependencies, but as GridHelper is not acom.vaadin.flow.component.Componentit does not work:Instead, when we force bundling by disabling the byte-code scanner with
<optimizeBundle>false</optimizeBundle>, it works:This will add the files to the prod bundle:
But this is not ideal as the prod bundle will now be unneccassary big.
timomeinen commentedon Mar 23, 2026
Note: adding the CSS import to my own view, works as well of course:
@CssImport(value = GridHelper.GRID_STYLES, themeFor = "vaadin-grid")javier-godoy commentedon Mar 24, 2026
Hello. Did you add
com.flowingcodeto whitelisted-packages?https://github.com/FlowingCode/GridHelpers?tab=readme-ov-file#special-configuration-when-using-spring
timomeinen commentedon Mar 24, 2026
Hi @javier-godoy,
whitelisted-packagesis deprecated but adding com.flowingcode is added to eitherwhitelisted-packagesorvaadin.allowed-packages:No change. the fcGridHelper resources are not added to the bundle:
❯ grep "fcGridHelper/" target/classes/META-INF/VAADIN/config/stats.jsonjavier-godoy commentedon Mar 24, 2026
I'll take a look.
javier-godoy commentedon Mar 26, 2026
The vaadin-maven-plugin production bundle scanner is reachability-based: it seeds from known entry points and follows bytecode references to discover
@CssImport/@JsModuledependencies.When a view calls a
GridHelpermethod, javac emits an instruction namingGridHelperas the owner class. TheFrontendClassVisitoradds it to the reachability set, then the scanner visitsGridHelper, and its@CssImportannotations are picked up. This is why our demo application works correctly in production (the demo for the dense theme feature is compiled with other demos that causeGridHelperto be reachable).In your sample project, only the DENSE_THEME constant is used. Javac inlines the constant and emits no field-access instruction at all
(it's the same as if you had written
grid.addThemeName("fcGh-dense")). ThereforeGridHelpernever appears in any executable instruction, the scanner never reaches it, and its annotations are not processed.fix: register VaadinServiceInitListener to bundle grid styles
fix: ensure dense theme CSS is included in production bundle
timomeinen commentedon Mar 27, 2026
The fix from commit 9ade7ea works, but I've created an alternative approach in #175 that I think is cleaner.
Instead of the
VaadinServiceInitListeneranchor class, it addssetDenseTheme(Grid, boolean)andisDenseTheme(Grid)methods. This solves the production bundle problem the same way (a method call creates a bytecode reference toGridHelper, so the scanner finds its@CssImportannotations), but it's also more consistent with the rest of theGridHelperAPI where every feature follows theGridHelper.setSomething(grid, value)/GridHelper.isSomething(grid)pattern — the dense theme was the only one that required direct theme name manipulation.paodb commentedon Mar 27, 2026
Thanks @timomeinen for this alternative. It's really interesting, we will discuss about it next week and we will keep you posted.
timomeinen commentedon Apr 8, 2026
Is it possible to release a patch version of the existing solution (GridHelperServiceInitListener) as we depend on this feature and I would like to get rid of my local hack?
fix: ensure dense theme CSS is included in production bundle
javier-godoy commentedon Apr 8, 2026
@timomeinen I'll revert #173 and release it with your changes, since it's a more clear approach.
fix: ensure dense theme CSS is included in production bundle