developit / web-worker

Consistent Web Workers in browser and Node.
https://npm.im/web-worker
Apache License 2.0
1.06k stars 55 forks source link

FIX ReferenceError: Worker is not defined in shared worker #45

Open pubkey opened 9 months ago

pubkey commented 9 months ago

Currently when this package is used somewhere in between a Shared worker, simply the import/require will fail because it does not have the Worker API set on the globals. Uncaught ReferenceError: Worker is not defined

This PR adds a check for undefined and only exports the Worker API when it really exists.