developit / developit/workerize-loader

ReferenceError: regeneratorRuntime is not defined

Aperta
#71 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub
documentation question
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:
![image](https://user-images.githubusercontent.com/5295397/61249686-31709a80-a756-11e9-813d-1448ffaf1b33.png)

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.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.