Skip to content
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

refactor: deprecate vite optimize command #19348

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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