Skip to content

Commit

Permalink
call function to detect initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
bumblehead committed Sep 9, 2023
1 parent 7763bd8 commit 67a5767
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/esmock.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/esmockRegister.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })

0 comments on commit 67a5767

Please sign in to comment.