-
-
Notifications
You must be signed in to change notification settings - Fork 778
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: style comparison error when hotUpdate #3387
Conversation
✅ Deploy Preview for unocss ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
If we don't inject styles on handleHotUpdate
, all applied styles disappear after HMR (you can try to run it locally to see what happens). Most likely it's the bug of @vitejs/plugin-vue
Ref: vitejs/vite-plugin-vue#301
I run it locally and everything seems to be ok. Because return {
name: "unocss:vue-scoped",
transform(code, id) {
if (!filter(id))
return;
return transformSFC(code); // will run after every HMR
},
handleHotUpdate(ctx) {
// const read = ctx.read;
// if (filter(ctx.file)) {
// ctx.read = async () => {
// const code = await read();
// return await transformSFC(code) || code;
// };
// }
}
}; |
Yes, you are right, transform hook is called. But updated styles are not pushed Reproduction: https://stackblitz.com/edit/vitejs-vite-mnvzcb?file=src%2FApp.vue I just commented out But maybe we need to push this change as temporary workaround? I guess the runtime error is worse than missed hot update |
I open a PR(vitejs/vite-plugin-vue#306) for |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
FIXED: #3358
I think it need not transform code when hotUpdate. File content comparison when hotUpdate should compare raw code, not transformed code. The transformed code include
unocss:vue-scoped
's generated code and raw code, generated code is not chaged.There is a comment from
@vitejs/plugin-vue
packages/plugin-vue/src/main.ts