From 7ad25fd0958cb39c8595a0d667e9bc0f4c0250f4 Mon Sep 17 00:00:00 2001 From: clintharris Date: Sat, 1 Jun 2019 13:09:11 -0400 Subject: [PATCH] Fixes 3076: HMR update breaks in webworker due to window (and location.reload) not existing in web worker context. (#3078) --- 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(); } }