Elm compiler in the browser: for those interested in experimenting
I’ve been working recently on a harness for running the elm compiler in a browser, due to this thread in elm-dev https://groups.google.com/forum/#!topic/elm-dev/nwo0ivWrY80
This work bore fruit early on in that it was quickly possible to produce a single module output from the elm compiler, but until recently didn’t have all the necessary infrastructure to produce a full executable javascript file with all dependencies and runtime code.
As of today, it can compile and execute test programs in the fashion of elm-lang.org/try, doing the compute work locally. Javascript for the elm compiler, built with ghcjs, weighs in at around 12mb, but executes surprisingly fast. For those interested in compiling elm code in the browser, or importing the elm compiler from javascript code for some other reason, there’s now experimental code that allows one to do that. Error reporting especially is not great yet, so consider this more of a proof of concept than something ready to use in every context.
To try it out:
checkout https://github.com/prozacchiwawa/elm-lang.org with branch 20161105-browser-compilebuild elm-basic-compile from the 20161022-deps branch (note, building the browserified javascript takes a long time, possibly 10 or 15 minutes).copy elm-basic-compile/js/browsertest.js to elm-lang.org/assetsbuild and run elm-lang.org and browse to localhost:8000/try
I think there’s a lot of potential in being able to run the elm compiler in the browser, such as being able to check freshly typed code locally, being able to use elm to script and tweak larger javascript apps using embedded elm components, and being able to distribute atom or node apps that use elm without strictly needing to distribute native code.