unit-test builder (Vitest): key `fsModuleCache` on the served build output instead of forcing it off
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 20/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- angular, typescript
- Ambito
- build-system, testing
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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).
- Lingua principale
- TypeScript
- Stelle
- 27k
- Fork
- 11.8k
- Merge medio
- 1g 2h
- PR unite (30g)
- 241
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di angular/angular-cli
-
area: @angular/build gemini-triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
angular/angular-cli#33955 ·
I maintainer di solito rispondono entro 1 giorno
-
area: @angular/cli gemini-triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
angular/angular-cli#33055 · 1 commento · 3 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
area: @angular/build
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
angular/angular-cli#34524 · 2 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
`ng generate app-shell` and `ng generate module --route` produce broken imports when a component `type` is configuredForse già presa @MeAkib l’ha presa 6 giorni fa. Apertaarea: @schematics/angular
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
angular/angular-cli#34449 ·
I maintainer di solito rispondono entro 1 giorno
-
Tailwind CSS v4 classes in new or moved files are not picked up by ng serve until another rebuildForse già presa @MeAkib l’ha presa 7 giorni fa. Apertaarea: @angular/build
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
angular/angular-cli#34446 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di angular/angular-cli
Issue simili
-
Plugin: sheet music can't be scrolled by hand before playbackForse già presa @snakajima l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
receptron/jinglescript#51 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 9 giorni
-
clawsweeper:needs-maintainer-review clawsweeper:needs-product-decision clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
openclaw/openclaw#186424 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
chore(worker): five module header comments describe the code from before later issues changed itApertaarea:dev U2-later
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
bentleypark/aiwatch#1824 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
Pal-AI-Lab/Coopanion#469 ·
I maintainer di solito rispondono entro 1 giorno