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

Possiblity to use this with Webpack@5.x worker loading? #1031

Open
Nantris opened this issue Mar 17, 2021 · 1 comment
Open

Possiblity to use this with Webpack@5.x worker loading? #1031

Nantris opened this issue Mar 17, 2021 · 1 comment

Comments

@Nantris
Copy link

Nantris commented Mar 17, 2021

I'm wondering if there's any way to use this package without needing to assign our worker file to a <div /> to be "upgraded."

The problem is that our worker thread is being bundled via Webpack at the same time as the rest of our application and the output page is created using an HTML template. I'm not sure how it would be possible to assign the worker scripts to a div in this setup. Is there any way we can use the library in conjunction with the way Webpack bundles workers?

For reference, our code for creating our worker threads right now looks like this:

new Worker(new URL('./heavyLifterWorker', import.meta.url), {
  name: 'heavyLifter',
}),

and then Webpack is automatically bundling the worker chunk and injecting it into the page without any input from us. Is there any way to leverage Worker-DOM together with the built-in Webpack worker loading functionality?

@samouri
Copy link
Member

samouri commented Apr 20, 2021

Hey @slapbox,

It doesn't need to be a div specifically, but in order to use this package you need to assign a worker to a specific DOM node. In your template you'd need to specify the filepath of the generated worker bundle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants