feat(bankai): bankai v10 — the isomorphic compiler & server on Vite 8
One command, zero config, and only the client ever bundles: v8 server code is plain ESM that Node runs as-authored, so there is no server build to rot (the lesson of v9). - start: Vite middleware mode + HMR with per-request streaming SSR via ssrLoadModule; a virtual client entry generates the browser glue so the user writes exactly one isomorphic module (plan decision D5). - build: client bundle via Vite 8/Rolldown, manifest-derived route assets in dist/bankai.json, service worker built with the precache list injected (choo-service-worker convention, manifest edition), brotli+gzip precompression of every text asset. - serve: immutable caching + precompressed negotiation for hashed assets, 103 Early Hints (res.writeEarlyHints) with the route's assets before every page, streaming SSR, and a window.initialState tail with script-breakout-safe serialization and choo internals filtered out. - inspect: raw/gzip/brotli size report. Integration tests drive the real counter example through build and serve, asserting the 103 interim response at the HTTP level. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014NgfSjHE11oFpoSnLVKLXd
This commit is contained in:
co-authored by
Claude Fable 5
parent
d755af5ca0
commit
7e08b585ac
@@ -0,0 +1,23 @@
|
||||
// The isomorphic entry contract (plan decision D5): the entry module's
|
||||
// default export is either a choo app instance (typically
|
||||
// `export default app.mount('body')` — mount() on the server records the
|
||||
// selector and returns the app) or a factory returning one (preferred:
|
||||
// fresh state per request). One module, three consumers: browser mount,
|
||||
// server render, build metadata.
|
||||
|
||||
export function resolveApp (mod, entry) {
|
||||
const value = mod && mod.default
|
||||
if (!value) {
|
||||
throw new Error(`bankai: ${entry} has no default export — export your choo app (or a function returning one)`)
|
||||
}
|
||||
// a factory is a plain function; an app instance has .mount
|
||||
const app = typeof value === 'function' && !value.mount ? value() : value
|
||||
if (typeof app.toStream !== 'function') {
|
||||
throw new Error(`bankai: the default export of ${entry} is not a choo v8 app (missing toStream)`)
|
||||
}
|
||||
return app
|
||||
}
|
||||
|
||||
export function selectorOf (app) {
|
||||
return app.selector || 'body'
|
||||
}
|
||||
Reference in New Issue
Block a user