-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
feat: show dependency optimization progress in CLI #21167
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
base: main
Are you sure you want to change the base?
Conversation
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: **Changes:** 1. Display "Scanning dependencies..." when dependency scanning starts 2. Display "Pre-bundling X dependencies..." when optimization begins 3. Display "✨ Dependencies optimized in Xs" when optimization completes **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 ``` These messages help users understand: - When the optimization process is happening - How many dependencies are being optimized - How long the process took The debug-level messages remain unchanged for developers who need detailed information. Closes vitejs#21149
| const durationMs = (performance.now() - start).toFixed(2) | ||
| const durationS = (parseInt(durationMs) / 1000).toFixed(2) |
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.
Logic error in time conversion causes precision loss. durationMs is already a string from .toFixed(2), and parseInt(durationMs) truncates the decimal part before converting to seconds.
For example, if the actual time is 1234.99ms:
- Current code:
parseInt("1234.99")= 1234, then 1234/1000 = 1.234s - Correct: 1234.99/1000 = 1.23499s
This loses up to 0.99ms of precision in the seconds display. Fix by storing the numeric value first:
const duration = performance.now() - start
const durationMs = duration.toFixed(2)
const durationS = (duration / 1000).toFixed(2)| const durationMs = (performance.now() - start).toFixed(2) | |
| const durationS = (parseInt(durationMs) / 1000).toFixed(2) | |
| const duration = performance.now() - start | |
| const durationMs = duration.toFixed(2) | |
| const durationS = (duration / 1000).toFixed(2) |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
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.
Good catch! Fixed the precision loss issue by storing the numeric duration first. Thanks for the detailed explanation! 👍
Store numeric duration value first before formatting to avoid parseInt truncating decimal part (up to 0.99ms precision loss).
- Preserve dependency optimization progress display feature - Update to use rolldown instead of esbuild optimizer - Maintain progress logging functionality
What is this PR solving?
Fixes #21149 - Users can't see dependency optimization progress in the CLI without debug mode.
When Vite optimizes dependencies (especially in large projects), users see no feedback and might think Vite is stuck. This adds simple progress messages so people know what's happening.
Changes
Added three progress messages:
Example output:
Example output:
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 messagesThat's it! Simple progress feedback without changing anything else.
Thanks for reviewing! 🙏