Rescript compiler + ninja working in the Browser - Rescript Web IDE

Just wanted to let you guys know that I finally got an early prototype of a rescript web IDE running! The ninja part is probably far from optimal, because that’s the first c++ code I have ever written/dug into, same thing with ocaml… So I basically removed this code part: ninja/ at 3a477ee7cac769d25f0a8993612a7ea59411e48c · rescript-lang/ninja · GitHub and replaced it with this:

  while (pending_commands >= 0) {
    if (Edge* edge = plan_.FindWork()) {
      string command = edge->EvaluateCommand(true);

      printf("RUN_CMD %s \n", command.c_str());

      for (int i = 0; i < edge->outputs_.size(); i++) {
        Node* subnode = edge->outputs_[i];

        for (int i = 0; i < subnode->out_edges().size(); i++) {
          Edge* subedge = subnode->out_edges()[i];
          string subcommand = subedge->EvaluateCommand(true);

          printf("RUN_CMD %s \n", subcommand.c_str());


Because it would get stuck when trying to execute a bsc.exe command with posix_spawn at: ninja/ at 3a477ee7cac769d25f0a8993612a7ea59411e48c · rescript-lang/ninja · GitHub

Not sure if this will even spit out all cmd’s, only tested it with a 2 .res files project, but I’m able to generate all the .ast .cmi .cmt .cmj files and can analyse them with a browser version of rescript-vscode/analysis at master · rescript-lang/rescript-vscode · GitHub. And real binary format, not base64 encoded.

So now ninja probably never cleanly finishes it’s stuff and always does a full rebuild, it actually builds nothing and just works as a .ninja file parser/reader, I think.

Is this even the right approach, running ninja in the browser? Maybe a bit overkill? I have already spend way too much time on this, but I could imagine emulating this posix_spawn call with a webworker postMessage. So if you have any tipps/ideas/hints on how to get ninja working, please let me know!

Anyways, for me that’s the coolest project I have ever worked on and I absolutely Love Rescript! I always had an eye on reasonml and after the recent syntax changes I gave rescript a try and boom :smile: (dumped all my typescript code)

Next part will be building a repl, something like has.


This is really cool! :smiley::+1:

1 Like

Very cool! Great work @adrianhunter

Amazing @adrianhunter! I’ve been working on creating a new tab for the react output from the official playground. Seeing that something much larger is being done is awesome! I’m eager to test it.

For the compiler on the web, another interesting route might be going through sebmarkbage/ocamlrun-wasm: OCamlrun WebAssembly - OCaml Bytecode Interpreter in WASM (, it might be slower, but it is more faithful in the semantics, e.g, proper tailcall

1 Like

Ah, interesting. Thanks for the link! I’m so happy that I currently got the basics working, maybe I can give this a try when running into issues with larger code bases