You could achieve this result of converting a
main : Html msg
into a static, JS-free HTML file using the existing compiler and ecosystem of tools.
I can’t see a good way of doing it this way. The problem I am seeing is: I can’t see a way to access the whole document (including <head>
for example) with the elm architecture… So if I would just print my elm/node.js Dom to stdout, wouldn’t it be missing something, which I am in no direct control of ?
I understand your points, but I think it would make a lot of sense for the compiler to care about this.
Have a look at this topic: "Native Code" in 0.19
There is this entry:
- Portability. Elm will likely compile to WebAssembly some day. It may target other domains, like servers where there is no JavaScript. It would be hugely valuable if the entire Elm ecosystem works across a boundary like that.
What I am basically thinking about is, is adding another compile target: Html.
If that would be possible, you would even have a basic approach to generate Html in the backend for servers natively.
Since there is no way in Elm to interact with stdout directly, creating specific tools like this, is somehow something, which runs outside of the scope where the Language itself might go. For example, I wonder what would happen to those tools, if Elm would switch to WebAssembly as a compile target ?