-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
43 lines (42 loc) · 1.48 KB
/
index.ts
File metadata and controls
43 lines (42 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { normalize } from "vinxi/lib/path";
export { client } from "./plugin/client";
import { fileURLToPath } from "url";
export { importsPlugin } from "./imports";
import { createTanStackServerFnPlugin } from "@tanstack/server-functions-plugin";
export const SolidSocketFnsPlugin = createTanStackServerFnPlugin({
// This is the ID that will be available to look up and import
// our server function manifest and resolve its module
manifestVirtualImportId: "socket:fn-manifest",
client: {
getRuntimeCode: () =>
`import { createServerReference } from "${normalize(
fileURLToPath(
new URL("./socket/plugin/client-runtime.js", import.meta.url)
)
)}"`,
replacer: (opts) =>
`createServerReference(${() => {}}, '${opts.functionId}', '${
opts.extractedFilename
}')`,
},
ssr: {
getRuntimeCode: () =>
`import { createServerReference } from '${normalize(
fileURLToPath(
new URL("../dist/runtime/server-runtime.js", import.meta.url)
)
)}'`,
replacer: (opts) =>
`createServerReference(${opts.fn}, '${opts.functionId}', '${opts.extractedFilename}')`,
},
server: {
getRuntimeCode: () =>
`import { createServerReference } from '${normalize(
fileURLToPath(
new URL("../dist/runtime/server-runtime.js", import.meta.url)
)
)}'`,
replacer: (opts) =>
`createServerReference(${opts.fn}, '${opts.functionId}', '${opts.extractedFilename}')`,
},
});