andywer / andywer/threads.js

Do not set `global.self` if not needed

オープン
#412 コメント 0 件 リアクション 2 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
3.5k
フォーク
173
PR マージ指標
30日以内にマージされた PR はありません

説明

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: https://github.com/andywer/threads.js/blob/545baa2533b25735b9e08b8b95c4d07a9a28120c/src/worker/implementation.tiny-worker.ts#L14-L16
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!

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。