Skip to content

Commit

Permalink
(wmr) - clear module-graph when the update isn't accepted (#430)
Browse files Browse the repository at this point in the history
* clear module-graph when the update isn't accepted

* Update five-carrots-juggle.md
  • Loading branch information
JoviDeCroock authored Mar 14, 2021
1 parent edca6ce commit b225cc2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/five-carrots-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'wmr': patch
---

Fix reload issue, when the bubbling hmr doesn't find a proper boundary it will give the browser a refresh signal (F5) which needs to clear the module-graph as modules could still be marked as stale which wouldn't be needed
1 change: 1 addition & 0 deletions packages/wmr/demo/public/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ export async function prerender(data) {

// @ts-ignore
if (module.hot) module.hot.accept(u => hydrate(<u.module.App />, document.body));

4 changes: 4 additions & 0 deletions packages/wmr/src/wmr-middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,15 @@ export default function wmrMiddleware({
pendingChanges.add('/' + filename);
} else if (/\.(mjs|[tj]sx?)$/.test(filename)) {
if (!bubbleUpdates(filename)) {
moduleGraph.clear();
pendingChanges.clear();
clearTimeout(timeout);
onChange({ reload: true });
}
} else {
WRITE_CACHE.delete(filename);
moduleGraph.clear();
pendingChanges.clear();
clearTimeout(timeout);
onChange({ reload: true });
}
Expand Down

0 comments on commit b225cc2

Please sign in to comment.