feat: show dependency optimization progress in CLI
📋 Description
Currently, users can only see dependency optimization progress when running Vite with --debug flag. Without debug mode, there is no way to know when Vite is actually ready to serve the app, which can be confusing especially for projects with many dependencies that take time to optimize.
This PR adds user-friendly progress messages in normal (non-debug) CLI mode to improve user experience.
🎯 What is this PR solving?
Fixes #21149 - Users cannot see dependency optimization progress in the CLI without debug mode.
Problem: When Vite is optimizing dependencies (especially in large projects), users see no feedback and might think Vite is stuck or not working.
Solution: Display clear progress messages at key stages of the optimization process.
✨ Changes
This PR adds three progress messages:
- "Scanning dependencies..." - when dependency scanning starts
- "Pre-bundling X dependencies..." - when optimization begins (shows count)
- "✨ Dependencies optimized in Xs" - when optimization completes (shows duration)
Example output:
10:30:15 AM [vite] Scanning dependencies...
10:30:16 AM [vite] Pre-bundling 42 dependencies...
10:30:23 AM [vite] ✨ Dependencies optimized in 7.23s
Files modified:
packages/vite/src/node/optimizer/optimizer.ts- Added scanning start messagepackages/vite/src/node/optimizer/index.ts- Added pre-bundling start and completion messages
🔍 What other alternatives have you explored?
- Adding a progress bar - Decided against it as it would be more complex and potentially noisy
- Only showing completion message - Not enough feedback during the process
- Using different log levels - Decided on
logger.infoto ensure visibility in normal mode
The current approach is minimal, non-intrusive, and provides just the right amount of feedback.
💡 Parts requiring more attention
- Message wording: Please review if the wording is clear and user-friendly
- Timing: The messages are placed at key stages, but please verify they appear at the right moments
- Debug mode: I've kept all existing debug messages unchanged to maintain compatibility
✅ Additional notes
- The debug-level messages remain unchanged for developers who need detailed information
- No breaking changes or API modifications
- Minimal performance impact (just three logger calls)
- Improves UX especially for first-time users and large projects
Thank you for reviewing! 🙏