andywer / andywer/threads.js

Documentation about parcel build is deprecated ? + tree-shaking not working

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

説明

Hi, I did some tests to package a library that depends on threads.js and is built with parcel-bundler.

For compatibility purposes with NodeJS and browsers the library is written in ES6 then compiled in CJS for NodeJS and bundled for CDN delivery.
What I discovered is that the recommended parcel import to register threads.js (described [here](https://github.com/andywer/threads.js/blob/master/docs/getting-started.md#build-with-parcel-bundler)) doesn't have any effect, and the library is working as expected without the `import 'threads/register'`. It also prevents users to properly build their application if they want to use webpack.

The CDN delivery method is not working as we can't import the worker as parcel automatically split the worker code in a different file.

I've created a test repository https://github.com/PacoDu/threads-package that defines a simple library using threads.js and implement multiple client softwares using this library.

Also the `--experimental-scope-hoisting` (tree-shaking) option of parcel is not working with threads.js it throws:
```
../node_modules/threads/dist-esm/worker/implementation.browser.js does not export 'default'
```

Maybe I'm doing this the wrong way. Do you have any recommendation for packaging threads.js in a library ? (maybe it should be a `peerDependencies` ?)

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

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

評価

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

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

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