Allow for convenient calling of bootModule with an exports dict.

This commit is contained in:
Tony Garnock-Jones 2018-11-13 20:53:24 +00:00
parent 5fe6eddcfe
commit 5d314f01db
1 changed files with 11 additions and 1 deletions

View File

@ -82,7 +82,17 @@ Ground.prototype.addStopHandler = function (h) {
function bootModule(mod) {
let g = new Ground(() => {
Dataspace.activate(mod.exports);
if (Dataspace.BootSteps in mod) {
// It's really an exports dict, not a module.
Dataspace.activate(mod);
} else if ('exports' in mod) {
// It's probably a module.
Dataspace.activate(mod.exports);
} else {
const e = new Error("Cannot boot Syndicate module");
e.irritant = mod;
throw e;
}
});
if (typeof document !== 'undefined') {
document.addEventListener("DOMContentLoaded", (e) => { g.start(); });