fix(hmr): fix HMR failure for @include markdown files due to cache key mis#5035
Open
yyznm wants to merge 2 commits intovuejs:mainfrom
Open
fix(hmr): fix HMR failure for @include markdown files due to cache key mis#5035yyznm wants to merge 2 commits intovuejs:mainfrom
yyznm wants to merge 2 commits intovuejs:mainfrom
Conversation
15a0278 to
09af6c7
Compare
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.
Description
Issue where HMR doesn't occur when markdown files included via
@includeare modified, caused by the route rewriting feature.This is the minimal reproducible code for the bug.
This is the normal behavior
success.mp4
After adding the rewrites configuration, it's found that updates don't work as expected
error.mp4
The root cause of this issue is that the
relativePathused to generate thecacheKeyis the rewritten path:However, the only place where
clearCacheis called with parameters is inplugin.ts, where therelativePathhere is the original path before rewriting. This prevents the cache from being cleared properly, resulting in consistent hits to the cached content and thus failing to update to the new content:My solution is to use the original path when generating the
cacheKey.Linked Issues
Additional Context