Support for complate
moonglum opened this issue · comments
Code by @FND and @tillsc. Entrypoint is supposed to be a "pseudo file"
tmp.jsx:
import Renderer, { createElement } from "complate-stream";
import BufferedStream from "complate-stream/src/buffered-stream";
export { Renderer, BufferedStream };
export let render = <p>lorem ipsum</p>;
bundle_on_demand.js
let Bundle = require("faucet-pipeline-js/lib/bundle");
let bundle = new Bundle("./_tmp.jsx", null, {
exports: "VIEW",
jsx: { pragma: "createElement" }
}, {
browsers: {}, // FIXME: should not be necessary
resolvePath: function() { // FIXME: should not be necessary
throw new Error("should never be invoked?");
}
});
module.exports = bundle.compile().
then(({ code, error }) => {
eval(code);
let { render, Renderer, BufferedStream } = VIEW;
let renderer = new Renderer();
let stream = new BufferedStream();
renderer.renderView(() => render, {}, stream);
return stream.read();
}).
then(res => {
console.log(res);
});
See rollup/rollup#2509 for details on pseudo files
Support added via #7