Repository navigation
Conversation
Contributor
|
@hsusul is attempting to deploy a commit to the resend Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: 086383d The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue or discussion
Fixes #3947
What this changes
css-tree only parses a nested rule in a style block when it starts with
&. Tailwind v4 writesspace-*,divide-*,*:,**:andin-*as nested rules that don't, such as:where(& > :not(:last-child))and:where(*:focus) &. Those stayed unparsedRawnodes, so the inliner dropped the class. Under a responsive variant, they went into<style>still nested.getStyleSheetinsetup-tailwind.tsnow runsparseNestedRuleson the parsed stylesheet. It re-parses eachRawchild of a block as rules and swaps it in only when every result is a rule whose selectors all contain&. Any otherRawis left as it is today. After that, the existing non-inlinable path and the flattening from #3901 handle these rules like any other nested variant:<style>space-y-4:where(.space-y-4>:not(:last-child)){margin-block-start:calc(1rem*0)!important;margin-block-end:calc(1rem*calc(1 - 0))!important}*:p-2:is(.__p-2>*){padding:0.5rem!important}in-focus:p-2:where(*:focus) .in-focus_p-2{padding:0.5rem!important}sm:space-y-4@media (min-width:40rem){:where(.sm_space-y-4>:not(:last-child)){...} }#3593 tried to keep
space-*anddivide-*and was closed because the output stayed nested. This PR writes flat rules only, with the same:is()and:where()selectors thatgroup-hover:and the #3901 flattening already produce.This touches a different file from #3945, but the two interact. Arbitrary variants with
&after an ancestor, like[.dark_&]:p-2(.dark &), are dropped on canary. With this PR alone they are parsed, then inlined unconditionally asstyle="padding:0.5rem", which is the bug #3943 tracks for[&_p]:. With #3945 applied as well, they render.dark ._dark___p-2{padding:0.5rem!important}. Merging #3945 first avoids that. Both PRs add tests at the same spot intailwind.spec.tsx, so the second one will need a small rebase.Tests in
tailwind.spec.tsxcover*:,**:,in-focus:,sm:*:anddivide-[#f00]. All 5 fail on canary.Verification on canary
e1c0044aplus this branch:vitest run src/components/tailwindinpackages/react-email: 206 passed.vitest runinpackages/react-email: 422 passed, 2 failed. The failures areexport-esbuild-plugins.spec.tsand theoutDir with glob syntaxcase inexport.spec.ts. They fail the same way on canary here: the first can't startpnpm, the second can't findcss-tree.biome checkat the root: clean apart from one existing warning inapps/web/src/app/editor/editor-overrides.css.tsc --noEmitinpackages/react-email: no errors.vitest run src/components/tailwindpassed, and[.dark_&]:p-2rendered as above.Not tested in any email client.
Checklist
Summary by cubic
Fixes Tailwind v4 classes like
*:,**:,in-*,space-*, anddivide-*being dropped from rendered emails. Under responsive variants they instead wrote nested CSS into<style>; these now render as flat rules too.What changed
&, so these variants stayed as unparsedRawnodes the inliner could not resolve.getStyleSheetnow runsparseNestedRules, which re-parses eachRawblock child and swaps it in when every result is a rule whose selectors all contain&; anything else is left as-is.Merge order
[.dark_&]:p-2get inlined as an unconditionalstyleattribute instead of being kept as a rule.Written for commit 086383d. Summary will update on new commits.