vaadin / hilla

Build better business applications, faster. No more juggling REST endpoints or deciphering GraphQL queries. Hilla seamlessly connects Spring Boot and React to accelerate application development.
https://hilla.dev
Apache License 2.0
906 stars 57 forks source link

Publish the @vaadin/form module to npm #290

Open vlukashov opened 3 years ago

vlukashov commented 3 years ago

As a developer I want to install the @vaadin/form package from npm with npm i @vaadin/form so that I can use it in my projects without having the full Vaadin Fusion project setup.

Related discussions:

Implementation notes: Publishing the Vaadin Fusion JS packages like @vaadin/form and @vaadin/connect to npm is complicated because we still want to keep the ability to create SNAPSHOT builds of Vaadin that use the locally-modified version of e.g. the @vaadin/form package (from this same repo, not from npm).

vicb commented 3 years ago

Thanks @vlukashov !

because we still want to keep the ability to create SNAPSHOT

I do not exactly understand why the form package needs to be handled differently from other packages (i.e. the form web components) but may git subtrees could help here ?

One thing that would also be nice is to make sure that the package works server side so that node backend could validate the forms. The only limitation I have found so far is that some properties are patched on window. This is easily fixed by creating separate entry points for the browser or node in package.json - or by checking if windows is defined.

vlukashov commented 3 years ago

I do not exactly understand why the form package needs to be handled differently from other packages (i.e. the form web components) but may git subtrees could help here ?

The intent behind the current setup is to make it easier to develop both the form package and the TS generator at the same time, as they are quite related. Currently, both the @vaadin/form package and vaadin-maven-plugin are in the same repo (as they are quite closely related). As long as that's the case I would expect Vaadin SNAPSHOT builds to take both the form package and the TS generator from the same git commit in the repo, and not the form package from npm and the TS generator from git.

Arguably, we could break this coupling and separate the form package into a separate repo (like it's done with @vaadin/router). In that case it becomes more difficult to make coordinated changes to the form and the TS generator, but it also makes it easier to use the form package stand alone.

vicb commented 3 years ago

The intent behind the current setup is to make it easier to develop both the form package and the TS generator at the same time, as they are quite related.

Thanks for the explanation. It makes perfect sense.

git subtree or npm link would be 2 different ways to solve this issue but they are arguably a less simple than the current setup.

Thanks for looking into making the form package standalone.

vicb commented 3 years ago

@vlukashov Some feedback from using the form framework in a TS project (both frontend and backend):

I'll add more as I progress with my integration.

Edit (dec 1, 2020):

It would be really nice to allow validation of the data on the server side - when the backend is Javascript.

The current implementation has a few problems with that: