|
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"; |
@@ -190,38 +189,15 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> { |
190 | 189 | envPlugin(options?.env), |
191 | 190 | // Must be placed after fsRoutes, as treeShake will remove the |
192 | 191 | // server fn exports added in by this plugin |
193 | | - TanStackServerFnPlugin({ |
194 | | - // This is the ID that will be available to look up and import |
195 | | - // our server function manifest and resolve its module |
196 | | - manifestVirtualImportId: VIRTUAL_MODULES.serverFnManifest, |
197 | | - directive: "use server", |
198 | | - callers: [ |
199 | | - { |
200 | | - envConsumer: "client", |
201 | | - envName: VITE_ENVIRONMENTS.client, |
202 | | - getRuntimeCode: () => |
203 | | - `import { createServerReference } from "${normalizePath( |
204 | | - fileURLToPath(new URL("../server/server-runtime", import.meta.url)), |
205 | | - )}"`, |
206 | | - replacer: opts => `createServerReference('${opts.functionId}')`, |
207 | | - }, |
208 | | - { |
209 | | - envConsumer: "server", |
210 | | - envName: VITE_ENVIRONMENTS.server, |
211 | | - getRuntimeCode: () => |
212 | | - `import { createServerReference } from '${normalizePath( |
213 | | - fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url)), |
214 | | - )}'`, |
215 | | - replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')`, |
216 | | - }, |
217 | | - ], |
218 | | - provider: { |
219 | | - envName: VITE_ENVIRONMENTS.server, |
220 | | - getRuntimeCode: () => |
221 | | - `import { createServerReference } from '${normalizePath( |
222 | | - fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url)), |
223 | | - )}'`, |
224 | | - replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')`, |
| 192 | + serverFunctionsPlugin({ |
| 193 | + manifest: VIRTUAL_MODULES.serverFnManifest, |
| 194 | + runtime: { |
| 195 | + server: normalizePath( |
| 196 | + fileURLToPath(new URL("../server/server-fns-runtime.ts", import.meta.url)), |
| 197 | + ), |
| 198 | + client: normalizePath( |
| 199 | + fileURLToPath(new URL("../server/server-runtime.ts", import.meta.url)), |
| 200 | + ), |
225 | 201 | }, |
226 | 202 | }), |
227 | 203 | { |
|
0 commit comments