developit / workerize-loader

🏗️ Automatically move a module into a Web Worker (Webpack loader)
https://npm.im/workerize-loader
2.31k stars 86 forks source link

SharedWorker support #38

Open Buom01 opened 6 years ago

Buom01 commented 6 years ago

Hi,

Does the shared worker feature is planned ? I also think that it could be nice for your Stockroom's state management system

developit commented 6 years ago

I believe worker-loader supports it. Isn't SharedWorker deprecated though?

Buom01 commented 6 years ago

worker-loader don't seem to support it: https://github.com/webpack-contrib/worker-loader/search?q=shared Else I don't think that SharedWorker are deprecated, but to be honest I don't used it a lot: There are not deprecation mentions on: https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker

I think that I will try to implement it in free time

Lemmmy commented 3 years ago

It looks like worker-loader now implements this by letting you change the constructor name: https://github.com/webpack-contrib/worker-loader/blob/08fa5c5c9984b9dda46c422d65ef83c92f2ef368/README.md#worker

I don't know if a similar thing could be applied to workerize-loader (given that SharedWorkers require you to use .port) somewhere around here: https://github.com/developit/workerize-loader/blob/7f649ef9857010449707d191a12e3abaae38c069/src/index.js#L158