feat: show dependency optimization progress in CLI#21167
Open
hlongc wants to merge 4 commits intovitejs:mainfrom
Open
feat: show dependency optimization progress in CLI#21167hlongc wants to merge 4 commits intovitejs:mainfrom
hlongc wants to merge 4 commits intovitejs:mainfrom
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
4 tasks
Comment on lines
+729
to
+730
| const durationMs = (performance.now() - start).toFixed(2) | ||
| const durationS = (parseInt(durationMs) / 1000).toFixed(2) |
Contributor
There was a problem hiding this comment.
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)
Suggested change
| 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.
Author
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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! 🙏