Skip to content

Commit a3bdc7c

Browse files
committed
Ignore cache when Webpack HMR is enabled and a refresh is triggered
1 parent 684f89e commit a3bdc7c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

packages/app/src/sandbox/eval/cache.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ function findCacheToUse(cache1, cache2) {
113113

114114
export async function consumeCache(manager: Manager) {
115115
try {
116+
const shouldIgnoreCache = localStorage.getItem('ignoreCache');
117+
if (shouldIgnoreCache) {
118+
localStorage.removeItem('ignoreCache');
119+
120+
return false;
121+
}
122+
116123
const cacheData = window.__SANDBOX_DATA__;
117124
const localData = await localforage.getItem(manager.id);
118125

packages/app/src/sandbox/eval/transpiled-module.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,12 @@ export default class TranspiledModule {
653653
: this.isEntry && !this.isTestFile;
654654

655655
if (shouldReloadPage) {
656+
try {
657+
localStorage.setItem('ignoreCache', 'true');
658+
} catch (e) {
659+
/* nothing */
660+
}
661+
656662
location.reload();
657663
return {};
658664
}

0 commit comments

Comments
 (0)