This seems quite possible from everything I've explored, and also is something I want to try soon. It's also interesting to use Nim through JS for a scripting layer for an application written in Nim; where they both communicate through shared data structures or something.
Here's a repo I found: https://github.com/Jipok/Nim-SDL2-and-Emscripten