diff --git a/packages/discovery/src/builders.ts b/packages/discovery/src/builders.ts index 3dfe182..95efc96 100644 --- a/packages/discovery/src/builders.ts +++ b/packages/discovery/src/builders.ts @@ -137,6 +137,19 @@ export function anonFunct(props: { }); } +export function wrapExprInFunct(expr: Expression) { + return paren({ + type: "ArrowFunctionExpression", + params: [], + body: expr, + expression: true, + async: false, + id: null, + generator: false, + ...defaultSpan, + }); +} + export function throwStmt(toThrow: Expression): ThrowStatement { return { type: "ThrowStatement", diff --git a/packages/discovery/src/transpile/api.ts b/packages/discovery/src/transpile/api.ts index 3f2ff69..56bcba4 100644 --- a/packages/discovery/src/transpile/api.ts +++ b/packages/discovery/src/transpile/api.ts @@ -1,6 +1,6 @@ import { unwrap } from "@vortexjs/common"; import type { CallExpression, Expression } from "oxc-parser"; -import { anonFunct, createObject, defaultSpan, exportNode, identifier, literal } from "../builders"; +import { anonFunct, createObject, defaultSpan, exportNode, identifier, literal, wrapExprInFunct } from "../builders"; import { type CompilerState, getObjectKeys, @@ -56,12 +56,10 @@ export function handleAPIFunction( if (state.target === "server") { const implExportId = exportNode(state, impl); - props.impl = identifier(implExportId); + props.impl = wrapExprInFunct(identifier(implExportId)); const schemaExportId = exportNode(state, schema); - props.schema = identifier(schemaExportId); - state.clientEligible = false; state.discoveries.push({ type: "api", diff --git a/packages/example-wormhole/src/features/home/index.tsx b/packages/example-wormhole/src/features/home/index.tsx index 15f08e4..d51da56 100644 --- a/packages/example-wormhole/src/features/home/index.tsx +++ b/packages/example-wormhole/src/features/home/index.tsx @@ -14,6 +14,8 @@ route("/", { } }) + const currentTime = time.use({}); + return ( <> @@ -22,7 +24,7 @@ route("/", {

This is an example app, go to the{" "} - docs + docs, current time is {currentTime}