Hi @fboucquez, I will find some time to check your example later this afternoon and update this comment with what I can figure out for you.
jira/projects/sidebar/expansion-manager module doesn’t get defined, which means things depending upon it don’t work, which means other files stop working, and so on and so forth.
The problem is emanating from Jira’s instantiation of the
moment library. The curious thing is that moment registers itself just fine on most other pages… what’s special about this one?
It turns out the problem is due to a bad interop between Webpack, Babel Runtime (core-js), Moment, Jira, and its JS libraries.
- Your webpacked code includes the babel-runtime and babel-polyfill code – aka, core-js. The code in core-js defines
var global = // effectively window.
- Moment.js tries to be a good citizen: if it sees that
global exists, it exports itself to that. Otherwise, it exports itself to
- The presence of core-js makes it export to
- JSLibs expects
global to not exist, so that moment will be exported to
- JSLibs fails to register the library correctly as an AMD module.
- Jira doesn’t pick up the library.
- The cascade of errors begins.
This is, in essence, a latent bug in Jira. As such, I’ve raised https://jira.atlassian.com/browse/JRASERVER-67644.
Of course, the bug is only caused if
window.global is defined. How is that getting on to the page? Through your inclusion of
babel-polyfill in your feature’s entrypoint.
To avoid this, I can see two options:
- Compile to es5 syntax; avoid use of the features that require the
babel-polyfill at runtime (mainly the new primitives like
- Install the
transform-runtime babel plugin, then configure it to include the stuff you need in a way that does not pollute the global scope:
I’m aware of discussions within the Atlassian developer community about
babel-polyfill and the runtime that products like Jira provide. As more vendors try to use language features that don’t exist in Atlassian’s supported browsers, interoperability problems like this continue to crop up. It may make sense for Atlassian products to provide a common runtime, though there are tradeoffs and risks to consider. That’s a separate discussion which I’ll start elsewhere.
Hope that helps get you unstuck in the short term.