Replies: 1 comment 4 replies
-
Hi @ravware, Functions defined within modules aren't added to the global object. That would constitute a side effect of module evaluation, and side effects are often considered undesirable. The module system aims to establish a standard mechanism for sharing script resources, and that mechanism is However, there are other ways. First, a module could deliberately create a side effect by leveraging import * as Test from 'module.js'
globalThis.TestStart = function () {
Debug.Message(Test.name);
} Another possibility is to import your module into a regular script. This is only possible with Dynamic Imports, which are disabled by default but can be enabled via import('module.js').then(exports => {
TestStart = () => {
Debug.Message(exports.name);
}
}); We don't see much difference between these approaches. Both use a small bit of throwaway code to expose module resources to regular scripts and the host application. Polluting the main module ("module.js") with side effects would be worse. Good luck! |
Beta Was this translation helpful? Give feedback.
-
Hello,
I looked through the examples, and tests and I am missing how to call a specific function using Modules.
Say this is the example:
And now say I want to call TestStart.
From the tests to call Modules there are a few parts:
Now when I try to call TestStart I get a can not be found error.
...Evaluate(docInfo,ScriptInMemory);
....Invoke("TestStart",null);
I tried different variations of referencing the function and I am wondering what I need to pass to call fire TestStart.
Beta Was this translation helpful? Give feedback.
All reactions