In short
A Module from outside the phis workspace is built as an npm package against @phis/ui. This page summarises
the rules its author must follow: what the Server half may import, what must be left to the browser, and
what phis module check verifies. It is for developers of third-party Modules.
How it fits
The package is installed into a Site with the phis CLI, which records it and generates a projection without
changing the Site's source. The Site is then rebuilt, and each Area selects the Module in the Builder. If the
package also carries an Add-on half, that is installed separately into the phis Core API.
What matters
Public pages are rendered once for everybody. A Widget's Server half must not depend on cookies,
headers or the viewer. Anything per visitor is loaded in the browser, and Module data may be up to 60 seconds
old.
Keep Client code out of the Server half. The Server half is part of every route of the Site. Importing a
Control there ships it, with Ant Design, to every Public landing. Render plain HTML, or pass a view model to
a Render Client through PhiRuntimeModuleRenderClientHost.
Import only what runs on the server. Types, constants, helpers, @phis/ui/module/*,
@phis/ui/server-helpers and @phis/ui/theme are fine. No Client value goes into plugin.tsx, server.tsx
or a loader descriptor.
Fixed doors. The package exports ., ./server, ./client and ./authoring-client. The last two begin
with "use client"; the first two do not.
Peers and ids. react and @phis/ui are not ordinary dependencies, and every id follows
<npm-package>/modules/<module>.
Check refuses violations. phis module check reports client_in_server_graph and names the offending
file.
Example
phis module add --site <site key> --package @acme/status --spec workspace:* --path <site root>
phis module check --site <site key> --package @acme/status --path <site root>