Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: better invalidation message when an export is added & fix HMR for export of nullish values #215

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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