Update excluded pages paths logic. Add HMR retries on errors.
This commit is contained in:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user