ReviewOS

home-lang/home

Port Bake development server and HMR runtime

#553
Closed chris opened this 9 days ago ·
9 days ago

Scope

#551 ports the pinned Bun production Bake command and its full framework configuration into Home. The remaining development path still uses Home's lifetime-only bake.DevServer shell and an empty getHmrRuntime, so Bun.serve({ app }), route rebundling, and browser HMR are not yet end-to-end ports.

Acceptance criteria

  • Port Bun's Bake DevServer orchestration without compile-only or unreachable behavior.
  • Port the client/server HMR runtime and protocol integration used by framework routes.
  • Make Bun.serve({ app }) load the full UserOptions, discover routes, bundle client/server graphs, and serve requests.
  • Cover initial requests, route updates, build diagnostics, and HMR reload/update behavior with focused integration tests.
  • Preserve production behavior and the non-JSC compiler boundary.

Parent: #66 Follows: #551

9 days ago

First #553 checkpoint published to main in eeeacf66974fa696afd0a6ea267aea839b3b102c (feat(runtime): embed Bake HMR runtimes).

This removes the empty bun.bake.getHmrRuntime placeholder and activates the full pinned generated payloads:

  • bake.client.js: 48,459 bytes, SHA-256 5d72d95e932ae28a6618cb530ed26d22d286b63cd2648976dc19dfa5a5b0dfc0
  • bake.server.js: 10,939 bytes, SHA-256 cacffe68ff74ffae93f4846d8e3d647755bc6be56846104e58c8b6f8ebec03b5

Both are byte-identical to the local Bun build at source pin 4982b91e3702094330f3be3883354c52b8c01323. Home now exposes the real HmrRuntime { code, line_count } contract used by incremental sourcemap generation. The new unit verifies nonempty payloads and the client WebSocket plus server handleRequest / registerUpdate interfaces.

Verification:

  • native runtime: 1,823 passed, 19 skipped, 0 failed; 20/20 build steps
  • Bake production integration: 18/18 build steps
  • JSC-disabled compiler: 5/5 build steps
  • generated hashes match the pinned Bun artifacts
  • whitespace check is clean; the generated payload path is marked -whitespace because an intentional template-literal character set contains trailing space bytes

#553 remains open: the next boundary is replacing Home's compile-only bun.bake.DevServer orchestration and then enabling the Bun.serve({ app }) route path.

9 days ago

Implemented and published to main in two sole-author/sole-committer Chris Breuer commits:

  • 1c5e32510 — feat(runtime): enable Bake development server
  • 88283e4b7 — test(runtime): cover Bake HMR error recovery

This replaces Home's compile-only top-level Bake DevServer shell with the full pinned Bun DevServer and child orchestration, adapted to Home's Zig/runtime APIs. HTML-route and filesystem-framework initialization are restored in Bun.serve, the real framework-router branch is enabled, HTML imports produce their actual JS object, macOS kqueue watching is active, the native Bake route exports replace their stubs, and the pinned error/visualizer assets are vendored. The earlier lifetime-only unit model remains isolated under DevServerLifetime so its ownership tests still measure the intended contracts.

During a real file-edit probe, incremental rebuild initially exposed a cross-heap free: bun.DefaultAllocator returned libc while JSC bun.default_allocator is mimalloc. The allocator type now wraps the actual runtime default allocator, with a regression invariant. The same HMR edit and recovery then passed normally and under AddressSanitizer.

test-bake-development is a permanent stdlib-only Python integration gate. It now verifies:

  • a development HTML route and injected bun:hmr client bundle;
  • the raw WebSocket version, subscription, and active-route protocol;
  • a real source edit producing a u hot-update frame with the edited module;
  • a real syntax error producing an e diagnostic frame naming client.ts and the parser failure;
  • repair after that error producing a new u frame without crashing;
  • filesystem framework discovery and execution for / and /alpha.

Final verification after rebasing onto the latest main:

  • non-JSC debug build: 5/5 steps;
  • JSC home_rt: 1,808 passed / 19 intentional skips / 0 failed, 20/20 steps;
  • Bake production: 18/18 steps;
  • Bake development/HMR/diagnostic recovery/framework routing: 18/18 steps;
  • focused Pickier, Python bytecode compilation, Zig formatting, generated-asset hashes, and git diff --check: pass.

The required repository-wide bunx --bun pickier . was also run; it reports the existing broad baseline of 20,866 problems across vendored fixtures/snapshots and made no working-tree changes. The new focused TypeScript fixtures are clean.

One adjacent framework-runtime gap found by deeper probing is split into #554: ordinary Response is rewritten through bun:app, and the invalid-response path needs Bun's generated $ERR_SSR_RESPONSE_EXPECTED builtin. The happy-path framework routing pipeline is covered here using globalThis.Response; #554 preserves that remaining bridge scope without modifying the byte-exact pinned generated server runtime.

Closing this DevServer/HMR checkpoint as completed. Parent tracking remains #66; whole-suite parity is still in progress.

Sign in to comment on this issue.