Created
December 20, 2019 21:55
-
-
Save developit/551a9d19b58d7d6169cfae2c008586e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { wrap, expose } from 'https://unpkg.com/[email protected]/dist/esm/comlink.mjs'; | |
export default name => wrap(new Worker(import.meta.url, { env:{name}, type:'module' })); | |
if (process.env.name && !self.document) { | |
const q = []; onmessage = q.push.bind(q); | |
import(process.env.name).then(expose).then(() => onmessage = q.map(dispatchEvent)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment