[sr-dev] [kamailio/kamailio] KEMI jsdt CommonJS-based module support (Issue #3037)

Ian Carlson notifications at github.com
Wed Feb 23 13:07:16 CET 2022


### Description

Kamailio uses Ducktape 2 without module-node or module-ducktape, requiring all routing in a single file.  

https://wiki.duktape.org/howtomodules

I'm attempting to add module-node support and creating this issue to track with PR.

Response from mailing list

> Hello,
>
> I didn't notice that require() was not in the duktape 2.x, I will try to add support for module-duktape when I get a chance. If someone wants to do it, pull requests are welcome -- it does not seem to be complex:
>   * https://github.com/svaarala/duktape/tree/master/extras/module-duktape
> The module-node sounds interesting, but not being familiar with node.js, looks it need more work to enable it:
>   * https://github.com/svaarala/duktape/tree/master/extras/module-node
>
> Cheers,
> Daniel


### Expected behavior
Include the required() JS file
`
var test = require('./test');
`

#### Actual observed behavior
Calling require() in a JSDT script throws TypeError: undefined not callable

#### Log Messages
```
ERROR: app_jsdt [app_jsdt_api.c:448]: jsdt_kemi_load_script(): failed running: TypeError: undefined not callable
```

### Possible Solutions
I played around a little with `module-duktape` but wasn't smart enough to define a `Duktape.modSearch()` that would work as desired.  I'm probably missing something obvious.  I've recently been playing with `asterisk/node-ari-client` which got me curious if `module-node` might be more aligned with thinking.


### Additional Information
  * **Kamailio Version** - kamailio 5.5.4





-- 
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/3037
You are receiving this because you are subscribed to this thread.

Message ID: <kamailio/kamailio/issues/3037 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20220223/c858dcb0/attachment.htm>


More information about the sr-dev mailing list