From 7e6731a0db765be5a132c7240882fdf4b95e4a03 Mon Sep 17 00:00:00 2001 From: Romain Lanz Date: Mon, 12 Oct 2026 09:54:30 +0000 Subject: [PATCH] perf: parse the controller once per routes invalidation RoutesScanner.invalidate created a new VirtualFileSystem for each route bound to the changed controller. Each instance had an empty AST cache, so the dev server read and parsed the same controller file once per route on every save. Create the VirtualFileSystem once before the loop, as scan() already does. A fresh instance is still created on each call, so an invalidation always reads the latest file contents. --- src/code_scanners/routes_scanner/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/code_scanners/routes_scanner/main.ts b/src/code_scanners/routes_scanner/main.ts index 295abe8a..4fd7f235 100644 --- a/src/code_scanners/routes_scanner/main.ts +++ b/src/code_scanners/routes_scanner/main.ts @@ -514,11 +514,11 @@ export class RoutesScanner { return false } + const vfs = new VirtualFileSystem(this.#appRoot) for (let scannedRoute of controllerRoutes) { if (scannedRoute.controller) { debug('invalidating route %O', scannedRoute) - const vfs = new VirtualFileSystem(this.#appRoot) await this.#setResponse(scannedRoute, scannedRoute.controller) await this.#setRequest(scannedRoute, scannedRoute.controller, vfs) }