flow icon indicating copy to clipboard operation
flow copied to clipboard

package.json got updated unexpectedly with mvn command

Open ZheSun88 opened this issue 2 years ago • 8 comments

Description of the bug / feature

the package.json got updated unexpectedly with mvn command

Minimal reproducible example

git clone [email protected]:vaadin/docs.git
cd docs
git checkout v21
mvn install -Pproduction (the package.json looks like [this](https://github.com/vaadin/docs/pull/727/files))
mvn (those mixin and polymer dependency will be added)

this is how the production profile has been set

Expected behavior

package.json should be kept the same

Actual behavior

the package.json got updated

Versions:

- Vaadin / Flow version: Vaadin 21. flow 8.0

related conversation can be found on slack

ZheSun88 avatar Sep 07 '21 08:09 ZheSun88

furthermore, if i manually remove the package.json, then run mvn install -Pproduction the generated file removes extra dependencies, like :

-    "date-fns": "^2.16.1",
-    "lit": "2.0.0-rc.3",
-    "lumo-css-framework": "^4.0.8",
-    "promise-file-reader": "^1.0.3",
-    "vanilla-colorful": "^0.5.3"
+    "lit": "2.0.0-rc.3"

this should not happen either, as those dependencies are needed for building the project.

ZheSun88 avatar Sep 09 '21 07:09 ZheSun88

Note, at least lit should not be removed because it's present in NodeUpdater. https://github.com/vaadin/flow/blob/7cab180688c94fdf2a471249b150ae8531b73a93/flow-server/src/main/java/com/vaadin/flow/server/frontend/NodeUpdater.java#L368

I think the fact that manually added dependencies get removed is a known problem.

web-padawan avatar Sep 09 '21 07:09 web-padawan

@web-padawan lit has not been removed. as this is V21 branch and at the moment, the released version of V21.0.0 is using lit 2.0.0-rc3

so i think all other dependencies mentioned in my previous comment are the manually added ones.

ZheSun88 avatar Sep 09 '21 07:09 ZheSun88

Some observations:

  1. Running mvn install -Pproduction with v21 Starter project gives the opposite result: polymer and mixin deps are added into package.json.
  2. Running mvn install with docs project doesn't update package.json.

I couldn't find the existing ticket about manually added dependencies get removed.

mshabarov avatar Sep 13 '21 07:09 mshabarov

Any manually added or changed dependencies should not be touched so if there is a case where this happens a ticket should be created with steps to reproduce as no user changes should be changed.

Only instance where user set versions may change is when a user has set a package that at some point becomes the same as the Vaadin version at which point it becomes FW handled and may later update or be removed if the project drops NpmPackage (or a extremely rare case of removed default dependency happens)

caalador avatar Sep 17 '21 05:09 caalador

user has set a package that at some point becomes the same as the Vaadin version at which point it becomes FW handled

BTW this is the case for date-fns in Vaadin 22 (see latest branch of docs repo). Previously it was used in some examples, but starting from Vaadin 22 it became part of DatePickerFlow and is now managed by Flow itself.

Anyways, the original issue about Polymer and mixins being added / removed is the main problem here.

web-padawan avatar Sep 17 '21 06:09 web-padawan

In this ticket 2 different collection usages is used the mvn install -Pproduction uses maven and the command mvn executes spring-boot:run which uses the Spring add-on VaadinServletContextInitializer:DevModeServletContextListener

The difference is that -Pproduction collects what is used and spring-boot:run collects everything on classpath. Is there something that is broken when running the production build?

caalador avatar Sep 17 '21 08:09 caalador

To be retested with Vaadin 23.2 after this fix https://github.com/vaadin/flow/pull/14556 .

mshabarov avatar Sep 20 '22 07:09 mshabarov