Skip to content

Commit

Permalink
fix: better invalidation message when an export is added & fix HMR fo…
Browse files Browse the repository at this point in the history
…r export of nullish values (#215)
  • Loading branch information
ArnaudBarre committed Aug 31, 2023
1 parent ccd25dd commit 2863602
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/plugin-react/src/refreshUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,19 @@ function registerExportsForReactRefresh(filename, moduleExports) {
}

function validateRefreshBoundaryAndEnqueueUpdate(prevExports, nextExports) {
if (!predicateOnExport(prevExports, (key) => !!nextExports[key])) {
if (!predicateOnExport(prevExports, (key) => key in nextExports)) {
return 'Could not Fast Refresh (export removed)'
}
if (!predicateOnExport(nextExports, (key) => key in prevExports)) {
return 'Could not Fast Refresh (new export)'
}

let hasExports = false
const allExportsAreComponentsOrUnchanged = predicateOnExport(
nextExports,
(key, value) => {
hasExports = true
if (exports.isLikelyComponentType(value)) return true
if (!prevExports[key]) return false
return prevExports[key] === nextExports[key]
},
)
Expand Down

0 comments on commit 2863602

Please sign in to comment.