Hi.
I apologize if this is a repeated question but the answers I found didn’t solve my problem.
I want to access a instance of a JS file in other JS file somewhere else im my project.
the structure would be somenthing like this:
Main.ux
<App>
<JavaScript File="someJS.js"/>
</App>
someJS.js
var someValue = "value";
module.exports = {
someValue : someValue
}
another.ux
<JavaScript File="anotherJS.js"/>
anotherJS.js
var otherValue = someValue;
I know that this is not the correct way to get this values but I already tried some things.
I’ve already tried to give a global name to my JS load markup but it dosent work.
Main.ux
<App>
<JavaScript File="someJS.js" ux:Global="nameSomeJS"/>
</App>
anotherJS.js
var nSomeJS = require("nameSomeJS");
var otherValue = nSomeJS.someValue;
this approach gives the following error
LOG: Error: JavaScript error in anotherJS.js line 1: Error message: Uncaught require(): module not found: nameSomeJS
File name: anotherJS.js
Line number: 1
Source line: (function(module, exports, require, popupAlert, showPopupEvent) { var t = require("nameSomeJS");
in Fuse.Reactive.JavaScript<C:\Users\AppData\Local\Fusetools\Packages\Fuse.Reactive\0.44.1\$.uno:1670>
I’ve also tried to require the JS file the but it generates a new instance of the module.exports object and the changes made in the required object does not propagate to the JS file loaded in the Main.ux file.
anotherJS.js
var nSomeJS = require("someJS.js");
nSomeJS.someValue = otherValue; //this works but not the way I want
I was able to achieve what I want using userEvents and functions in my JS file to access and change my variables but I was wondering if there is a more direct, and efficient way to do this.