Skip to content

Conversation

@manuelleduc
Copy link
Contributor

@manuelleduc manuelleduc commented Nov 3, 2025

Jira URL

Changes

Description

  • decide if json is the right configuration choice (maybe xml is best on a pom? or a custom syntax)
  • enhance the format to fir the expressivness of the webjar url API
  • move parsing to commons to be able to reuse it on maven validators

Clarifications

Screenshots & Video

Executed Tests

Expected merging strategy

  • Prefers squash: Yes
  • Backport on branches:
    *

@manuelleduc manuelleduc self-assigned this Nov 3, 2025
<xwiki.minification.skip>true</xwiki.minification.skip>
<xwiki.javascript.modules.importmap>
{
"xwiki-livedata": "org.xwiki.platform:xwiki-platform-livedata-webjar/main.es.js",
Copy link
Member

@tmortagne tmortagne Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if it's not a bit too simple, I mean you might need more information that just the extension id and path (the webjars URL API can take custom parameters, for example).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More than what "xwiki-livedata": "org.xwiki.platform:xwiki-platform-livedata-webjar/main.es.js?myparam=42" could do?

Copy link
Contributor Author

@manuelleduc manuelleduc Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@tmortagne tmortagne Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I forgot to mention that only the Maven properties which name starts with "xwiki.extension." are extracted from the pom.xml to be exposed as Extension property. So you will need something which looks more like xwiki.extension.javascript.modules.importmap I guess.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More than what "xwiki-livedata": "org.xwiki.platform:xwiki-platform-livedata-webjar/main.es.js?myparam=42" could do?

Since you use JSON, it might be less error-prone to fully use JSON syntax to define all this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the format to also support namespace and parameters.
moduleA is an example of the compact and straighforward declaration of a simple webjar with a path.
But as you can see with moduleB, the string can be replaced with an object with 4 keys:

  • webjarId and path are mandatory
  • namespace and params are optionals
{
  "moduleA": "org.xwiki.js/thepath.js",
  "moduleB": {
    "webjarId": "org.xwiki.js",
    "path": "path.js",
    "namespace": "s1",
    "params": {
      "key": "value"
    }
  }
}

Copy link
Member

@mflorea mflorea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm looking forward to using this feature.

@manuelleduc manuelleduc changed the title XWIKI-23609: Easier importmap declaration for webjars XCOMMONS-3470: Easier importmap declaration for webjars Nov 10, 2025
.configure(SORT_PROPERTIES_ALPHABETICALLY, true)
.build();

private static final JavascriptImportmapParser JAVASCRIPT_IMPORTMAP_PARSER = new JavascriptImportmapParser();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parser cannot be a component as I'd also like it to be usable in the maven enforcers who do not have access to components injection.

import java.util.Map;
import java.util.Objects;

import javax.inject.Named;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tmortagne if jakarta is used instead, the enforcer is not found.
Mentioning it in case this is not a know issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's more something to report to the enforcer plugin (this is not an XWiki component/feature).

var isSelf =
areDependenciesEquals(model.getGroupId(), model.getArtifactId(), groupIdWebjar, artifactIdWebjar);
if (isSelf) {
continue;
Copy link
Contributor Author

@manuelleduc manuelleduc Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last issue: I'm not sure how to find out if the path exists when the map defines the current artifact itself since the target directory is not populated when the check is performed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@manuelleduc manuelleduc marked this pull request as ready for review November 14, 2025 10:47
@manuelleduc manuelleduc merged commit f294505 into xwiki:master Nov 21, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants