diff --git a/src/esmock.js b/src/esmock.js index d5a28164..dde113b9 100644 --- a/src/esmock.js +++ b/src/esmock.js @@ -9,7 +9,7 @@ import esmockErr from './esmockErr.js' const esmockGo = opts => async (...args) => { const [moduleId, parent, defs, gdefs, opt] = esmockArgs(args, opts) - if (!esmockRegister && !await esmockLoader()) + if (!esmockRegister.register() && !await esmockLoader()) throw esmockErr.errMissingLoader() const fileURLKey = await esmockModule(moduleId, parent, defs, gdefs, opt) diff --git a/src/esmockRegister.js b/src/esmockRegister.js index 75f376e2..748cc001 100644 --- a/src/esmockRegister.js +++ b/src/esmockRegister.js @@ -19,10 +19,10 @@ const register = (res => () => { return res })() -export default msg => { +export default Object.assign(msg => { if (register()) { channel.port1.postMessage(msg) } else if (typeof global.postMessageEsmk === 'function') { global.postMessageEsmk(msg) } -} +}, { register })