-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
fix: add empty transform to vite scan plugin for Vite 7.0+ compatibility #19380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add empty transform to vite scan plugin for Vite 7.0+ compatibility #19380
Conversation
Fixes tailwindlabs#19376 - Cannot read properties of undefined (reading 'call') - Added empty transform() function to @tailwindcss/vite:scan plugin - Returns null to tell Vite to skip transformation for this plugin - Prevents undefined error when Vite 7.0+ tries to call plugin.transform.call() - Maintains backward compatibility with older Vite versions
|
@thecrypticace Can you please review this and tell me if there is any scope of improvement? |
WalkthroughAn empty Pre-merge checks✅ Passed checks (2 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (1)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. 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 |
|
The transform hook is optional in Vite. If it's throwing this is likely a Vite bug. |
|
See my comment here: #19376 (comment) I'm going to work on triaging this and filing a bug with Vite. Seems like something is causing a stale / incorrect cache and that is ultimately the bug here from what I can tell. |
|
@thecrypticace Thanks Man! |
|
I thought i found the solution! |
Summary
Fixes issue #19376 where
@tailwindcss/viteplugin causes "Cannot read properties of undefined (reading 'call')" error in Vite 7.0.0, especially during massive code changes, formatting, or branch switches.The problem occurs because Vite 7.0.0's plugin container system expects all plugins to have a
transformproperty, but the first plugin in the Tailwind CSS plugin array (@tailwindcss/vite:scan) only hadconfigureServerandconfigResolvedhooks without atransformproperty.Root cause:
pluginContainer.tstries to callplugin.transform.call()on all pluginstransformproperty, causingplugin.transformto beundefinedplugin.transform.call()Changes made:
transform()function to the@tailwindcss/vite:scanplugin that returnsnulltransformproperty for Vite 7.0.0 compatibilityTest plan
Verified the fix with:
Build verification:
The plugin builds successfully without TypeScript errors.
Plugin structure verification:
transformproperty definedtransformreturnsnull, telling Vite to skip transformationCompatibility verification:
No breaking changes - all existing functionality remains intact. The fix is minimal and only adds the missing property to prevent the undefined error.