WebJar Node Maven Handler

Last modified by Vincent Massol on 2026/11/17 12:25

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"
  }
}

SBOM of the bundled npm packages

XWiki 18.10.0+

The packaging embeds in the webjar a CycloneDX SBOM (Software Bill of Materials) of the npm packages it bundles (META-INF/sbom/npm.cdx.json), generated by pnpm sbom from the lockfile. When releasing, it's added to the SBOM of the webjar and of everything that depends on it (e.g. the WAR), so that vulnerability scanners report the advisories affecting these packages (see Using Profiles).

  • Only the production dependencies are listed: every package bundled in the webjar must be declared in dependencies (directly or transitively), not in devDependencies.
  • To skip it (e.g. with a pnpm version that doesn't support pnpm sbom): -Dxwiki.sbom.npm.skip=true, or set the xwiki.sbom.npm.skip property to true in the POM. It's also skipped when skip.pnpm is true.
  • The release of a module that is, or ships (i.e. depends on, other than for its tests), a webjar-node webjar without this SBOM fails when xwiki.sbom.failOnMissingEmbeddedSBOM is true, which is the case for the modules inheriting from the XWiki Platform parent POM (extensions included). Otherwise it only logs a warning. Set it to false to release anyway.

Get Connected