-
Notifications
You must be signed in to change notification settings - Fork 79
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
Creating a worker on electron doesn't include Node.js #53
Comments
I'm using |
Hiya - this module bundles Web Workers, not Node workers_threads. I think it might be possible to add an option for outputing worker_threads, but I worry that FWIW it seems like in Electron you're getting a Web Worker. For a lot of use-cases, especially when you've already bundled source with Webpack, that might be a reasonable approach. One thing you could try to get this working without any library changes would be to import the correct worker implementation yourself: const { Worker } = require('worker_threads');
const worker = new Worker("./worker.js", { type: "module" }); |
I'm actually going to close this issue since it's a duplicate of #10 - we can continue discussion there! |
Hey @developit - I'm also facing this issue. My use-case is to use OffscreenCanvas within a Worker, which is impossible in a worker_therad as OffscreenCanvas is a browser API, not a NodeJS one. However I need access to NodeJS to use a native module (Electron docs say to avoid doing this, but so-far it has been successful). I'm trying to migrate from |
@2xAA did did you manage to workaround this issue? Im facing it too.. |
@edenhermelin Unfortunately not. I wrote some pretty awful Worked for a while but has broken with Electron 11 for some reason. |
I'm trying to solve this exact issue also. @edenhermelin or @2xAA did either of you figure this out? I also followed the directions in #75, which DOES let me create a worker from the |
@developit can we re-open this issue? It is not the same as creating a node worker. What this is about:
|
Nope, sorry. vcync/modV@81eac0a#diff-7b4e11be73603a3ee2c4d37bd49f053930d6056507a005e5639cea7c15686d5fR7-R14 |
Hi, amazing library.
I'm having problems because when I create a simple worker like this one:
If I create the worker like this:
var worker1 = new Worker('./workerTest.js');
It works, but when I create the worker like this:
var worker2 = new Worker('./workerTest.js', { type: 'module' });
It shows this message
Module not found: Error: Can't resolve 'child_process'
meaning that theworker2
doesn't includeNode.js
. I don't know if I should include another option apart fromtype: 'module'
or if this is not supported by this library.Also, I can't use
worker1
method because the real worker is more complex and has a lot of imports.The text was updated successfully, but these errors were encountered: