Skip to content

vite-plugin-angular: vitest run is treated as watch mode (only the --run flag is detected) #2372

@fyvfyv

Description

@fyvfyv

Please provide the environment you discovered this bug in.

@analogjs/vite-plugin-angular: 2.5.1 (still present on beta, 2.6.1-beta.2)
@analogjs/vitest-angular: 2.5.1
vite: 8.x
vitest: 4.x
node: 24
OS: any

Which area/package is the issue in?

vite-plugin-angular

Description

isTestWatchMode() in packages/vite-plugin-angular/src/lib/angular-vite-plugin.ts looks for a --run flag in argv to decide between a one-shot run and watch mode. It does not know about the vitest run subcommand form, so vitest run (common in CI scripts and nx setups) falls through to return true and the plugin stays in watch mode.

Its result is OR-ed into testWatchMode in configResolved, so nothing later corrects it.

Impact is speed only, not correctness: in watch mode the plugin keeps sourceFileCache attached, and any module invalidation during the run (for example a mid-run dep re-optimize) triggers another incremental compilation over the full program roots. One-shot CI runs pay watch-mode recompile cost they should not.

Repro: run any analog vitest project with vitest run (the subcommand, not vitest --run) and check isTestWatchMode() / watch-mode behavior on invalidation.

Please provide the exception or error you saw

No error. Extra recompiles / slower one-shot runs only.

Other information

Suggested fix: also treat an exact run argument as a one-shot run. Watch cases started by nx still win through the existing OR with config.server.watch in configResolved. I have a fix with tests ready and will open a PR.

I would be willing to submit a PR to fix this issue

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions