"require is not defined" when trying to use the native jira macro inside a macro body

We are fetching our macro bodies by converting the content using the rest/api/contentbody/convert/styled_view? endpoint. We also expand the following: webresource.superbatch.metatags,webresource.superbatch.tags.all,webresource.tags.all and add the returned scripts to the head section of our macro.

When trying to use a Jira macro as macro body of one of our macros, the Jira macro won’t load (it will display but the loading spinner will just keep spinning), with the following console errors (multiple times):

  • ReferenceError: define is not defined
  • ReferenceError: jQuery is not defined
  • ReferenceError: require is not defined
  • ReferenceError: AJS is not defined

I suppose we need to load another script but I’m unsure where to get these from. Does anyone know?

Thanks

3 Likes

The reason for this problem is a race condition in the order in which resources are loaded on the page. If all tags are loaded simultaneously, this issue will arise. To resolve it, load “webresource.tags.all” after “webresource.superbatch.tags.all”.