Merge user resolve.conditions in @tailwindcss/vite CSS @import resolver - #20499
Dextheking1 wants to merge 1 commit into
Conversation
@tailwindcss/vite built its CSS @import resolver by spreading the user's resolve config and then overwriting conditions with a hardcoded list, silently discarding custom conditions (e.g. monorepo 'source' conditions). The JS resolver already inherited config.resolve as-is, so the two resolvers disagreed about which copy of a package to load. Append the user's resolve.conditions to the built-in CSS conditions instead of replacing them, in both the pre-Environment-API branch and the Environment API branch. Includes a regression test covering both branches.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. WalkthroughThe Vite plugin now appends user-provided Priority: ➖ Normal Severity of issue fixed: Medium 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Fixes #20426.
Summary
@tailwindcss/viteresolves CSS@importwith a custom Vite resolver. That resolver spread the user'sresolveconfig but then overwroteconditionswith a hardcoded list (['style', 'development|production']), so user-configuredresolve.conditionswere silently dropped for CSS@importeven though they were honoured for JS imports. This happened in both resolver branches (legacy pre-Environment-API and Environment API).The fix merges instead of overwrites:
so the built-in conditions keep priority while user conditions still apply.
Test plan
integrations/vite/resolvers.test.tscovering both resolver branches: vite^8(Environment API) and vite^5.3.5(legacy). A fixture package exposes./custom.cssunder amy-custom-conditionexport and./default.cssunderstyle/default; withresolve.conditions: ['my-custom-condition']the built CSS must contain the custom-condition rule. 2/2 new tests pass; fullvite/resolvers.test.ts: 15/15 pass.default.css(bug reproduced), new shape resolvescustom.css(fixed).tscreports 0 errors in the changed file (remaining 39 errors elsewhere in the monorepo are pre-existing environmental issues unrelated to this change).Note: the fixture includes
@import 'tailwindcss';in the test CSS (with an explanatory comment) because the plugin returns early for files without Tailwind features, so the resolver under test would never run otherwise.