Skip to content
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

Version 1.2.0 does not export function on worker instance in production mode #85

Closed
leifg opened this issue May 7, 2020 · 6 comments · Fixed by #90
Closed

Version 1.2.0 does not export function on worker instance in production mode #85

leifg opened this issue May 7, 2020 · 6 comments · Fixed by #90
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@leifg
Copy link

leifg commented May 7, 2020

I just upgraded to workerize-loader v1.2.0

When the worker instance is created, it does not have the exported functions attached to it.

All this only happens in the production build (development server works fine)

This the the output of console.log(instance) in development server (parseFormula is the exported function):

Worker {onmessage: null, onerror: null, parseFormula: ƒ}
  onerror: null
  onmessage: null
  parseFormula: ƒ ()
__proto__: Worker

When creating a production build, this is the output:

Worker {onmessage: null, onerror: null}
  onerror: null
  onmessage: null
  __proto__: Worker

I have a suspicion it might have something to do with this commit but I don't know enough about the project.

I call the worker like this

the worker function is defined like this

I know I am using the API differently than described in the README, however all of this worked in 1.1.0 and I also converted the examples exactly like described and it still did not export the function in 1.2.0.

@hlolli
Copy link

hlolli commented May 7, 2020

I was going to open a ticket too :D, all I can say, is that this is happening to me too. I can't see any exported function in my worker instance. But I could see everything in 1.1.0. That said, happy to see this project maintained, and hope it will work with webpack 5 in near future.

@bilwit
Copy link

bilwit commented May 7, 2020

I have the same issue. I forced "workerize-loader": "~1.1.0" in my package.json and it works perfectly fine after the build.

@developit
Copy link
Owner

Yikes! I'll take a look.

@developit developit added bug Something isn't working help wanted Extra attention is needed labels May 8, 2020
@shareefalis
Copy link

shareefalis commented May 10, 2020

You could basically do

if node is production build
{ don't export as a local cache object} 
else 
{ export as a local cache object }  

but that is a quick and dirty fix..

@developit
Copy link
Owner

A fix has been published in 1.2.1. Thanks all.

@titocosta
Copy link

Whenever there is a syntax error in the web worker file, you will see a "x is not a function" error first. So if you land here from google, check the web worker file first, problem on workerize was indeed fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants