Skip to content

refactor(server): index imported modules by url in soft invalidation#22723

Draft
shulaoda wants to merge 1 commit into
mainfrom
shulaoda/06-19-refactor_server_index_imported_modules_by_url_in_soft_invalidation
Draft

refactor(server): index imported modules by url in soft invalidation#22723
shulaoda wants to merge 1 commit into
mainfrom
shulaoda/06-19-refactor_server_index_imported_modules_by_url_in_soft_invalidation

Conversation

@shulaoda

Copy link
Copy Markdown
Member

handleModuleSoftInvalidation rewrites import timestamps by scanning the whole mod.importedModules set for every parsed import, i.e. O(imports × importedModules).

Change

  • Build a Map<url, EnvironmentModuleNode> from mod.importedModules once, then look up each import's hmrUrl in O(1). The map keeps the first node per url, matching the previous break-on-first-match behavior.

This is a readability / scalability cleanup (linear instead of quadratic for modules with many imports, e.g. barrels). Behavior is unchanged.

Tests

  • No fails-without/passes-with test is included: this is a behavior-preserving change with identical output, so there is nothing new to assert. Soft-invalidation behavior is exercised by the playground/hmr e2e suite, and the existing transformRequest unit tests pass.

@shulaoda shulaoda marked this pull request as draft June 19, 2026 15:08
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.

1 participant