Context
The Bake development server/HMR port in #553 now serves HTML routes, performs real incremental HMR, and discovers filesystem framework routes. While validating framework route execution against Bun 4982b91e3702094330f3be3883354c52b8c01323, two adjacent runtime bridge gaps remained:
- A framework route using the global
Responseconstructor is transformed to import{ Response }frombun:app, but the server HMR loader cannot load that bundled module (Failed to load bundled module 'bun:app'). Callingnew globalThis.Response(...)works and proves the framework route pipeline itself is functional. - The pinned generated
bake.server.jsreferences$ERR_SSR_RESPONSE_EXPECTEDfor an invalid server-render response, but Home does not yet install Bun's generated ErrorCode builtins, so the error path raises aReferenceErrorinstead of the intended diagnostic.
Scope
- Port the
bun:appresponse/runtime bridge needed by Bake server bundles. - Expose the generated
$ERR_SSR_RESPONSE_EXPECTEDbuiltin with Bun-compatible behavior. - Add focused integration coverage using ordinary
Responseand the invalid-response diagnostic path. - Preserve the pinned generated
bake.server.jsasset byte-for-byte rather than patching generated output.
Acceptance criteria
- Filesystem framework routes can return
new Response(...)without usingglobalThisas an escape hatch. - Invalid server-render return values produce Bun's expected SSR response error rather than a missing-global
ReferenceError. - Existing Bake production, development/HMR, JSC runtime, and non-JSC build gates remain green.