Skip to content

Conversation

@hlongc
Copy link

@hlongc hlongc commented Nov 28, 2025

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:

  1. "Scanning dependencies..." when dependency scanning starts
  2. "Pre-bundling X dependencies..." when optimization begins
  3. "Dependencies optimized in Xs" when optimization completes

Example output:

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 message
  • packages/vite/src/node/optimizer/index.ts - Added pre-bundling start and completion messages

That's it! Simple progress feedback without changing anything else.

Thanks for reviewing! 🙏

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
Comment on lines 729 to 730
const durationMs = (performance.now() - start).toFixed(2)
const durationS = (parseInt(durationMs) / 1000).toFixed(2)
Copy link
Contributor

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)
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

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Copy link
Author

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show dep optimization progress in the CLI

1 participant