Ok, some last notes in case others are interested in it. Installing Cheerp was 
much quicker / easier than either `brew install llvm` or emscripten's setup.

It appears the Cheerp/clang++ works well with Nim output and strips any 
unneeded items. For a basic hello-world the `.wasm` output is only 88B, wow! 
The JS output is 1.3kb. IIRC, the default emscripten output was much larger.

The javascript integration is pretty nice, though Nim code doesn't work with 
the `[[cheerp::genericjs]]` style functions. On that side either use `nim js` 
or JS. The `[[cheerp::exportjs]]` annotations would probably work, but might be 
easier to manually wrap a C++ function over a Nim one.

Though you can do things like this too which:
    
    
    {.emit: """
    [[cheerp::genericjs]] void domOutput(const char* str)
    {
      client::console.log(str);
    }
    """.}
    
    proc domOutput(msg: cstring) {.importc, header: "cheerp/clientlib.h".}
    
    proc webMain() {.exportc.} =
      domOutput("hello world!")
    
    
    Run

Here's an example 
[config.nims](https://github.com/elcritch/cheerp/blob/main/tests/config.nims) 
that compiles a JS/WASM output. 

Reply via email to