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);