[
https://issues.apache.org/jira/browse/WICKET-7187?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18093520#comment-18093520
]
ASF GitHub Bot commented on WICKET-7187:
----------------------------------------
jstuyts commented on PR #1498:
URL: https://github.com/apache/wicket/pull/1498#issuecomment-4878937699
@bitstorm in my opinion, moving `type` to `JavaScriptHeaderItem` is the
wrong approach. There are certain types (currently import maps and speculation
rules) that can really benefit from a dedicated API. These sub types of
`JavaScriptHeaderItem` would also inherit `type`, but ignore its value because
they already know their type.
With the type hierarchy in the schema above, the API is nicer: the user is
prevented from making mistakes. Also, there is no need for breaking
compatibility.
The only "downside" is that 2 enum values of `JavaScriptReferenceType`
(`TEXT_JAVASCRIPT` and `MODULE`) have to be duplicated in
`JavaScriptWellKnownContentType`. I feel that the improvement of the API is
worth it.
What I can do is: make a PR for everything in the hierarchy above, except
for `JavaScriptImportMapHeaderItem` and `JavaScriptSpeculationRulesHeaderItem`
(which I was not going to build as I have found no use for it yet). I can
create a separate PR for the import map later. This way, the type for content
items will be available sooner.
> JavaScript header items: `module` for content, and import maps
> --------------------------------------------------------------
>
> Key: WICKET-7187
> URL: https://issues.apache.org/jira/browse/WICKET-7187
> Project: Wicket
> Issue Type: Improvement
> Components: wicket-core
> Reporter: Johan Stuyts
> Priority: Major
>
> A number of JavaScript components has stopped providing
> [UMD|https://github.com/umdjs/umd] builds, and provide [ECMAScript
> modules|https://tc39.es/ecma262/#sec-modules] instead. To be able to use
> those modules, JavaScript in the header must also be a module. But currently
> it is not possible to specify the type for
> {{{}JavaScriptContentHeaderItem{}}}.
> Additionally, modules use "[bare
> modules|https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap#bare_modules]"
> to import dependencies, and these bare modules need to be mapped to the URLs
> of resource references so the JavaScript can be loaded.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)