Description
When using workerize-loader, things work great (it's a fantastic tool), except that it does not work in dev mode. This is because HotModuleReplacement gets loaded into the webworker and the HMR file references window
.
Describe the solution you'd like
I'd like to have the webpack configuration set output.globalObject
to 'this'
. The default is 'window'
. Changing it to 'this'
will have no negative impact on existing or future users, and it will allow people to begin using workerize-loader without ejecting.
Describe alternatives you've considered
You can manually modify the configuration in node_modules
(and just remember to do that anytime you re-install deps). Or you can eject.
Additional context
Before:
After:
This code is generated from this template:
Activity
set output.globalObject to 'this'
kentcdodds commentedon Sep 26, 2019
Made a PR for this: #7742. It's a simple change with no downside and plenty of upside :)
iansu commentedon Sep 26, 2019
Do you not have to eject to use
workerize-loader
?kentcdodds commentedon Sep 26, 2019
Nope :) Just use the loader import syntax (as documented in the workerize-loader docs) and it works (you do have to disable the lint rule for that to work, but it's not like you do this in many places in the app so it's NBD).
set output.globalObject to 'this' (#7742)
set output.globalObject to 'this' (facebook#7742)
Update cra fork (#2)
8 remaining items