From a90d3683d3fcf0171e70f1762f16fa21e58e3fc9 Mon Sep 17 00:00:00 2001 From: Ajay Ghanwat Date: Sun, 9 Aug 2026 13:32:00 +0530 Subject: [PATCH] fix(dev-server): normalize hot reload module paths --- packages/dev-server/src/pipeline.ts | 2 ++ packages/dev-server/test/pipeline.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/dev-server/src/pipeline.ts b/packages/dev-server/src/pipeline.ts index 030d574b..0457fa67 100644 --- a/packages/dev-server/src/pipeline.ts +++ b/packages/dev-server/src/pipeline.ts @@ -259,6 +259,7 @@ async function rewriteArtifactImportsAsync( } export async function loadModule(file: string): Promise> { + file = resolve(file); let mod = moduleCache.get(file); if (!mod) { mod = (async () => { @@ -631,6 +632,7 @@ export function serveWrnBrowserArtifact(pathname: string): Response | null { /** Forget one module and force its next dynamic import to bypass Bun's import cache. */ export function invalidateModule(file: string): void { + file = resolve(file); moduleCache.delete(file); moduleVersions.set(file, (moduleVersions.get(file) ?? 0) + 1); } diff --git a/packages/dev-server/test/pipeline.test.ts b/packages/dev-server/test/pipeline.test.ts index 0be320a7..dd3d9648 100644 --- a/packages/dev-server/test/pipeline.test.ts +++ b/packages/dev-server/test/pipeline.test.ts @@ -83,7 +83,7 @@ test("invalidateModule loads changed server modules without restarting the proce } }); -test("invalidateModule recompiles changed WRN files in-process", async () => { +test("invalidateModule recompiles changed WRN files with watcher-normalized separators", async () => { const root = mkdtempSync(join(tmpdir(), "wrnexus-hmr-")); const file = join(root, "page.wrn"); setCompileCacheDir(join(root, ".wrnexus")); @@ -94,7 +94,7 @@ test("invalidateModule recompiles changed WRN files in-process", async () => { expect(String(first({}))).toContain("First"); writeFileSync(file, "page Home { view {

Second

} }\n"); - invalidateModule(file); + invalidateModule(file.replace(/\\/g, "/")); const second = (await loadModule(file)).default as (ctx: unknown) => unknown; expect(String(second({}))).toContain("Second"); } finally {