Last modified by Eleni Cojocariu on 2026/07/24 18:31

Hide last authors
Manuel Leduc 8.1 1 It is possible to define an eager and anonymous module using the importmap declaration, meaning that the module is going to be loaded an executed directly on page load and will not be listed in the importmap.
Manuel Leduc 1.1 2
Eleni Cojocariu 8.2 3 1. Add the dependency you wish to load eagerly and anonymously.(((
Manuel Leduc 3.1 4
Manuel Leduc 1.1 5 {{code language="xml"}}
6 <?xml version="1.0" encoding="UTF-8"?>
7 <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">
Manuel Leduc 3.1 8 <dependencies>
9 <!-- ... -->
10 <dependency>
Manuel Leduc 7.1 11 <groupId>my.group.id</groupId>
12 <artifactId>my-webjar</artifactId>
Manuel Leduc 3.1 13 <scope>runtime</scope>
14 </dependency>
15 <!-- ... -->
16 </dependencies>
17 </project>
18 {{/code}}
Eleni Cojocariu 8.2 19 )))
20 1. Declare theĀ ##xwiki.extension.javascript.modules.importmap## property. See the ##!## at the start of the value and the ##_## at the start of the key.(((
Manuel Leduc 3.1 21
22 {{code language="xml"}}
23 <?xml version="1.0" encoding="UTF-8"?>
24 <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">
25 <properties>
Manuel Leduc 4.1 26 <xwiki.extension.javascript.modules.importmap>
27 {
Manuel Leduc 8.1 28 "_module-id": "!my.group.id:my-webjar/index.prod.js"
Manuel Leduc 4.1 29 }
30 </xwiki.extension.javascript.modules.importmap>
Manuel Leduc 3.1 31 </properties>
32 </project>
33 {{/code}}
Eleni Cojocariu 8.2 34 )))
35 1. Check the final result.(((
Manuel Leduc 3.1 36
37 {{code language="xml"}}
38 <?xml version="1.0" encoding="UTF-8"?>
39 <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">
Manuel Leduc 1.1 40 <modelVersion>4.0.0</modelVersion>
41 <parent>
42 <groupId>org.xwiki.platform</groupId>
43 <artifactId>xwiki-platform-livedata</artifactId>
44 <version>18.1.0-SNAPSHOT</version>
45 </parent>
46 <packaging>webjar-node</packaging>
47 <artifactId>xwiki-platform-livedata-webjar</artifactId>
48 <properties>
Manuel Leduc 7.1 49 <xwiki.extension.javascript.modules.importmap>
Manuel Leduc 5.1 50 {
Manuel Leduc 8.1 51 "_module-id": "!my.group.id:my-webjar/index.prod.js"
Manuel Leduc 5.1 52 }
Manuel Leduc 1.1 53 </properties>
54 <dependencies>
55 <dependency>
Manuel Leduc 7.1 56 <groupId>my.group.id</groupId>
57 <artifactId>module-id</artifactId>
Manuel Leduc 1.1 58 <scope>runtime</scope>
59 </dependency>
60 </dependencies>
61 </project>
62 {{/code}}
Eleni Cojocariu 8.2 63 )))

Get Connected