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(variant-group): hmr in vite #3741

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

Simon-He95
Copy link
Contributor

close: #3518

@Simon-He95 Simon-He95 requested a review from antfu as a code owner April 18, 2024 04:04
Copy link

netlify bot commented Apr 18, 2024

Deploy Preview for unocss ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 476cbae
🔍 Latest deploy log https://app.netlify.com/sites/unocss/deploys/6641b9d06a927600083ebfd1
😎 Deploy Preview https://deploy-preview-3741--unocss.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@antfu
Copy link
Member

antfu commented Apr 18, 2024

I am not sure about it - can you explain a bit more about the problem and why this would be helpful?

@Simon-He95
Copy link
Contributor Author

I am not sure about it - can you explain a bit more about the problem and why this would be helpful?
The affectedModules themselves collect all the ids that need to be updated, but our HMR needs to filter these ids based on the clientImportedModules that depend on them, which should enable on-demand updates

@Simon-He95
Copy link
Contributor Author

Morning, @antfu
I have a question, should we only hot update the current file, or the current file and its sub-files? If it is the current file, there is no need to add ctx.affectedModules.add(id) to the transformerVariantGroup. If necessary, it should Filter all changed pages based on dependencies on the current page

@Simon-He95
Copy link
Contributor Author

I feel that there is no need to add ctx.affectedModules.add(id) in transformerVariantGroup, because if you modify the hasChanged file, this plug-in will be used. If you do not modify the hasChanged file, it will also trigger the style update of uno.css.

@@ -40,7 +40,7 @@ export async function applyTransformers(
}

if (code !== original) {
ctx.affectedModules.add(id)
// ctx.affectedModules.add(id)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems that this line of code is not needed. It will cause additional updates. For example, I modified file a, but multiple files may be added to the change list for the first time. Modification of file a will cause hot updates of all files. uno.css is also updated multiple times. If the a file changes, you should only need to initiate the hot update of the a file and the hot update of uno.css.

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.

vue2/3 keep-alive + transformerVariantGroup hmr error
2 participants