Skip to content

Commit cf4f3e6

Browse files
fix: dev serverfn resolution on windows (#5520)
1 parent 7d8e105 commit cf4f3e6

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

packages/server-functions-plugin/src/index.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,32 @@ export function TanStackServerFnPlugin(
6868
const entryIdToFunctionId = new Map<string, string>()
6969
const functionIds = new Set<string>()
7070

71+
function withTrailingSlash(path: string): string {
72+
if (path[path.length - 1] !== '/') {
73+
return `${path}/`
74+
}
75+
return path
76+
}
77+
7178
const generateFunctionId: GenerateFunctionIdFn = ({
7279
extractedFilename,
7380
functionName,
7481
filename,
7582
}) => {
7683
if (serverDevEnv) {
84+
const root = serverDevEnv.config.root
85+
86+
let file = extractedFilename
87+
if (extractedFilename.startsWith(withTrailingSlash(root))) {
88+
file = extractedFilename.slice(root.length)
89+
}
90+
file = `/@id${file[0] === '/' ? '' : '/'}${file}`
91+
7792
const serverFn: {
7893
file: string
7994
export: string
8095
} = {
81-
file: extractedFilename,
96+
file,
8297
export: functionName,
8398
}
8499
const base64 = Buffer.from(JSON.stringify(serverFn), 'utf8').toString(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export function getServerFnById() {}
1+
export async function getServerFnById(): Promise<any> {}

0 commit comments

Comments
 (0)