Is there any lightweight library to turn the wasm text format in to binary in the browser? I've seen emscripten compiled versions of the desktop compilers but nothing else.
wat2wasm can do that (part of https://github.com/webassembly/wabt). Since it's C++, I guess you could compile to it (wat2wasm) to webassembly to run in the browser as a library, and if it's works, no need for separate web/desktop version.
You might be able to find something more lightweight over here though: https://github.com/xtuc/webassemblyjs but I didn't find what you were looking for (but just did a quick look)