Skip to content

Commit

Permalink
refactor: deprecate vite optimize command (#19348)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red authored Feb 5, 2025
1 parent 7c2a794 commit 6e0e3c0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/guide/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ vite build [root]

Pre-bundle dependencies.

**Deprecated**: the pre-bundle process runs automatically and does not need to be called.

#### Usage

```bash
Expand Down
5 changes: 4 additions & 1 deletion packages/vite/src/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,10 @@ cli

// optimize
cli
.command('optimize [root]', 'pre-bundle dependencies')
.command(
'optimize [root]',
'pre-bundle dependencies (deprecated, the pre-bundle process runs automatically and does not need to be called)',
)
.option(
'--force',
`[boolean] force the optimizer to ignore the cache and re-bundle`,
Expand Down
8 changes: 8 additions & 0 deletions packages/vite/src/node/optimizer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ export interface DepOptimizationMetadata {
/**
* Scan and optimize dependencies within a project.
* Used by Vite CLI when running `vite optimize`.
*
* @deprecated the optimization process runs automatically and does not need to be called
*/

export async function optimizeDeps(
Expand All @@ -255,6 +257,12 @@ export async function optimizeDeps(
): Promise<DepOptimizationMetadata> {
const log = asCommand ? config.logger.info : debug

config.logger.warn(
colors.yellow(
'manually calling optimizeDeps is deprecated. This is done automatically and does not need to be called manually.',
),
)

const environment = new ScanEnvironment('client', config)
await environment.init()

Expand Down

0 comments on commit 6e0e3c0

Please sign in to comment.