From 525b69618d2f8b19e8b9c13149c836af6af7a5c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Tue, 25 May 2021 12:08:09 +0200 Subject: [PATCH] fix: use global when evaluating HMR update (#33) --- src/runtime/setupChunkLoader.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/runtime/setupChunkLoader.ts b/src/runtime/setupChunkLoader.ts index 1a18c6e2e..a5129badc 100644 --- a/src/runtime/setupChunkLoader.ts +++ b/src/runtime/setupChunkLoader.ts @@ -24,11 +24,13 @@ async function loadHmrUpdate(url: string, cb: LoadCallback) { try { // @ts-ignore const globalEvalWithSourceUrl = global.globalEvalWithSourceUrl; - if (globalEvalWithSourceUrl) { - globalEvalWithSourceUrl(script, null); - } else { - eval(script); - } + (function () { + if (globalEvalWithSourceUrl) { + globalEvalWithSourceUrl(script, null); + } else { + eval(script); + } + }.call(global)); cb(); } catch (error) { console.error('Loading HMR update chunk failed:', error);