From a84ac10b24b1e58b471984fff358a619a82cfa13 Mon Sep 17 00:00:00 2001 From: Benjamin Toby Date: Wed, 8 Apr 2026 06:51:44 +0100 Subject: [PATCH] Bugfix. Update watcher to reload on excluded file/directory addition and deletion. --- dist/functions/server/watcher-esbuild-ctx.js | 14 ++++++++++---- package.json | 2 +- src/functions/server/watcher-esbuild-ctx.ts | 15 +++++++++++---- .../server/web-pages/grab-page-server-res.tsx | 2 ++ 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/dist/functions/server/watcher-esbuild-ctx.js b/dist/functions/server/watcher-esbuild-ctx.js index b92eaee..1bdf4e1 100644 --- a/dist/functions/server/watcher-esbuild-ctx.js +++ b/dist/functions/server/watcher-esbuild-ctx.js @@ -30,7 +30,7 @@ export default async function watcherEsbuildCTX() { }); return; } - const excluded_match = /node_modules\/|^public\/|^\.bunext\/|^\.git\/|^dist\/|bun\.lockb$/; + const excluded_match = /node_modules\/|^public\/|^\.bunext\/|^\.git\/|^\.?dist\/|bun\.lockb$/; if (filename.match(excluded_match)) return; if (filename.match(/bunext.config\.ts/)) { @@ -61,11 +61,11 @@ export default async function watcherEsbuildCTX() { return; } if (!filename.match(/^src\/pages\/|\.css$/)) - return; + return reloadWatcher(); if (filename.match(/\/(--|\()/)) - return; + return reloadWatcher(); if (filename.match(/ /)) - return; + return reloadWatcher(); if (global.RECOMPILING) return; const action = does_file_exist ? "created" : "deleted"; @@ -105,3 +105,9 @@ async function fullRebuild(params) { watcherEsbuildCTX(); } } +function reloadWatcher(params) { + if (global.PAGES_SRC_WATCHER) { + global.PAGES_SRC_WATCHER.close(); + watcherEsbuildCTX(); + } +} diff --git a/package.json b/package.json index 2077ff7..792b782 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@moduletrace/bunext", - "version": "1.0.56", + "version": "1.0.57", "main": "dist/index.js", "module": "index.ts", "dependencies": { diff --git a/src/functions/server/watcher-esbuild-ctx.ts b/src/functions/server/watcher-esbuild-ctx.ts index 9503e1c..add1e45 100644 --- a/src/functions/server/watcher-esbuild-ctx.ts +++ b/src/functions/server/watcher-esbuild-ctx.ts @@ -40,7 +40,7 @@ export default async function watcherEsbuildCTX() { } const excluded_match = - /node_modules\/|^public\/|^\.bunext\/|^\.git\/|^dist\/|bun\.lockb$/; + /node_modules\/|^public\/|^\.bunext\/|^\.git\/|^\.?dist\/|bun\.lockb$/; if (filename.match(excluded_match)) return; @@ -84,9 +84,9 @@ export default async function watcherEsbuildCTX() { return; } - if (!filename.match(/^src\/pages\/|\.css$/)) return; - if (filename.match(/\/(--|\()/)) return; - if (filename.match(/ /)) return; + if (!filename.match(/^src\/pages\/|\.css$/)) return reloadWatcher(); + if (filename.match(/\/(--|\()/)) return reloadWatcher(); + if (filename.match(/ /)) return reloadWatcher(); if (global.RECOMPILING) return; @@ -137,3 +137,10 @@ async function fullRebuild(params?: { msg?: string }) { watcherEsbuildCTX(); } } + +function reloadWatcher(params?: { msg?: string }) { + if (global.PAGES_SRC_WATCHER) { + global.PAGES_SRC_WATCHER.close(); + watcherEsbuildCTX(); + } +} diff --git a/src/functions/server/web-pages/grab-page-server-res.tsx b/src/functions/server/web-pages/grab-page-server-res.tsx index 9f499c6..1a55f02 100644 --- a/src/functions/server/web-pages/grab-page-server-res.tsx +++ b/src/functions/server/web-pages/grab-page-server-res.tsx @@ -49,11 +49,13 @@ export default async function grabPageServerRes({ ...routeParams, query: { ...routeParams.query, ...query }, }); + return { ...serverData, ...default_props, }; } + return { ...default_props, };