Native JavaScript Modules

Hi,

Ive been playing around with creating my own modules but I cant seem to get them to load properly. Ive tried the code from the docs (https://www.fusetools.com/docs/native-interop/native-js-modules), but still seem to get the following error:

Error: : Error message: Uncaught require(): module not found: MyLogModule

Following is the setup I am using:

MyLogModule.uno:

using Fuse;
using Fuse.Scripting;
using Uno.UX;

[UXGlobalModule]
public class MyLogModule : NativeModule
{
    static readonly MyLogModule _instance;

    public MyLogModule()
    {
        // Make sure we're only initializing the module once
        if (_instance != null) return;

        _instance = this;
        Resource.SetGlobalKey(_instance, "MyLogModule");
        AddMember(new NativeFunction("Log", (NativeCallback)Log));
    }

    static object Log(Context c, object[] args)
    {
        foreach (var arg in args)
            debug_log arg;

        return null;
    }
}

Main.ux

<App>
	<Panel>
        <JavaScript>
            var LogModule = require("MyLogModule");

            LogModule.Log("Hello from JavaScript!");
        </JavaScript>
    </Panel>
</App>

LearnFuse.unoproj

{
  "RootNamespace":"",
  "Packages": [
  	"Fuse",
  	"FuseJS"
  ],
  "Includes": [
    "*",
    "MyLogModule.uno:Source"
  ]
}

What am I doing wrong?

Hi kvhauw,

that second line in Includes is not necessary, since the * includes any .uno files at the project root.

Did you run uno clean and rebuilt the preview?