WebJar Node Maven Handler

Last modified by Manuel Leduc on 2026/02/11 14:12

Warning

XWiki 17.5.0+ Between version 17.5.0RC and 17.10.0RC1. npm was used instead of pnpm.
If you are using the webjar-node handle in those versions, you can ignore the pnpm-specific instructions below.

XWiki 17.10.0+

Similarly to the WebJar Maven Handler, the Webjar Node Maven Handler helps to build webjar packages, using node and pnpm to build the artifacts.

To do so, the pom must declare a webjar-node packaging. This handler automates all the plumbing required to make a webjar using node and pnpm.

Pom example:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.xwiki.platform</groupId>
    <artifactId>xwiki-platform-livedata</artifactId>
    <version>17.10.1-SNAPSHOT</version>
  </parent>
  <packaging>webjar-node</packaging>
  <artifactId>xwiki-platform-livedata-webjar</artifactId>
</project>

Notes:

  • the node project must be located in src/main/node
  • the package.json must declare
    • a build script to build the artifacts from the sources
    • a test:unit script to run the unit tests
    • a lint script to check the code quality
    • the sources copied into the webjar must be in a dist directory at the root of the node project
  • The module must be listed in the packages list of pnpm-workspace.yaml (located at the root of xwiki-platform)
  • External dependencies must use the catalog feature of pnpm. The version used in the local package.json is "catalog:" and the exact version is defined in the catalog list of pnpm-workspace.yaml. This allows all packages to share the same external dependency versions.

 If one of the scripts must do nothing, the best practice is to make it return the 0 exit code and to add a comment explaining why the script is skipped. For instance:

{
  "script": {
    "lint": "exit 0 # This package has a single line of code that does not need linting"
  }
}

Get Connected