import NakamaJs from "./pc-nakama.min.js";
var nakama = new NakamaJs(param1, param2, param3, param4, param5);
using the engine-only works but i need to import my Module inside a Playcanvas script or find a way to load it.
[Solution]:
Instead use the name of the object (‘NakamaJS’) use ‘module.default’
Example:
var module;
(function() {
var asset = pc.Application.getApplication().assets.find('pc-nakama.min.js');
async function load() {
module = await import(asset.getFileUrl());
var nakama = new module.default(params, params..);
}
load();
})();
yeah it works, but i need to apply it using the editor. I tried something like, but it tells me that the object i want to construct (NakamaJS) is not defined:
(function() {
var asset = pc.Application.getApplication().assets.find('pc-nakama.min.js');
async function load() {
let module = await import(asset.getFileUrl());
//client = new nakamajs.Client("defaultkey", "134.209.219.5", "7350");
var nakama = new NakamaJs(param, param, param, param, param);
}
load();
})();
In that code, check what module variable is in the debugger. I’ve not used modules in the Editor before but I think that contains the module objects/functions etc.