How to declare ES6 js modules in Server plugins

Hi all,

I’m in the process of porting my Cloud and Server apps from pure vanilla .js to multiple ES6 .js modules. Primarily I’m looking to create re-usable components between generalPages, reports, dashboards etc.

From a cloud (Connect) perspective, this is fairly straight forward; just add ‘type=module’ to your main .js script and you’re off to the races.

However, I’m unsure of what the equivalent is in the server (SDK) space. In the atlassian-plugin.xml file the ‘type’ variable is already declared as ‘download’ when listing .js resources, example below:

 <web-resource key="jira-basic-view-resources" name="jira-basic-view Web Resources">
     <dependency>com.atlassian.auiplugin:ajs</dependency>
     <resource type="download" name="foo.js" location="/js/foo.js"/>
     <context>jira-basic-view</context>
 </web-resource>

Is there a way to properly declare .js resources as an ES6 module? Ideally I’d like to avoid using transpilers like webpack if possible, and I’ve already tried implementing frontend-maven-plugin but for the life of me couldn’t get it running.

Cheers,
Brad

2 Likes

AFAIK there is no support for type="module" in dc/server at the moment. But modern frontend configuration is likely to be added to plugin structure in the future (so you don’t have to do it manually).

Currently you would have to use a transpiler and frontend-maven-plugin.
If you have Jira source code, you can look at jira-frontend-plugin within it as an example for setting up modern frontend in Jira server plugin using Webpack and atlassian-webresource-webpack-plugin.

I also found this talk from a past conference about similar topic: https://youtu.be/VamdjcJCc0Y

1 Like

That’s right. It is tracked here https://ecosystem.atlassian.net/browse/PLUGWEB-418

1 Like

Thanks @tjoy & @dennis.fischer, good to know I’m at least in the right frame of mind and that this is being talked about internally.