unit-test builder (Vitest): key `fsModuleCache` on the served build output instead of forcing it off
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 20/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- angular, typescript
- Área
- build-system, testing
Línea de trabajo
Start in the angular:test-in-memory-provider plugin’s configureVitest hook and inspect how buildResultFiles are served and hashed. Check the unit-test builder configuration that forces fsModuleCache off, then trace how the cache key can include the served output and source map hashes. Done means the cache can be enabled without stale results when an imported file changes; the issue reports a fix-ready linked pull request, #34444.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Command
test
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
No response
Description
Since f0a74e8f0 (released in 22.2.3), @angular/build:unit-test forces fsModuleCache: false, at the root and on the test project, overriding the runnerConfig. The reason is sound: Vitest keys its file system module cache on the file found on disk, while a test entry point is served from its bundle, which also holds the application code the spec imports. Changing an imported file without touching the spec left the key unchanged, and the cache served a stale bundle.
Vitest provides a hook for exactly this case: a plugin can add its own part to the cache key with defineCacheKeyGenerator, from configureVitest. The angular:test-in-memory-provider plugin already implements configureVitest and holds buildResultFiles, the files its load() serves, each with a content hash. Keying the cache on the served build output (the output file hash plus its source map hash) removes the staleness at its root, so the cache does not need to be turned off.
Since #34337 (also in 22.2.3) the test bundles are byte-identical from one build to the next, so such a key is stable and the cache can be reused across runs and CI pipelines.
Measured on a workspace application with 255 spec files (warm Angular cache, macOS, runs alternated on an idle machine), the builder patched as described:
| builder | Vitest duration | ng test wall time |
|---|---|---|
| 22.2.3 (cache forced off) | 21.4 s, 21.4 s | 36.6 s, 37.9 s |
patched, warm fsModuleCache |
20.0 s, 18.4 s | 35.8 s, 35.8 s |
The gain is modest here, since execution dominates this suite; it grows with the share of transform time. On the same workspace, changing a file imported by a spec (without touching the spec) makes that spec fail as expected, and reverting the change reuses the original cache entry.
I have a fix ready and will open a PR referencing this issue.
Minimal Reproduction
- In a project using
@angular/build:unit-testwith Vitest 5, setfsModuleCache: trueandfsModuleCachePath: './.vitest-cache'in therunnerConfig. - Run
ng test --no-watch. - No
.vitest-cachedirectory is created: the builder overrides the option.
Exception or Error
No response
Your Environment
Angular CLI : 22.2.3
Angular : 22.2.3
Node.js : 24.21.0
Package Manager : npm 11.19.0
Operating System : darwin arm64
@angular/build : 22.2.3
vitest : 5.0.4
Anything else relevant?
Follow-up of #34335 / #34337 (deterministic test discovery) and of f0a74e8f0 (fsModuleCache disabled to avoid stale bundles).
- Lenguaje dominante
- TypeScript
- Estrellas
- 27k
- Forks
- 11.8k
- Merge medio
- 1 d 5 h
- PR fusionados (30 d)
- 244
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de angular/angular-cli
-
Can't use an array of hostnames in --allowedHosts cli parameter in @angular/build:dev-serverAbiertoarea: @angular/build gemini-triaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
angular/angular-cli#33955 ·
Los mantenedores suelen responder en 1 día
-
area: @angular/cli gemini-triaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
angular/angular-cli#33055 · 1 comentario · 3 reacciones ·
Los mantenedores suelen responder en 1 día
-
Angular SSR Unescaped prerender parameters enable RCE through generated manifests and XSS in redirect pagesPosiblemente ocupada @SkyZeroZx la tomó hace 152 días. Abiertoarea: @angular/ssr
Dificultad 4/5 3-5 días Aptitud para principiantes 53/100
angular/angular-cli#34474 ·
Los mantenedores suelen responder en 1 día
-
`ng generate app-shell` and `ng generate module --route` produce broken imports when a component `type` is configuredPosiblemente ocupada @MeAkib la tomó hace 2 días. Abiertoarea: @schematics/angular
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
angular/angular-cli#34449 ·
Los mantenedores suelen responder en 1 día
-
Tailwind CSS v4 classes in new or moved files are not picked up by ng serve until another rebuildPosiblemente ocupada @MeAkib la tomó hace 3 días. Abiertoarea: @angular/build
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
angular/angular-cli#34446 ·
Los mantenedores suelen responder en 1 día
Todos los issues de angular/angular-cli
Issues similares
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
openclaw/openclaw#182077 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
aikido high security
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
dequelabs/axe-linter-action#161 ·
-
[Feature Request] Update the DimCode agent icon to the 45:32 brand markPosiblemente ocupada @eric8810 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
[Feature]: 建议导入源后,自动切换到新导入的源Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
lyswhut/lx-music-desktop#3026 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
abhigyanpatwari/GitNexus#3704 ·
Los mantenedores suelen responder en 1 día