You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am able to use worker-loader in a simple webpack bundled app to import web worker into my APP. But how to do the same thing in CRA, i also want the capability of importing other modules to my web worker to do those tasks inside web worker.
As I mentioned before, we can't provide support for ejected setups. There are too many unknowns and we have limited time to help. I'd suggest reading over the worker-loader docs and maybe trying to get this working in a fresh project first.
I'm going to close this now as work on this feature is already underway.
Yes, you can't currently use Web Workers in Create React App until #3934 is merged and released.
I'm not really sure what you mean about importing modules into the worker. The worker files are run through babel-loader just like all the other JS so you should be able to do all the same things, including importing modules.
Activity
iansu commentedon May 23, 2018
We are hoping to add support for Web Workers and
worker-loaderin react-scripts 2.0: #3934subhranshudas commentedon May 23, 2018
@iansu thanks for the reply, any way to do it if i am using an ejected setup? use the same changes of #3934 to
config\webpack.config.*.js??iansu commentedon May 23, 2018
We don't support ejected setups but that will most likely work. If not then check out the
worker-loaderdocs.subhranshudas commentedon May 23, 2018
i tried with whatever is provided in the worker-loader config
package.jsonwebpack configApp.jsworker.jsERROR
TypeError: _Worker2.default is not a constructor
iansu commentedon May 23, 2018
As I mentioned before, we can't provide support for ejected setups. There are too many unknowns and we have limited time to help. I'd suggest reading over the
worker-loaderdocs and maybe trying to get this working in a fresh project first.I'm going to close this now as work on this feature is already underway.
subhranshudas commentedon May 23, 2018
Ok. thanks for the information.. the above error was from a fresh project...
subhranshudas commentedon May 23, 2018
@iansu one quick thing i noticed
in your PR #3934
so when i eject CRA, in
package.jsoni don't see this module. Is it needed to have your other changes work?iansu commentedon May 23, 2018
Yes, that module is required. You'll have to install it yourself since you've ejected.
subhranshudas commentedon May 24, 2018
@iansu and as of now in non-ejected CRA there is no way we can use web workers apart from
react-app-rewiredas explained in https://medium.com/@danilog1905/how-to-use-web-workers-with-react-create-app-and-not-ejecting-in-the-attempt-3718d2a1166bAs per #1277 (comment) i don't see how we can ES6 import several modules which i want to process in the worker itself.
iansu commentedon May 24, 2018
Yes, you can't currently use Web Workers in Create React App until #3934 is merged and released.
I'm not really sure what you mean about importing modules into the worker. The worker files are run through
babel-loaderjust like all the other JS so you should be able to do all the same things, including importing modules.subhranshudas commentedon May 30, 2018
@iansu thanks for the reply, when is
coming out. any expected timelines.