andywer / threads.js

🧵 Make web workers & worker threads as simple as a function call.
https://threads.js.org/
MIT License
3.06k stars 164 forks source link

Unexpected Token #421

Open ttessarolo opened 2 years ago

ttessarolo commented 2 years ago

To avoid Unexpected Token Error, just use:

 const worker = await spawn(new Worker(new URL("./worker.js", import.meta.url)));

instead of:

const worker = await spawn(new Worker("./worker.js"))
andywer commented 2 years ago

Thanks for sharing, @ttessarolo!

We should document that somewhere… Feel free to propose a PR.

ttessarolo commented 2 years ago

@andywer remote: Permission to andywer/threads.js.git denied ;)

trasherdk commented 2 years ago

Fork on github, make changes on your fork, make pull request from your fork to here :)

rghaemifar commented 1 year ago

Thanks for sharing, @ttessarolo!

We should document that somewhere… Feel free to propose a PR.

I'm using typescript and it says new Worker only gets string: Argument of type 'URL' is not assignable to parameter of type 'string'