Following the docs here: https://nim-lang.org/docs/backends.html#backends-the-javascript-target
I have the following code in fib.nim
proc fib(a: cint): cint {.exportc.} =
if a <= 2:
result = 1
else:
result = fib(a - 1) + fib(a - 2)
If I run nim js -o:fib.js fib.nim
then it compiles it to JS.
How do I then run fib from nodejs? In the example, its an html file and a browser, but on node, I cant figure out how to import the fib function. It looks like the .js file is missing the exports
. How can I build the nim module so that nodejs can import it?