[]previous and next page

transformServerFns

Finds the server functions of a module and, for the client and server targets, rewrites it.

Finds the server functions of a module and, for the client and server targets, rewrites it.

Import#

ts
import { transformServerFns } from "@shadow-js/dusk/vite";

Signature#

ts
function transformServerFns(
  options: ServerFnTransformOptions,
): ServerFnTransformResult | null

Parameters#

Name Description
options The module, its place in the project and the target.

Returns#

The new text and the list of server functions, or null for a module with none.

Throws#

  • ServerFnError for a server function that cannot be compiled: options the build cannot read, a function that is not exported, a "use server" function that captures local variables.
  • ModuleParseError for a syntax error.

Examples#

ts
const result = transformServerFns({ code, file, root, target: "client" });
result?.fns.map((fn) => fn.id);