Including libraries in js Interface Asset

Hi,

I am trying to write an Interface Asset. I would like to include external libraries. As far as I have seen there is no word on how to include dependencies.
I am assuiming there is some magical way the built-in runtime envorenment does this (apparently the SimpleCounter example works even though any no nodejs debugger will execute it)

I have tried listing my dependencies in the .ifd-file… that just throws an execption. So I am at as to how this should work…

Hi Max,

I recommend you to add a Clock Interface Asset in a blank experience, right-click it, then “Open File location”.

It will open the folder where this IA is stored and you will be able to dig in and see how it includes moment.js library.

As you guessed, the reference is in the Clock.ifd file:

"if.dependencies": [
   "EventEmitter.js",
   "moment-with-locales.js",
   "moment-timezone-with-data.js",
   "Clock.js"
],

Then you will be able to use the library in the associated Clock.js file

Don’t forget, as pointed in the related article, when including a library:

Some common Web browser JavaScript properties and methods, implemented by the ‘window’ object - such as ‘location’ - are not available. As a result, your IA must rely on JavaScript code only and will not work with libraries such as JQuery, Dojo and so on.

Also, if you haven’t done it already, I recommend our Video Lesson “Create a Custom Interface Asset Using JavaScript” from the Connecting to the World Course in Intuiface Academy.

Regards,

Alex.

hi,

okay if I include the libraries in the .ifd file I get this in the Trace.log:

14.12.2020 16:01:35+01:00 : 26156 : Error : Unable to create protocol from descriptor: 'C:\Users\maximilian.berthold\Documents\IntuiFace\Project 1\Files\InterfaceAssets\EcClient\EcClient.ifd'. - inner exception level 1
14.12.2020 16:01:35+01:00 : 26156 : Error : ReferenceError: exports is not defined in 'undefined':   bei Noesis.Javascript.JavascriptContext.Run(String iSourceCode)
   bei IntuiLab.Assets.ExternalAssets.Protocols.JavaScript.IFWExternalAssetJavaScriptProtocol.Init()
   bei IntuiLab.Assets.ExternalAssets.Protocols.IFWExternalAssetFactory.CreateProtocolFromDescriptor(IIFWServicesLocator servicesLocator, IFWExternalAssetDescriptor descriptor)
   bei IntuiLab.Assets.ExternalAssets.DomainComponents.IFWExternalAssetDCVM.LoadDescriptor(String strNewDescriptorPath)

Any way around that? I’ll have a look at the course now…

For such specific and maybe a little complex topic, I recommend you to open a ticket on Support.