The `render` port is trying to transmit a `Node` value:
11| port render : Html.Html a -> Cmd msg
^^^^^^
I cannot handle that. The types that CAN flow in and out of Elm include:
Ints, Floats, Bools, Strings, Maybes, Lists, Arrays, tuples, records, and
JSON values.
Would there be negative consequences, if ports were to allow VirtualDom.node to pass through?
VirtualDom.node is an opaque type. The main advantage of opaque types is that you are shielded from any change in the implementation. Serializing such an opaque type would mean that you would expose the implementation which would tie you to the implementation.
Problem with that approach is that you then cannot share code between server rendered and browser rendered. I have a lot of code that I share between both.
But I take your point about not exposing the implementation of VirtualDom.node. I suppose it would be helpful if VirtualDom exposed a toString function.
I believe elm-html-string exposes a the same API as elm/html so you could get your code to work on the client or server by replacing the import. Should be able to automate that during a build.
Server-side rendering Elm is a little hacky because there is no official SSR support (yet). But when it does land, I would expect something like React’s ReactDOM.renderToString.
Not going to work either, but it is a reasonable idea.
I am using rtfeldman/elm-css, and I chose that rather than elm-ui so that I could stick with using CSS for responsive rendering. That has elm/html as a transient dependency.
Maybe it’s a bit more heavyweight than you were hoping for, but sounds like a headless browser/browser automation tool would work? I’ve used Selenium + headless Chrome/Firefox before, there’s PhantomJS and a bunch of others I’ve never used, too. Send out a message through a port when everything’s rendered, so you know when to capture the page source.