This repository has been archived by the owner on Mar 3, 2024. It is now read-only.
Releases: lxsmnsyc/use-server-directive
Releases · lxsmnsyc/use-server-directive
Server Blocks
- Adds a superset for
"use server"
functions called"use server"
blocks. This aims to bring the capability of"use server"
to not just functions but to every block statements, and any statements that has them (e.g.if-else
,try-catch
, for loops, while loops, etc.)
Example:
if (checkCond()) {
'use server';
await doStuffAfterCond();
}
Output:
import { $$server as _$$server } from "use-server-directive/server";
const _server = _$$server("/__server/202f5a9f-input-0-anonymous", async function () /*@skip use-server-directive*/{
'use server';
await doStuffAfterCond();
return [3];
});
if (checkCond()) {
const [_type, _result] = await _server();
}
Full Changelog: v0.2.1...v0.3.0