_When updating the platform version in pom.xml file, I expect the project to keep on working without any additional changes, instead of causing errors in the client side and forcing me to remove files I have no idea about_
_When some frontend dependency has updated, I don't want it to automatically break my project, but instead keep things working as is and maybe provide me the information that I might want to update things_
Related to issues like vaadin/beverage-starter-flow#383, vaadin/bookstore-starter-flow#152 and vaadin/skeleton-starter-flow#192.
Related slack threads:
For me it would also be fine if I need to do some extra when I add an external 3rd party frontend dependency to the project to get everything up-to-date, in comparison to having to wait for more time on
1) starting up the project without any frontend dependency changes
2) waiting for automatic refresh tools (Java/frontend) to resolve things
Though I do recall someone saying that Webpack should be able to do npm install for requested new modules on the fly.
For the investigation:
1.- Revert the starters to the status where the package-lock file was breaking the app
2.- Check that project is broken
3.- run npm ci and see if project fixed
4.- if project continues broken, run rm package-lock.json && npm ci and see if project is fixed.
If project was fixed in 3, we just need to replace npm install with npm clean-install in java executor, and update the documentation about the required npm version.
If project was fixed in 4, we replace npm install with npm clean-install but in addition remove package-lock.json from java when executor updates target/frontend/package.json because a version change (not in the case of a new component addition)
Note on investigation step 4. npm ci states ci can only install packages with an existing package-lock.json or npm-shrinkwrap.json
This means that in the case where package-lock.json doesn't exist we should run npm install for the first installation round to get the package-lock.json file. and onlu it the pacage-lock exists should we run npm ci
node_modules, package-lock.json, and /target/frontend/node_modulesvaadin-skeleton-starter-flowmvn jetty:runTabs) to MainViewjetty:run -> BAM! No styles for TabsSomething related to consider:
https://vaadin.slack.com/archives/C6X43FE8M/p1561555544080700
It appears that introducing new components to skeleton started might not work out of the box, if the project has been built once. It will skip npm install and does not download the necessary dependencies.
Preliminary notes:
beverage project is: remove node_modules, all config files, do mvn clean. Only after this I may run the application and it works as expected.npm ci doesn't fix if I have node_modules. But I can't find a way when it works at all at the moment (so I don't know whether the node_modules is a reason or not)target folder, all package* file, all webpack* files it doesn't help, the project is still broken. As mentioned above: I have to run mvn clean and remove everything.So I need to see what exactly influence on the behavior when the project is broken. There are too many artifacts.
So the final results are:
npm ci doesn't work without node_modules.npm ci doesn't help if you don't delete node_modules.npm ci is uselessnode_modules, package-lock.json and target ( do mvn clean ) or only target/frontend/node_modules inside target .npm ci works fine without the node_modules directory, but it requires that package-lock exists and all the package.json files should be available e.g. ./package.json and ./target/frontend/package.json
And running npm ci will not help if the package-lock.json is already corrupted (e.g. there exists a /target/frontend/node_modules for the package-lock , this is an error by the updater also as it was not understood that this may happen).
Technical details about implementation decided.
Considerations
target/frontend/package.json which is updated each time a new dependency is added or removed or the version changestarget/frontend/package.json there is an entry for the "@vaadin/vaadin-core-shrinkwrap": "14.0.0-rc1" whose version meets the platform one node_modules/@vaadin/flow-deps/package.json we have the same content thatn in the target/frontend/package.json package-lock.json fileImplementation
shrink-wrap version we should delete rm -rf package-lock.json node_modules target/frontend/node_modulesshrink-wrap version would need to visit package-lock.json, node_modules/@vaadin/flow-deps/package.json and target/frontend/package.jsonReferences
*.json and get its JsonObject representation https://github.com/vaadin/flow/blob/master/flow-server/src/main/java/com/vaadin/flow/server/frontend/NodeUpdater.java#L182 it should work for parsing the package-lock.json file, for the others there should be already a method using this.
Most helpful comment
Note on investigation step 4.
npm cistatesci can only install packages with an existing package-lock.json or npm-shrinkwrap.jsonThis means that in the case where package-lock.json doesn't exist we should run
npm installfor the first installation round to get the package-lock.json file. and onlu it the pacage-lock exists should we runnpm ci