From 5d314f01dbebbecb02eab0c21ec05975eb77de34 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Tue, 13 Nov 2018 20:53:24 +0000 Subject: [PATCH] Allow for convenient calling of bootModule with an exports dict. --- packages/core/src/ground.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/core/src/ground.js b/packages/core/src/ground.js index 277264d..c16307f 100644 --- a/packages/core/src/ground.js +++ b/packages/core/src/ground.js @@ -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(); });