-
Notifications
You must be signed in to change notification settings - Fork 276
Closed
Description
Steps to reproduce:
- Clone repo on Windows (Node 20+, pnpm)
- pnpm install
- pnpm run dev
- Console shows error resolving import /@fsc:/... (missing slash after /@fs)
Error:
Failed to resolve import "/@fsc:/.../src/pizzaz/index.jsx"
Root cause:
Helper toFs in vite.config.mts used "/@fs" (no trailing slash), emitting /@fsc:/... on Windows. path.posix.relative was also not Windows-aware.
i,e:
const toFs = (abs: string) => "/@fs" + abs.replace(/\\/g, "/");
const toServerRoot = (abs: string) =>
"./" + path.posix.relative(process.cwd(), abs).replace(/\\/g, "/");
Fix:
Use "/@fs/" and platform-aware path.relative with a fallback to /@fs for non-relative cases.
i.e:
const toFs = (abs: string) => "/@fs/" + abs.replace(/\\/g, "/");
const toServerRoot = (abs: string) => {
const rel = path.relative(process.cwd(), abs).replace(/\\/g, "/");
// If it's not really relative (different drive or absolute), fall back to fs URL
if (!rel || rel.startsWith("..") || path.isAbsolute(rel)) return toFs(abs);
return "./" + rel;
};
Validated:
- Windows 11: dev server loads all endpoints (HMR works)
- Linux (Ubuntu): unchanged
No other files changed.
Metadata
Metadata
Assignees
Labels
No labels