From 69e5cf7ecbea818d05de48d643d1ef00a6b0f789 Mon Sep 17 00:00:00 2001 From: Mehrshad Date: Wed, 26 Aug 2026 07:38:12 +0330 Subject: [PATCH 1/2] test: lazy-ref src values must serialize with forward slashes On Windows OS, node:path relative() returns backslashed src values in serialized lazy refs. Vite client-manifest keys are always posix, so they never match: SSR hydration preloads silently miss and SolidJS server lazy() breaks. The test fails on Windows today and pins the invariant before the fix lands. --- test/vite.spec.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/vite.spec.ts b/test/vite.spec.ts index d0af478..299a704 100644 --- a/test/vite.spec.ts +++ b/test/vite.spec.ts @@ -85,6 +85,20 @@ describe("fileRoutes vite plugin", () => { expect(code.match(/pick=default&pick=\$css&lang\.tsx'\)/g)?.length).toBe(2); }); + it("serializes lazy-ref src values with forward slashes", async () => { + const directory = createRouteTree({ + "index.tsx": "export default () =>

Home

;" + }); + + const split = await loadVirtualModule(directory); + const eager = await loadWith(createPlugin(directory, { codeSplitting: false }), directory); + + expect(split).toContain('"src"'); + expect(eager).toContain('"src"'); + expect(split).not.toContain("\\"); + expect(eager).not.toContain("\\"); + }); + it("resolves only the virtual module id", async () => { const [plugin] = fileRoutes() as any[]; expect(moduleId).toBe("virtual:file-routes"); From 745ffdf776dd3a63773f4a073cc48e24b091b8f7 Mon Sep 17 00:00:00 2001 From: Mehrshad Date: Wed, 26 Aug 2026 07:53:17 +0330 Subject: [PATCH 2/2] fix: normalize lazy-ref src values to posix separators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit node:path relative() emits Windows separators, which never match Vite's always-posix client-manifest keys — SSR hydration preloads miss and server lazy() breaks. Every other path in the pipeline is already normalized through normalizePath(); these two sites were the only ones missed. Turns the regression test from the previous commit green on Windows. --- src/vite/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vite/index.ts b/src/vite/index.ts index 4279b50..3bc19fa 100644 --- a/src/vite/index.ts +++ b/src/vite/index.ts @@ -319,12 +319,12 @@ export function fileRoutes(options: FileRoutesOptions = {}): PluginOption[] { // plus the `src` lazy refs already expose. if (!codeSplitting) { return { - src: relative(root, buildId), + src: normalizePath(relative(root, buildId)), require: `_$() => (${js.addNamespaceImport(buildId)})$_` }; } return { - src: relative(root, buildId), + src: normalizePath(relative(root, buildId)), build: isBuild ? `_$() => import('${buildId}')$_` : undefined, import: `_$() => import('${buildId}')$_` };