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

Updated to support daisyui 4.0.0+ version. #1

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

Conversation

LeekJay
Copy link

@LeekJay LeekJay commented Dec 5, 2023

No description provided.

@gorango
Copy link

gorango commented Jan 11, 2024

Hey @LeekJay!

Are you still using this package? Running the /playground, I noticed an infinite loop of requests for hmr:

image

Related to unocss/issues/2039. Seems that cssnano is the culprit but I'm not sure where it's being invoked.

Update:
On closer inspection, removing the daisy.handler solves the hmr issue, so I'll investigate further.

@gorango
Copy link

gorango commented Jan 13, 2024

Wow, really great find, thanks a lot!

P.S. there seems to be another call to parents.reverse() on line 115 but it doesn't seem to trigger the loop..

@LeekJay
Copy link
Author

LeekJay commented Jan 13, 2024

Hey @LeekJay!

Are you still using this package? Running the /playground, I noticed an infinite loop of requests for hmr:

image

Related to unocss/issues/2039. Seems that cssnano is the culprit but I'm not sure where it's being invoked.

Update: On closer inspection, removing the daisy.handler solves the hmr issue, so I'll investigate further.

Fixed.unocss-preset-component/pr/1

This issue has been identified:

Array.reverse() is an in-place operation, changing the original array.

If this array is in the module's global scope, its state (including the global scope's array state) will be retained when the module is read and cached by Vite.

Then when using Array.reverse(), since this is an in-place operation, the array state will be changed. This will be detected by Vite, which will consider the module to have changed, thus triggering a hot update.

When a hot update is triggered, Vite will not re-read and parse the module file, but will use the cached module state, which has been changed by Array.reverse().

Therefore, after each hot update Array.reverse() will be run again, and the array state changes again, which triggers a hot update, forming an infinite loop.

To fix this problem, we can avoid using Array.reverse() directly in the global scope. Or we can use Array.from(array).reverse() or [...array].reverse(), copy the array before each use, and then use Array.reverse(). This way the original array will not be changed.

@LeekJay
Copy link
Author

LeekJay commented Jan 13, 2024

Wow, really great find, thanks a lot!

P.S. there seems to be another call to parents.reverse() on line 115 but it doesn't seem to trigger the loop..

Wow, really great find, thanks a lot!

P.S. there seems to be another call to parents.reverse() on line 115 but it doesn't seem to trigger the loop..

Yes, maybe unocss already handles that in rules, but preflights doesn't.

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.

2 participants