andywer / andywer/threads.js

TypeError: _dist_worker_index_js__WEBPACK_IMPORTED_MODULE_0___default.a is undefined

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

説明

I'm trying to incorporate threads into a large existing Vue / Quasar app. So far, I've installed threads and threads-plugin, and set up the hello world example from the docs. My app calls a function `testWorker()`:
```
import { spawn, Thread, Worker } from "threads"
const testWorker = async () => {
const add = await spawn(new Worker('./test-worker.js'))
const sum = await add(2, 3)
await Thread.terminate(add)
return sum
}
```
and test-worker is just:
```
import { expose } from "threads/worker"

expose(function add(a, b) {
return a + b
})
```
The console error is:
```
TypeError: _dist_worker_index_js__WEBPACK_IMPORTED_MODULE_0___default.a is undefined 0.worker.js line 227 > eval:9:16
webpack-internal:///./node_modules/threads/worker.mjs:9
```
The webpack / babel setup for Vue / Quasar is quite complex, and I think I've added things where they should be (mainly, just added the webpack plugin at the appropriate point in the webpack config). I tried setting the plugin target to web and webworker, but the error is unchanged. The Babel modules option is `false` in the Quasar framework setup I believe, and I tried adding the setting like this in babel.config.js—again, no change in the error:
```
module.exports = {
presets: [
['@quasar/babel-preset-app', { modules: false }]
]
}
```

I'm assuming this is a configuration issue—any clues as to where to start digging further?

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

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

評価

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

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

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