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

docs(hmr): improve handleHotUpdate and add further reading #15996

Merged
merged 1 commit into from
Feb 21, 2024

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Feb 21, 2024

Description

close #15215

Also added a link to https://bjornlu.com/blog/hot-module-replacement-is-easy 🙈

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Copy link

stackblitz bot commented Feb 21, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Comment on lines +433 to +442
// Invalidate modules manually
const invalidatedModules = new Set()
for (const mod of modules) {
server.moduleGraph.invalidateModule(
mod,
invalidatedModules,
timestamp,
true
)
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally I think, we shouldn't need to have user invalidate this way. This line

// invalidate module graph cache on file change
moduleGraph.onFileChange(file)

Should already cover the invalidation, but this code here is to also invalidate for HMR (forth param). The param is used for

if (isHmr) {
mod.lastHMRTimestamp = timestamp
} else {
// Save the timestamp for this invalidation, so we can avoid caching the result of possible already started
// processing being done for this module
mod.lastInvalidationTimestamp = timestamp
}

But I was thinking of combining the two timestamps in the future. And then we can remove the HMR param.

@patak-dev patak-dev merged commit 18b9b31 into main Feb 21, 2024
10 checks passed
@patak-dev patak-dev deleted the docs-hmr-improv branch February 21, 2024 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add more documentation for handleHotUpdate() and/or how plugins can control HMR vs. page refresh
2 participants