andywer / andywer/threads.js

Working around ERR_PACKAGE_PATH_NOT_EXPORTED

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

説明

I'm trying to print your default thread size for a dry run purpose (without initialising a pool first).

```js
let {
dryRun,
threads = require('threads/dist/master/implementation').defaultPoolSize,
// ...
} = argv;

if (dryRun) {
console.log('threads', threads);
}
```

I'm having trouble updating to the latest version because of ERR_PACKAGE_PATH_NOT_EXPORTED. My workaround is:

```js
let {
dryRun,
threads,
// ...
} = argv;

let pool = Pool(() => spawn(new Worker('foo')), ...[threads].filter(Boolean));

if (dryRun) {
console.log('threads', pool.workers.length);
}
```

It works, but the original was more elegant. I know your implementation is simple and based on `cpus().length`, but I'd prefer not diverge from your default and start guessing wrong. What are your thoughts? Should a default config be exposed? If my workaround is what you recommend, feel free to close this issue. Thanks.

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

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

評価

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

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

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