Selectively exclude Javascript files from bundle in Vaadin 14 builds

I am using a component (in my case the excellent Full Calendar 4 addon from StefanUebe, but I have several other cases), that is seldom needed and it requires a large dependent Javascript file moment.js.

Is it possible to exclude any arbitrary large Javascript from the build bundle (I don’t know how to do this) and then dynamically load it when/if it is required (I know how to do this)?

In development mode build Vaadin includes everything in the frontend bundle. However when you do production mode build, the plugin scans what frontend components are actually used and picks only those into frontend bundle.

By default resources used with @JavaScript or @JsModule annotations are inlined in the frontend bundle. With this mechanism this on demand loading is not possible.

You can however also use @JavaScript(“context://…”) which loads the file dynamically. Then the loaded file should not be under frontend folder, but elsewhere in WEB-INF/resources. This naturally works only with your own imports, if you are using Vaadin components or add-ons, you cannot affect this.

Hi,

I think you can follow this github issue: https://github.com/vaadin/flow/issues/5623

And in your case (for the Calendar component), you can follow this issue: https://github.com/stefanuebe/vaadin_fullcalendar/issues/53