Skip to content

refactor: register server-action/client-component to registry at comptime #153

Description

@nurulhudaapon

Currently for client component we are collecting them while parsing all the files but that has several limitations,
the component must need to be public decl, and also client components from a ui library is not being analyzed hence currently client component from other zx library is not working.

Server actions are being registered at runtime, and works mostly fine because on first render of the page those are being registered, but that doesn't work in case of stateless env (edge function) so we are currently invoking the WASi twice for server action request to make sure server actions are registered.


Now we would like to move towards a comp time solution, where we will register the client components and server actions by appending comp time registerer at the bottom or top of the file with detected client component and server action in the page.

pub fn Page() zx.Component {
...
};
....

comptime {
      zx.x.register(.server_action, handler);
      zx.x.register(.client_component, ClientCounter);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions