Update excluded pages paths logic. Add HMR retries on errors.

This commit is contained in:
2026-04-12 05:47:12 +01:00
parent e0c2ab5872
commit 532d0d6b56
29 changed files with 168 additions and 65 deletions
+12 -9
View File
@@ -1,11 +1,13 @@
import handleWebPages from "./web-pages/handle-web-pages";
import handleRoutes from "./handle-routes";
import isDevelopment from "../../utils/is-development";
import grabConstants from "../../utils/grab-constants";
import handleHmr from "./handle-hmr";
import handlePublic from "./handle-public";
import handleFiles from "./handle-files";
import handleBunextPublicAssets from "./handle-bunext-public-assets";
import checkExcludedPatterns from "../../utils/check-excluded-patterns";
import { AppData } from "../../data/app-data";
import fullRebuild from "./full-rebuild";
type Params = {
req: Request;
server: Bun.Server<any>;
@@ -21,12 +23,14 @@ export default async function bunextRequestHandler({
try {
const url = new URL(req.url);
const { config } = grabConstants();
if (checkExcludedPatterns({ path: url.pathname })) {
return Response.json({ success: false, msg: `Invalid Path` });
}
let response: Response | undefined = undefined;
if (config?.middleware) {
const middleware_res = await config.middleware({
if (global.CONSTANTS.config?.middleware) {
const middleware_res = await global.CONSTANTS.config.middleware({
req: initial_req,
url,
});
@@ -40,11 +44,10 @@ export default async function bunextRequestHandler({
}
}
// const server_upgrade = server.upgrade(req);
// if (server_upgrade) {
// return undefined;
// }
if (is_dev && url.pathname == AppData["BunextHMRRetryRoute"]) {
await fullRebuild({ msg: `HMR Retry Rebuild ...` });
return new Response("Modules Rebuilt");
}
if (url.pathname === "/__hmr" && is_dev) {
response = await handleHmr({ req });