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(hmr): don't mutate module graph when collecting modules #16302

Merged
merged 1 commit into from Mar 29, 2024

Conversation

sapphi-red
Copy link
Member

Description

#16288 had a code that breaks the module graph.

@sapphi-red sapphi-red added feat: hmr p4-important Violate documented behavior or significantly improves performance (priority) labels Mar 29, 2024
Copy link

stackblitz bot commented Mar 29, 2024

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

Comment on lines +165 to 168
const mods = new Set(moduleGraph.getModulesByFile(file))
if (type === 'create' || type === 'delete') {
for (const mod of getAffectedGlobModules(file, server)) {
mods.add(mod)
Copy link
Member Author

Choose a reason for hiding this comment

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

moduleGraph.getModulesByFile(file) returns a Set. mods.add(mod) mutates that Set causing the module graph to have incorrect fileToModulesMap.

@patak-dev patak-dev merged commit dfffea1 into vitejs:main Mar 29, 2024
10 checks passed
@sapphi-red sapphi-red deleted the fix-hmr-dont-mutate-graph-hmr branch March 29, 2024 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: hmr p4-important Violate documented behavior or significantly improves performance (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants