Vaadin 14.3.4
Implement something akin to the Vaadin Gradle Plugin's vaadinClean task. Sometimes the node_modules may become corrupted or npm install may not run for mysterious reasons. While Vaadin team figures out how to tackle these issues properly, as a workaround it would be good to have a task that would perform the Vaadin Dance and delete the npm-related files and folders:
node_modulespackage*.jsonwebpack.generated.jstsconfig.json and types.d.tsIt is really a need to have a task that would perform the Vaadin Dance and delete the npm-related en pnpm-related files and folders.
:thumbsup:
I totally agree
Deleting package.json would also remove info about installed npm dependencies in Fusion projects, please don't delete that.
Presumably if you take a start.vaadin.com project, run it and/or build it for production and then run clean and this clean target, you should be back with the downloaded project?
I agree with Artur. The vaadin clean goal should be there to help the developer when Vaadin doesn't start for some reason. In this case, preserving custom-added packages is secondary; primary is to get the dev env up and running. You can always checkout package.json from git later on.
Should it also reset pom.xml in that case?
Touching package.json or pom.xml from the clean target would be very unexpected behavior in my opinion.
Yeah I did not at all say "preserving custom-added packages is secondary". You should not delete package.json as it is not an autogenerated file - it is included in the generated project. It would be the same as removing stuff from the <dependencies> section from pom.xml.
The lock files, node_modules and *.generated.js are generated and can be removed. It is unlikely that removing webpack.generated.js will help with many problems though. Removing node_modules and the package lock file should be enough to reinstall npm dependencies from scratch
You should not delete package.json as it is not an autogenerated file - it is included in the generated project. It would be the same as removing stuff from the
section from pom.xml.
I disagree. The first reason is that the Java dev is capable of maintaining pom.xml, but not really interested in the contents of package.json (unless there's a client-side code). Therefore, the Java dev is capable of fixing pom.xml-related issues, but not usually capable of fixing npm, bower or other JS-related errors stemming from malformed package.json. The second reason is that Vaadin plugin generates package.json but doesn't generate pom.xml; removing package.json causes Vaadin code to regenerate it safely, while removing pom.xml causes the project to not to compile anymore.
You are mixing "autogenerated files" and "initial version auto generated for you". If you can detect that there has not been any changes done to package.json, then it is fine to delete it as the same will be autogenerated (why delete it then?).
I wonder whether there is a way to add some crazy stuff to package.json unknowingly, which would cause the project to fail to compile with webpack (or other tools from the JS chain) - say npm install --save or such... however you do have a point that in such case it's probably better to git revert all files.
The entire point of vaadinClean is to help the Java developer, who wants to stay as far as possible from the JavaScript, when the JS toolchain fails with a mystery error message on his machine, because something broke somewhere. It's not designed to help a JavaScript developer since he will be able to figure the error out.