-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
refactor(hmr): simplify fetchUpdate #9881
Conversation
2f3b3d4
to
32f3168
Compare
const modulesToUpdate = new Set<string>() | ||
if (isSelfUpdate) { | ||
// self update - only update self | ||
modulesToUpdate.add(path) | ||
} else { | ||
// dep update | ||
for (const { deps } of mod.callbacks) { | ||
deps.forEach((dep) => { | ||
if (acceptedPath === dep) { | ||
modulesToUpdate.add(dep) | ||
} | ||
}) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modulesToUpdate
was always new Set([])
or new Set([acceptedPath])
.
Because:
- in
if (isSelfUpdate)
blockpath === acceptedPath
istrue
so it's callingmodulesToUpdate.add(acceptedPath)
- in
else
block- it's only calling
modulesToUpdate.add(dep)
whenacceptedPath === dep
. So it's callingmodulesToUpdate.add(acceptedPath)
.
- it's only calling
For review, it might be easier to see each commit, because I made each commit equivalent before and after the change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the step-by-step commits @sapphi-red, that helped a lot!
Some historic bits for reference, the current implementation needed the Set
when it was first created. It was first changed here, and then again here. After that second change, this part of the codebase remained untouched.
Just read through the commits, and it's beautiful. Reminds me of the days we do equation simplification in math classes 😄 |
Description
Refactored
fetchUpdate
function inclient/client.ts
.Splitted from #9773.
Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).