From d0896b76ff15a948a8b4827f20bd1e54075a1461 Mon Sep 17 00:00:00 2001 From: uhyo Date: Mon, 23 Mar 2026 23:04:16 +0900 Subject: [PATCH] fix: normalize file paths embedded in virtual modules for Windows compatibility Use Vite's normalizePath() to convert backslashes to forward slashes in resolved paths before embedding them in generated virtual module code. Closes #93 Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/static/src/plugin/index.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/static/src/plugin/index.ts b/packages/static/src/plugin/index.ts index b909562..b5b7d29 100644 --- a/packages/static/src/plugin/index.ts +++ b/packages/static/src/plugin/index.ts @@ -1,5 +1,5 @@ import path from "node:path"; -import type { Plugin } from "vite"; +import { normalizePath, type Plugin } from "vite"; import rsc from "@vitejs/plugin-rsc"; import { buildApp } from "../build/buildApp"; import { serverPlugin } from "./server"; @@ -129,12 +129,18 @@ export default function funstackStatic( name: "@funstack/static:config", configResolved(config) { if (isMultiEntry) { - resolvedEntriesModule = path.resolve(config.root, options.entries); + resolvedEntriesModule = normalizePath( + path.resolve(config.root, options.entries), + ); } else { // For single-entry, we store both resolved paths to generate a // synthetic entries module in the virtual module loader. - const resolvedRoot = path.resolve(config.root, options.root); - const resolvedApp = path.resolve(config.root, options.app); + const resolvedRoot = normalizePath( + path.resolve(config.root, options.root), + ); + const resolvedApp = normalizePath( + path.resolve(config.root, options.app), + ); // Encode as JSON for safe embedding in generated code resolvedEntriesModule = JSON.stringify({ root: resolvedRoot, @@ -142,7 +148,9 @@ export default function funstackStatic( }); } if (clientInit) { - resolvedClientInitEntry = path.resolve(config.root, clientInit); + resolvedClientInitEntry = normalizePath( + path.resolve(config.root, clientInit), + ); } }, configEnvironment(_name, config) {