-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Worker is not defined for target Node.js #12299
Comments
Because webpack/lib/dependencies/WorkerPlugin.js Line 37 in 923be31
Worker from worker_threads
|
@alexander-akait I need help. How do I use this syntax?
Is not valid and breaks typescript
How would I do this? |
Please also read the node.js documentation about how to use workers in node. It's a bit different compared to the browser. import { Worker } from "worker_threads";
new Worker(new URL(...)) |
@kevzettler answer above |
thanks yall. got it. |
Bug report
I am trying to use the new Webpack 5 native worker features. per @alexander-akait 's comment at webpack-contrib/worker-loader#301 (comment)
I was under the impression the worker support would work for both web workers and node.js worker-threads.
I understand the documentation is not yet ready and hope i'm missing something obvious.
What is the current behavior?
ReferenceError: Worker is not defined
in a
target:node
buildIf the current behavior is a bug, please provide the steps to reproduce.
I have created a minimal reproduction repository at: https://github.com/kevzettler/webpack5-worker-test
What is the expected behavior?
Per comment at: webpack-contrib/worker-loader#301 (comment)
and discussion at:
#6472 (comment)
I assumed
new Worker(new URL("./worker", import.meta.url))
would work in a Node.js targetOther relevant information:
webpack version:
Node.js version:
v12.18.1
Operating System:
macOs Mojave 10.14.6
Additional tools:
The text was updated successfully, but these errors were encountered: