|
1 | | -import { TanStackServerFnPlugin } from "@tanstack/server-functions-plugin"; |
2 | 1 | import { defu } from "defu"; |
3 | 2 | import { globSync } from "node:fs"; |
4 | 3 | import { extname, isAbsolute, join } from "node:path"; |
5 | 4 | import { fileURLToPath } from "node:url"; |
6 | 5 | import { normalizePath, type PluginOption } from "vite"; |
7 | 6 | import solid, { type Options as SolidOptions } from "vite-plugin-solid"; |
8 | | - |
| 7 | +import { serverFunctionsPlugin } from "../directives/index.ts"; |
9 | 8 | import { DEFAULT_EXTENSIONS, VIRTUAL_MODULES, VITE_ENVIRONMENTS } from "./constants.ts"; |
10 | 9 | import { devServer } from "./dev-server.ts"; |
11 | 10 | import { type EnvPluginOptions, envPlugin } from "./env.ts"; |
@@ -180,38 +179,15 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> { |
180 | 179 | envPlugin(options?.env), |
181 | 180 | // Must be placed after fsRoutes, as treeShake will remove the |
182 | 181 | // server fn exports added in by this plugin |
183 | | - TanStackServerFnPlugin({ |
184 | | - // This is the ID that will be available to look up and import |
185 | | - // our server function manifest and resolve its module |
186 | | - manifestVirtualImportId: VIRTUAL_MODULES.serverFnManifest, |
187 | | - directive: "use server", |
188 | | - callers: [ |
189 | | - { |
190 | | - envConsumer: "client", |
191 | | - envName: VITE_ENVIRONMENTS.client, |
192 | | - getRuntimeCode: () => |
193 | | - `import { createServerReference } from "${normalizePath( |
194 | | - fileURLToPath(new URL("../server/server-runtime", import.meta.url)), |
195 | | - )}"`, |
196 | | - replacer: opts => `createServerReference('${opts.functionId}')`, |
197 | | - }, |
198 | | - { |
199 | | - envConsumer: "server", |
200 | | - envName: VITE_ENVIRONMENTS.server, |
201 | | - getRuntimeCode: () => |
202 | | - `import { createServerReference } from '${normalizePath( |
203 | | - fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url)), |
204 | | - )}'`, |
205 | | - replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')`, |
206 | | - }, |
207 | | - ], |
208 | | - provider: { |
209 | | - envName: VITE_ENVIRONMENTS.server, |
210 | | - getRuntimeCode: () => |
211 | | - `import { createServerReference } from '${normalizePath( |
212 | | - fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url)), |
213 | | - )}'`, |
214 | | - replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')`, |
| 182 | + serverFunctionsPlugin({ |
| 183 | + manifest: VIRTUAL_MODULES.serverFnManifest, |
| 184 | + runtime: { |
| 185 | + server: normalizePath( |
| 186 | + fileURLToPath(new URL("../server/server-fns-runtime.ts", import.meta.url)), |
| 187 | + ), |
| 188 | + client: normalizePath( |
| 189 | + fileURLToPath(new URL("../server/server-runtime.ts", import.meta.url)), |
| 190 | + ), |
215 | 191 | }, |
216 | 192 | }), |
217 | 193 | { |
|
0 commit comments