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

vue2/3 keep-alive + transformerVariantGroup hmr error #3518

Open
4 tasks done
webaddkevin opened this issue Jan 20, 2024 · 9 comments · May be fixed by #3741
Open
4 tasks done

vue2/3 keep-alive + transformerVariantGroup hmr error #3518

webaddkevin opened this issue Jan 20, 2024 · 9 comments · May be fixed by #3741

Comments

@webaddkevin
Copy link

webaddkevin commented Jan 20, 2024

UnoCSS version

0.58.3

Describe the bug

In a Vue + Unocss project, using the keep-alive component, the code hot update during inactive pages will cause the components containing the "unocss transformerVariantGroup" code to reload as well

Reproduction

a3m9y-bcebh.mp4

System Info

demo:https://github.com/webaddkevin/uno-test

Validations

@MrFoxPro
Copy link

MrFoxPro commented Apr 6, 2024

Probably I have similiar issue with SolidJS + UnoCSS as well. Enabling transformerVariantGroup make Solid's HMR go crazy on first run. But then, after caching. it works fine.

UPD: @webaddkevin setting mode: "per-module" in config fixed issue for me.

@MrFoxPro
Copy link

MrFoxPro commented Apr 16, 2024

Well, it doesn't fix issue, but whole page refresh is not so annoying
Had to disable HMR at all due UnoCSS continues to infinity refresh itself

@webaddkevin
Copy link
Author

Probably I have similiar issue with SolidJS + UnoCSS as well. Enabling transformerVariantGroup make Solid's HMR go crazy on first run. But then, after caching. it works fine.

UPD: @webaddkevin setting mode: "per-module" in config fixed issue for me.

Thanks, setting 'mode: "per-module" is useful, problem solved

@MrFoxPro
Copy link

unocss.mp4

@Simon-He95
Copy link
Contributor

unocss.mp4

Can you provide a reproducible demo?

@MrFoxPro
Copy link

MrFoxPro commented Apr 24, 2024

unocss.mp4

Can you provide a reproducible demo?

I'd be happy to, but I have large project. I'll try

@MrFoxPro
Copy link

MrFoxPro commented Apr 26, 2024

More clear description of my problem:

I have SolidJS project with vite-plugin-solid, HMR enabled. I have self-made "keep-alive" components. They probably very different from OP's Vue components.
Anyway, after enabling transformerVariantGroup, navigating to any "keep-alive" lazy-loaded page triggers HMR for many components on page and page flickers. Sometimes new page doesn't load at all. However, after navigating multiple times seems components become cached and it works kinda ok. Switching to mode: "per-module" fixes this flickering, but, if exception throws in my code, in about half of times it starts to infinity refresh HMR as shown on video.

I'm not sure I can provide repdoducible demo, because I have pretty large project which is closed-source for now. But, if any maintainer is interested to help and fix this, I can send project in PM.

Also, I tried to use #3741 branch, but it didn't fix the issue for me

UPD: maybe it's more related to vite/vite-plugin-solid.
UPD2: I ran my project without unocss vite plugin and it works perfectly fine -_-

@Simon-He95
Copy link
Contributor

vite

@MrFoxPro If possible, I hope you can streamline the project and send it to me, and I can help debug it.

@MrFoxPro
Copy link

MrFoxPro commented Apr 29, 2024

vite

@MrFoxPro If possible, I hope you can streamline the project and send it to me, and I can help debug it.

Ok,seems like the main problem is resolved with using mode: 'per-module' in dev mode. When using "global" it changes Solid plugin HMR behaviour, namely: it starts reloading all components dependening on target instead of only target itself. Repro & demo:

unocsshmr.mp4

https://github.com/MrFoxPro/unocss-hmr-bug

But since per-module is experimental, it doesn't work well, like in this video (I wasn't able to reproduce this so far) and also seems like styles are applied in different order, so result is kinda inconsistent with build output. It also produces large number of CSS files, so firefox slows down a lot.

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 a pull request may close this issue.

3 participants