-
Notifications
You must be signed in to change notification settings - Fork 40
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
TypeError: Worker is not a function #26
Comments
|
@GlenHughes I had the same issue. Do you have |
I am getting the same error from code that worked fine until I upgraded react-scripts to 4.0, which introduced Webpack 4.0. Here is my code: /workers/storage.worker.js:
/index.js:
And the error message happens every time, in every browser, in development and production mode. Again, this worked fine before the upgrade to react-scripts 4.0.0. |
Update: downgrading worker-loader to 2.0.0 fixed the issue. When I upgraded react-scripts, I apparently also upgraded the worker-loader package. I created a new project with create-react-app, added a simple test worker and added a line to load it in index.js and it failed with the error referenced above (Worker is not a function). So apparently worker-loader 3.x does not work with comlink-loader with newer React apps made with create-react-app. Replication steps:
|
I would not suggest you install |
My program uses react-pdf, which requires worker-loader ^3.0.0. So if I do not specifically install worker-loader ^2.0.0 in my package.json, it uses worker-loader 3.0.5 and fails immediately. I imagine there are a number of other programs that require the 3.0 branch. Would it not make sense to make comlink-loader work with the latest stable branch? |
@outlawpractice that would be cool to upgrade the worker loader to the latest version. I am not sure if I can do it. Will see. |
+1, the same |
I'm trying to implement comlink into a project. I'm currently getting a
TypeError: Worker is not a function
error thrown in the console but the code compiles fine without any warnings or errors."comlink": "^4.3.0"
"comlink-loader": "^2.0.0"
How I'm using comlink-loader:
import MyWorker from "comlink-loader!./assets/worker.js"
const worker = new MyWorker()
I also want to inline the workers so they are included within the webpack generated bundle. Is this possible?
The text was updated successfully, but these errors were encountered: