developit / developit/workerize-loader
ReferenceError: regeneratorRuntime is not defined
- Lingua principale
- JavaScript
- Stelle
- 2.3k
- Fork
- 85
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
I'm trying to use this library with Babel and TypeScript, but I'm getting a weird error.
```ts
// queue.worker.ts
import { TrackData } from "modules/track/types"
import { shuffleArray } from "common/lang/array/helpers/shuffleArray"
export async function getShuffledTracks(tracks: TrackData[], active: number) {
return shuffleArray(tracks).sort((track) => (track.id === active ? -1 : 0))
}
```
```ts
// somewhere.ts
import * as QueueWorker from "../queue.worker"
const worker = (QueueWorker as any)() as typeof QueueWorker
// somewhere in the file
await worker.getShuffledTracks(...)
```
Then, when the function is called, I get this error:

This is what the config for the loader looks like:
```js
const workerRule = {
test: /\.worker\.ts$/,
use: [
"workerize-loader",
{
loader: "babel-loader",
options: {
presets: [
[
"@babel/env",
{
modules: false,
},
],
],
},
},
],
}
```
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.