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

Postcss + async rules doesn't work well #3699

Closed
4 tasks done
DarkHole1 opened this issue Apr 8, 2024 · 1 comment · Fixed by #3701
Closed
4 tasks done

Postcss + async rules doesn't work well #3699

DarkHole1 opened this issue Apr 8, 2024 · 1 comment · Fixed by #3701

Comments

@DarkHole1
Copy link
Contributor

DarkHole1 commented Apr 8, 2024

UnoCSS version

0.59.0

Describe the bug

@unocss/postcss doesn't replaces @apply with rule contents on a certain conditions:

  • Source extractors didn't found class (probably)
  • File has @unocss directive
  • Rule is async

The problems comes from here:

// @ts-expect-error types doesn't allow async callback but it seems work
root.walkAtRules(directiveName, async (rule) => {

I tried patching package locally and awaiting all functions something like that:

let promises: Promise<unknown>[] = [];
root.walkAtRules(directiveName, (rule) => {
    promises.push((async () => {
        // ...
    })())
});
await Promise.all(promises);

And this fixes it.

Reproduction

https://github.com/DarkHole1/uno-postcss-bug

System Info

No response

Validations

@antfu
Copy link
Member

antfu commented Apr 8, 2024

Would you like to send a quick PR? Thanks

DarkHole1 added a commit to DarkHole1/unocss that referenced this issue Apr 8, 2024
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.

2 participants