From e1c984a05d096c8ffff007bcea4ef3bdd7712b1f Mon Sep 17 00:00:00 2001 From: Clint Harris Date: Thu, 23 May 2019 17:13:12 -0400 Subject: [PATCH] Fixes 3076: HMR update breaks in webworker due to window (and location.reload) not existing in web worker context. --- packages/core/parcel-bundler/src/builtins/hmr-runtime.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/parcel-bundler/src/builtins/hmr-runtime.js b/packages/core/parcel-bundler/src/builtins/hmr-runtime.js index 526a10d20cd..ae91e67cddf 100644 --- a/packages/core/parcel-bundler/src/builtins/hmr-runtime.js +++ b/packages/core/parcel-bundler/src/builtins/hmr-runtime.js @@ -59,8 +59,8 @@ if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') { assetsToAccept.forEach(function (v) { hmrAcceptRun(v[0], v[1]); }); - } else { - window.location.reload(); + } else if (location.reload) { // `location` global exists in a web worker context but lacks `.reload()` function. + location.reload(); } }