Skip to content

Commit 6e0e3c0

Browse files
authored
refactor: deprecate vite optimize command (#19348)
1 parent 7c2a794 commit 6e0e3c0

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

docs/guide/cli.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ vite build [root]
7979

8080
Pre-bundle dependencies.
8181

82+
**Deprecated**: the pre-bundle process runs automatically and does not need to be called.
83+
8284
#### Usage
8385

8486
```bash

packages/vite/src/node/cli.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,10 @@ cli
333333

334334
// optimize
335335
cli
336-
.command('optimize [root]', 'pre-bundle dependencies')
336+
.command(
337+
'optimize [root]',
338+
'pre-bundle dependencies (deprecated, the pre-bundle process runs automatically and does not need to be called)',
339+
)
337340
.option(
338341
'--force',
339342
`[boolean] force the optimizer to ignore the cache and re-bundle`,

packages/vite/src/node/optimizer/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ export interface DepOptimizationMetadata {
246246
/**
247247
* Scan and optimize dependencies within a project.
248248
* Used by Vite CLI when running `vite optimize`.
249+
*
250+
* @deprecated the optimization process runs automatically and does not need to be called
249251
*/
250252

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

260+
config.logger.warn(
261+
colors.yellow(
262+
'manually calling optimizeDeps is deprecated. This is done automatically and does not need to be called manually.',
263+
),
264+
)
265+
258266
const environment = new ScanEnvironment('client', config)
259267
await environment.init()
260268

0 commit comments

Comments
 (0)