Repository navigation
[Bug?]: "use server" functions are not compiled when the project is opened through a junction or symlink on Windows #2356
Description
Duplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Current behavior 😯
On Windows, when the working directory reaches the project through a directory junction or a symbolic link, no "use server" function is compiled. A build whose server functions import server-only code such as @solidjs/start/http fails:
RolldownError: Attempt to import 'server-only' in a client module: C:/path/to/my-app/node_modules/@solidjs/start/dist/http/index.js. Code that uses this module must run only on the server: mark it with "use server", or make sure it is only imported by server code.
Without such an import the build succeeds, but the body of the server function is in the client bundle. The same project builds correctly when the working directory is its real path.
The server functions plugin creates its filter with createFilter("src/**/*.{jsx,tsx,...}", "node_modules/**/*...") and no resolve option, so the relative patterns are resolved against process.cwd(). On Windows the working directory keeps the path it was entered through, while Vite resolves every module id, and since 8.2 also config.root, to the real path. The filter then matches no module. Linux and macOS report the real path from process.cwd(), so they are not affected.
The lazy plugin derives id$$ from process.cwd() in the same way. Once the filter matches, a build through a junction succeeds, but the ids of lazily loaded route components match no client manifest key, so their CSS is missing from the server-rendered HTML (in the basic template, the index route's CSS).
Expected behavior 🤔
Building the project through a junction compiles its server functions and puts the route CSS in the server-rendered HTML, as a build through its real path does.
Steps to reproduce 🕹
Steps (Windows, cmd):
npm create solid@latest -- -s --v2 --ts -t basic -p my-app, thencd my-appandnpm install.- Add
src/routes/agent.tsx:import { createAsync, query } from "@solidjs/router"; import { getRequestHeader } from "@solidjs/start/http"; const getUserAgent = query(async () => { "use server"; return getRequestHeader("user-agent") ?? "unknown"; }, "user-agent"); export default function Agent() { const agent = createAsync(() => getUserAgent()); return <p>{agent()}</p>; }
npm run buildsucceeds.- Create a junction to the project and build through it:
mklink /J C:\my-app-link C:\path\to\my-app, thencd /d C:\my-app-linkandnpm run build. The build fails with the error above. The junction is on the same drive as the project, so this is not Vite's known problem with links across drives; a junction to another drive fails the same way.
A pull request follows that fixes the filter andlazy, with tests that reproduce both on any OS by makingprocess.cwd()differ from Vite's root.
Context 🔦
I open my checkouts through a junction from another drive, and the error suggests a mistake in the application code rather than a path problem, so the cause was hard to find.
Your environment 🌎
System:
OS: Windows 11
Binaries:
Node: 26.10.0
npm: 12.0.2
npmPackages:
@solidjs/start: 2.0.6
vite: 8.3.4
nitro: 3.0.260610-beta
Activity