`postinstall` in `package.json` scripts seems not to be executed anymore in VAADIN 23+ with `vaadin-maven-plugin:build-frontend`
See original GitHub issueDescription of the bug
This is a bug regarding the VAADIN Maven Plugin. I hope this is the right place, I couldn’t find a dedicated GitHub repository for it.
In our project, we adjusted the tsconfig.json
to use a custom output directory for compiled JS files. This was set to frontend/target
and worked for years now including VAADIN 22.0.12. After upgrading to VAADIN 23, this folder won’t be created anymore.
It was created when building the application in production mode / starting the application in non-production mode.
We rely on a JS file in the frontend/target
folder to be present with using @JsModule("./target/folder1/component.js")
in a Java class (see Minimal reproducible example).
As said, since VAADIN 23, this folder won’t be created anymore. Due to that, the required JS file cannot be found leading to a failure of the build-frontend
goal of the VAADIN Maven Plugin.
Error Log
[ERROR] Failed to execute goal com.vaadin:vaadin-maven-plugin:23.0.5:build-frontend (default) on project %project name%: Could not execute build-frontend goal: Error occured during goal execution:
[ERROR]
[ERROR] Failed to find the following files:
[ERROR] - ./target/folder1/component.js
[ERROR]
[ERROR] Locations searched were:
[ERROR] - `C:\Users\%username%\[...]\project\frontend` in this project
[ERROR] - `META-INF/frontend` in included JARs
[ERROR] - `META-INF/resources/frontend` in included JARs
Debugging
From debugging I noticed that the postinstall
defined in the package.json
scripts isn’t executed anymore since VAADIN 23. There we have "postinstall": "tsc"
which should create the frontend/target
folder which is missing now (see Minimal reproducible example). This is most likely the issue for the bug.
VAADIN 22:
[INFO] Running `npm install` to resolve and optionally download frontend dependencies. This may take a moment, please stand by...
[DEBUG]
C:\Program Files\nodejs\npm.cmd --no-update-notifier \
--no-audit --scripts-prepend-node-path=true install
[DEBUG] Output of `C:\Program Files\nodejs\npm.cmd --no-update-notifier --no-audit --scripts-prepend-node-path=true install`:
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated core-js@2.6.12: core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up
to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
[DEBUG]
[DEBUG] > postinstall
[DEBUG] > tsc
[DEBUG]
[DEBUG]
[DEBUG] added 1436 packages in 3m
[DEBUG]
[DEBUG] 102 packages are looking for funding
[DEBUG] run `npm fund` for details
[INFO] Frontend dependencies resolved successfully.
VAADIN 23:
[INFO] Running `npm install` to resolve and optionally download frontend dependencies. This may take a moment, please stand by...
[INFO] Globally node version 16.13.1 is older than 16.14.0. Using node from C:\Users\%username%\.vaadin.
[DEBUG] Using node 16.14.0 located at C:\Users\%username%\.vaadin\node\node.exe
[DEBUG] Using npm 8.3.1 located at C:\Users\%username%\.vaadin\node\node.exe
[DEBUG]
C:\Users\%username%\.vaadin\node\node.exe \
C:\Users\%username%\.vaadin\node\node_modules\npm\bin\npm-cli.js \
--no-update-notifier --no-audit \
--scripts-prepend-node-path=true --ignore-scripts \
install
[INFO] using 'C:\Users\%username%\.vaadin\node\node.exe C:\Users\%username%\.vaadin\node\node_modules\npm\bin\npm-cli.js --no-update-notifier --no-audit --scripts-prepend-node-path=true --ignore-scripts install' for frontend package installation
[WARNING] package-lock.json is missing from this project. This may cause the npm package installation to take several minutes. It is recommended to keep the package-lock.json file persistently in your project. Please stand by...
[DEBUG] Output of `C:\Users\%username%\.vaadin\node\node.exe C:\Users\%username%\.vaadin\node\node_modules\npm\bin\npm-cli.js --no-update-notifier --no-audit --scripts-prepend-node-path=true --ignore-scripts install`:
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated core-js@2.6.12: core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up
to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
[DEBUG]
[DEBUG] added 1208 packages in 3m
[DEBUG]
[DEBUG] 101 packages are looking for funding
[DEBUG] run `npm fund` for details
[INFO] Frontend dependencies resolved successfully.
Expected behavior
The folder should be created by tsc
after building in production mode or starting the application in non-production mode.
Minimal reproducible example
I made an example project showcasing it: missing-target-folder.zip
Note: I downloaded the project from https://vaadin.com/docs/latest/flow/guide/quick-start and adjusted it.
Simply run mvn clean install -Pproduction
to build it.
It has a git repository so you can have a look at 229bdcaf2dfb9206ef4fa1021787cd5a738281a0
to see what I exactly changed. This commit uses VAADIN 22.0.12. The build will succeed on that commit.
In commit 95f7d3e33b7eeb67f802d7aa6e86f13632d402aa
, I set the version back to VAADIN 23.0.5. The build will fail on that commit.
Important parts:
- Added a dummy TS and Java file.
- Added our
scripts
section in thepackage.json
. - Adjustments to the
tsconfig.json
. - Set
pnpm.enable
tofalse
in thepom.xml
.
Versions
- Vaadin / Flow version: 23.0.0+
- Java version: 17.0.2 2022-01-18 LTS
- OS version: Windows 10 21H1
- Browser version (if applicable): Not needed.
- Application Server (if applicable): Not needed.
- IDE (if applicable): Not needed.
Issue Analytics
- State:
- Created a year ago
- Comments:11 (3 by maintainers)
Top GitHub Comments
Can confirm VAADIN 23.1.1 could be built again due to the
postinstall
script running again. No additional changes were needed. Thanks!We could change the logic to run the postinstall for the project itself also by default. I cannot imagine any security implication of that