Do not set `global.self` if not needed
ohana54 opened this issue · 0 comments
ohana54 commented
Hi,
We have a node CLI that uses threads.js, and discovered that global.self
is being set by the library although it's not needed.
It is always being set here, even if the tiny-worker implementation is not needed:
threads.js/src/worker/implementation.tiny-worker.ts
Lines 14 to 16 in 545baa2
This happens because it is always imported and the code is running on the module level.
This causes other 3rd party code we have to assume it's running in a browser. There might be a better way for the 3rd party to detect whether it's in a browser, although I think regardless we should not set self
if not needed.
Would love to hear your thoughts, thanks!