donejs / done-ssr

Server Side Rendering for DoneJS
https://www.npmjs.com/package/done-ssr
MIT License
23 stars 11 forks source link

Allow to be used with any DOM implementation #124

Open matthewp opened 8 years ago

matthewp commented 8 years ago

Currently we rely on can/util/vdom/vdom but it would be nice if it could work with jsdom since that is more robust.

matthewp commented 8 years ago

Deferring this for now, it's harder than it sounds. Currently canjs maps can/util/vdom/vdom to load on the server, so we'd want to disable that somehow when using an alternative implementation.

matthewp commented 7 years ago

This should be possible now with can 3.0. We no longer shim any libraries.

matthewp commented 7 years ago

Just a matter of picking an API now. We need to be able to receive a window object that is distinct for each request. So if the user provides their own DOM implementation a function makes most sense. My first thought is:

const ssr = require("done-ssr");
const { JSDOM } = require("jsdom");

function makeDom() {
  var dom = new JSDOM();
  return dom.window;
}

const render = ssr({}, {
  dom: makeDom
}); 
matthewp commented 7 years ago

cc @justinbmeyer what do you think about the above API?