Archi Forum

Archi Plug-ins => jArchi => Topic started by: mohitd on August 19, 2022, 15:52:51 PM

Title: jArchi Plugin: Support for external Javascript libraries and script files.
Post by: mohitd on August 19, 2022, 15:52:51 PM
Greetings,

I am working on a problem statement involving adding some transformation to the EA models based on mathematical computations.

I am trying to achieve these transformations on EA models via a script using the jArchi scripting plugin version 1.2.0. and the version of Archi I am using is 4.9.3. And I am also using JDK 11 with HotSpot JVM from Eclipse Adoptium (previously, AdoptOpenJDK ), which ships with the Nashorn scripting engine.

Now, I know that we can use external libraries like PapaParse using
load(__DIR__ + "lib/papaparse.min.js");
which works fine, but when I try to add a library like
load(__DIR__ + "lib/math.min.js");
the scripts fail to execute because of the Nashorn scripting engine.

After reading the documentation, I understood that the engine shipped with the JDK does not support all features of ES6 and has full support until ES 5.1. The documentation for the engine says it supports scopes like let and const, but when I run the script from the plugin, it fails. Also, the arrow function expressions commonly used in the foreach loop of JS are not working because of the lack of support from the JS engine.

With the above background information out of the way, I have the following questions,


Thank you,
Mohit
Title: Re: jArchi Plugin: Support for external Javascript libraries and script files.
Post by: Phil Beauvoir on August 19, 2022, 16:08:59 PM
Try it with the GraalVM engine which has been present in jArchi for some time. Just select that engine in Archi's preferences.
Title: Re: jArchi Plugin: Support for external Javascript libraries and script files.
Post by: mohitd on August 19, 2022, 16:11:53 PM
Hi Phil,

Thank you for your prompt response. I am very new to Archi, and I didn't know we could change the engine from preference. Thank you so much. This feature will save a lot of time.

Kind Regards,
Mohit