[SOLVED] New Worker causing build fail

So when building the project or turning on concatenate scripts option on launch, I happend to get this sort of error. Saying Documents or pc is not defined on scripts. Strangely, that code do work no matter the error happens or not

since error happens nevertheless code is working or not, I think it is some issue happening when merging script to one file.

through the excluding scripts and adding “//” to scripts, I think I found the one causing problems.


when defining new Worker, it seems like build is failing.
when adding citation to all code using new Worker, building project seems to go without error.
What is the cause of this, and what is the way around this?

Is the worker script part of the project assets or are you fetching it from some other server?

CC @Mark_Lundin

its part of project asset. I’m getting it through project attribbute

Hmm, then it should work. There was a recent issue with it, but was fixed and it works for me:

When you say “building fails” what do you mean exactly? Do you have any error messages from console to share?

Hey @Deanies I’m not 100% but this could be an editor parsing issue, but I can’t really tell. Can you provide a simple test case that replicates the issue, and I can take a look on my end

Thank you all for answer. I think our team found what is the problem. We were getting script through file url, which was getting merged script url. So worker was registering whole script, not the file intended.


We could try to register txt rather than js, so script wont be merged, but I think that solution is not clean enough. Or Is there option to prevent script from being merged?

Thank you for the find! I was able to reproduce and created an issue for tracking:

For short term, no sure there is an elegant workaround, apart from what you mentioned.

1 Like

Set preload = false to the worker script asset to exclude it from concatenation, that should fix the error.

I think there is rarely a reason to preload worker scripts since the worker will request the file separately.


yep, so the worker script unfortunately gets concatenated into the main build. Something we should hopefully fix in the upcoming ES Module support. for now you probably want to use an inline worker

1 Like

Ahh of course, that’s a much better option :laughing:

1 Like