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

Request to support third party packages in worker threads #17

Closed
johnfung95 opened this issue Jan 29, 2024 · 5 comments · Fixed by #20
Closed

Request to support third party packages in worker threads #17

johnfung95 opened this issue Jan 29, 2024 · 5 comments · Fixed by #20
Labels
documentation Improvements or additions to documentation feature request requesting a new feature

Comments

@johnfung95
Copy link

johnfung95 commented Jan 29, 2024

Hi, I came across your package and tried to use the worker function.
However, I received the following error when running.
ReferenceError: moment__WEBPACK_IMPORTED_MODULE_0___default is not defined

Any idea on the resolution?

@johnfung95 johnfung95 added the question Further information is requested label Jan 29, 2024
@johnfung95
Copy link
Author

I suspect the problem is related to the usage of third-party library because I am currently adopting moment js in the build. Is it a bug? I am unsure, but I guess one workaround is to abandon third-party package usage when using the useWorkerFunc?

@jpwallace22
Copy link
Owner

jpwallace22 commented Jan 29, 2024

@johnfung95 A snippet of the use code would help me deduce more of what is going on in this use case. But from what you are describing, it sounds like you are attempting to load a third party resource into the web worker. This won't work because of restrictions with the worker thread.

I am currently (slowly) working on a way to transport third party resources.

@johnfung95
Copy link
Author

johnfung95 commented Jan 30, 2024

@jpwallace22 thanks for your reply. There is not too much going on in my program, basically just a function call with the moment js and return a value. But the code always stops in the moment js usage line.

import moment from "moment";
const dates = moment().utc().format("YYYY-MM-DD"); <======= error in here

where it becomes moment__WEBPACK_IMPORTED_MODULE_0___default().utc().format("YYYY-MM-DD"); from the source code panel in the browser. That's why raising the aforementioned undefined error.

By the way, I tested my program without the moment js and it works just fine. Therefore it is very likely due to the restriction of using third-party resources in the worker thread (as you mentioned).

I think I can find a workaround for my problem.
Thank you for your effort and progress in maintaining this repo. 🙏

@jpwallace22
Copy link
Owner

jpwallace22 commented Feb 4, 2024

@johnfung95 I'm working on the docs to transfer third-party resources over to worker as well. I'm ging to switch this over to a feature request, and hopefully I can hop on it soon!

@jpwallace22 jpwallace22 added feature request requesting a new feature and removed question Further information is requested labels Feb 4, 2024
@jpwallace22 jpwallace22 changed the title Error when using the package Request to support third party packages in worker threads Feb 4, 2024
@Rushclin
Copy link

Rushclin commented Mar 7, 2024

Same error

@jpwallace22 jpwallace22 added the documentation Improvements or additions to documentation label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation feature request requesting a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants