Reputation: 31
When running mvn clean package -Pproduction
on Vaadin 24 the frontend files package.json
, package-lock.json
, vite.generated.ts
, etc. as well as the node_modules
folder arent created in the application folder, or rather, they are created during the build-frontend
goal and then deleted. Since our pipeline uses the package.json, is there any way to get these files to get built again?
Also, the documentation on the matter seems to imply these files should still be created:
prepare-frontend
This goal validates whether the node and npm tools are installed and aren’t too old (i.e., not earlier than node version 16.14, and not older than npm version 8.3). It installs them in the .vaadin folder in the user’s home directory if they’re missing. If they’re already installed globally, but too old, an error message is generated suggesting that you install newer versions.
Node.js is needed to run npm to install frontend dependencies and Vite, which bundles the frontend files served to the client.
Additionally, this goal reviews all resources used by the application and copies them into the node_modules folder, so they’re available when vite builds the frontend. It also creates or updates the package.json, vite.config.ts and vite.generated.ts files. [1]
These files are also mentioned in the documentation regarding source control.
Reproduction
@NpmPackage
annotation on a view (e.g. @NpmPackage(value = "line-awesome", version = "1.3.0")
)mvn clean package -Pproduction
I would expect the frontend files to be present in the application folder then, but they are first created and then deleted during the Runnig Vite...
step of the build-frontend
goal. Our current workaround is to create an empty package.json in the application folder, which is then updated by Vaadin as expected.
Edit:
Here is a link to a repository with a reproducible example of the problem. When I run mvn clean package -Pproduction
on this project, the frontend files are first created, then deleted at the end of the build-frontend
goal. Here is my output for prepare-frontend
and build-frontend
:
[INFO] --- vaadin-maven-plugin:24.2.0:prepare-frontend (default) @ my-app ---
[INFO] Reflections took 1831 ms to scan 124 urls, producing 4661 keys and 24042 values
[INFO] Copying frontend resources from jar files ...
[INFO] Visited 123 resources. Took 333 ms.
[INFO]
[INFO] --- vaadin-maven-plugin:24.2.0:build-frontend (default) @ my-app ---
[INFO] Reflections took 705 ms to scan 124 urls, producing 4661 keys and 24042 values
[INFO] Scanning classes to find frontend configurations and dependencies...
[INFO] Visited 2655 classes. Took 3425 ms.
[INFO] Checking if a production mode bundle build is needed
[INFO] Dependency line-awesome is missing from the bundle
[INFO] A production mode bundle build is needed
[INFO] Running `npm install` to resolve and optionally download frontend dependencies. This may take a moment, please stand by...
[INFO] using 'C:\Program Files\nodejs\npm.cmd --no-update-notifier --no-audit --scripts-prepend-node-path=true --ignore-scripts install' for frontend package installation
[INFO] Frontend dependencies resolved successfully.
[INFO] Copying frontend resources from jar files ...
[INFO] Visited 123 resources. Took 189 ms.
[INFO] Running Vite ...
[INFO] Reflections took 1049 ms to scan 124 urls, producing 4661 keys and 24042 values
[INFO] Scanning classes to find frontend configurations and dependencies...
[INFO] Visited 2655 classes. Took 4760 ms.
[INFO] Build frontend completed in 157955 ms.
Upvotes: 3
Views: 666