antonmedv / monkberry

Monkberry is a JavaScript library for building web user interfaces
https://monkberry.js.org
MIT License
1.49k stars 78 forks source link

Server side rendering. #2

Open DylanPiercey opened 8 years ago

DylanPiercey commented 8 years ago

Randomly stumbled on this library - it looks awesome. One thing that seems missing is the ability to initially render on the server side.

Even internally using something like https://github.com/krisselden/simple-dom would help.

Ideally there would be a "monkberry-server" compiler that rendered a string instead of dom for isomorphic apps though.

// You could expose something similar to reacts renderString.
monkberry.renderString(...);

However I think the trickiest bit is "bootstrapping" existing dom so that you aren't destroying inputs and such when the js takes over.

If this was to be done I think a node-js "require hook" similar to babel and coffee-script would be handy as well to allow for isomorphic code when paired with monkberryify.

Something like:

require("monkberry/register");

Great work with this, although I haven't tested it out yet it looks very promising.

antonmedv commented 8 years ago

Hi,

I have plans to implement server rendering, via separation of compilers: DOM compiler and string compiler. There well be different compiled javascripts for string compiler. But now i don't know how to best integrate this in node.js.