Hi Remi,
You are thinking synchronous, while writing asynchronous code. This is the tricky part of Javascript
https://blog.bitsrc.io/understanding-asynchronous-javascript-the-event-loop-74cd408419ff
you have to scope your access of you code correctly, like:
function RequireExternalModule() {
// BEGIN USER CODE
let val;
console.log("Before");
require(["test1"], function (test2) {
console.log("Callback");
val = test2;
console.log("Log in js action");
console.error("Error in js action");
return val.hello();
});
console.log("After");
// END USER CODE
}
Cheers, Andries