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

Emitted @media AtRules are invalid #557

Closed
sandhose opened this issue Feb 9, 2024 · 4 comments · Fixed by #558
Closed

Emitted @media AtRules are invalid #557

sandhose opened this issue Feb 9, 2024 · 4 comments · Fixed by #558

Comments

@sandhose
Copy link

sandhose commented Feb 9, 2024

@import ... media queries; statements emit invalid AtRule, as the AtRule.params is an array instead of being a string.

This breaks the tailwindcss plugin in some scenarios, like:

@import url('./dark.css') screen and (prefered-color-scheme: dark);
@import url('./light.css') screen and (prefered-color-scheme: light);

Compiling this with both the postcss-import and tailwindcss plugin results to:

TypeError: (intermediate value)(intermediate value)(intermediate value).replace is not a function
    at ./node_modules/tailwindcss/lib/lib/collapseAdjacentRules.js:37:149
    at Array.every (<anonymous>)
    at ./node_modules/tailwindcss/lib/lib/collapseAdjacentRules.js:37:35
    at Root.each (./node_modules/postcss/lib/container.js:53:16)
    at collapseRulesIn (./node_modules/tailwindcss/lib/lib/collapseAdjacentRules.js:24:14)
    at ./node_modules/tailwindcss/lib/lib/collapseAdjacentRules.js:59:9
    at ./node_modules/tailwindcss/lib/processTailwindFeatures.js:61:53
    at async plugins (./node_modules/tailwindcss/lib/plugin.js:38:17)
    at async LazyResult.runAsync (./node_modules/postcss/lib/lazy-result.js:261:11)
    at async Promise.all (index 0)

I've done a minimal example to reproduce this issue here: https://github.com/sandhose/postcss-import-bug-repro

This bug was introduced in version 16.0.0

@romainmenke
Copy link
Collaborator

@sandhose Thank you for reporting this.
I will take a look shortly!

@romainmenke romainmenke changed the title Emitted @media AtRules are invalid Emitted @media AtRules are invalid Feb 9, 2024
@romainmenke
Copy link
Collaborator

I've prepared a fix here : #558
Thank you again for the reproduction.

@sandhose
Copy link
Author

sandhose commented Feb 9, 2024

You're welcome! Thanks for your really quick response!

@RyanZim
Copy link
Collaborator

RyanZim commented Feb 15, 2024

Published in v16.0.1 🎆

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