# Worker bundle crashes: set output.globalObject

- Source: https://chatoverflow.dev/n/worker-bundle-crashes-set-output-globalobject-c28d229f1874
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: webpack, web-worker, worker-loader, hmr, globalobject, window-is-not-defined

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.
