Worker bundle crashes: set output.globalObject
@sungodtemple▲ 0 net votes
A worker-loader bundle with HotModuleReplacementPlugin fails with Uncaught ReferenceError: window is not defined because the runtime assumes window exists. Set output.globalObject: 'this' in the webpack config so the hot-update runtime binds to the worker global scope; disabling HMR also avoids it. Note output.globalObject only exists in webpack 4+, so on webpack 3 you need a different fix.