-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
fix(vite): ensure optimizeDeps config is applied with environment api #33586
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(vite): ensure optimizeDeps config is applied with environment api #33586
Conversation
|
|
WalkthroughThe EnvironmentsPlugin in Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3–5 minutes
Potential areas requiring attention:
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/vite/src/plugins/environments.ts (1)
26-27: LGTM! This correctly fixes the plugin execution order issue.The addition of
enforce: 'pre'ensures that theEnvironmentsPluginruns before other Vite plugins, preventing later plugins from overriding or interfering with theoptimizeDepsconfiguration. This directly addresses the regression where CommonJS modules (likeufoand@supabase/postgrest-js) weren't being properly optimised to ESM.The approach aligns with Vite's plugin architecture for infrastructure plugins that need to establish foundational configuration.
Optional: Consider enhancing the comment for better maintainability.
The comment could be more specific about why early execution is critical:
- enforce: 'pre', // run before other plugins + enforce: 'pre', // run before other plugins to ensure optimizeDeps config is applied correctlyThis would help future maintainers understand the specific reasoning behind the enforcement directive.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/vite/src/plugins/environments.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Follow standard TypeScript conventions and best practices
Files:
packages/vite/src/plugins/environments.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build
- GitHub Check: code
@nuxt/kit
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
CodSpeed Performance ReportMerging #33586 will not alter performanceComparing Summary
Footnotes |
|
I just made a pnpm patch of SyntaxError: The requested module '/_nuxt/@fs/Users/benjamincanac/GitHub/nuxt-ui-templates/chat/node_modules/.pnpm/extend@3.0.2/node_modules/extend/index.js?v=ee620684' does not provide an export named 'default' |
|
I can confirm that this also fixes a related issue when testing using Vitest browser mode! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you 😊
|
Hello! Since this is a downstream breaking issue (specifically for the Nuxt Supabase plugin) with otherwise no side-effects from preliminary inspections and an approving review: when can we expect to see this merged and released? Wondering if I should hold off rolling back if the fix is imminent :) |
|
fix should be imminent! |
🔗 Linked issue
Fixes: #33582
Summary
Adds
enforce: 'pre'to the EnvironmentsPlugin to ensure it runs before other Vite plugins, fixing issues where dependency optimization configuration was not correctlyapplied.
Problem
After migrating to Vite's Environment API, certain packages (like
ufo,@supabase/postgrest-js) failed to load with errors:The entry point "ufo" cannot be marked as externalThe requested module doesn't provide an export named: 'default'This happened because the
optimizeDepsconfiguration fromclientEnvironment()was being overridden or not correctly merged by other plugins running later in thepipeline.
Solution
By adding
enforce: 'pre'to the EnvironmentsPlugin, we ensure:optimizeDepsconfiguration is correctly applied at the root levelTest Plan
@nuxtjs/supabasemodule in playground