Skip to content

Suppress dependency optimizations on nuxt dev #1141

@alashchev17

Description

@alashchev17

Problem

Vite's automatic dependency optimization causes disruptive "optimized dependencies changed. reloading" messages that severely impact development workflows:

  1. CI/CD Testing: Playwright/Cypress tests fail with ECONNRESET errors or freeze when dependencies optimize mid-test
  2. Local Package Development: Virtual links (pnpm/npm link) get overridden, breaking monorepo workflows
  3. Complex Applications: Apps with many pages/routes trigger endless reloads as each page imports new dependencies during manual testing
  4. Debugging Sessions: Unexpected reloads cause loss of application state

Developers need control over when optimization happens to avoid it when unnecessary.

Proposed Solution

Add a CLI flag to disable Vite's dependency optimization:

nuxt dev --suppress-dependency-optimization

This would set vite.optimizeDeps.disabled = true internally.

Use Cases

E2E Testing:

nuxt dev --suppress-dependency-optimization & npm run test:e2e

Testing Complex Apps:

# Navigate through all pages without constant reloads
nuxt dev --suppress-dependency-optimization

Monorepo Development:

# Preserve linked local packages
nuxt dev --suppress-dependency-optimization

Why This Matters

  • Current workaround requires manually listing all dependencies in vite.optimizeDeps.include - impractical for large apps
  • Optimization is helpful for production but often unnecessary during active development
  • Developers should control when optimization occurs, not be forced into it

Implementation

Non-breaking opt-in flag that passes through to existing Vite configuration. Simple addition to the dev command args.

Would the team accept a PR for this feature?

Related: #27700, nuxt/nuxt#26783, nuxt/nuxt#27372

Additional information

  • Would you be willing to help implement this feature?
  • Could this feature be implemented as a module?

Final checks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions