Invalidate importer modules in runner cache during HMR#16777
Merged
Conversation
When an SSR-only module changes, moduleGraph.invalidateModule() recursively walks importers and populates the invalidatedModules set. However, the runner's evaluatedModules cache was only invalidated for the directly changed file. Barrel files (e.g. index.ts re-exporting components) stayed cached in the runner, so dynamic import() calls returned stale exports. Invalidate all modules in the invalidatedModules set in the runner cache, not just the directly changed ones. Fixes #16000
🦋 Changeset detectedLatest commit: 5eba863 The changes in this PR will be included in the next version bump. This PR includes changesets to release 417 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
louisescher
approved these changes
May 19, 2026
Merged
ematipico
pushed a commit
that referenced
this pull request
May 20, 2026
When an SSR-only module changes, moduleGraph.invalidateModule() recursively walks importers and populates the invalidatedModules set. However, the runner's evaluatedModules cache was only invalidated for the directly changed file. Barrel files (e.g. index.ts re-exporting components) stayed cached in the runner, so dynamic import() calls returned stale exports. Invalidate all modules in the invalidatedModules set in the runner cache, not just the directly changed ones. Fixes #16000
dadezzz
pushed a commit
to dadezzz/university_notes
that referenced
this pull request
May 24, 2026
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [astro](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/astro)) | [`6.3.5` → `6.3.6`](https://renovatebot.com/diffs/npm/astro/6.3.5/6.3.6) |  |  | --- ### Release Notes <details> <summary>withastro/astro (astro)</summary> ### [`v6.3.6`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#636) [Compare Source](https://github.com/withastro/astro/compare/astro@6.3.5...astro@6.3.6) ##### Patch Changes - [#​16774](withastro/astro#16774) [`8f77583`](withastro/astro@8f77583) Thanks [@​astrobot-houston](https://github.com/astrobot-houston)! - Fixes markdown images with empty alt text (``) in content collections dropping the `alt` attribute entirely. The `alt=""` attribute is now correctly preserved in the rendered HTML output, which is important for accessibility (indicating decorative images). - [#​16776](withastro/astro#16776) [`3d10b5e`](withastro/astro@3d10b5e) Thanks [@​matthewp](https://github.com/matthewp)! - Fixes HMR serving stale content when components are passed as props via `getStaticPaths()` - [#​16784](withastro/astro#16784) [`7453860`](withastro/astro@7453860) Thanks [@​ematipico](https://github.com/ematipico)! - Improved the printing of the build time if it goes over the 60 seconds. - [#​16665](withastro/astro#16665) [`3dbbcee`](withastro/astro@3dbbcee) Thanks [@​Princesseuh](https://github.com/Princesseuh)! - Fixes remote SVG sources erroring with `dangerouslyProcessSVG` after the v6.3 SVG-processing gate. The default Sharp service now resolves the output format from the source up-front when it can (URL extension, `data:` MIME, ESM metadata), and from the actual buffer at request time when it can't, so SVG sources pass through untouched without needing to set `image.dangerouslyProcessSVG: true` or an explicit `format="svg"`. The error message has also been updated to point at `format="svg"` as the simpler workaround when an SVG source is encountered without `dangerouslyProcessSVG` enabled. - [#​16777](withastro/astro#16777) [`1754b91`](withastro/astro@1754b91) Thanks [@​matthewp](https://github.com/matthewp)! - Fixes HMR serving stale content for dynamically imported components through barrel files - [#​16730](withastro/astro#16730) [`068d924`](withastro/astro@068d924) Thanks [@​harshagarwalnyu](https://github.com/harshagarwalnyu)! - Fixes an issue where the `file()` content loader did not generate a valid JSON Schema for collections whose JSON or YAML data is a top-level array instead of an object. </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xODIuMSIsInVwZGF0ZWRJblZlciI6IjQzLjE4Mi4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
evaluatedModulescache, not just the directly changed file.moduleGraph.invalidateModule()already walks importers and populates aninvalidatedModulesset, but the runner cache only cleared the leaf module. Barrel files (e.g.index.tsre-exporting components) stayed cached, soawait import("../components")returned stale exports even after a full page reload.Fixes #16000
Testing
hmr-reload.test.ts: "invalidates importers in the module graph for dynamic import chains" -- sets up a component with a barrel file importer and verifies the invalidation propagates through the mock module graph.invalidateModuleto simulate Vite's recursive importer walk by adding importers to theseenset.Docs