Fix 'Sourcemap is likely to be incorrect' warnings when using @tailwindcss/vite#20103
Conversation
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.
Confidence Score: 5/5Safe 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 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
WalkthroughThe Tailwind Vite plugin's CSS transform handlers for both serve-mode and build-mode now return 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
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
transformstep, we return thesrcof that module as-is because we didn't modify anything. However, when nothing changed, you have to return aNullValuesuch asundefined.So this is a stupid little fix, but it should get rid of a bunch of annoying warnings.
Fixes: #19930
Test plan
Before:

After:
