Compiling to Javascript


#1

Hello everyone!

I’d like to write a program and compile it into Javascript so that it can be accessed via a web browser. I know about the emscripten project and the fact rustc can compile to LLVM. So… what is the typical workflow for turning your typical desktop codebase into a web app? I guess that you need to turn all of your dependencies into Javascript as well (for instance I have OpenAL, OpenGL and so on as dependencies…).


#2

There is no proper workflow yet.
We don’t even have proper emscripten support yet, we just landed a LLVM upgrade, that will help us bring this forward.

But even with that, it is nowhere near being a “just write it in Rust, compile and run it”.
You will always need to at least have some wrapper around what the web offers (DOM access, frontend APIs, etc., pp.)


#3

I guess that you need to turn all of your dependencies into Javascript as well (for instance I have OpenAL, OpenGL and so on as dependencies…).

Emscripten supports OpenAL and OpenGL out of the box, so you don’t need to port them. You do need to port other dependencies though.


#4

Ok, I see. Well, I’ll just test emscripten and post my experience with it then! :slight_smile:


#5

You might want to take a look at the talk named Interaction with real-world JavaScript from compiled Rust from the recent RustFest in Kiev.