When trying to access JQuery in 9.7 from a servlet page like so
require(['jira/api/jquery-2.2.4'],($)=>{console.log($)})
we get
almond.js:297 Uncaught Error: undefined missing jira/api/jquery-2.2.4 at main (almond.js:297:27) at almond.js:372:17
This happens despite having defined a web resource dependency on JQuery:
<dependency>jira-frontend-api:jquery-2.2.4</dependency>
Hello @MarkusDarko!
Apologies for the inconvenience. I can see a bug in the WR-dependency in the frontend-api module.
Please use <dependency>jira.webresources:jquery</dependency>
before <dependency>jira-frontend-api:jquery-2.2.4</dependency>
. It’ll also work after the fix.
Best,
Rzymek
2 Likes
Thank you for the reply, Rzymek. Unfortunately, that did not resolve the issue - the module is still unavailable. We have a workaround for now, though.
Best,
Markus
2 Likes
Uh, I’m happy you have a workaround working.
Although, it’s odd that adding <dependency>jira.webresources:jquery</dependency>
didn’t solve the issue. As WRM doesn’t guarantee the order of <dependency>
it might be that in your case. For sure, you should be able to see jquery
AMD module with it.
Neverthless, we’ll work on the fix in the frontend-api module as well as revamping it a bit. This shouldn’t happen in the first place.
Best,
Rzymek
2 Likes
Looks like your sample code came from Atlassian’s promised Jira Front-end API. Atlassian never followed through (gasp) and now it’s just another source of broken documentation.
Just ‘jquery’ works for me:
require(['jquery'], ($)=>{console.log("Yay, got jQuery: ", $)})
or multiple vars:
require(['jquery', 'underscore'], function($, _) {
console.log("jQuery lib:", $);
console.log("Underscore lib:", _);
});
In Jira 9.12.x the available modules are shown on the filesystem:
cd $JIRA/atlassian-jira/includes
rg --no-filename -o “require(‘.*?’.” --type js | sort | uniq -c | sort -n
2 require(‘jira/issuenavigator/issue-navigator/shortcuts’)
2 require(‘jira/issuetable’)
2 require(‘jira/jql/jql-parser’)
2 require(‘jira/lib/class’)
2 require(‘jira/mention/mention’)
2 require(‘jira/mention/mention-matcher’)
…
8 require(‘jira/util/events’)
10 require(‘jira/ajs/ajax/smart-ajax’)
10 require(‘jira/legacy/namespace’)
10 require(‘jira/util/data/meta’)
11 require(‘jira/backbone-1.3.3’)
11 require(‘wrm/context-path’)
16 require(‘jira/util/formatter’)
26 require(‘underscore’)
73 require(‘jquery’)
2 Likes