Skip to content

Fix 'Sourcemap is likely to be incorrect' warnings when using @tailwindcss/vite#20103

Merged
RobinMalfait merged 3 commits into
mainfrom
fix/issue-19930
May 22, 2026
Merged

Fix 'Sourcemap is likely to be incorrect' warnings when using @tailwindcss/vite#20103
RobinMalfait merged 3 commits into
mainfrom
fix/issue-19930

Conversation

@RobinMalfait
Copy link
Copy Markdown
Member

@RobinMalfait RobinMalfait commented May 22, 2026

This PR fixes an issue where a bunch of warnings would be shown related to sourcemaps.

This happens when we are dealing with CSS files that are not Tailwind CSS roots. In that case, in the transform step, we return the src of that module as-is because we didn't modify anything. However, when nothing changed, you have to return a NullValue such as undefined.

So this is a stupid little fix, but it should get rid of a bunch of annoying warnings.

Fixes: #19930

Test plan

Before:
8oQNG5Lqr2B

After:
8oQND5kWSb4

When something changed in the `transform` hook, then we have to return
the result. But if nothing changed, then we have to return a `NullValue`
(`undefined` is a `NullValue`). This gets rid of the warning you get
that the sourcemaps _might_ be wrong.
@RobinMalfait RobinMalfait requested a review from a team as a code owner May 22, 2026 15:43
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 22, 2026

Confidence Score: 5/5

Safe to merge — the change is a two-line fix with a focused integration test and no impact on files that are Tailwind roots.

The fix aligns with Vite's documented transform hook contract: returning undefined skips the plugin for a given module, while returning the unchanged source string creates an unwanted sourcemap chain entry. Both affected call sites are corrected identically, and the new integration test directly reproduces the reported failure scenario using getCombinedSourcemap() to surface the warning.

No files require special attention.

Reviews (2): Last reviewed commit: "update changelog" | Re-trigger Greptile

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 22, 2026

Review Change Stack

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: 0bfc2d07-0e34-4053-b04b-4679513dfb7b

📥 Commits

Reviewing files that changed from the base of the PR and between d6c37b3 and 8da98f5.

📒 Files selected for processing (1)
  • CHANGELOG.md
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md

Walkthrough

The Tailwind Vite plugin's CSS transform handlers for both serve-mode and build-mode now return undefined when encountering non-Tailwind-root CSS files instead of returning the original source. A new test case validates that this change does not trigger sourcemap warnings when running a production build without Tailwind content roots present, even when sourcemaps are explicitly enabled.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly summarizes the main fix: preventing 'Sourcemap is likely to be incorrect' warnings in the @tailwindcss/vite plugin.
Description check ✅ Passed The description clearly explains the issue (CSS files not Tailwind roots returning src instead of undefined), the fix, and testing approach, directly relating to the changeset.
Linked Issues check ✅ Passed The PR fixes the exact issue from #19930 by returning undefined instead of src for non-root CSS files in the transform hook, eliminating sourcemap warnings.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the sourcemap warning issue: test case, plugin logic fix, and changelog entry directly address #19930 requirements.

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


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

@RobinMalfait RobinMalfait merged commit 73983e1 into main May 22, 2026
9 checks passed
@RobinMalfait RobinMalfait deleted the fix/issue-19930 branch May 22, 2026 15:57
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 still emits SOURCEMAP_BROKEN warnings in Nuxt/Vite builds

1 participant