Skip to content

example(document): replace mocket with moonback - #170

Merged
bobzhang merged 1 commit into
mainfrom
example/document-moonback
Sep 5, 2026
Merged

example(document): replace mocket with moonback#170
bobzhang merged 1 commit into
mainfrom
example/document-moonback

Conversation

@bobzhang

@bobzhang bobzhang commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

oboard/mocket was the last mocket user in the repo, and it no longer builds: @async/http moved to CaseInsensitiveString headers, so mocket.native.mbt fails to check.

mocket.native.mbt:370  has type : Map[String, String]
                       wanted   : Map[@async/http.CaseInsensitiveString, String]

hackwaly/moonback is already the server library behind rabbita/server, so the example now goes through that rather than carrying a second HTTP stack.

Layout

moonback is native+wasm only, so the single main package (which used #cfg(target=...) to be both the browser entry and the server) had to split into the layout warren already expects:

app/ the shared component, js+native+wasm
main/ browser entry, hydrates the server-rendered document
cmd/server/ server entry, native+wasm

cmd/server registers /issues as a @moonback.Module and hands it to @rabbita_server.Server, which supplies the page route and the static middleware. That replaces the hand-rolled /assets/index.js and /assets/styles.css handlers, so the server entry is ~25 lines. Assets move to /index.js and /styles.css to match the head page_service injects, and the component no longer writes its own <script> tag.

This is the first in-repo consumer of rabbita/server.

Verification

Checked on js, native, and wasm — and actually run, not just checked:

/           200  full SSR document: data-theme, <title>5</title>, and a
                 __rabbita_transcript already carrying the /issues payload
/issues     200  application/json
/index.js   200  text/javascript; charset=utf-8  (249363 bytes)
/styles.css 200  text/css; charset=utf-8

The transcript is the interesting one: create_resource resolves /issues during SSR, so the list is in the response document instead of being refetched after hydration.

warren dev --browser-entry main --server-target native also works — warren picks up cmd/server as the server entry and injects the live-reload client through WARREN_CLIENT.

The example's rabbita dependency was pinned at 0.12.2; bumped to 0.15.5 to match the repo.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AmoyPMELemz5hdNNdXyAkm

`oboard/mocket` was the last mocket user in the repo and no longer builds:
`@async/http` moved to `CaseInsensitiveString` headers, so
`mocket.native.mbt` fails to check. `hackwaly/moonback` is already the
server library behind `rabbita/server`, so the example now goes through
that instead of a second HTTP stack.

moonback is native+wasm only, so the single `main` package had to split
into the layout warren already expects:

  app/         the shared component, js+native+wasm
  main/        browser entry, hydrates the server-rendered document
  cmd/server/  server entry, native+wasm

`cmd/server` registers `/issues` as a `@moonback.Module` and hands it to
`@rabbita_server.Server`, which supplies the page route and the static
middleware — replacing the hand-rolled `/assets/index.js` and
`/assets/styles.css` handlers. Assets move to `/index.js` and
`/styles.css` to match the head that `page_service` injects, so the
component no longer writes its own `<script>` tag. This is the first
in-repo consumer of `rabbita/server`.

Verified running, not just checking: `/` returns the full SSR document
with `data-theme`, `<title>`, and a `__rabbita_transcript` that already
carries the `/issues` payload, so `create_resource` resolves during SSR
rather than refetching after hydration. `/issues`, `/index.js`, and
`/styles.css` all serve correctly, and `warren dev --browser-entry main
--server-target native` picks up `cmd/server` and injects the reload
client.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmoyPMELemz5hdNNdXyAkm
@bobzhang
bobzhang merged commit bb4d2dc into main Sep 5, 2026
5 checks passed
@bobzhang
bobzhang deleted the example/document-moonback branch September 5, 2026 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant