Skip to content

Commit 5ab586c

Browse files
uhyoclaude
andauthored
fix: normalize file paths embedded in virtual modules for Windows compatibility (#95)
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) <noreply@anthropic.com>
1 parent 66298e9 commit 5ab586c

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

packages/static/src/plugin/index.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import path from "node:path";
2-
import type { Plugin } from "vite";
2+
import { normalizePath, type Plugin } from "vite";
33
import rsc from "@vitejs/plugin-rsc";
44
import { buildApp } from "../build/buildApp";
55
import { serverPlugin } from "./server";
@@ -129,20 +129,28 @@ export default function funstackStatic(
129129
name: "@funstack/static:config",
130130
configResolved(config) {
131131
if (isMultiEntry) {
132-
resolvedEntriesModule = path.resolve(config.root, options.entries);
132+
resolvedEntriesModule = normalizePath(
133+
path.resolve(config.root, options.entries),
134+
);
133135
} else {
134136
// For single-entry, we store both resolved paths to generate a
135137
// synthetic entries module in the virtual module loader.
136-
const resolvedRoot = path.resolve(config.root, options.root);
137-
const resolvedApp = path.resolve(config.root, options.app);
138+
const resolvedRoot = normalizePath(
139+
path.resolve(config.root, options.root),
140+
);
141+
const resolvedApp = normalizePath(
142+
path.resolve(config.root, options.app),
143+
);
138144
// Encode as JSON for safe embedding in generated code
139145
resolvedEntriesModule = JSON.stringify({
140146
root: resolvedRoot,
141147
app: resolvedApp,
142148
});
143149
}
144150
if (clientInit) {
145-
resolvedClientInitEntry = path.resolve(config.root, clientInit);
151+
resolvedClientInitEntry = normalizePath(
152+
path.resolve(config.root, clientInit),
153+
);
146154
}
147155
},
148156
configEnvironment(_name, config) {

0 commit comments

Comments
 (0)