JavaScript Importmap API

Last modified by Manuel Leduc on 2026/05/11 18:00

Reference

The importmap extension scans for xwiki.extension.javascript.modules.importmap properties in installed extensions.

The content of the property is expected to be an object with:

  • Keys corresponding to the IDs of JavaScript modules imported in the JavaScript bundled in the extension
  • Values corresponding to the webjars reference to the module to resolve when the key is used for an import in the browser

The webjars reference is composed of ${groupId}:${packageId}/${pathInwebjar.js}.

The reference is checked at build time, and the build fails if the reference is not correctly resolved.

XWiki 18.1.0+ Transitive dependencies can be used in the values of the importmap.

XWiki 18.4.0+

Eager

A module is eager when it is loaded directly during page load (i.e., not when another module explicitly imports it).

A module is eager when its webjar reference starts with a !.

Anonymous

A module is anonymous when it does not need to be imported by other modules.
In other words, it is not included in the importmap definition.
Not that it is not advised to make a non-eager module anonymous as it wouldn't be declared anywhere (i.e. the declaration would be dead code).

A module is anonymous when its key starts with a _.

FAQ

Get Connected