Bugfix. Update watcher to reload on excluded file/directory addition and deletion.

This commit is contained in:
Benjamin Toby 2026-04-08 06:51:44 +01:00
parent 4b3a4dbc77
commit a84ac10b24
4 changed files with 24 additions and 9 deletions

View File

@ -30,7 +30,7 @@ export default async function watcherEsbuildCTX() {
}); });
return; 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)) if (filename.match(excluded_match))
return; return;
if (filename.match(/bunext.config\.ts/)) { if (filename.match(/bunext.config\.ts/)) {
@ -61,11 +61,11 @@ export default async function watcherEsbuildCTX() {
return; return;
} }
if (!filename.match(/^src\/pages\/|\.css$/)) if (!filename.match(/^src\/pages\/|\.css$/))
return; return reloadWatcher();
if (filename.match(/\/(--|\()/)) if (filename.match(/\/(--|\()/))
return; return reloadWatcher();
if (filename.match(/ /)) if (filename.match(/ /))
return; return reloadWatcher();
if (global.RECOMPILING) if (global.RECOMPILING)
return; return;
const action = does_file_exist ? "created" : "deleted"; const action = does_file_exist ? "created" : "deleted";
@ -105,3 +105,9 @@ async function fullRebuild(params) {
watcherEsbuildCTX(); watcherEsbuildCTX();
} }
} }
function reloadWatcher(params) {
if (global.PAGES_SRC_WATCHER) {
global.PAGES_SRC_WATCHER.close();
watcherEsbuildCTX();
}
}

View File

@ -1,6 +1,6 @@
{ {
"name": "@moduletrace/bunext", "name": "@moduletrace/bunext",
"version": "1.0.56", "version": "1.0.57",
"main": "dist/index.js", "main": "dist/index.js",
"module": "index.ts", "module": "index.ts",
"dependencies": { "dependencies": {

View File

@ -40,7 +40,7 @@ export default async function watcherEsbuildCTX() {
} }
const excluded_match = 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; if (filename.match(excluded_match)) return;
@ -84,9 +84,9 @@ export default async function watcherEsbuildCTX() {
return; return;
} }
if (!filename.match(/^src\/pages\/|\.css$/)) return; if (!filename.match(/^src\/pages\/|\.css$/)) return reloadWatcher();
if (filename.match(/\/(--|\()/)) return; if (filename.match(/\/(--|\()/)) return reloadWatcher();
if (filename.match(/ /)) return; if (filename.match(/ /)) return reloadWatcher();
if (global.RECOMPILING) return; if (global.RECOMPILING) return;
@ -137,3 +137,10 @@ async function fullRebuild(params?: { msg?: string }) {
watcherEsbuildCTX(); watcherEsbuildCTX();
} }
} }
function reloadWatcher(params?: { msg?: string }) {
if (global.PAGES_SRC_WATCHER) {
global.PAGES_SRC_WATCHER.close();
watcherEsbuildCTX();
}
}

View File

@ -49,11 +49,13 @@ export default async function grabPageServerRes({
...routeParams, ...routeParams,
query: { ...routeParams.query, ...query }, query: { ...routeParams.query, ...query },
}); });
return { return {
...serverData, ...serverData,
...default_props, ...default_props,
}; };
} }
return { return {
...default_props, ...default_props,
}; };