Flow: Create default bundle to make getting started quicker

Created on 14 Aug 2019  路  8Comments  路  Source: vaadin/flow

If I have a project where I only use the Java API and the core set of Vaadin components, it would be nice to be able to skip downloading npm dependencies and running Webpack. This would speed up getting started significantly.

Suggestion
Use a pre-built default bundle containing all Vaadin components if:

  1. Project is in dev mode
  2. No @JSModule or @JavaScript annotations are pulling in code that's not already in the bundle.

This is analogous to the default widgetset of earlier Vaadin versions.

DX Epic enhancement needs design nodnppnpm

Most helpful comment

I realize this is more of a conversation starter than a concrete proposal. But I think it's worth investigating because it could have a big positive impact for developer experience.

All 8 comments

To benefit from that feature, you'd also have to opt out from the feature that leaves out e.g. Charts from the bundle of you're not using that component anywhere in your project.

The default bundle should only be used in development mode

That would increase the risk of hard-to-debug defences between development mode and production mode.

The most likely cause of problems is if there's some component that is actually used but not detected as such because of one of the edge cases not supported by the bytecode traverser. In that case, everything would seem to work in development mode but then in production mode some components would be missing.

Immediately when you would eg. try to create a new view with designer (or a new template by hand), everything would have to be downloaded.

But this is still an interesting idea, that we'll take into consideration. Another opportunity is to add an option to get the starters/archetypes to include all necessary things to avoid multiple downloads.

I realize this is more of a conversation starter than a concrete proposal. But I think it's worth investigating because it could have a big positive impact for developer experience.

Another thing that is similar to this "default bundle" is to make it possible to "build the bundle once and then avoid all npm & webpack work" when not necessary, which is for some users _all the time_. This could be achieved by adding a capability to use a _prebuilt bundle_. This can be an issue when the network is very slow or behind a proxy. Then you could basically define all the dependencies for your work during development time and run the frontend build once, and then enjoy the faster start-up and development turnaround. To my understanding this can be achieved already now with some extra configuration.

I wonder if we could make it so that, in development mode:
1) By default for all new _Java-only_ application projects, only the vaadin / vaadin-core bundle is loaded. This could be distributed inside the jars (?)
2) User can build their own default bundle which will be used instead of 1) bundle. This build could be a stand-alone goal from the plugin ?

Not sure if we should then
a) disable the classpath scanning for @JsModule & @JavaScript when there is this prebuilt bundle in use. This would become problematic for anyone who e.g. tries to use the Designer and would not result in a good experience when things won't work
b) keep scanning with every Java reload and retrigger new build and/or npm install if necessary

Slightly related issues about improving the getting started experience with having node & npm installed: #6249 and #6262

Still relevant to speed up initial Vaadin experience. Would help e.g. with online environments like Gitpod.io.

Also good to note here that starting with webpack 5, we could split the "default bundle" out from the webpack build and ship it with the framework for development mode (idea credits to @Legioth)

This is because webpack 5 will support "module federation" https://dev.to/marais/webpack-5-and-module-federation-4j1i

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joheriks picture joheriks  路  4Comments

pleku picture pleku  路  4Comments

SomeoneToIgnore picture SomeoneToIgnore  路  4Comments

Artur- picture Artur-  路  4Comments

pleku picture pleku  路  4Comments