-
-
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
perf(hmr): implement soft invalidation #14654
Conversation
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.
This is actually something I noticed while implementing my "own Vite" 1 and half year ago but completely forgot to backport this idea.
For sourcemap I think this should be fine because the length of query params will be stable after and before.
Co-authored-by: patak <matias.capeletto@gmail.com>
Thanks to Arnaud's suggestion to use
|
/ecosystem-ci run |
📝 Ran ecosystem CI on
|
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.
Not an easy change, but I think the complexity is quite low compare to the big benefit for HMR perf (this would not be visible in benchmarks that update just a file that self-update, but sure will be in real world usages)
Description
When a module is invalidated, and its importers are invalidated recursively (to invalidate import with timestamp to retrieve new module), this PR implements a soft invalidation for those importers as they don't need a full
load
+transform
. They only need to update the import timestamps which is done specifically as a fast path now.However, some importers may still need to be hard invalidated, for example if they call
addWatchFile
on certain files. In the module graph, the representation for this is thatimporter
would import those certain files, hence to differentiate files that are actually imported in the file, I createdstaticImportedUrls
.Soft-invalidation is optional, and is only an optimization for static imports in a file.
Additional context
For the record, I was thinking about this idea before I saw Evan's comment 😄
I had "soft invalidation" in my head, but happy to rename it to "partial invalidation" if anyone prefers it. For me, "soft" kinda refers to soft/hard caches and soft/hard deletes.
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).