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
+5
View File
@@ -0,0 +1,5 @@
type Params = {
path: string;
};
export default function ({ path }: Params): boolean;
export {};
+8
View File
@@ -0,0 +1,8 @@
export default function ({ path }) {
for (let i = 0; i < global.CONSTANTS.RouteIgnorePatterns.length; i++) {
const regex = global.CONSTANTS.RouteIgnorePatterns[i];
if (path.match(regex))
return true;
}
return false;
}
+6 -2
View File
@@ -3,6 +3,7 @@ import grabDirNames from "./grab-dir-names";
import path from "path";
import AppNames from "./grab-app-names";
import pagePathTransform from "./page-path-transform";
import checkExcludedPatterns from "./check-excluded-patterns";
export default function grabAllPages(params) {
const { PAGES_DIR } = grabDirNames();
const pages = grabPageDirRecursively({ page_dir: PAGES_DIR });
@@ -31,7 +32,10 @@ function grabPageDirRecursively({ page_dir }) {
if (page.match(new RegExp(`${AppNames["RootPagesComponentName"]}`))) {
continue;
}
if (page.match(/\(|\)|--|\/api\//)) {
if (checkExcludedPatterns({ path: page })) {
continue;
}
if (page.match(/\/api\//)) {
continue;
}
if (page_name.split(".").length > 2) {
@@ -39,7 +43,7 @@ function grabPageDirRecursively({ page_dir }) {
}
const page_stat = statSync(full_page_path);
if (page_stat.isDirectory()) {
if (page.match(/\(|\)/))
if (checkExcludedPatterns({ path: page }))
continue;
const new_page_files = grabPageDirRecursively({
page_dir: full_page_path,
+2 -2
View File
@@ -1,7 +1,7 @@
import AppNames from "./grab-app-names";
export default function grabAssetsPrefix() {
if (global.CONFIG.assetsPrefix) {
return global.CONFIG.assetsPrefix;
if (global.CONFIG.assets_prefix) {
return global.CONFIG.assets_prefix;
}
const { defaultAssetPrefix } = AppNames;
return defaultAssetPrefix;
+1
View File
@@ -6,4 +6,5 @@ export default function grabConstants(): {
readonly ClientRootComponentWindowName: "BUNEXT_ROOT";
readonly MaxBundlerRebuilds: 5;
readonly config: import("../types").BunextConfig;
readonly RouteIgnorePatterns: RegExp[];
};
+5
View File
@@ -6,6 +6,10 @@ export default function grabConstants() {
const ClientRootComponentWindowName = "BUNEXT_ROOT";
const ServerDefaultRequestBodyLimitBytes = MB_IN_BYTES * 10;
const MaxBundlerRebuilds = 5;
const RouteIgnorePatterns = [/\/\(/];
if (config.pages_exclude_patterns) {
RouteIgnorePatterns.push(...config.pages_exclude_patterns);
}
return {
ClientRootElementIDName,
ClientWindowPagePropsName,
@@ -14,5 +18,6 @@ export default function grabConstants() {
ClientRootComponentWindowName,
MaxBundlerRebuilds,
config,
RouteIgnorePatterns,
};
}