Skip to content

fix(tailwind): parse non inline configuration variables#3466

Merged
dielduarte merged 7 commits intocanaryfrom
feature/dev-361-tailwind-config-parse-failing
May 4, 2026
Merged

fix(tailwind): parse non inline configuration variables#3466
dielduarte merged 7 commits intocanaryfrom
feature/dev-361-tailwind-config-parse-failing

Conversation

@dielduarte
Copy link
Copy Markdown
Contributor

@dielduarte dielduarte commented May 4, 2026

Description

getTailwindConfig only handled cases where the prop was an inline object literal. If the config was stored in a variable (e.g., const config = { ... }; ), it failed to parse it.

The Fix: When the config prop value is an Identifier (a variable reference), a new findVariableInitializer helper traverses the AST to locate that variable's declaration and extract its source code, then uses that as the config value.


Summary by cubic

Fixes Tailwind config parsing when the config prop uses a variable instead of an inline object. The compatibility check now resolves the variable initializer from the right scope (even with shadowed names), addressing DEV-361.

  • Bug Fixes
    • Resolve config identifiers with scope-aware AST binding and extract the initializer source; keep parsing local (avoid shared helper).
    • Add tests for variable config, empty config, and shadowed config names; add biome-ignore to allow intentional shadowing in the fixture.

Written for commit 561fdc3. Summary will update on new commits.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-email Ready Ready Preview, Comment May 4, 2026 5:56pm
react-email-demo Ready Ready Preview, Comment May 4, 2026 5:56pm

Request Review

@dielduarte dielduarte requested a review from gabrielmfern May 4, 2026 16:41
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 4, 2026

🦋 Changeset detected

Latest commit: 561fdc3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
react-email Patch
@react-email/editor Patch
@react-email/ui Patch

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 4, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@react-email/ui@3466

commit: 561fdc3

@dielduarte dielduarte changed the title fix(tailwind): parse inline configuration variables fix(tailwind): parse non inline configuration variables May 4, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 4 files

Confidence score: 3/5

  • Potential wrong Tailwind config resolution in packages/ui/src/utils/caniemail/tailwind/get-tailwind-config.ts when identifiers are reused could lead to incorrect styling behavior.
  • Score reflects a concrete, user-facing risk (severity 7/10) but limited in scope to config lookup logic.
  • Pay close attention to packages/ui/src/utils/caniemail/tailwind/get-tailwind-config.ts - identifier-based lookup isn’t scope-aware and may bind the wrong variable.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/ui/src/utils/caniemail/tailwind/get-tailwind-config.ts">

<violation number="1" location="packages/ui/src/utils/caniemail/tailwind/get-tailwind-config.ts:137">
P1: Identifier-based Tailwind config lookup is not scope-aware, so it can bind to the wrong variable when names are reused.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread packages/ui/src/utils/caniemail/tailwind/get-tailwind-config.ts Outdated
Comment thread packages/ui/src/utils/caniemail/tailwind/get-tailwind-config.ts Outdated
Comment thread packages/ui/src/utils/caniemail/tailwind/get-tailwind-config.spec.ts Outdated
Comment thread .changeset/old-shirts-tan.md Outdated
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 4 files (changes from recent commits).

Auto-approved: Fixes Tailwind config parsing to support variable references by resolving AST bindings. Well-tested and isolated to the Tailwind config utility.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

Requires human review: Modifies core Tailwind configuration parsing logic using AST traversal and scope resolution, which requires human verification of potential side effects.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 2 files (changes from recent commits).

Requires human review: Introduces AST traversal and scope-aware variable resolution for Tailwind config parsing, which is non-trivial logic that requires human review.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

Auto-approved: Resolves Tailwind config from variables via AST scope analysis. Includes comprehensive tests for shadowing. Isolated fix for a parsing limitation in the UI utility.

@dielduarte dielduarte merged commit 65525e0 into canary May 4, 2026
17 checks passed
@dielduarte dielduarte deleted the feature/dev-361-tailwind-config-parse-failing branch May 4, 2026 18:13
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