This commit is contained in:
2026-03-29 17:08:10 +01:00
parent 950bdc3dca
commit 2b170d24e1
11 changed files with 27 additions and 13 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
type Params = {
req: Request;
server: Bun.Server<any>;
};
export default function bunextRequestHandler({ req: initial_req, }: Params): Promise<Response>;
export default function bunextRequestHandler({ req: initial_req, server, }: Params): Promise<Response>;
export {};
+5 -1
View File
@@ -6,7 +6,7 @@ import handleHmr from "./handle-hmr";
import handlePublic from "./handle-public";
import handleFiles from "./handle-files";
import handleBunextPublicAssets from "./handle-bunext-public-assets";
export default async function bunextRequestHandler({ req: initial_req, }) {
export default async function bunextRequestHandler({ req: initial_req, server, }) {
const is_dev = isDevelopment();
let req = initial_req.clone();
try {
@@ -25,6 +25,10 @@ export default async function bunextRequestHandler({ req: initial_req, }) {
req = middleware_res;
}
}
// const server_upgrade = server.upgrade(req);
// if (server_upgrade) {
// return undefined;
// }
if (url.pathname === "/__hmr" && is_dev) {
response = await handleHmr({ req });
}
+1 -1
View File
@@ -9,7 +9,7 @@ export default async function () {
const config = await grabConfig();
return {
async fetch(req, server) {
return await bunextRequestHandler({ req });
return await bunextRequestHandler({ req, server });
},
port,
idleTimeout: development ? 0 : undefined,
+1 -1
View File
@@ -14,7 +14,7 @@ export default async function serverPostBuildFn() {
}
const target_artifact = global.BUNDLER_CTX_MAP[controller.target_map.local_path];
const mock_req = new Request(controller.page_url);
const { serverRes } = await grabPageComponent({
const { serverRes, bundledMap, module, root_module } = await grabPageComponent({
req: mock_req,
});
const final_artifact = {
+1 -1
View File
@@ -62,7 +62,7 @@ export default async function genWebHTML({ component, pageProps, bundledMap, mod
__html: `window.${ClientWindowPagePropsName} = ${serializedProps}`,
} }), bundledMap?.path ? (_jsxs(_Fragment, { children: [_jsx("script", { type: "importmap", dangerouslySetInnerHTML: {
__html: importMap,
}, fetchPriority: "high" }), _jsx("script", { src: `/${bundledMap.path}`, type: "module", id: AppData["BunextClientHydrationScriptID"], defer: true })] })) : null, is_dev ? (_jsx("script", { defer: true, dangerouslySetInnerHTML: {
}, defer: true }), _jsx("script", { src: `/${bundledMap.path}`, type: "module", id: AppData["BunextClientHydrationScriptID"], defer: true })] })) : null, is_dev ? (_jsx("script", { defer: true, dangerouslySetInnerHTML: {
__html: page_hydration_script,
} })) : null, RootHead ? (_jsx(RootHead, { serverRes: pageProps, ctx: routeParams })) : null, Head ? _jsx(Head, { serverRes: pageProps, ctx: routeParams }) : null] }), _jsx("body", { children: _jsx("div", { id: ClientRootElementIDName, suppressHydrationWarning: !dev, children: component }) })] }));
let html = `<!DOCTYPE html>\n`;