Skip to content

fix(vite): resolve tsconfig paths in CSS and JS resolvers#19803

Open
nightah wants to merge 2 commits intotailwindlabs:mainfrom
nightah:fix/vite-resolver-tsconfig-paths
Open

fix(vite): resolve tsconfig paths in CSS and JS resolvers#19803
nightah wants to merge 2 commits intotailwindlabs:mainfrom
nightah:fix/vite-resolver-tsconfig-paths

Conversation

@nightah
Copy link

@nightah nightah commented Mar 15, 2026

Change aliasOnly from true to false when calling Vite's resolver so that the full resolution pipeline runs, including the oxc resolver responsible for tsconfig path resolution.

When aliasOnly was true, only the @rollup/plugin-alias plugin ran, which meant resolve.tsconfigPaths: true had no effect on CSS @import or JS @plugin resolution in @tailwindcss/vite.

Closes #19802.

Change `aliasOnly` from `true` to `false` when calling Vite's resolver
so that the full resolution pipeline runs, including the oxc resolver
responsible for tsconfig path resolution.

When `aliasOnly` was `true`, only the @rollup/plugin-alias plugin ran,
which meant `resolve.tsconfigPaths: true` had no effect on CSS
`@import` or JS `@plugin` resolution in `@tailwindcss/vite`.

Closes tailwindlabs#19802
@nightah nightah requested a review from a team as a code owner March 15, 2026 09:29
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d1c0bc1e-509b-44cb-be18-bcf7ee45b47e

📥 Commits

Reviewing files that changed from the base of the PR and between 12c1e7e and 941631b.

📒 Files selected for processing (1)
  • packages/@tailwindcss-vite/src/index.ts

Walkthrough

The pull request adds an import for json in the Vite resolvers test and two new tests that verify tsconfig path resolution in both production build and dev server modes, asserting emitted CSS contains expected utilities. Separately, the Vite integration resolver logic is changed so CSS and JS resolvers are invoked with false for the CSS-related flag and CSS-only results are enforced by returning undefined when a resolved path does not end with .css; these changes apply to both environment-less and environment-present code paths.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly describes the main change: fixing Vite resolver to support tsconfig path resolution for CSS and JS resolvers.
Description check ✅ Passed The description accurately explains the root cause and solution: changing aliasOnly from true to false to enable the full Vite resolution pipeline including oxc resolver.
Linked Issues check ✅ Passed The PR changes address the core requirement from #19802: modifying aliasOnly from true to false in both environment-less and environment-present branches to enable tsconfig path resolution.
Out of Scope Changes check ✅ Passed All changes are directly related to the objective: modifying CSS/JS resolver calls and adding test cases for tsconfig path resolution in Vite builds.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can generate a title for your PR based on the changes.

Add @coderabbitai placeholder anywhere in the title of your PR and CodeRabbit will replace it with a title based on the changes in the PR. You can change the placeholder by changing the reviews.auto_title_placeholder setting.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
integrations/vite/resolvers.test.ts (1)

15-165: Optional: extract shared fixture setup to reduce duplication.

Both new tests repeat the same filesystem fixture; extracting a small helper/object for shared files would make future resolver test updates less error-prone.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@integrations/vite/resolvers.test.ts` around lines 15 - 165, Extract the
duplicated filesystem fixture used in the two tests titled "resolves tsconfig
paths in production build" and "resolves tsconfig paths in dev mode" into a
shared constant (e.g., sharedFs) and reference that constant in each test's
options instead of duplicating the object; update the tests to pass the sharedFs
to the test helper (replace the inline fs: { ... } blocks with fs: sharedFs) so
future changes to the fixture live in one place and both tests (production build
and dev mode) reuse the same setup.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@integrations/vite/resolvers.test.ts`:
- Around line 15-165: Extract the duplicated filesystem fixture used in the two
tests titled "resolves tsconfig paths in production build" and "resolves
tsconfig paths in dev mode" into a shared constant (e.g., sharedFs) and
reference that constant in each test's options instead of duplicating the
object; update the tests to pass the sharedFs to the test helper (replace the
inline fs: { ... } blocks with fs: sharedFs) so future changes to the fixture
live in one place and both tests (production build and dev mode) reuse the same
setup.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a1c6b6ce-a66b-41d5-a9dd-78be04245a20

📥 Commits

Reviewing files that changed from the base of the PR and between a4be983 and 12c1e7e.

📒 Files selected for processing (2)
  • integrations/vite/resolvers.test.ts
  • packages/@tailwindcss-vite/src/index.ts

@RobinMalfait
Copy link
Member

Hey! Looks like CI is failing. Do you mind making sure that things work as expected? Thanks!

@nightah
Copy link
Author

nightah commented Mar 16, 2026

Thanks for the ping @RobinMalfait. I believe this is now fixed.

When aliasOnly was changed to false, the full Vite resolution pipeline could resolve bare specifiers like tailwindcss to JS entry points (e.g. lib.mjs) instead of CSS files. The enhanced-resolve fallback, which respects mainFields: ['style'], never ran.

That said, I'm unsure whether the remaining test failures are related to my change or an environmental issue.
Following the contribution guidelines after getting to pnpm build and pnpm test:integrations against a4be983 for a baseline, the following tests failed for me:

  • oxide/wasm.test.ts: wasm32-wasi loading (timeout)
  • postcss/source.test.ts: (these look like they didn't even fail in CI)
  • vite/nuxt.test.ts: build (timeout)
  • vite/qwik.test.ts: dev mode (pnpm install warning causing failure)

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.

@tailwindcss/vite: CSS @import fails to resolve tsconfig path aliases due to aliasOnly: true

2 participants